From: Avadhut Naik <avadhut.naik@amd.com>
To: <linux-edac@vger.kernel.org>
Cc: <bp@alien8.de>, <yazen.ghannam@amd.com>,
<linux-kernel@vger.kernel.org>, <avadhut.naik@amd.com>
Subject: [PATCH 2/4] EDAC/amd64: Remove NUM_CONTROLLERS macro
Date: Mon, 13 Oct 2025 17:30:41 +0000 [thread overview]
Message-ID: <20251013173632.1449366-3-avadhut.naik@amd.com> (raw)
In-Reply-To: <20251013173632.1449366-1-avadhut.naik@amd.com>
Currently, the NUM_CONTROLLERS macro is only used to statically allocate
the csels array of struct chip_select in struct amd64_pvt.
The size of this array, however, will never exceed the number of UMCs on
the SOC. Since, max_mcs variable in struct amd64_pvt already stores the
number of UMCs on the SOC, the macro can be removed and the static array
can be dynamically allocated instead.
The max_mcs variable and the csels array are used for legacy systems too.
These systems have a max of 2 controllers (DCTs). Since the default value
of max_mcs, set in per_family_init(), is 2, these legacy system are also
covered by this change.
Signed-off-by: Avadhut Naik <avadhut.naik@amd.com>
---
drivers/edac/amd64_edac.c | 5 +++++
drivers/edac/amd64_edac.h | 5 ++---
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index 886ad075d222..2391f3469961 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -3732,6 +3732,7 @@ static void hw_info_put(struct amd64_pvt *pvt)
pci_dev_put(pvt->F1);
pci_dev_put(pvt->F2);
kfree(pvt->umc);
+ kfree(pvt->csels);
}
static struct low_ops umc_ops = {
@@ -3915,6 +3916,10 @@ static int per_family_init(struct amd64_pvt *pvt)
scnprintf(pvt->ctl_name, sizeof(pvt->ctl_name), "F%02Xh_M%02Xh",
pvt->fam, pvt->model);
+ pvt->csels = kcalloc(pvt->max_mcs, sizeof(*pvt->csels), GFP_KERNEL);
+ if (!pvt->csels)
+ return -ENOMEM;
+
return 0;
}
diff --git a/drivers/edac/amd64_edac.h b/drivers/edac/amd64_edac.h
index bb6cf4b1ab77..5f61631c8a7d 100644
--- a/drivers/edac/amd64_edac.h
+++ b/drivers/edac/amd64_edac.h
@@ -96,7 +96,6 @@
/* Hardware limit on ChipSelect rows per MC and processors per system */
#define NUM_CHIPSELECTS 8
#define DRAM_RANGES 8
-#define NUM_CONTROLLERS 16
#define ON true
#define OFF false
@@ -347,8 +346,8 @@ struct amd64_pvt {
u32 dbam0; /* DRAM Base Address Mapping reg for DCT0 */
u32 dbam1; /* DRAM Base Address Mapping reg for DCT1 */
- /* one for each DCT/UMC */
- struct chip_select csels[NUM_CONTROLLERS];
+ /* Allocate one for each DCT/UMC */
+ struct chip_select *csels;
/* DRAM base and limit pairs F1x[78,70,68,60,58,50,48,40] */
struct dram_range ranges[DRAM_RANGES];
--
2.43.0
next prev parent reply other threads:[~2025-10-13 17:37 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-13 17:30 [PATCH 0/4] Cleanups in amd64_edac Avadhut Naik
2025-10-13 17:30 ` [PATCH 1/4] EDAC/amd64: Generate ctl_name string at runtime Avadhut Naik
2025-10-20 13:47 ` Borislav Petkov
2025-10-20 18:28 ` Naik, Avadhut
2025-10-20 19:09 ` Borislav Petkov
2025-10-13 17:30 ` Avadhut Naik [this message]
2025-10-21 10:44 ` [PATCH 2/4] EDAC/amd64: Remove NUM_CONTROLLERS macro Borislav Petkov
2025-10-22 6:07 ` Naik, Avadhut
2025-10-13 17:30 ` [PATCH 3/4] EDAC/amd64: Set zn_regs_v2 flag for all AMD Family 1Ah-based SOCs Avadhut Naik
2025-10-29 17:10 ` Borislav Petkov
2025-10-30 13:48 ` Yazen Ghannam
2025-11-03 21:18 ` Borislav Petkov
2025-11-04 14:59 ` Yazen Ghannam
2025-10-13 17:30 ` [PATCH 4/4] EDAC/mc_sysfs: Begin deprecating legacy sysfs EDAC interface Avadhut Naik
2025-10-29 17:24 ` Borislav Petkov
2025-10-30 14:52 ` Naik, Avadhut
2025-10-30 15:01 ` Greg KH
2025-10-30 19:18 ` Borislav Petkov
2025-10-31 12:38 ` Greg KH
2025-10-31 12:54 ` Borislav Petkov
2025-10-31 19:34 ` Naik, Avadhut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251013173632.1449366-3-avadhut.naik@amd.com \
--to=avadhut.naik@amd.com \
--cc=bp@alien8.de \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=yazen.ghannam@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox