diff options
author | Ravi Kumar Bokka <rbokka@codeaurora.org> | 2022-04-06 07:35:53 +0530 |
---|---|---|
committer | Julius Werner <jwerner@chromium.org> | 2022-04-13 20:43:44 +0000 |
commit | 4f9cb426be4aaad6c0f2a5bc127d764e4df0877f (patch) | |
tree | d218162c8feff243486279e466df1e591d3a55bb /src/soc/qualcomm | |
parent | b3a042f6192f77a0f65fa56853fced2a41a0c904 (diff) |
soc/qualcomm/common: Fix mem_chip_info bugs in QcLib glue
This patch fixes an issue introduced by CB:59195 when QcLib
doesn't return a mem_chip_info structure to coreboot, and
solves some other minor leftover issues from that patch.
BUG=b:182963902,b:177917361
TEST=Validated on qualcomm sc7280 development board
Signed-off-by: Ravi Kumar Bokka <rbokka@codeaurora.org>
Change-Id: I0d59669adaf287d0eb7b58ccb0fe3f98e3d23281
Reviewed-on: https://review.coreboot.org/c/coreboot/+/63026
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'src/soc/qualcomm')
-rw-r--r-- | src/soc/qualcomm/common/qclib.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/soc/qualcomm/common/qclib.c b/src/soc/qualcomm/common/qclib.c index 43b63995b7..b6d04b1d0d 100644 --- a/src/soc/qualcomm/common/qclib.c +++ b/src/soc/qualcomm/common/qclib.c @@ -24,22 +24,31 @@ static void *mem_chip_addr; static void write_mem_chip_information(struct qclib_cb_if_table_entry *te) { - /* Save mem_chip_info in local variables ahead of hook running */ - mem_chip_addr = (void *)te->blob_address; + if (te->size > sizeof(struct mem_chip_info) && + te->size == mem_chip_info_size((void *)te->blob_address)) { + /* Save mem_chip_addr in global variable ahead of hook running */ + mem_chip_addr = (void *)te->blob_address; + } } static void add_mem_chip_info(int unused) { void *mem_region_base = NULL; + size_t size; + + if (!mem_chip_addr) { + printk(BIOS_ERR, "Did not receive valid mem_chip_info from QcLib!"); + return; + } + + size = mem_chip_info_size(mem_chip_addr); /* Add cbmem table */ - if (sizeof(struct mem_chip_info) != 0) - mem_region_base = cbmem_add(CBMEM_ID_MEM_CHIP_INFO, - sizeof(struct mem_chip_info)); + mem_region_base = cbmem_add(CBMEM_ID_MEM_CHIP_INFO, size); ASSERT(mem_region_base != NULL); /* Migrate the data into CBMEM */ - memcpy(mem_region_base, mem_chip_addr, sizeof(struct mem_chip_info)); + memcpy(mem_region_base, mem_chip_addr, size); } ROMSTAGE_CBMEM_INIT_HOOK(add_mem_chip_info); @@ -168,9 +177,8 @@ void qclib_load_and_run(void) qclib_add_if_table_entry(QCLIB_TE_DDR_TRAINING_DATA, _ddr_training, REGION_SIZE(ddr_training), 0); - /* Attempt to read MEM CHIP information */ - qclib_add_if_table_entry(QCLIB_TE_MEM_CHIP_INFO, - mem_chip_addr, sizeof(mem_chip_addr), 0); + /* Address and size of this entry will be filled in by QcLib. */ + qclib_add_if_table_entry(QCLIB_TE_MEM_CHIP_INFO, NULL, 0, 0); /* Attempt to load PMICCFG Blob */ data_size = cbfs_load(CONFIG_CBFS_PREFIX "/pmiccfg", |