drivers/mrc_cache: Fix size comparison in mrc_cache update

`mrc_cache_needs_update` is comparing the "new size" of the MRC data
(minus metadata size) to the size including the metadata, which causes
the driver to think the data has changed, and so it will rewrite the
MRC cache on every boot. This patch removes the metadata size from
the comparison.

BUG=b:171513942
BRANCH=volteer
TEST=1) Memory training data gets written the on a boot where the data
was wiped out.
2) Memory training data does not get written back on every subsequent
boot.

Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Change-Id: I7280276f71fdaa492c327b2b7ade8e53e7c59f51
Reviewed-on: https://review.coreboot.org/c/coreboot/+/46824
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Shelley Chen <shchen@google.com>
Reviewed-by: Furquan Shaikh <furquan@google.com>
This commit is contained in:
Tim Wawrzynczak 2020-10-26 11:40:41 -06:00 committed by Patrick Georgi
parent 71b546773d
commit 6ad856825a
1 changed files with 2 additions and 2 deletions

View File

@ -337,10 +337,10 @@ static bool mrc_cache_needs_update(const struct region_device *rdev,
const void *new_data, size_t new_data_size) const void *new_data, size_t new_data_size)
{ {
void *mapping, *data_mapping; void *mapping, *data_mapping;
size_t size = region_device_sz(rdev); size_t old_data_size = region_device_sz(rdev) - sizeof(struct mrc_metadata);
bool need_update = false; bool need_update = false;
if (new_data_size != size) if (new_data_size != old_data_size)
return true; return true;
mapping = rdev_mmap_full(rdev); mapping = rdev_mmap_full(rdev);