Andrey Petrov has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/37214 )
Change subject: lib: Fix FMAP cache on FSP1.0 platforms ......................................................................
lib: Fix FMAP cache on FSP1.0 platforms
On FSP1.0 platforms CAR region is torn down by FspMemoryInit() on exit, since there is no FspTempRamExit() API. Current FMAP cache code correctly assumes CAR is around and usable after. However this assumption is only correct for >= FSP1.0.
This change address the problem by using cache only if CAR region is usable.
TEST=boot test on OCP monolake.
Change-Id: I9f64c26650fa4c397a0e4835e470ab41922e1290 --- M src/lib/fmap.c 1 file changed, 14 insertions(+), 7 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/14/37214/1
diff --git a/src/lib/fmap.c b/src/lib/fmap.c index 48aab8f..b2dde6b 100644 --- a/src/lib/fmap.c +++ b/src/lib/fmap.c @@ -114,15 +114,22 @@ { const struct region_device *boot; struct fmap *fmap; - struct mem_region_device *cache; + struct mem_region_device *cache = NULL; size_t offset = FMAP_OFFSET;
- /* Try FMAP cache first */ - cache = car_get_var_ptr(&fmap_cache); - if (!region_device_sz(&cache->rdev)) - setup_preram_cache(cache); - if (region_device_sz(&cache->rdev)) - return rdev_chain_full(fmrd, &cache->rdev); + /* + * Try FMAP cache first. + * On FSP 1.0 platforms make sure CAR is still around because + * the contents are destroyed on FspMemoryInit() exit. + */ + if (!CONFIG(PLATFORM_USES_FSP1_0) || + (CONFIG(PLATFORM_USES_FSP1_0) && car_active())) { + cache = car_get_var_ptr(&fmap_cache); + if (!region_device_sz(&cache->rdev)) + setup_preram_cache(cache); + if (region_device_sz(&cache->rdev)) + return rdev_chain_full(fmrd, &cache->rdev); + }
boot_device_init(); boot = boot_device_ro();