]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
EDAC/skx_common: Make skx_dev->imc[] a flexible array
authorQiuxu Zhuo <qiuxu.zhuo@intel.com>
Thu, 31 Jul 2025 14:55:31 +0000 (22:55 +0800)
committerTony Luck <tony.luck@intel.com>
Tue, 19 Aug 2025 23:24:09 +0000 (16:24 -0700)
The current skx->imc[NUM_IMC] array of memory controller instances is
sized using the macro NUM_IMC. Each time EDAC support is added for a
new CPU, NUM_IMC needs to be updated to ensure it is greater than or
equal to the number of memory controllers for the new CPU. This approach
is inconvenient and results in memory waste for older CPUs with fewer
memory controllers.

To address this, make skx->imc[] a flexible array and determine its size
from configuration data or at runtime.

Suggested-by: Tony Luck <tony.luck@intel.com>
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-5-qiuxu.zhuo@intel.com
drivers/edac/skx_common.c
drivers/edac/skx_common.h

index e03268e9073f19c0d52e38aeee678da70fe41f93..09187043c0451d5be937c956002b142bebf8e437 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/acpi.h>
 #include <linux/dmi.h>
 #include <linux/adxl.h>
+#include <linux/overflow.h>
 #include <acpi/nfit.h>
 #include <asm/mce.h>
 #include <asm/uv/uv.h>
@@ -343,7 +344,7 @@ int skx_get_all_bus_mappings(struct res_config *cfg, struct list_head **list)
                if (!pdev)
                        break;
                ndev++;
-               d = kzalloc(sizeof(*d), GFP_KERNEL);
+               d = kzalloc(struct_size(d, imc, imc_num), GFP_KERNEL);
                if (!d) {
                        pci_dev_put(pdev);
                        return -ENOMEM;
index 95d61d23f89ef41ad0449ff32cfe72d8fde0016f..e7038fd45d0631a43916cc287ce022bb91c2257b 100644 (file)
@@ -172,7 +172,7 @@ struct skx_dev {
                                u8 colbits;
                        } dimms[NUM_DIMMS];
                } chan[NUM_CHANNELS];
-       } imc[NUM_IMC];
+       } imc[];
 };
 
 struct skx_pvt {