mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vishal Badole <Vishal.Badole@amd.com>
To: <bp@alien8.de>, <yazen.ghannam@amd.com>, <tony.luck@intel.com>,
	<linux-edac@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: Vishal Badole <Vishal.Badole@amd.com>
Subject: [PATCH Intenal 2/2] EDAC/amd64: Limit UMC csrow decode to the implemented chip selects
Date: Wed, 23 Sep 2026 16:50:03 +0530	[thread overview]
Message-ID: <20260923112003.3677719-3-Vishal.Badole@amd.com> (raw)
In-Reply-To: <20260923112003.3677719-1-Vishal.Badole@amd.com>

For DRAM ECC errors on SMCA systems, the Chip Select which reported the
error is encoded in the MCA_SYND[ErrorInformation] field. The EDAC core
uses that value to index into the csrow array which was sized during
probe from pvt->csels[].b_cnt.

On Family 1Ah Model 88h a corrected DRAM error results in:

  EDAC MC0: INTERNAL ERROR: csrow value is out of range (5 >= 4)
  WARNING: drivers/edac/edac_mc.c:919 at edac_raw_mc_handle_error

and the error is subsequently reported against "unknown memory", so the
DIMM which actually reported the error cannot be identified.

This happens because the syndrome field is masked with a hardcoded 0x7,
i.e. eight possible chip selects, while umc_prep_chip_selects() sizes
every UMC channel for four. Bit 2 of that field is therefore not a valid
Chip Select bit, and whenever hardware leaves it set the decoded value
exceeds the number of csrows the EDAC core knows about.

Mask with the number of chip selects the controller actually implements
so the decoded value can never exceed what was allocated, instead of
relying on an assumption about the field width that no longer holds.

Signed-off-by: Vishal Badole <Vishal.Badole@amd.com>
---
 drivers/edac/amd64_edac.c | 13 +++++++------
 drivers/edac/amd64_edac.h |  2 +-
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index ff0ebc8e15f6..f6f9b8e63234 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -2796,13 +2796,14 @@ static inline void decode_bus_error(int node_id, struct mce *m)
  * the instance_id. For example, instance_id=0xYXXXXX where Y is the channel
  * number.
  *
- * For DRAM ECC errors, the Chip Select number is given in bits [2:0] of
- * the MCA_SYND[ErrorInformation] field.
+ * For DRAM ECC errors, the Chip Select number is given in the low bits of
+ * the MCA_SYND[ErrorInformation] field. Only as many bits as the UMC has
+ * implemented chip selects are valid there.
  */
-static void umc_get_err_info(struct mce *m, struct err_info *err)
+static void umc_get_err_info(struct amd64_pvt *pvt, struct mce *m, struct err_info *err)
 {
 	err->channel = (m->ipid & GENMASK(31, 0)) >> 20;
-	err->csrow = m->synd & 0x7;
+	err->csrow = m->synd & (pvt->csels[0].b_cnt - 1);
 }
 
 static void decode_umc_error(int node_id, struct mce *m)
@@ -2841,7 +2842,7 @@ static void decode_umc_error(int node_id, struct mce *m)
 			err.err_code = ERR_CHANNEL;
 	}
 
-	pvt->ops->get_err_info(m, &err);
+	pvt->ops->get_err_info(pvt, m, &err);
 
 	a_err.addr = m->addr;
 	a_err.ipid = m->ipid;
@@ -3514,7 +3515,7 @@ static int umc_hw_info_get(struct amd64_pvt *pvt)
  * UMC1 CH[3:0] = 0x0025[3:0]000
  * UMC1 CH[7:4] = 0x0035[3:0]000
  */
-static void gpu_get_err_info(struct mce *m, struct err_info *err)
+static void gpu_get_err_info(struct amd64_pvt *pvt, struct mce *m, struct err_info *err)
 {
 	u8 ch = (m->ipid & GENMASK(31, 0)) >> 20;
 	u8 phy = ((m->ipid >> 12) & 0xf);
diff --git a/drivers/edac/amd64_edac.h b/drivers/edac/amd64_edac.h
index 1757c1b99fc8..9a8b7e296087 100644
--- a/drivers/edac/amd64_edac.h
+++ b/drivers/edac/amd64_edac.h
@@ -467,7 +467,7 @@ struct low_ops {
 	bool (*ecc_enabled)(struct amd64_pvt *pvt);
 	void (*setup_mci_misc_attrs)(struct mem_ctl_info *mci);
 	void (*dump_misc_regs)(struct amd64_pvt *pvt);
-	void (*get_err_info)(struct mce *m, struct err_info *err);
+	void (*get_err_info)(struct amd64_pvt *pvt, struct mce *m, struct err_info *err);
 };
 
 int __amd64_read_pci_cfg_dword(struct pci_dev *pdev, int offset,
-- 
2.34.1


  parent reply	other threads:[~2026-09-23 11:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23 11:20 [PATCH Intenal 0/2] EDAC/amd64: Add Family 1Ah Model 80h-8Fh support and fix csrow decode Vishal Badole
2026-09-23 11:20 ` [PATCH Intenal 1/2] EDAC/amd64: Add support for AMD family 1Ah models 80h-8Fh Vishal Badole
2026-09-24 14:11   ` Yazen Ghannam
2026-09-23 11:20 ` Vishal Badole [this message]
2026-09-24 14:27   ` [PATCH Intenal 2/2] EDAC/amd64: Limit UMC csrow decode to the implemented chip selects Yazen Ghannam

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=20260923112003.3677719-3-Vishal.Badole@amd.com \
    --to=vishal.badole@amd.com \
    --cc=bp@alien8.de \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tony.luck@intel.com \
    --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®