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 v3 2/5] EDAC/amd64: Remove NUM_CONTROLLERS macro
Date: Tue, 9 Sep 2025 18:53:11 +0000 [thread overview]
Message-ID: <20250909185748.1621098-3-avadhut.naik@amd.com> (raw)
In-Reply-To: <20250909185748.1621098-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.
Signed-off-by: Avadhut Naik <avadhut.naik@amd.com>
---
Changes in v3:
Patch introduced.
---
drivers/edac/amd64_edac.c | 19 +++++++++++++------
drivers/edac/amd64_edac.h | 5 ++---
2 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index 3989794e4f29..0fade110c3fb 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -4000,30 +4000,34 @@ static int probe_one_instance(unsigned int nid)
if (ret < 0)
goto err_enable;
+ pvt->csels = kcalloc(pvt->max_mcs, sizeof(*pvt->csels), GFP_KERNEL);
+ if (!pvt->csels)
+ goto err_enable;
+
ret = pvt->ops->hw_info_get(pvt);
if (ret < 0)
- goto err_enable;
+ goto err_csels;
ret = 0;
if (!instance_has_memory(pvt)) {
amd64_info("Node %d: No DIMMs detected.\n", nid);
- goto err_enable;
+ goto err_csels;
}
if (!pvt->ops->ecc_enabled(pvt)) {
ret = -ENODEV;
if (!ecc_enable_override)
- goto err_enable;
+ goto err_csels;
if (boot_cpu_data.x86 >= 0x17) {
amd64_warn("Forcing ECC on is not recommended on newer systems. Please enable ECC in BIOS.");
- goto err_enable;
+ goto err_csels;
} else
amd64_warn("Forcing ECC on!\n");
if (!enable_ecc_error_reporting(s, nid, F3))
- goto err_enable;
+ goto err_csels;
}
ret = init_one_instance(pvt);
@@ -4033,7 +4037,7 @@ static int probe_one_instance(unsigned int nid)
if (boot_cpu_data.x86 < 0x17)
restore_ecc_error_reporting(s, nid, F3);
- goto err_enable;
+ goto err_csels;
}
amd64_info("%s detected (node %d).\n", pvt->ctl_name, pvt->mc_node_id);
@@ -4043,6 +4047,8 @@ static int probe_one_instance(unsigned int nid)
return ret;
+err_csels:
+ kfree(pvt->csels);
err_enable:
hw_info_put(pvt);
kfree(pvt);
@@ -4077,6 +4083,7 @@ static void remove_one_instance(unsigned int nid)
/* Free the EDAC CORE resources */
mci->pvt_info = NULL;
+ kfree(pvt->csels);
hw_info_put(pvt);
kfree(pvt);
edac_mc_free(mci);
diff --git a/drivers/edac/amd64_edac.h b/drivers/edac/amd64_edac.h
index 56999ed3ae56..39d30255c767 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 12
#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-09-09 18:58 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-09 18:53 [PATCH v3 0/5] Cleanup and add support for AMD Family 1Ah-based SOCs Avadhut Naik
2025-09-09 18:53 ` [PATCH v3 1/5] EDAC/amd64: Generate ctl_name string at runtime Avadhut Naik
2025-09-10 14:51 ` Yazen Ghannam
2025-09-10 15:53 ` Naik, Avadhut
2025-09-09 18:53 ` Avadhut Naik [this message]
2025-09-10 15:05 ` [PATCH v3 2/5] EDAC/amd64: Remove NUM_CONTROLLERS macro Yazen Ghannam
2025-09-10 15:48 ` Naik, Avadhut
2025-09-09 18:53 ` [PATCH v3 3/5] EDAC/amd64: Add support for AMD family 1Ah-based newer models Avadhut Naik
2025-09-10 15:13 ` Yazen Ghannam
2025-09-10 16:08 ` Naik, Avadhut
2025-09-09 18:53 ` [PATCH v3 4/5] EDAC/mc_sysfs: Increase legacy channel support to 16 Avadhut Naik
2025-09-10 15:17 ` Yazen Ghannam
2025-09-10 15:29 ` Naik, Avadhut
2025-09-09 18:53 ` [PATCH v3 5/5] EDAC/mc_sysfs: Begin deprecating legacy sysfs EDAC interface Avadhut Naik
2025-09-10 15:24 ` Yazen Ghannam
2025-09-10 17:38 ` Naik, Avadhut
2025-09-15 17:04 ` Yazen Ghannam
2025-09-16 16:09 ` 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=20250909185748.1621098-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