From: Avadhut Naik <avadhut.naik@amd.com>
To: <linux-edac@vger.kernel.org>, <linux-doc@vger.kernel.org>
Cc: <bp@alien8.de>, <gregkh@linuxfoundation.org>, <corbet@lwn.net>,
<chenhuacai@kernel.org>, <mchehab+huawei@kernel.org>,
<yazen.ghannam@amd.com>, <linux-kernel@vger.kernel.org>,
<avadhut.naik@amd.com>
Subject: [PATCH v2 2/3] EDAC/amd64: Remove NUM_CONTROLLERS macro
Date: Thu, 6 Nov 2025 01:54:45 +0000 [thread overview]
Message-ID: <20251106015727.1987246-3-avadhut.naik@amd.com> (raw)
In-Reply-To: <20251106015727.1987246-1-avadhut.naik@amd.com>
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 by this
change.
Signed-off-by: Avadhut Naik <avadhut.naik@amd.com>
---
drivers/edac/amd64_edac.c | 5 +++++
drivers/edac/amd64_edac.h | 3 +--
2 files changed, 6 insertions(+), 2 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 4ec6133d5179..1757c1b99fc8 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
@@ -348,7 +347,7 @@ struct amd64_pvt {
u32 dbam1; /* DRAM Base Address Mapping reg for DCT1 */
/* one for each DCT/UMC */
- struct chip_select csels[NUM_CONTROLLERS];
+ 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-11-06 1:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-06 1:54 [PATCH v2 0/3] Cleanups in amd64_edac and removal of legacy EDAC sysfs interface Avadhut Naik
2025-11-06 1:54 ` [PATCH v2 1/3] EDAC/amd64: Generate ctl_name string at runtime Avadhut Naik
2025-11-06 1:54 ` Avadhut Naik [this message]
2025-11-06 1:54 ` [PATCH v2 3/3] edac: Remove the legacy EDAC sysfs interface Avadhut Naik
2025-11-07 12:40 ` [PATCH v2 0/3] Cleanups in amd64_edac and removal of " Borislav Petkov
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=20251106015727.1987246-3-avadhut.naik@amd.com \
--to=avadhut.naik@amd.com \
--cc=bp@alien8.de \
--cc=chenhuacai@kernel.org \
--cc=corbet@lwn.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab+huawei@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
all inboxes | Powered by JetHome®