mrc_cache: Move mrc_cache_stash_data to end of file
We need to pull update_mrc_cache into mrc_cache_stash_data, so moving to end of the file to make sure update_mrc_cache is defined before. BUG=b:150502246 BRANCH=None TEST=Testing on a nami (x86) device: reboot from ec console. Make sure memory training happens. reboot from ec console. Make sure that we don't do training again. Signed-off-by: Shelley Chen <shchen@google.com> Change-Id: I9e14fec96e9dabceafc2f6f5663fc6f1023f0395 Reviewed-on: https://review.coreboot.org/c/coreboot/+/44195 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Furquan Shaikh <furquan@google.com>
This commit is contained in:
parent
ad9cd687b8
commit
9c9353422e
|
@ -109,41 +109,6 @@ static const struct cache_region *lookup_region_type(int type)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int mrc_cache_stash_data(int type, uint32_t version, const void *data,
|
||||
size_t size)
|
||||
{
|
||||
const struct cache_region *cr;
|
||||
size_t cbmem_size;
|
||||
struct mrc_metadata *md;
|
||||
|
||||
cr = lookup_region_type(type);
|
||||
if (cr == NULL) {
|
||||
printk(BIOS_ERR, "MRC: failed to add to cbmem for type %d.\n",
|
||||
type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
cbmem_size = sizeof(*md) + size;
|
||||
|
||||
md = cbmem_add(cr->cbmem_id, cbmem_size);
|
||||
|
||||
if (md == NULL) {
|
||||
printk(BIOS_ERR, "MRC: failed to add '%s' to cbmem.\n",
|
||||
cr->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(md, 0, sizeof(*md));
|
||||
md->signature = MRC_DATA_SIGNATURE;
|
||||
md->data_size = size;
|
||||
md->version = version;
|
||||
md->data_checksum = compute_ip_checksum(data, size);
|
||||
md->header_checksum = compute_ip_checksum(md, sizeof(*md));
|
||||
memcpy(&md[1], data, size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct cache_region *lookup_region(struct region *r, int type)
|
||||
{
|
||||
const struct cache_region *cr;
|
||||
|
@ -596,6 +561,41 @@ static void update_mrc_cache(void *unused)
|
|||
protect_mrc_region();
|
||||
}
|
||||
|
||||
int mrc_cache_stash_data(int type, uint32_t version, const void *data,
|
||||
size_t size)
|
||||
{
|
||||
const struct cache_region *cr;
|
||||
size_t cbmem_size;
|
||||
struct mrc_metadata *md;
|
||||
|
||||
cr = lookup_region_type(type);
|
||||
if (cr == NULL) {
|
||||
printk(BIOS_ERR, "MRC: failed to add to cbmem for type %d.\n",
|
||||
type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
cbmem_size = sizeof(*md) + size;
|
||||
|
||||
md = cbmem_add(cr->cbmem_id, cbmem_size);
|
||||
|
||||
if (md == NULL) {
|
||||
printk(BIOS_ERR, "MRC: failed to add '%s' to cbmem.\n",
|
||||
cr->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(md, 0, sizeof(*md));
|
||||
md->signature = MRC_DATA_SIGNATURE;
|
||||
md->data_size = size;
|
||||
md->version = version;
|
||||
md->data_checksum = compute_ip_checksum(data, size);
|
||||
md->header_checksum = compute_ip_checksum(md, sizeof(*md));
|
||||
memcpy(&md[1], data, size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ensures MRC training data is stored into SPI after PCI enumeration is done.
|
||||
* Some implementations may require this to be later than others.
|
||||
|
|
Loading…
Reference in New Issue