soc/intel/common: Store MRC data in next available slot in the cache

Currently, coreboot performs an erase of the entire MRC cache region on
flash if there is a version mismatch for the MRC data. Instead of doing
that, store the new MRC data in the next available slot, if there is
enough space available in the cache region.

BUG=chrome-os-partner:55699

Change-Id: Ib24a94f0a47c79941ed9f60095360ae3aad5540b
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://review.coreboot.org/15915
Tested-by: build bot (Jenkins)
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
Furquan Shaikh 2016-07-27 08:04:54 -07:00
parent bc24b85e6a
commit c31973760f
1 changed files with 7 additions and 1 deletions

View File

@ -135,6 +135,13 @@ static int __mrc_cache_get_current(const struct mrc_data_region *region,
slot++; slot++;
} }
/*
* Update pointer to the most recently saved MRC data before returning
* any error. This ensures that the caller can use next available slot
* if required.
*/
*cache = verified_cache;
if (verified_cache == NULL) if (verified_cache == NULL)
return -1; return -1;
@ -144,7 +151,6 @@ static int __mrc_cache_get_current(const struct mrc_data_region *region,
return -1; return -1;
} }
*cache = verified_cache;
printk(BIOS_DEBUG, "MRC cache slot %d @ %p\n", slot-1, verified_cache); printk(BIOS_DEBUG, "MRC cache slot %d @ %p\n", slot-1, verified_cache);
return 0; return 0;