Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

EDAC/i10nm: Reallocate skx_dev list if preconfigured cnt != runtime cnt

Ideally, read the present DDR memory controller count first and then
allocate the skx_dev list using this count. However, this approach
requires adding a significant amount of code similar to
skx_get_all_bus_mappings() to obtain the PCI bus mappings for the first
socket and use these mappings along with the related PCI register offset
to read the memory controller count.

Given that the Granite Rapids CPU is the only one that can detect the
count of memory controllers at runtime (other CPUs use the count in the
configuration data), to reduce code complexity, reallocate the skx_dev
list only if the preconfigured count of DDR memory controllers differs
from the count read at runtime for Granite Rapids CPU.

Signed-off-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Link: https://lore.kernel.org/r/20250731145534.2759334-7-qiuxu.zhuo@intel.com

authored by

Qiuxu Zhuo and committed by
Tony Luck
f7a29a37 91ded20f

+7 -6
+7 -6
drivers/edac/i10nm_base.c
··· 468 468 return -ENODEV; 469 469 } 470 470 471 - if (imc_num > I10NM_NUM_DDR_IMC) { 472 - i10nm_printk(KERN_ERR, "Need to make I10NM_NUM_DDR_IMC >= %d\n", imc_num); 473 - return -EINVAL; 474 - } 475 - 476 471 if (cfg->ddr_imc_num != imc_num) { 477 472 /* 478 - * Store the number of present DDR memory controllers. 473 + * Update the configuration data to reflect the number of 474 + * present DDR memory controllers. 479 475 */ 480 476 cfg->ddr_imc_num = imc_num; 481 477 edac_dbg(2, "Set DDR MC number: %d", imc_num); 478 + 479 + /* Release and reallocate skx_dev list with the updated number. */ 480 + skx_remove(); 481 + if (skx_get_all_bus_mappings(cfg, &i10nm_edac_list) <= 0) 482 + return -ENODEV; 482 483 } 483 484 484 485 return 0;