From 3460aa3a421f57dc9a5cd9657cd9f0fd0ead8b72 Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Mon, 24 Oct 2022 19:06:03 -0700 Subject: mem_chip_info: Update to new format The original version of the mem_chip_info structure does not record rank information and does not allow precise modeling of certain DDR configurations, so it falls short on its purpose to compile all available memory information. This patch updates the format to a new layout that remedies these issues. Since the structure was introduced so recently that no firmware using it has been finalized and shipped yet, we should be able to get away with this without accounting for backwards compatibility. BRANCH=corsola Cq-Depend: chromium:3980175 Signed-off-by: Julius Werner Change-Id: If34e6857439b6f6ab225344e5b4dd0ff11d8d42a Reviewed-on: https://review.coreboot.org/c/coreboot/+/68871 Reviewed-by: Yu-Ping Wu Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel Reviewed-by: Xixi Chen --- src/soc/qualcomm/common/qclib.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/soc/qualcomm') diff --git a/src/soc/qualcomm/common/qclib.c b/src/soc/qualcomm/common/qclib.c index 4d005e53af..2769dede2f 100644 --- a/src/soc/qualcomm/common/qclib.c +++ b/src/soc/qualcomm/common/qclib.c @@ -21,14 +21,15 @@ #define QCLIB_VERSION 0 /* store QcLib return data until CBMEM_CREATION_HOOK runs */ -static void *mem_chip_addr; +static struct mem_chip_info *mem_chip_info; static void write_mem_chip_information(struct qclib_cb_if_table_entry *te) { + struct mem_chip_info *info = (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; + te->size == mem_chip_info_size(info->num_entries)) { + /* Save mem_chip_info in global variable ahead of hook running */ + mem_chip_info = info; } } @@ -37,19 +38,20 @@ static void add_mem_chip_info(int unused) void *mem_region_base = NULL; size_t size; - if (!mem_chip_addr) { + if (!mem_chip_info || !mem_chip_info->num_entries || + mem_chip_info->struct_version != MEM_CHIP_STRUCT_VERSION) { printk(BIOS_ERR, "Did not receive valid mem_chip_info from QcLib!"); return; } - size = mem_chip_info_size(mem_chip_addr); + size = mem_chip_info_size(mem_chip_info->num_entries); /* Add cbmem table */ 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, size); + memcpy(mem_region_base, mem_chip_info, size); } CBMEM_CREATION_HOOK(add_mem_chip_info); -- cgit v1.2.3