Lean Sheng Tan has submitted this change. ( https://review.coreboot.org/c/coreboot/+/80632?usp=email )
Change subject: soc/intel/xeon_sp: Add memory type check utils ......................................................................
soc/intel/xeon_sp: Add memory type check utils
FSP memory type representations change across Xeon-SP SoCs. This patch adds type check utils to abstract the differences.
TEST=intel/archercity CRB
Change-Id: I2f5f3c0f16dc50bc739146e46afce2e5fbf4f62c Signed-off-by: Shuo Liu shuo.liu@intel.com Signed-off-by: Jincheng Li jincheng.li@intel.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/80632 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Lean Sheng Tan sheng.tan@9elements.com --- M src/soc/intel/xeon_sp/cpx/soc_util.c M src/soc/intel/xeon_sp/include/soc/util.h M src/soc/intel/xeon_sp/skx/soc_util.c M src/soc/intel/xeon_sp/spr/soc_util.c M src/soc/intel/xeon_sp/uncore_acpi.c 5 files changed, 61 insertions(+), 8 deletions(-)
Approvals: Lean Sheng Tan: Looks good to me, approved build bot (Jenkins): Verified
diff --git a/src/soc/intel/xeon_sp/cpx/soc_util.c b/src/soc/intel/xeon_sp/cpx/soc_util.c index 5dbac98..2d6005b 100644 --- a/src/soc/intel/xeon_sp/cpx/soc_util.c +++ b/src/soc/intel/xeon_sp/cpx/soc_util.c @@ -121,3 +121,18 @@ } } } + +bool is_memtype_reserved(uint16_t mem_type) +{ + return !!(mem_type & MEM_TYPE_RESERVED); +} + +bool is_memtype_non_volatile(uint16_t mem_type) +{ + return !(mem_type & MEMTYPE_VOLATILE_MASK); +} + +bool is_memtype_processor_attached(uint16_t mem_type) +{ + return true; +} diff --git a/src/soc/intel/xeon_sp/include/soc/util.h b/src/soc/intel/xeon_sp/include/soc/util.h index dd84f0c..a7d5dac 100644 --- a/src/soc/intel/xeon_sp/include/soc/util.h +++ b/src/soc/intel/xeon_sp/include/soc/util.h @@ -19,6 +19,10 @@ void set_bios_init_completion(void); uint8_t soc_get_iio_ioapicid(int socket, int stack);
+bool is_memtype_non_volatile(uint16_t mem_type); +bool is_memtype_reserved(uint16_t mem_type); +bool is_memtype_processor_attached(uint16_t mem_type); + struct iiostack_resource { uint8_t no_of_stacks; STACK_RES res[CONFIG_MAX_SOCKET * MAX_IIO_STACK]; diff --git a/src/soc/intel/xeon_sp/skx/soc_util.c b/src/soc/intel/xeon_sp/skx/soc_util.c index 12d30d4..38d834f 100644 --- a/src/soc/intel/xeon_sp/skx/soc_util.c +++ b/src/soc/intel/xeon_sp/skx/soc_util.c @@ -195,3 +195,18 @@ } return ioapic_id; } + +bool is_memtype_reserved(uint16_t mem_type) +{ + return !!(mem_type & MEM_TYPE_RESERVED); +} + +bool is_memtype_non_volatile(uint16_t mem_type) +{ + return !(mem_type & MEMTYPE_VOLATILE_MASK); +} + +bool is_memtype_processor_attached(uint16_t mem_type) +{ + return true; +} diff --git a/src/soc/intel/xeon_sp/spr/soc_util.c b/src/soc/intel/xeon_sp/spr/soc_util.c index b8f06ac..41b256c 100644 --- a/src/soc/intel/xeon_sp/spr/soc_util.c +++ b/src/soc/intel/xeon_sp/spr/soc_util.c @@ -167,3 +167,24 @@ cmos_write(new_mrc_status, CMOS_OFFSET_MRC_STATUS);
} + +bool is_memtype_reserved(uint16_t mem_type) +{ + return !!(mem_type & MEM_TYPE_RESERVED); +} + +bool is_memtype_non_volatile(uint16_t mem_type) +{ + return !(mem_type & MEMTYPE_VOLATILE_MASK); +} + +bool is_memtype_processor_attached(uint16_t mem_type) +{ + /* + * Refer to the definition of MEM_TYPE enum type in + * vendorcode/intel/fsp/fsp2_0/sapphirerapids_sp/MemoryMapDataHob.h, + * values less than MemTypeCxlAccVolatileMem represents + * processor attached memory + */ + return (mem_type < MemTypeCxlAccVolatileMem); +} diff --git a/src/soc/intel/xeon_sp/uncore_acpi.c b/src/soc/intel/xeon_sp/uncore_acpi.c index b4856120..b7c6640 100644 --- a/src/soc/intel/xeon_sp/uncore_acpi.c +++ b/src/soc/intel/xeon_sp/uncore_acpi.c @@ -99,19 +99,17 @@ "ElementSize: 0x%x, type: %d, reserved: %d\n", e, addr, mem_element->BaseAddress, size, mem_element->ElementSize, mem_element->Type, - (mem_element->Type & MEM_TYPE_RESERVED)); + is_memtype_reserved(mem_element->Type));
assert(mmap_index < MAX_ACPI_MEMORY_AFFINITY_COUNT);
/* skip reserved memory region */ - if (mem_element->Type & MEM_TYPE_RESERVED) + if (is_memtype_reserved(mem_element->Type)) continue; -#if CONFIG(SOC_INTEL_SAPPHIRERAPIDS_SP) - /* Skip all non processor attached memory regions */ - /* In other words, skip all the types >= MemTypeCxlAccVolatileMem */ - if (mem_element->Type >= MemTypeCxlAccVolatileMem) + /* skip all non processor attached memory regions */ + if (CONFIG(SOC_INTEL_HAS_CXL) && + (!is_memtype_processor_attached(mem_element->Type))) continue; -#endif
/* skip if this address is already added */ bool skip = false; @@ -134,7 +132,7 @@ srat_mem[mmap_index].length_high = (uint32_t)(size >> 32); srat_mem[mmap_index].proximity_domain = mem_element->SocketId; srat_mem[mmap_index].flags = ACPI_SRAT_MEMORY_ENABLED; - if ((mem_element->Type & MEMTYPE_VOLATILE_MASK) == 0) + if (is_memtype_non_volatile(mem_element->Type)) srat_mem[mmap_index].flags |= ACPI_SRAT_MEMORY_NONVOLATILE; ++mmap_index; }