From 6ad856825a0c4b2c2d64b633e7cb83fcb4dd8ff2 Mon Sep 17 00:00:00 2001 From: Tim Wawrzynczak Date: Mon, 26 Oct 2020 11:40:41 -0600 Subject: 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 Change-Id: I7280276f71fdaa492c327b2b7ade8e53e7c59f51 Reviewed-on: https://review.coreboot.org/c/coreboot/+/46824 Tested-by: build bot (Jenkins) Reviewed-by: Shelley Chen Reviewed-by: Furquan Shaikh --- src/drivers/mrc_cache/mrc_cache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/drivers/mrc_cache/mrc_cache.c b/src/drivers/mrc_cache/mrc_cache.c index 3b98dbaa63..eb43123c67 100644 --- a/src/drivers/mrc_cache/mrc_cache.c +++ b/src/drivers/mrc_cache/mrc_cache.c @@ -337,10 +337,10 @@ static bool mrc_cache_needs_update(const struct region_device *rdev, const void *new_data, size_t new_data_size) { 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; - if (new_data_size != size) + if (new_data_size != old_data_size) return true; mapping = rdev_mmap_full(rdev); -- cgit v1.2.3