Skip to content

Commit 6a85796

Browse files
Avadhut Naikbp3tk0v
authored andcommitted
EDAC/amd64: Remove NUM_CONTROLLERS macro
Currently, the NUM_CONTROLLERS macro is used to limit the amount of memory controllers (UMCs) available per node. The number of UMCs available per node, however, is already cached by the max_mcs variable of struct amd64_pvt. Allocate the relevant data structures dynamically using the variable instead of static allocation through the macro. The max_mcs variable is used for legacy systems too. These systems have a max of 2 controllers. Since the default value of max_mcs, set in per_family_init(), is 2, these legacy systems are also covered. Signed-off-by: Avadhut Naik <avadhut.naik@amd.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://lore.kernel.org/20251106015727.1987246-1-avadhut.naik@amd.com
1 parent e9abd99 commit 6a85796

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

drivers/edac/amd64_edac.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3732,6 +3732,7 @@ static void hw_info_put(struct amd64_pvt *pvt)
37323732
pci_dev_put(pvt->F1);
37333733
pci_dev_put(pvt->F2);
37343734
kfree(pvt->umc);
3735+
kfree(pvt->csels);
37353736
}
37363737

37373738
static struct low_ops umc_ops = {
@@ -3915,6 +3916,10 @@ static int per_family_init(struct amd64_pvt *pvt)
39153916
scnprintf(pvt->ctl_name, sizeof(pvt->ctl_name), "F%02Xh_M%02Xh",
39163917
pvt->fam, pvt->model);
39173918

3919+
pvt->csels = kcalloc(pvt->max_mcs, sizeof(*pvt->csels), GFP_KERNEL);
3920+
if (!pvt->csels)
3921+
return -ENOMEM;
3922+
39183923
return 0;
39193924
}
39203925

drivers/edac/amd64_edac.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@
9696
/* Hardware limit on ChipSelect rows per MC and processors per system */
9797
#define NUM_CHIPSELECTS 8
9898
#define DRAM_RANGES 8
99-
#define NUM_CONTROLLERS 16
10099

101100
#define ON true
102101
#define OFF false
@@ -348,7 +347,7 @@ struct amd64_pvt {
348347
u32 dbam1; /* DRAM Base Address Mapping reg for DCT1 */
349348

350349
/* one for each DCT/UMC */
351-
struct chip_select csels[NUM_CONTROLLERS];
350+
struct chip_select *csels;
352351

353352
/* DRAM base and limit pairs F1x[78,70,68,60,58,50,48,40] */
354353
struct dram_range ranges[DRAM_RANGES];

0 commit comments

Comments
 (0)