public inbox for linux-edac@vger.kernel.org
 help / color / mirror / Atom feed
From: Muralidhara M K <muralimk@amd.com>
To: <linux-edac@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <bp@alien8.de>,
	<mchehab@kernel.org>, Muralidhara M K <muralidhara.mk@amd.com>
Subject: [PATCH v2 4/6] RAS: Add static lookup table to get CS physical ID
Date: Wed, 29 Nov 2023 07:35:19 +0000	[thread overview]
Message-ID: <20231129073521.2127403-5-muralimk@amd.com> (raw)
In-Reply-To: <20231129073521.2127403-1-muralimk@amd.com>

From: Muralidhara M K <muralidhara.mk@amd.com>

AMD MI300A models have a single Data Fabric (DF) instance per socket.
So, all 4 AIDs are not software-visible (using PCI Device 18h, etc.).

The MCA_IPID_UMC[InstanceId] field holds the SMN base address for the
UMC instance and SMN address mapping repeated same for each of all 4
AIDs in as socket.

Add a static lookup table by reading the UMC SMN address from the
MCA_IPID_UMC[InstanceId] field and use the value to look up the
CS physical ID from the table.

Signed-off-by: Muralidhara M K <muralidhara.mk@amd.com>
---
Changes:
v1 -> v2 : None

 drivers/ras/amd/atl/umc.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/drivers/ras/amd/atl/umc.c b/drivers/ras/amd/atl/umc.c
index 94eb2c5eae3b..3533db279cec 100644
--- a/drivers/ras/amd/atl/umc.c
+++ b/drivers/ras/amd/atl/umc.c
@@ -153,6 +153,35 @@ static int umc_ondie_addr_to_normaddr(u64 mca_addr, u16 nid)
 	return mca_addr;
 }
 
+/*
+ * MCA_IPID_UMC[InstanceId] holds the SMN Base Address for a UMC instance.
+ * MI-300 has a fixed, model-specific mapping between a UMC instance and its
+ * related Data Fabric CS instance.
+ * Use the UMC SMN Base Address value to find the appropriate CS instance ID.
+ */
+static const u32 csmap[32] = {
+	0x393f00, 0x293f00, 0x193f00, 0x093f00, 0x392f00, 0x292f00,
+	0x192f00, 0x092f00, 0x391f00, 0x291f00, 0x191f00, 0x091f00,
+	0x390f00, 0x290f00, 0x190f00, 0x090f00, 0x793f00, 0x693f00,
+	0x593f00, 0x493f00, 0x792f00, 0x692f00, 0x592f00, 0x492f00,
+	0x791f00, 0x691f00, 0x591f00, 0x491f00, 0x790f00, 0x690f00,
+	0x590f00, 0x490f00 };
+
+/* MCA_IPID[InstanceId] give the Instance Number UMC SmnAddr */
+#define UMC_PHY_INSTANCE_NUM GENMASK(31, 0)
+
+static u8 fixup_cs_inst_id(struct mce *m)
+{
+	u32 smn_addr = FIELD_GET(UMC_PHY_INSTANCE_NUM, m->ipid);
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(csmap); i++) {
+		if (smn_addr == csmap[i])
+			break;
+	}
+	return i;
+}
+
 static u8 get_socket_id(struct mce *m)
 {
 	return m->socketid;
@@ -187,6 +216,10 @@ static u64 get_norm_addr(struct mce *m)
 #define UMC_CHANNEL_NUM	GENMASK(31, 20)
 static u8 get_cs_inst_id(struct mce *m)
 {
+	/* MI300: static mapping table for MCA_IPID[InstanceId] to CS physical ID. */
+	if (df_cfg.rev == DF4p5 && df_cfg.flags.heterogeneous)
+		return fixup_cs_inst_id(m);
+
 	return FIELD_GET(UMC_CHANNEL_NUM, m->ipid);
 }
 
-- 
2.25.1


  parent reply	other threads:[~2023-11-29  7:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-29  7:35 [PATCH v2 0/6] Address Translation support for MI200 and MI300 models Muralidhara M K
2023-11-29  7:35 ` [PATCH v2 1/6] RAS: Add Address Translation support for MI200 Muralidhara M K
2023-11-29  7:35 ` [PATCH v2 2/6] RAS: Add Address Translation support for MI300 Muralidhara M K
2023-11-29  7:35 ` [PATCH v2 3/6] RAS: Add MCA Error address conversion for UMC Muralidhara M K
2023-11-29  7:35 ` Muralidhara M K [this message]
2023-11-29  7:35 ` [PATCH v2 5/6] RAS: Add fixed Physical to logical CS ID mapping table Muralidhara M K
2023-11-29  7:35 ` [PATCH v2 6/6] RAS: EDAC/amd64: Retire all system physical address from HBM3 row Muralidhara M K

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=20231129073521.2127403-5-muralimk@amd.com \
    --to=muralimk@amd.com \
    --cc=bp@alien8.de \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=muralidhara.mk@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