Skip to contentSkip to conversation

x86/MCE/AMD, EDAC/mce_amd: Add new SMCA bank types.

PATCH Superseded Naveen Krishna Chatradhi 7 participants 34 messages May 11, 2021 – Sep 27, 2021

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 x86/MCE/AMD, EDAC/mce_amd: Add new SMCA bank types.

From: Muralidhara M K <[email protected]>

Add the (HWID, MCATYPE) tuples and names for new
SMCA bank types.

Also, add their respective error descriptions to the MCE decoding module edac_mce_amd.

---
 arch/x86/include/asm/mce.h    |  5 +++
 arch/x86/kernel/cpu/mce/amd.c | 16 ++++++++
 drivers/edac/mce_amd.c        | 70 +++++++++++++++++++++++++++++++++++
 3 files changed, 91 insertions(+)
arch/x86/include/asm/mce.h +5 -0
index ddfb3cad8dff..cf7f35fdf2c8 100644
@@ -317,6 +317,7 @@ enum smca_bank_types {
 	SMCA_CS_V2,	/* Coherent Slave */
 	SMCA_PIE,	/* Power, Interrupts, etc. */
 	SMCA_UMC,	/* Unified Memory Controller */
+	SMCA_UMC_V2,	/* Unified Memory Controller */
 	SMCA_PB,	/* Parameter Block */
 	SMCA_PSP,	/* Platform Security Processor */
 	SMCA_PSP_V2,	/* Platform Security Processor */
@@ -325,6 +326,10 @@ enum smca_bank_types {
 	SMCA_MP5,	/* Microprocessor 5 Unit */
 	SMCA_NBIO,	/* Northbridge IO Unit */
 	SMCA_PCIE,	/* PCI Express Unit */
+	SMCA_PCIE_V2,	/* PCI Express Unit */
+	SMCA_XGMI_PCS,	/* xGMI PCS Unit */
+	SMCA_XGMI_PHY,	/* xGMI PHY Unit */
+	SMCA_WAFL_PHY,	/* WAFL PHY Unit */
 	N_SMCA_BANK_TYPES
 };
 
arch/x86/kernel/cpu/mce/amd.c +16 -0
index e486f96b3cb3..055f3a0acf5e 100644
@@ -90,6 +90,7 @@ static struct smca_bank_name smca_names[] = {
 	[SMCA_CS_V2]	= { "coherent_slave",	"Coherent Slave" },
 	[SMCA_PIE]	= { "pie",		"Power, Interrupts, etc." },
 	[SMCA_UMC]	= { "umc",		"Unified Memory Controller" },
+	[SMCA_UMC_V2]	= { "umc_v2",		"Unified Memory Controller" },
 	[SMCA_PB]	= { "param_block",	"Parameter Block" },
 	[SMCA_PSP]	= { "psp",		"Platform Security Processor" },
 	[SMCA_PSP_V2]	= { "psp",		"Platform Security Processor" },
@@ -98,6 +99,10 @@ static struct smca_bank_name smca_names[] = {
 	[SMCA_MP5]	= { "mp5",		"Microprocessor 5 Unit" },
 	[SMCA_NBIO]	= { "nbio",		"Northbridge IO Unit" },
 	[SMCA_PCIE]	= { "pcie",		"PCI Express Unit" },
+	[SMCA_PCIE_V2]	= { "pcie",		"PCI Express Unit" },
+	[SMCA_XGMI_PCS]	= { "xgmi_pcs",		"Ext Global Memory Interconnect PCS Unit" },
+	[SMCA_XGMI_PHY]	= { "xgmi_phy",		"Ext Global Memory Interconnect PHY Unit" },
+	[SMCA_WAFL_PHY]	= { "wafl_phy",		"WAFL PHY Unit" },
 };
 
 static const char *smca_get_name(enum smca_bank_types t)
@@ -155,6 +160,7 @@ static struct smca_hwid smca_hwid_mcatypes[] = {
 
 	/* Unified Memory Controller MCA type */
 	{ SMCA_UMC,	 HWID_MCATYPE(0x96, 0x0)	},
+	{ SMCA_UMC_V2,	 HWID_MCATYPE(0x96, 0x1)	},
 
 	/* Parameter Block MCA type */
 	{ SMCA_PB,	 HWID_MCATYPE(0x05, 0x0)	},
@@ -175,6 +181,16 @@ static struct smca_hwid smca_hwid_mcatypes[] = {
 
 	/* PCI Express Unit MCA type */
 	{ SMCA_PCIE,	 HWID_MCATYPE(0x46, 0x0)	},
+	{ SMCA_PCIE_V2,	 HWID_MCATYPE(0x46, 0x1)	},
+
+	/* xGMI PCS MCA type */
+	{ SMCA_XGMI_PCS, HWID_MCATYPE(0x50, 0x0)	},
+
+	/* xGMI PHY MCA type */
+	{ SMCA_XGMI_PHY, HWID_MCATYPE(0x259, 0x0)	},
+
+	/* WAFL PHY MCA type */
+	{ SMCA_WAFL_PHY, HWID_MCATYPE(0x267, 0x0)	},
 };
 
 struct smca_bank smca_banks[MAX_NR_BANKS];
drivers/edac/mce_amd.c +70 -0

94 lines not on this page · raw message

Signature · 1 line
2.17.1
#1 lore raw

PATCH 2/3 x86/MCE/AMD: Helper function to check UMC v2

From: Mukul Joshi <[email protected]>

Add a helper function to check if a given bank is
UMCv2 or not.

---
 arch/x86/include/asm/mce.h    | 2 ++
 arch/x86/kernel/cpu/mce/amd.c | 6 ++++++
 2 files changed, 8 insertions(+)
arch/x86/include/asm/mce.h +2 -0
index cf7f35fdf2c8..8cbe7221a253 100644
@@ -357,6 +357,7 @@ extern int mce_threshold_remove_device(unsigned int cpu);
 
 void mce_amd_feature_init(struct cpuinfo_x86 *c);
 int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr);
+bool is_smca_umc_v2(int bank);
 
 #else
 
@@ -366,6 +367,7 @@ static inline bool amd_mce_is_memory_error(struct mce *m)		{ return false; };
 static inline void mce_amd_feature_init(struct cpuinfo_x86 *c)		{ }
 static inline int
 umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr)	{ return -EINVAL; };
+static inline bool is_smca_umc_v2(int bank)				{ return false;	};
 #endif
 
 static inline void mce_hygon_feature_init(struct cpuinfo_x86 *c)	{ return mce_amd_feature_init(c); }
arch/x86/kernel/cpu/mce/amd.c +6 -0
index 055f3a0acf5e..41718e3111f2 100644
@@ -1542,3 +1542,9 @@ int mce_threshold_create_device(unsigned int cpu)
 	mce_threshold_remove_device(cpu);
 	return err;
 }
+
+bool is_smca_umc_v2(int bank)
+{
+	return (smca_get_bank_type(bank) == SMCA_UMC_V2);
+}
+EXPORT_SYMBOL_GPL(is_smca_umc_v2);
Signature · 1 line
2.17.1
maintainer
#2 lore raw

Re: [PATCH 2/3] x86/MCE/AMD: Helper function to check UMC v2

Quoted 1 line · Naveen Krishna Chatradhi

Subject: Re: [PATCH 2/3] x86/MCE/AMD: Helper function to check UMC v2

The condensed patch description in the subject line should start with a uppercase letter and should be written in imperative tone:

"x86/MCE/AMD: Add a helper function... "

Quoted 3 lines

This is all fine and dandy but it needs your SOB too when you send the patch.

Please read Documentation/process/submitting-patches.rst

sections

Sign your work - the Developer's Certificate of Origin When to use Acked-by:, Cc:, and Co-developed-by:

arch/x86/kernel/cpu/mce/amd.c int mce_threshold_create_device(unsigned int cpu) · line 1550

Quoted 5 lines
arch/x86/kernel/cpu/mce/amd.c +5 -0
+bool is_smca_umc_v2(int bank)
+{
+	return (smca_get_bank_type(bank) == SMCA_UMC_V2);
+}
+EXPORT_SYMBOL_GPL(is_smca_umc_v2);

This addition looks useless when it doesn't have any users.

Also, I'm pretty sceptical this even makes sense to have it exported - I'm guessing this is for mce_amd.c but I can't say without seeing it in use.

The same remarks hold true for your patch 3.

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#3 lore raw

RE: [PATCH 2/3] x86/MCE/AMD: Helper function to check UMC v2

[AMD Official Use Only - Internal Distribution Only]

Hi Boris,

Thanks for the review comments.
I will update the Subject line and send out an updated patch.

In the meantime, here is the link to where the changes in Patch 2 and 3 are being used:
https://lists.freedesktop.org/archives/amd-gfx/2021-May/063423.html

Thanks.

Regards,
Mukul

-----Original Message-----
From: Borislav Petkov <[email protected]>
Sent: Tuesday, May 11, 2021 1:35 PM
To: Chatradhi, Naveen Krishna <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Joshi, Mukul <[email protected]>
Subject: Re: [PATCH 2/3] x86/MCE/AMD: Helper function to check UMC v2

[CAUTION: External Email]

Quoted 1 line · Naveen Krishna Chatradhi

Subject: Re: [PATCH 2/3] x86/MCE/AMD: Helper function to check UMC v2

The condensed patch description in the subject line should start with a uppercase letter and should be written in imperative tone:

"x86/MCE/AMD: Add a helper function... "

Quoted 3 lines

This is all fine and dandy but it needs your SOB too when you send the patch.

Please read Documentation/process/submitting-patches.rst

sections

Sign your work - the Developer's Certificate of Origin When to use Acked-by:, Cc:, and Co-developed-by:

arch/x86/kernel/cpu/mce/amd.c int mce_threshold_create_device(unsigned int cpu) · line 1550

Quoted 4 lines
arch/x86/kernel/cpu/mce/amd.c +4 -0
+bool is_smca_umc_v2(int bank)
+{
+     return (smca_get_bank_type(bank) == SMCA_UMC_V2); } 
+EXPORT_SYMBOL_GPL(is_smca_umc_v2);

This addition looks useless when it doesn't have any users.

Also, I'm pretty sceptical this even makes sense to have it exported - I'm guessing this is for mce_amd.c but I can't say without seeing it in use.

The same remarks hold true for your patch 3.

Thx.

--
Regards/Gruss,
Boris.

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpeople.kernel.org%2Ftglx%2Fnotes-about-netiquette&amp;data=04%7C01%7Cmukul.joshi%40amd.com%7C0a7f1e0a3bf04c9ed89408d914a3141c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637563512928580623%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=z3xbuS8yX4Ea1kG9tWv0tGNQRPZP9N6QcBI2VNjn6W0%3D&amp;reserved=0

maintainer
#4 lore raw

Re: [PATCH 2/3] x86/MCE/AMD: Helper function to check UMC v2

Hi Mukul,

Quoted 1 line · Mukul

[AMD Official Use Only - Internal Distribution Only]

first of all, please do not top-post.

Quoted 2 lines

Thanks for the review comments.
I will update the Subject line and send out an updated patch.

Ok.

Quoted 2 lines

In the meantime, here is the link to where the changes in Patch 2 and 3 are being used:
https://lists.freedesktop.org/archives/amd-gfx/2021-May/063423.html

Yes, in the future, please Cc [email protected] too when you're using/exporting facilities to be used by other subsystems.

I'll try to reply to that patch through lore.kernel.org now.

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#5 lore raw

PATCH v2 1/2 x86/MCE/AMD: Export smca_get_bank_type symbol

In reply to Naveen Krishna Chatradhi

Export smca_get_bank_type for use in the AMD GPU driver to determine MCA bank while handling correctable and uncorrectable errors in GPU UMC.

v1->v2:
- Drop the function is_smca_umc_v2().
- Drop the patch to introduce a new MCE priority (MCE_PRIO_ACEL) for GPU/accelarator cards.

---
 arch/x86/include/asm/mce.h    | 2 +-
 arch/x86/kernel/cpu/mce/amd.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
arch/x86/include/asm/mce.h +1 -1
index fc3d36f1f9d0..d90d3ccb583a 100644
@@ -358,7 +358,7 @@ extern int mce_threshold_remove_device(unsigned int cpu);
 
 void mce_amd_feature_init(struct cpuinfo_x86 *c);
 int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr);
-
+enum smca_bank_types smca_get_bank_type(unsigned int bank);
 #else
 
 static inline int mce_threshold_create_device(unsigned int cpu)		{ return 0; };
arch/x86/kernel/cpu/mce/amd.c +2 -1
index 67a337672ee4..c9272c53026e 100644
@@ -123,7 +123,7 @@ const char *smca_get_long_name(enum smca_bank_types t)
 }
 EXPORT_SYMBOL_GPL(smca_get_long_name);
 
-static enum smca_bank_types smca_get_bank_type(unsigned int bank)
+enum smca_bank_types smca_get_bank_type(unsigned int bank)
 {
 	struct smca_bank *b;
 
@@ -136,6 +136,7 @@ static enum smca_bank_types smca_get_bank_type(unsigned int bank)
 
 	return b->hwid->bank_type;
 }
+EXPORT_SYMBOL_GPL(smca_get_bank_type);
 
 static struct smca_hwid smca_hwid_mcatypes[] = {
 	/* { bank_type, hwid_mcatype } */
Signature · 1 line
2.17.1
#6 lore raw

PATCH v2 2/2 drm/amdgpu: Register MCE notifier for Aldebaran RAS

On Aldebaran, GPU driver will handle bad page retirement even though UMC is host managed. As a result, register a bad page retirement handler on the mce notifier chain to retire bad pages on Aldebaran.

v1->v2:
- Use smca_get_bank_type() to determine MCA bank.
- Envelope the changes under #ifdef CONFIG_X86_MCE_AMD.
- Use MCE_PRIORITY_UC instead of MCE_PRIO_ACCEL as we are only handling uncorrectable errors.
- Use macros to determine UMC instance and channel instance where the uncorrectable error occured.
- Update the headline.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 142 ++++++++++++++++++++++++
 1 file changed, 142 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +142 -0
index b5332db4d287..35cfcc71ff94 100644
@@ -35,7 +35,11 @@
 #include "amdgpu_xgmi.h"
 #include "ivsrcid/nbio/irqsrcs_nbif_7_4.h"
 #include "atom.h"
+#ifdef CONFIG_X86_MCE_AMD
+#include <asm/mce.h>
 
+static bool notifier_registered;
+#endif
 static const char *RAS_FS_NAME = "ras";
 
 const char *ras_error_string[] = {
@@ -86,6 +90,9 @@ static bool amdgpu_ras_check_bad_page_unlock(struct amdgpu_ras *con,
 				uint64_t addr);
 static bool amdgpu_ras_check_bad_page(struct amdgpu_device *adev,
 				uint64_t addr);
+#ifdef CONFIG_X86_MCE_AMD
+static void amdgpu_register_bad_pages_mca_notifier(void);
+#endif
 
 void amdgpu_ras_set_error_query_ready(struct amdgpu_device *adev, bool ready)
 {
@@ -2018,6 +2025,11 @@ int amdgpu_ras_recovery_init(struct amdgpu_device *adev)
 			adev->smu.ppt_funcs->send_hbm_bad_pages_num(&adev->smu, con->eeprom_control.ras_num_recs);
 	}
 
+#ifdef CONFIG_X86_MCE_AMD
+	if ((adev->asic_type == CHIP_ALDEBARAN) &&
+	    (adev->gmc.xgmi.connected_to_cpu))
+		amdgpu_register_bad_pages_mca_notifier();
+#endif
 	return 0;
 
 free:
@@ -2511,3 +2523,133 @@ void amdgpu_release_ras_context(struct amdgpu_device *adev)
 		kfree(con);
 	}
 }
+
+#ifdef CONFIG_X86_MCE_AMD
+static struct amdgpu_device *find_adev(uint32_t node_id)
+{
+	struct amdgpu_gpu_instance *gpu_instance;
+	int i;
+	struct amdgpu_device *adev = NULL;
+
+	mutex_lock(&mgpu_info.mutex);
+
+	for (i = 0; i < mgpu_info.num_gpu; i++) {
+		gpu_instance = &(mgpu_info.gpu_ins[i]);
+		adev = gpu_instance->adev;
+
+		if (adev->gmc.xgmi.connected_to_cpu &&
+		    adev->gmc.xgmi.physical_node_id == node_id)
+			break;
+		adev = NULL;
+	}
+
+	mutex_unlock(&mgpu_info.mutex);
+
+	return adev;
+}
+
+#define GET_MCA_IPID_GPUID(m)	(((m) >> 44) & 0xF)
+#define GET_UMC_INST(m)		(((m) >> 21) & 0x7)
+#define GET_CHAN_INDEX(m)	((((m) >> 12) & 0x3) | (((m) >> 18) & 0x4))
+#define GPU_ID_OFFSET		8
+
+static int amdgpu_bad_page_notifier(struct notifier_block *nb,
+				    unsigned long val, void *data)
+{
+	struct mce *m = (struct mce *)data;
+	struct amdgpu_device *adev = NULL;
+	uint32_t gpu_id = 0;
+	uint32_t umc_inst = 0;
+	uint32_t ch_inst, channel_index = 0;
+	struct ras_err_data err_data = {0, 0, 0, NULL};
+	struct eeprom_table_record err_rec;
+	uint64_t retired_page;
+
+	/*
+	 * If the error was generated in UMC_V2, which belongs to GPU UMCs,
+	 * and error occurred in DramECC (Extended error code = 0) then only
+	 * process the error, else bail out.
+	 */
+	if (!m || !((smca_get_bank_type(m->bank) == SMCA_UMC_V2) &&
+		    (XEC(m->status, 0x1f) == 0x0)))
+		return NOTIFY_DONE;
+
+	/*
+	 * GPU Id is offset by GPU_ID_OFFSET in MCA_IPID_UMC register.
+	 */
+	gpu_id = GET_MCA_IPID_GPUID(m->ipid) - GPU_ID_OFFSET;
+
+	adev = find_adev(gpu_id);
+	if (!adev) {
+		dev_warn(adev->dev, "%s: Unable to find adev for gpu_id: %d\n",
+				     __func__, gpu_id);
+		return NOTIFY_DONE;
+	}
+
+	/*
+	 * If it is correctable error, return.
+	 */
+	if (mce_is_correctable(m)) {
+		return NOTIFY_OK;
+	}
+
+	/*
+	 * If it is uncorrectable error, then find out UMC instance and
+	 * channel index.
+	 */
+	umc_inst = GET_UMC_INST(m->ipid);
+	ch_inst = GET_CHAN_INDEX(m->ipid);
+
+	dev_info(adev->dev, "Uncorrectable error detected in UMC inst: %d, chan_idx: %d",
+			     umc_inst, ch_inst);
+
+	memset(&err_rec, 0x0, sizeof(struct eeprom_table_record));
+
+	/*
+	 * Translate UMC channel address to Physical address
+	 */
+	channel_index =
+		adev->umc.channel_idx_tbl[umc_inst * adev->umc.channel_inst_num
+					  + ch_inst];
+
+	retired_page = ADDR_OF_8KB_BLOCK(m->addr) |
+			ADDR_OF_256B_BLOCK(channel_index) |
+			OFFSET_IN_256B_BLOCK(m->addr);
+
+	err_rec.address = m->addr;
+	err_rec.retired_page = retired_page >> AMDGPU_GPU_PAGE_SHIFT;
+	err_rec.ts = (uint64_t)ktime_get_real_seconds();
+	err_rec.err_type = AMDGPU_RAS_EEPROM_ERR_NON_RECOVERABLE;
+	err_rec.cu = 0;
+	err_rec.mem_channel = channel_index;
+	err_rec.mcumc_id = umc_inst;
+
+	err_data.err_addr = &err_rec;
+	err_data.err_addr_cnt = 1;
+
+	if (amdgpu_bad_page_threshold != 0) {
+		amdgpu_ras_add_bad_pages(adev, err_data.err_addr,
+						err_data.err_addr_cnt);
+		amdgpu_ras_save_bad_pages(adev);
+	}
+
+	return NOTIFY_OK;
+}
+
+static struct notifier_block amdgpu_bad_page_nb = {
+	.notifier_call  = amdgpu_bad_page_notifier,
+	.priority       = MCE_PRIO_UC,
+};
+
+static void amdgpu_register_bad_pages_mca_notifier(void)
+{
+	/*
+	 * Register the x86 notifier only once
+	 * with MCE subsystem.
+	 */
+	if (notifier_registered == false) {
+		mce_register_decode_chain(&amdgpu_bad_page_nb);
+		notifier_registered = true;
+	}
+}
+#endif
Signature · 1 line
2.17.1
maintainer
#7 lore raw

Re: [PATCHv2 2/2] drm/amdgpu: Register MCE notifier for Aldebaran RAS

Quoted 5 lines · Mukul Joshi

On Aldebaran, GPU driver will handle bad page retirement even though UMC is host managed. As a result, register a bad page retirement handler on the mce notifier chain to retire bad pages on Aldebaran.

Quoted 8 lines

v1->v2:
- Use smca_get_bank_type() to determine MCA bank.
- Envelope the changes under #ifdef CONFIG_X86_MCE_AMD.
- Use MCE_PRIORITY_UC instead of MCE_PRIO_ACCEL as we are only handling uncorrectable errors.
- Use macros to determine UMC instance and channel instance where the uncorrectable error occured.
- Update the headline.

Same note as for the previous patch.

Quoted 29 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +29 -0
+static int amdgpu_bad_page_notifier(struct notifier_block *nb,
+				    unsigned long val, void *data)
+{
+	struct mce *m = (struct mce *)data;
+	struct amdgpu_device *adev = NULL;
+	uint32_t gpu_id = 0;
+	uint32_t umc_inst = 0;
+	uint32_t ch_inst, channel_index = 0;
+	struct ras_err_data err_data = {0, 0, 0, NULL};
+	struct eeprom_table_record err_rec;
+	uint64_t retired_page;
+
+	/*
+	 * If the error was generated in UMC_V2, which belongs to GPU UMCs,
+	 * and error occurred in DramECC (Extended error code = 0) then only
+	 * process the error, else bail out.
+	 */
+	if (!m || !((smca_get_bank_type(m->bank) == SMCA_UMC_V2) &&
+		    (XEC(m->status, 0x1f) == 0x0)))
+		return NOTIFY_DONE;
+
+	/*
+	 * GPU Id is offset by GPU_ID_OFFSET in MCA_IPID_UMC register.
+	 */
+	gpu_id = GET_MCA_IPID_GPUID(m->ipid) - GPU_ID_OFFSET;
+
+	adev = find_adev(gpu_id);
+	if (!adev) {
+		dev_warn(adev->dev, "%s: Unable to find adev for gpu_id: %d\n",

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c void amdgpu_release_ras_context(struct amdgpu_device *adev) · line 2594

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +10 -0
+				     __func__, gpu_id);
+		return NOTIFY_DONE;
+	}
+
+	/*
+	 * If it is correctable error, return.
+	 */
+	if (mce_is_correctable(m)) {
+		return NOTIFY_OK;
+	}

This can run before you find_adev().

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c void amdgpu_release_ras_context(struct amdgpu_device *adev) · line 2653

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +10 -0
+static void amdgpu_register_bad_pages_mca_notifier(void)
+{
+	/*
+	 * Register the x86 notifier only once
+	 * with MCE subsystem.
+	 */
+	if (notifier_registered == false) {
+		mce_register_decode_chain(&amdgpu_bad_page_nb);
+		notifier_registered = true;
+	}

I have a patchset which will get rid of the need to do this silliness - only if I had some time to actually prepare it for submission... :-\

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#8 lore raw

RE: [PATCHv2 2/2] drm/amdgpu: Register MCE notifier for Aldebaran RAS

[AMD Official Use Only]

Quoted 26 lines

-----Original Message-----
From: Borislav Petkov <[email protected]>
Sent: Wednesday, September 22, 2021 7:41 AM
To: Joshi, Mukul <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Ghannam, Yazen <[email protected]>; [email protected]
Subject: Re: [PATCHv2 2/2] drm/amdgpu: Register MCE notifier for Aldebaran RAS

[CAUTION: External Email]

Quoted 4 lines · Mukul Joshi

On Aldebaran, GPU driver will handle bad page retirement even though UMC is host managed. As a result, register a bad page retirement handler on the mce notifier chain to retire bad pages on Aldebaran.

Quoted 8 lines

v1->v2:
- Use smca_get_bank_type() to determine MCA bank.
- Envelope the changes under #ifdef CONFIG_X86_MCE_AMD.
- Use MCE_PRIORITY_UC instead of MCE_PRIO_ACCEL as we are only handling uncorrectable errors.
- Use macros to determine UMC instance and channel instance where the uncorrectable error occured.
- Update the headline.

Quoted 2 lines

Same note as for the previous patch.

Acked.

Quoted 32 lines
Quoted 32 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +32 -0
+static int amdgpu_bad_page_notifier(struct notifier_block *nb,
+                                 unsigned long val, void *data) {
+     struct mce *m = (struct mce *)data;
+     struct amdgpu_device *adev = NULL;
+     uint32_t gpu_id = 0;
+     uint32_t umc_inst = 0;
+     uint32_t ch_inst, channel_index = 0;
+     struct ras_err_data err_data = {0, 0, 0, NULL};
+     struct eeprom_table_record err_rec;
+     uint64_t retired_page;
+
+     /*
+      * If the error was generated in UMC_V2, which belongs to GPU UMCs,
+      * and error occurred in DramECC (Extended error code = 0) then only
+      * process the error, else bail out.
+      */
+     if (!m || !((smca_get_bank_type(m->bank) == SMCA_UMC_V2) &&
+                 (XEC(m->status, 0x1f) == 0x0)))
+             return NOTIFY_DONE;
+
+     /*
+      * GPU Id is offset by GPU_ID_OFFSET in MCA_IPID_UMC register.
+      */
+     gpu_id = GET_MCA_IPID_GPUID(m->ipid) - GPU_ID_OFFSET;
+
+     adev = find_adev(gpu_id);
+     if (!adev) {
+             dev_warn(adev->dev, "%s: Unable to find adev for gpu_id: %d\n",
+                                  __func__, gpu_id);
+             return NOTIFY_DONE;
+     }
+
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c void amdgpu_release_ras_context(struct amdgpu_device *adev) · line 2594

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +6 -0
+     /*
+      * If it is correctable error, return.
+      */
+     if (mce_is_correctable(m)) {
+             return NOTIFY_OK;
+     }

This can run before you find_adev().

Acked.

Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +5 -0
+static void amdgpu_register_bad_pages_mca_notifier(void)
+{
+     /*
+      * Register the x86 notifier only once
+      * with MCE subsystem.
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c void amdgpu_release_ras_context(struct amdgpu_device *adev) · line 2653

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +5 -0
+      */
+     if (notifier_registered == false) {
+             mce_register_decode_chain(&amdgpu_bad_page_nb);
+             notifier_registered = true;
+     }

I have a patchset which will get rid of the need to do this silliness - only if I had some time to actually prepare it for submission... :-\

:-\

Thank you.

Regards,
Mukul

Quoted 11 lines

--
Regards/Gruss,
Boris.

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpeople.
kernel.org%2Ftglx%2Fnotes-about- netiquette&amp;data=04%7C01%7Cmukul.joshi%40amd.com%7C7ae9c87153f7 4572712908d97dbdcc7a%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0 %7C637679076423976867%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata =M5UDrSea0lnEi5%2BhU4ck0zk1dZD9kX4DUoXt95J6dJ4%3D&amp;reserved=0

#9 lore raw

PATCH v3 2/2 drm/amdgpu: Register MCE notifier for Aldebaran RAS

In reply to Mukul Joshi

On Aldebaran, GPU driver will handle bad page retirement even though UMC is host managed. As a result, register a bad page retirement handler on the mce notifier chain to retire bad pages on Aldebaran.

---
v1->v2:
- Use smca_get_bank_type() to determine MCA bank.
- Envelope the changes under #ifdef CONFIG_X86_MCE_AMD.
- Use MCE_PRIORITY_UC instead of MCE_PRIO_ACCEL as we are only handling uncorrectable errors.
- Use macros to determine UMC instance and channel instance where the uncorrectable error occured.

v2->v3:
- Move the check for correctable error before find_adev().
- Fix a NULL pointer dereference if find_adev() returns NULL.

 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 141 ++++++++++++++++++++++++
 1 file changed, 141 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +141 -0
index 912ea1f9fd04..c1e806762e41 100644
@@ -35,7 +35,11 @@
 #include "amdgpu_xgmi.h"
 #include "ivsrcid/nbio/irqsrcs_nbif_7_4.h"
 #include "atom.h"
+#ifdef CONFIG_X86_MCE_AMD
+#include <asm/mce.h>
 
+static bool notifier_registered;
+#endif
 static const char *RAS_FS_NAME = "ras";
 
 const char *ras_error_string[] = {
@@ -107,6 +111,9 @@ static bool amdgpu_ras_check_bad_page_unlock(struct amdgpu_ras *con,
 				uint64_t addr);
 static bool amdgpu_ras_check_bad_page(struct amdgpu_device *adev,
 				uint64_t addr);
+#ifdef CONFIG_X86_MCE_AMD
+static void amdgpu_register_bad_pages_mca_notifier(void);
+#endif
 
 void amdgpu_ras_set_error_query_ready(struct amdgpu_device *adev, bool ready)
 {
@@ -2089,6 +2096,11 @@ int amdgpu_ras_recovery_init(struct amdgpu_device *adev)
 			adev->smu.ppt_funcs->send_hbm_bad_pages_num(&adev->smu, con->eeprom_control.ras_num_recs);
 	}
 
+#ifdef CONFIG_X86_MCE_AMD
+	if ((adev->asic_type == CHIP_ALDEBARAN) &&
+	    (adev->gmc.xgmi.connected_to_cpu))
+		amdgpu_register_bad_pages_mca_notifier();
+#endif
 	return 0;
 
 free:
@@ -2583,3 +2595,132 @@ void amdgpu_release_ras_context(struct amdgpu_device *adev)
 		kfree(con);
 	}
 }
+
+#ifdef CONFIG_X86_MCE_AMD
+static struct amdgpu_device *find_adev(uint32_t node_id)
+{
+	struct amdgpu_gpu_instance *gpu_instance;
+	int i;
+	struct amdgpu_device *adev = NULL;
+
+	mutex_lock(&mgpu_info.mutex);
+
+	for (i = 0; i < mgpu_info.num_gpu; i++) {
+		gpu_instance = &(mgpu_info.gpu_ins[i]);
+		adev = gpu_instance->adev;
+
+		if (adev->gmc.xgmi.connected_to_cpu &&
+		    adev->gmc.xgmi.physical_node_id == node_id)
+			break;
+		adev = NULL;
+	}
+
+	mutex_unlock(&mgpu_info.mutex);
+
+	return adev;
+}
+
+#define GET_MCA_IPID_GPUID(m)	(((m) >> 44) & 0xF)
+#define GET_UMC_INST(m)		(((m) >> 21) & 0x7)
+#define GET_CHAN_INDEX(m)	((((m) >> 12) & 0x3) | (((m) >> 18) & 0x4))
+#define GPU_ID_OFFSET		8
+
+static int amdgpu_bad_page_notifier(struct notifier_block *nb,
+				    unsigned long val, void *data)
+{
+	struct mce *m = (struct mce *)data;
+	struct amdgpu_device *adev = NULL;
+	uint32_t gpu_id = 0;
+	uint32_t umc_inst = 0;
+	uint32_t ch_inst, channel_index = 0;
+	struct ras_err_data err_data = {0, 0, 0, NULL};
+	struct eeprom_table_record err_rec;
+	uint64_t retired_page;
+
+	/*
+	 * If the error was generated in UMC_V2, which belongs to GPU UMCs,
+	 * and error occurred in DramECC (Extended error code = 0) then only
+	 * process the error, else bail out.
+	 */
+	if (!m || !((smca_get_bank_type(m->bank) == SMCA_UMC_V2) &&
+		    (XEC(m->status, 0x1f) == 0x0)))
+		return NOTIFY_DONE;
+
+	/*
+	 * If it is correctable error, return.
+	 */
+	if (mce_is_correctable(m))
+		return NOTIFY_OK;
+
+	/*
+	 * GPU Id is offset by GPU_ID_OFFSET in MCA_IPID_UMC register.
+	 */
+	gpu_id = GET_MCA_IPID_GPUID(m->ipid) - GPU_ID_OFFSET;
+
+	adev = find_adev(gpu_id);
+	if (!adev) {
+		DRM_WARN("%s: Unable to find adev for gpu_id: %d\n", __func__,
+								gpu_id);
+		return NOTIFY_DONE;
+	}
+
+	/*
+	 * If it is uncorrectable error, then find out UMC instance and
+	 * channel index.
+	 */
+	umc_inst = GET_UMC_INST(m->ipid);
+	ch_inst = GET_CHAN_INDEX(m->ipid);
+
+	dev_info(adev->dev, "Uncorrectable error detected in UMC inst: %d, chan_idx: %d",
+			     umc_inst, ch_inst);
+
+	memset(&err_rec, 0x0, sizeof(struct eeprom_table_record));
+
+	/*
+	 * Translate UMC channel address to Physical address
+	 */
+	channel_index =
+		adev->umc.channel_idx_tbl[umc_inst * adev->umc.channel_inst_num
+					  + ch_inst];
+
+	retired_page = ADDR_OF_8KB_BLOCK(m->addr) |
+			ADDR_OF_256B_BLOCK(channel_index) |
+			OFFSET_IN_256B_BLOCK(m->addr);
+
+	err_rec.address = m->addr;
+	err_rec.retired_page = retired_page >> AMDGPU_GPU_PAGE_SHIFT;
+	err_rec.ts = (uint64_t)ktime_get_real_seconds();
+	err_rec.err_type = AMDGPU_RAS_EEPROM_ERR_NON_RECOVERABLE;
+	err_rec.cu = 0;
+	err_rec.mem_channel = channel_index;
+	err_rec.mcumc_id = umc_inst;
+
+	err_data.err_addr = &err_rec;
+	err_data.err_addr_cnt = 1;
+
+	if (amdgpu_bad_page_threshold != 0) {
+		amdgpu_ras_add_bad_pages(adev, err_data.err_addr,
+						err_data.err_addr_cnt);
+		amdgpu_ras_save_bad_pages(adev);
+	}
+
+	return NOTIFY_OK;
+}
+
+static struct notifier_block amdgpu_bad_page_nb = {
+	.notifier_call  = amdgpu_bad_page_notifier,
+	.priority       = MCE_PRIO_UC,
+};
+
+static void amdgpu_register_bad_pages_mca_notifier(void)
+{
+	/*
+	 * Register the x86 notifier only once
+	 * with MCE subsystem.
+	 */
+	if (notifier_registered == false) {
+		mce_register_decode_chain(&amdgpu_bad_page_nb);
+		notifier_registered = true;
+	}
+}
+#endif
Signature · 1 line
2.17.1
maintainer
#10 lore raw

Re: [PATCHv3 2/2] drm/amdgpu: Register MCE notifier for Aldebaran RAS

Quoted 5 lines · Mukul Joshi

On Aldebaran, GPU driver will handle bad page retirement even though UMC is host managed. As a result, register a bad page retirement handler on the mce notifier chain to retire bad pages on Aldebaran.

I think this should state that the driver will do page retirement for GPU-managed memory. As written, it implies that the driver do page retirement in general for the system.

...

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +10 -0
+
+static int amdgpu_bad_page_notifier(struct notifier_block *nb,
+				    unsigned long val, void *data)
+{
+	struct mce *m = (struct mce *)data;
+	struct amdgpu_device *adev = NULL;
+	uint32_t gpu_id = 0;
+	uint32_t umc_inst = 0;
+	uint32_t ch_inst, channel_index = 0;
+	struct ras_err_data err_data = {0, 0, 0, NULL};

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c void amdgpu_release_ras_context(struct amdgpu_device *adev) · line 2646

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +10 -0
+	struct eeprom_table_record err_rec;
+	uint64_t retired_page;
+
+	/*
+	 * If the error was generated in UMC_V2, which belongs to GPU UMCs,
+	 * and error occurred in DramECC (Extended error code = 0) then only
+	 * process the error, else bail out.
+	 */
+	if (!m || !((smca_get_bank_type(m->bank) == SMCA_UMC_V2) &&
+		    (XEC(m->status, 0x1f) == 0x0)))

The MCA_STATUS[ErrorCodeExt] field is bits [21:16], so the mask should be 0x3f.

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c void amdgpu_release_ras_context(struct amdgpu_device *adev) · line 2653

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +7 -0
+		return NOTIFY_DONE;
+
+	/*
+	 * If it is correctable error, return.
+	 */
+	if (mce_is_correctable(m))
+		return NOTIFY_OK;

Shouldn't this be "NOTIFY_DONE" if "don't care" about this error?

Thanks,
Yazen

maintainer
#11 lore raw

Re: [PATCHv3 2/2] drm/amdgpu: Register MCE notifier for Aldebaran RAS

Quoted 11 lines · Yazen Ghannam

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c void amdgpu_release_ras_context(struct amdgpu_device *adev) · line 2646

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +7 -0
+	/*
+	 * If the error was generated in UMC_V2, which belongs to GPU UMCs,
+	 * and error occurred in DramECC (Extended error code = 0) then only
+	 * process the error, else bail out.
+	 */
+	if (!m || !((smca_get_bank_type(m->bank) == SMCA_UMC_V2) &&
+		    (XEC(m->status, 0x1f) == 0x0)))

The MCA_STATUS[ErrorCodeExt] field is bits [21:16], so the mask should be 0x3f.

Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c void amdgpu_release_ras_context(struct amdgpu_device *adev) · line 2653

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +7 -0
+		return NOTIFY_DONE;
+
+	/*
+	 * If it is correctable error, return.
+	 */
+	if (mce_is_correctable(m))
+		return NOTIFY_OK;

Shouldn't this be "NOTIFY_DONE" if "don't care" about this error?

I think the logic here is to stop calling any further consumers on the notify chain because this is a GPU correctable error and they can't do anything about it anyway, right?

Or am I misreading it?

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#12 lore raw

RE: [PATCHv3 2/2] drm/amdgpu: Register MCE notifier for Aldebaran RAS

[AMD Official Use Only]

Quoted 32 lines

-----Original Message-----
From: Borislav Petkov <[email protected]>
Sent: Thursday, September 23, 2021 10:37 AM
To: Ghannam, Yazen <[email protected]>
Cc: Joshi, Mukul <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCHv3 2/2] drm/amdgpu: Register MCE notifier for Aldebaran RAS

[CAUTION: External Email]

Quoted 19 lines · Yazen Ghannam

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c void amdgpu_release_ras_context(struct amdgpu_device *adev) · line 2646

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +7 -0
+   /*
+    * If the error was generated in UMC_V2, which belongs to GPU UMCs,
+    * and error occurred in DramECC (Extended error code = 0) then only
+    * process the error, else bail out.
+    */
+   if (!m || !((smca_get_bank_type(m->bank) == SMCA_UMC_V2) &&
+               (XEC(m->status, 0x1f) == 0x0)))

The MCA_STATUS[ErrorCodeExt] field is bits [21:16], so the mask should be 0x3f.

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +7 -0
+           return NOTIFY_DONE;
+
+   /*
+    * If it is correctable error, return.
+    */
+   if (mce_is_correctable(m))
+           return NOTIFY_OK;
Quoted 5 lines
Quoted 1 line

Shouldn't this be "NOTIFY_DONE" if "don't care" about this error?

I think the logic here is to stop calling any further consumers on the notify chain because this is a GPU correctable error and they can't do anything about it anyway, right?

That's correct.

Regards,
Mukul

Quoted 14 lines

Or am I misreading it?

--
Regards/Gruss,
Boris.

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpeople.
kernel.org%2Ftglx%2Fnotes-about- netiquette&amp;data=04%7C01%7Cmukul.joshi%40amd.com%7C1493bcdae62 8466d5b8408d97e9fa6f0%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0 %7C637680046455034969%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata =uqbjJslUPJabZonJc6m9Ub3C5IkZDPdqwr6MI0oLPcc%3D&amp;reserved=0

#13 lore raw

RE: [PATCHv3 2/2] drm/amdgpu: Register MCE notifier for Aldebaran RAS

In reply to Yazen Ghannam

[AMD Official Use Only]

Quoted 11 lines

-----Original Message-----
From: Ghannam, Yazen <[email protected]>
Sent: Thursday, September 23, 2021 10:29 AM
To: Joshi, Mukul <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; amd- [email protected]
Subject: Re: [PATCHv3 2/2] drm/amdgpu: Register MCE notifier for Aldebaran RAS

On Wed, Sep 22, 2021 at 03:36:20PM -0400, Mukul Joshi wrote:

Quoted 9 lines
Quoted 4 lines

On Aldebaran, GPU driver will handle bad page retirement even though UMC is host managed. As a result, register a bad page retirement handler on the mce notifier chain to retire bad pages on Aldebaran.

I think this should state that the driver will do page retirement for GPU-managed memory. As written, it implies that the driver do page retirement in general for the system.

ACK. I will update the description.

Quoted 16 lines

...

Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +14 -0
+
+static int amdgpu_bad_page_notifier(struct notifier_block *nb,
+				    unsigned long val, void *data) {
+	struct mce *m = (struct mce *)data;
+	struct amdgpu_device *adev = NULL;
+	uint32_t gpu_id = 0;
+	uint32_t umc_inst = 0;
+	uint32_t ch_inst, channel_index = 0;
+	struct ras_err_data err_data = {0, 0, 0, NULL};
+	struct eeprom_table_record err_rec;
+	uint64_t retired_page;
+
+	/*
+	 * If the error was generated in UMC_V2, which belongs to GPU UMCs,
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c void amdgpu_release_ras_context(struct amdgpu_device *adev) · line 2646

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +5 -0
+	 * and error occurred in DramECC (Extended error code = 0) then only
+	 * process the error, else bail out.
+	 */
+	if (!m || !((smca_get_bank_type(m->bank) == SMCA_UMC_V2) &&
+		    (XEC(m->status, 0x1f) == 0x0)))

The MCA_STATUS[ErrorCodeExt] field is bits [21:16], so the mask should be 0x3f.

Ack. Thanks for catching this.

Quoted 10 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c void amdgpu_release_ras_context(struct amdgpu_device *adev) · line 2653

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +7 -0
+		return NOTIFY_DONE;
+
+	/*
+	 * If it is correctable error, return.
+	 */
+	if (mce_is_correctable(m))
+		return NOTIFY_OK;

Shouldn't this be "NOTIFY_DONE" if "don't care" about this error?

The thinking is we want to stop calling further consumers since it's a correctable error in GPU UMC and we are not taking any action about the correctable errors.

Thanks,
Mukul

Quoted 3 lines

Thanks,
Yazen

maintainer
#14 lore raw

Re: [PATCHv3 2/2] drm/amdgpu: Register MCE notifier for Aldebaran RAS

On Thu, Sep 23, 2021 at 11:30:55AM -0400, Joshi, Mukul wrote:
...

Quoted 11 lines
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c void amdgpu_release_ras_context(struct amdgpu_device *adev) · line 2653

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +7 -0
+		return NOTIFY_DONE;
+
+	/*
+	 * If it is correctable error, return.
+	 */
+	if (mce_is_correctable(m))
+		return NOTIFY_OK;

Shouldn't this be "NOTIFY_DONE" if "don't care" about this error?

The thinking is we want to stop calling further consumers since it's a correctable error in GPU UMC and we are not taking any action about the correctable errors.

Shouldn't the error still be reported to EDAC for decoding and counting? I think users want this.

But it looks to me that either NOTIFY_OK or NOTIFY_DONE will allow this, so it's not a big deal. Was this intended to be NOTIFY_STOP?

Thanks,
Yazen

maintainer
#15 lore raw

Re: [PATCHv3 2/2] drm/amdgpu: Register MCE notifier for Aldebaran RAS

Quoted 2 lines · Yazen Ghannam

Shouldn't the error still be reported to EDAC for decoding and counting? I think users want this.

You know what happens with users getting ECCs reported, right? They think immediately their hw is going bad and start wanting to replace it...

So what does actually tell you if you were a simple user and you had 5 correctable errors in the GPU VRAM?

All you wanna do is play, I'd say.

:-)

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
maintainer
#16 lore raw

Re: [PATCHv3 2/2] drm/amdgpu: Register MCE notifier for Aldebaran RAS

Quoted 11 lines · Borislav Petkov
Quoted 2 lines · Yazen Ghannam

Shouldn't the error still be reported to EDAC for decoding and counting? I think users want this.

You know what happens with users getting ECCs reported, right? They think immediately their hw is going bad and start wanting to replace it...

So what does actually tell you if you were a simple user and you had 5 correctable errors in the GPU VRAM?

I agree with you in general. But this device isn't really a GPU. And users of this device seem to want to count *every* error, at least for now.

Quoted 4 lines

All you wanna do is play, I'd say.

:-)

Definitely. :)

Thanks,
Yazen

maintainer
#17 lore raw

Re: [PATCHv3 2/2] drm/amdgpu: Register MCE notifier for Aldebaran RAS

Quoted 3 lines · Yazen Ghannam

I agree with you in general. But this device isn't really a GPU. And users of this device seem to want to count *every* error, at least for now.

Aha, so something accelerator-y where they do general purpose computation.

So what's the big picture here: they count all the errors and when they reach a certain amount, they decide to replace the GPUs just in case?

Or wait until they become uncorrectable? But then it doesn't matter because we will handle it properly by excluding the VRAM range from further use.

Or do they wanna see *when* they had the correctable errors so that they can restart the computation, just in case.

Dunno, it would be a lot helpful if we had some RAS strategy for those things...

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
maintainer
#18 lore raw

Re: [PATCHv3 2/2] drm/amdgpu: Register MCE notifier for Aldebaran RAS

Quoted 14 lines · Borislav Petkov
Quoted 3 lines · Yazen Ghannam

I agree with you in general. But this device isn't really a GPU. And users of this device seem to want to count *every* error, at least for now.

Aha, so something accelerator-y where they do general purpose computation.

So what's the big picture here: they count all the errors and when they reach a certain amount, they decide to replace the GPUs just in case?

Or wait until they become uncorrectable? But then it doesn't matter because we will handle it properly by excluding the VRAM range from further use.

Quoted 6 lines

Or do they wanna see *when* they had the correctable errors so that they can restart the computation, just in case.

Dunno, it would be a lot helpful if we had some RAS strategy for those things...

I completely agree. The system integrators have their own policies for error tracking, part replacement, etc. I expect they'll propose kernel changes if they want any. Though I think general strategies will become apparent once these sort of devices are in wider use.

Thanks,
Yazen

#19 lore raw

RE: [PATCHv3 2/2] drm/amdgpu: Register MCE notifier for Aldebaran RAS

In reply to Yazen Ghannam

[AMD Official Use Only]

Quoted 22 lines

-----Original Message-----
From: Ghannam, Yazen <[email protected]>
Sent: Thursday, September 23, 2021 1:23 PM
To: Joshi, Mukul <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; amd- [email protected]
Subject: Re: [PATCHv3 2/2] drm/amdgpu: Register MCE notifier for Aldebaran RAS

On Thu, Sep 23, 2021 at 11:30:55AM -0400, Joshi, Mukul wrote:
...

Quoted 10 lines
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c void amdgpu_release_ras_context(struct amdgpu_device *adev) · line 2653

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +7 -0
+		return NOTIFY_DONE;
+
+	/*
+	 * If it is correctable error, return.
+	 */
+	if (mce_is_correctable(m))
+		return NOTIFY_OK;

Shouldn't this be "NOTIFY_DONE" if "don't care" about this error?

Quoted 4 lines
Quoted 1 line

The thinking is we want to stop calling further consumers since it's a

correctable error in GPU UMC and we are not taking any action about the correctable errors.

Sorry I have to retract this back a bit. I remembered I started with the intention Of using NOTIFY_STOP but realized that we would not be doing any accounting in this function.

Quoted 6 lines

Shouldn't the error still be reported to EDAC for decoding and counting? I think users want this.

But it looks to me that either NOTIFY_OK or NOTIFY_DONE will allow this, so it's not a big deal. Was this intended to be NOTIFY_STOP?

Sorry I have to retract my previous comment about stopping further consumers a bit.
I remembered I started with the intention to use NOTIFY_STOP but realized we were not doing any accounting in this function. Later I guess I went by the comments put against NOTIFY_OK in notifier.h:
#define NOTIFY_DONE 0x0000 /* Don't care */
#define NOTIFY_OK 0x0001 /* Suits me */

Because this was a correctable error on GPU UMC, NOTIFY_OK ("Suits me") was probably more suited to this condition, even though we were not taking any action on the correctable errors.

Thanks,
Mukul

Quoted 2 lines

Thanks,
Yazen

#20 lore raw

PATCH v4 2/2 drm/amdgpu: Register MCE notifier for Aldebaran RAS

In reply to Mukul Joshi

On Aldebaran, GPU driver will handle bad page retirement for GPU memory even though UMC is host managed. As a result, register a bad page retirement handler on the mce notifier chain to retire bad pages on Aldebaran.

---
v1->v2:
- Use smca_get_bank_type() to determine MCA bank.
- Envelope the changes under #ifdef CONFIG_X86_MCE_AMD.
- Use MCE_PRIORITY_UC instead of MCE_PRIO_ACCEL as we are only handling uncorrectable errors.
- Use macros to determine UMC instance and channel instance where the uncorrectable error occured.

v2->v3:
- Move the check for correctable error before find_adev().
- Fix a NULL pointer dereference if find_adev() returns NULL.

v3->v4:
- Update the commit log to specify page retirement for GPU memory only.
- Fix the mask passed to XEC macro.

 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 141 ++++++++++++++++++++++++
 1 file changed, 141 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +141 -0
index e1c34eef76b7..02841a0efbb9 100644
@@ -35,7 +35,11 @@
 #include "amdgpu_xgmi.h"
 #include "ivsrcid/nbio/irqsrcs_nbif_7_4.h"
 #include "atom.h"
+#ifdef CONFIG_X86_MCE_AMD
+#include <asm/mce.h>
 
+static bool notifier_registered;
+#endif
 static const char *RAS_FS_NAME = "ras";
 
 const char *ras_error_string[] = {
@@ -107,6 +111,9 @@ static bool amdgpu_ras_check_bad_page_unlock(struct amdgpu_ras *con,
 				uint64_t addr);
 static bool amdgpu_ras_check_bad_page(struct amdgpu_device *adev,
 				uint64_t addr);
+#ifdef CONFIG_X86_MCE_AMD
+static void amdgpu_register_bad_pages_mca_notifier(void);
+#endif
 
 void amdgpu_ras_set_error_query_ready(struct amdgpu_device *adev, bool ready)
 {
@@ -2089,6 +2096,11 @@ int amdgpu_ras_recovery_init(struct amdgpu_device *adev)
 			adev->smu.ppt_funcs->send_hbm_bad_pages_num(&adev->smu, con->eeprom_control.ras_num_recs);
 	}
 
+#ifdef CONFIG_X86_MCE_AMD
+	if ((adev->asic_type == CHIP_ALDEBARAN) &&
+	    (adev->gmc.xgmi.connected_to_cpu))
+		amdgpu_register_bad_pages_mca_notifier();
+#endif
 	return 0;
 
 free:
@@ -2552,3 +2564,132 @@ void amdgpu_release_ras_context(struct amdgpu_device *adev)
 		kfree(con);
 	}
 }
+
+#ifdef CONFIG_X86_MCE_AMD
+static struct amdgpu_device *find_adev(uint32_t node_id)
+{
+	struct amdgpu_gpu_instance *gpu_instance;
+	int i;
+	struct amdgpu_device *adev = NULL;
+
+	mutex_lock(&mgpu_info.mutex);
+
+	for (i = 0; i < mgpu_info.num_gpu; i++) {
+		gpu_instance = &(mgpu_info.gpu_ins[i]);
+		adev = gpu_instance->adev;
+
+		if (adev->gmc.xgmi.connected_to_cpu &&
+		    adev->gmc.xgmi.physical_node_id == node_id)
+			break;
+		adev = NULL;
+	}
+
+	mutex_unlock(&mgpu_info.mutex);
+
+	return adev;
+}
+
+#define GET_MCA_IPID_GPUID(m)	(((m) >> 44) & 0xF)
+#define GET_UMC_INST(m)		(((m) >> 21) & 0x7)
+#define GET_CHAN_INDEX(m)	((((m) >> 12) & 0x3) | (((m) >> 18) & 0x4))
+#define GPU_ID_OFFSET		8
+
+static int amdgpu_bad_page_notifier(struct notifier_block *nb,
+				    unsigned long val, void *data)
+{
+	struct mce *m = (struct mce *)data;
+	struct amdgpu_device *adev = NULL;
+	uint32_t gpu_id = 0;
+	uint32_t umc_inst = 0;
+	uint32_t ch_inst, channel_index = 0;
+	struct ras_err_data err_data = {0, 0, 0, NULL};
+	struct eeprom_table_record err_rec;
+	uint64_t retired_page;
+
+	/*
+	 * If the error was generated in UMC_V2, which belongs to GPU UMCs,
+	 * and error occurred in DramECC (Extended error code = 0) then only
+	 * process the error, else bail out.
+	 */
+	if (!m || !((smca_get_bank_type(m->bank) == SMCA_UMC_V2) &&
+		    (XEC(m->status, 0x3f) == 0x0)))
+		return NOTIFY_DONE;
+
+	/*
+	 * If it is correctable error, return.
+	 */
+	if (mce_is_correctable(m))
+		return NOTIFY_OK;
+
+	/*
+	 * GPU Id is offset by GPU_ID_OFFSET in MCA_IPID_UMC register.
+	 */
+	gpu_id = GET_MCA_IPID_GPUID(m->ipid) - GPU_ID_OFFSET;
+
+	adev = find_adev(gpu_id);
+	if (!adev) {
+		DRM_WARN("%s: Unable to find adev for gpu_id: %d\n", __func__,
+								gpu_id);
+		return NOTIFY_DONE;
+	}
+
+	/*
+	 * If it is uncorrectable error, then find out UMC instance and
+	 * channel index.
+	 */
+	umc_inst = GET_UMC_INST(m->ipid);
+	ch_inst = GET_CHAN_INDEX(m->ipid);
+
+	dev_info(adev->dev, "Uncorrectable error detected in UMC inst: %d, chan_idx: %d",
+			     umc_inst, ch_inst);
+
+	memset(&err_rec, 0x0, sizeof(struct eeprom_table_record));
+
+	/*
+	 * Translate UMC channel address to Physical address
+	 */
+	channel_index =
+		adev->umc.channel_idx_tbl[umc_inst * adev->umc.channel_inst_num
+					  + ch_inst];
+
+	retired_page = ADDR_OF_8KB_BLOCK(m->addr) |
+			ADDR_OF_256B_BLOCK(channel_index) |
+			OFFSET_IN_256B_BLOCK(m->addr);
+
+	err_rec.address = m->addr;
+	err_rec.retired_page = retired_page >> AMDGPU_GPU_PAGE_SHIFT;
+	err_rec.ts = (uint64_t)ktime_get_real_seconds();
+	err_rec.err_type = AMDGPU_RAS_EEPROM_ERR_NON_RECOVERABLE;
+	err_rec.cu = 0;
+	err_rec.mem_channel = channel_index;
+	err_rec.mcumc_id = umc_inst;
+
+	err_data.err_addr = &err_rec;
+	err_data.err_addr_cnt = 1;
+
+	if (amdgpu_bad_page_threshold != 0) {
+		amdgpu_ras_add_bad_pages(adev, err_data.err_addr,
+						err_data.err_addr_cnt);
+		amdgpu_ras_save_bad_pages(adev);
+	}
+
+	return NOTIFY_OK;
+}
+
+static struct notifier_block amdgpu_bad_page_nb = {
+	.notifier_call  = amdgpu_bad_page_notifier,
+	.priority       = MCE_PRIO_UC,
+};
+
+static void amdgpu_register_bad_pages_mca_notifier(void)
+{
+	/*
+	 * Register the x86 notifier only once
+	 * with MCE subsystem.
+	 */
+	if (notifier_registered == false) {
+		mce_register_decode_chain(&amdgpu_bad_page_nb);
+		notifier_registered = true;
+	}
+}
+#endif
Signature · 1 line
2.17.1
maintainer Reviewed-by on v4 2/2
#21 lore raw

Re: [PATCHv4 2/2] drm/amdgpu: Register MCE notifier for Aldebaran RAS

Quoted 7 lines · Mukul Joshi

On Aldebaran, GPU driver will handle bad page retirement for GPU memory even though UMC is host managed. As a result, register a bad page retirement handler on the mce notifier chain to retire bad pages on Aldebaran.

---

This patch looks good to me overall.

Thanks,
Yazen

maintainer
#22 lore raw

Re: [PATCHv2 1/2] x86/MCE/AMD: Export smca_get_bank_type symbol

In reply to Mukul Joshi
Quoted 8 lines · Mukul Joshi

Export smca_get_bank_type for use in the AMD GPU driver to determine MCA bank while handling correctable and uncorrectable errors in GPU UMC.

v1->v2:
- Drop the function is_smca_umc_v2().
- Drop the patch to introduce a new MCE priority (MCE_PRIO_ACEL) for GPU/accelarator cards.

Patch changelog information goes...

Quoted 3 lines

---

... under this line so that it gets automatically removed by git when applying the patch.

Alex, how do you wanna handle this?

Want me to ACK this and you can carry it through your tree along with the second patch?

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#23 lore raw

RE: [PATCHv2 1/2] x86/MCE/AMD: Export smca_get_bank_type symbol

[Public]

Quoted 29 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Borislav Petkov
Sent: Wednesday, September 22, 2021 7:34 AM
To: Joshi, Mukul <[email protected]>; Alex Deucher <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; Ghannam, Yazen <[email protected]>; amd- [email protected]
Subject: Re: [PATCHv2 1/2] x86/MCE/AMD: Export smca_get_bank_type symbol

Quoted 8 lines · Mukul Joshi

Export smca_get_bank_type for use in the AMD GPU driver to determine MCA bank while handling correctable and uncorrectable errors in GPU UMC.

v1->v2:
- Drop the function is_smca_umc_v2().
- Drop the patch to introduce a new MCE priority (MCE_PRIO_ACEL) for GPU/accelarator cards.

Patch changelog information goes...

Quoted 3 lines

---

Quoted 7 lines

... under this line so that it gets automatically removed by git when applying the patch.

Alex, how do you wanna handle this?

Want me to ACK this and you can carry it through your tree along with the second patch?

That would be great. Thanks!

Alex

Quoted 13 lines

--
Regards/Gruss,
Boris.

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpeo
ple.kernel.org%2Ftglx%2Fnotes-about- netiquette&amp;data=04%7C01%7Calexander.deucher%40amd.com%7C12b cf4eeffad4e2533b508d97dca1cf4%7C3dd8961fe4884e608e11a82d994e183d% 7C0%7C0%7C637679129761221057%7CUnknown%7CTWFpbGZsb3d8eyJWIjoi MC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C200 0&amp;sdata=tK9aK%2FHf5RimF%2FenuTGeJSFFmRuk86Q%2BqY9Jt23gKMQ %3D&amp;reserved=0

maintainer Acked-by
#24 lore raw

Re: [PATCHv2 1/2] x86/MCE/AMD: Export smca_get_bank_type symbol

Quoted 19 lines · Alexander
Quoted 19 lines · Mukul Joshi
Quoted 8 lines

Export smca_get_bank_type for use in the AMD GPU driver to determine MCA bank while handling correctable and uncorrectable errors in GPU UMC.

v1->v2:
- Drop the function is_smca_umc_v2().
- Drop the patch to introduce a new MCE priority (MCE_PRIO_ACEL) for GPU/accelarator cards.

Patch changelog information goes...

Quoted 3 lines

---

... under this line so that it gets automatically removed by git when applying the patch.

Quoted 6 lines
Quoted 4 lines

Alex, how do you wanna handle this?

Want me to ACK this and you can carry it through your tree along with the second patch?

That would be great. Thanks!

Ok, with the above changelog removed:

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#25 lore raw

RE: [PATCHv2 1/2] x86/MCE/AMD: Export smca_get_bank_type symbol

[AMD Official Use Only]

Quoted 37 lines

-----Original Message-----
From: Borislav Petkov <[email protected]>
Sent: Wednesday, September 22, 2021 12:44 PM
To: Deucher, Alexander <[email protected]>
Cc: Joshi, Mukul <[email protected]>; Alex Deucher <[email protected]>; [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; Ghannam, Yazen <[email protected]>; [email protected]
Subject: Re: [PATCHv2 1/2] x86/MCE/AMD: Export smca_get_bank_type symbol

[CAUTION: External Email]

Quoted 24 lines · Alexander
Quoted 23 lines · Mukul Joshi
Quoted 8 lines

Export smca_get_bank_type for use in the AMD GPU driver to determine MCA bank while handling correctable and uncorrectable errors in GPU UMC.

v1->v2:
- Drop the function is_smca_umc_v2().
- Drop the patch to introduce a new MCE priority (MCE_PRIO_ACEL) for GPU/accelarator cards.

Patch changelog information goes...

Quoted 3 lines

---

... under this line so that it gets automatically removed by git when applying the patch.

Alex, how do you wanna handle this?

Want me to ACK this and you can carry it through your tree along with the second patch?

Quoted 8 lines
Quoted 1 line

That would be great. Thanks!

Ok, with the above changelog removed:

Thx.

Thank you so much!
I will make sure to remove the changelog.
And I will send the updated version for the second patch soon.

Regards,
Mukul

Quoted 12 lines

--
Regards/Gruss,
Boris.

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpeople.
kernel.org%2Ftglx%2Fnotes-about- netiquette&amp;data=04%7C01%7CMukul.Joshi%40amd.com%7C3dc61ec5018f 487ec06e08d97de83039%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0 %7C637679258473597532%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata =4JqFDJpxM%2Bzl4%2BZoaC3tTwScEhRy2Aa7xJaNJn3rxbE%3D&amp;reserved= 0

#26 lore raw

PATCH 3/3 x86/mce: Add MCE priority for Accelerator devices

In reply to Naveen Krishna Chatradhi

From: Mukul Joshi <[email protected]>

Create a new MCE priority for accelerator devices on the notifier chain. On some future AMD platforms, GPU devices will process MCE errors and work as error detection devices.

---
 arch/x86/include/asm/mce.h | 1 +
 1 file changed, 1 insertion(+)
arch/x86/include/asm/mce.h +1 -0
index 8cbe7221a253..849f10a8602d 100644
@@ -173,6 +173,7 @@ enum mce_notifier_prios {
 	MCE_PRIO_LOWEST,
 	MCE_PRIO_MCELOG,
 	MCE_PRIO_EDAC,
+	MCE_PRIO_ACCEL,
 	MCE_PRIO_NFIT,
 	MCE_PRIO_EXTLOG,
 	MCE_PRIO_UC,
Signature · 1 line
2.17.1
maintainer
#27 lore raw
In reply to Naveen Krishna Chatradhi

arch/x86/kernel/cpu/mce/amd.c static struct smca_bank_name smca_names[] = { · line 93

Quoted 9 lines · Naveen Krishna Chatradhi
arch/x86/kernel/cpu/mce/amd.c +1 -0
index e486f96b3cb3..055f3a0acf5e 100644
@@ -90,6 +90,7 @@ static struct smca_bank_name smca_names[] = {
 	[SMCA_CS_V2]	= { "coherent_slave",	"Coherent Slave" },
 	[SMCA_PIE]	= { "pie",		"Power, Interrupts, etc." },
 	[SMCA_UMC]	= { "umc",		"Unified Memory Controller" },
+	[SMCA_UMC_V2]	= { "umc_v2",		"Unified Memory Controller" },

So this is called "umc_v2" but the other V2 FUs's strings are the same. Why?

Also, if you're going to repeat strings, you can just as well group all those which are the same this way:

[ SMCA_UMC ... SMCA_UMC_V2 ] = { "umc", "Unified Memory Controller" },

and do that for all which have V1 and V2.

I mean, gcc is smart enough to do that behind the scenes for identical strings but you should do that in C too.

drivers/edac/mce_amd.c static const char * const smca_umc_mce_desc[] = { · line 326

Quoted 9 lines
drivers/edac/mce_amd.c +1 -0
index 5dd905a3f30c..5515fd9336b1 100644
@@ -323,6 +323,21 @@ static const char * const smca_umc_mce_desc[] = {
 	"AES SRAM ECC error",
 };
 
+static const char * const smca_umc2_mce_desc[] = {

Ok, gcc reuses the identical string pointers from smca_umc_mce_desc[] so we should be ok wrt duplication.

Quoted 13 lines
drivers/edac/mce_amd.c +13 -0
+	"DRAM ECC error",
+	"Data poison error",
+	"SDP parity error",
+	"Reserved",
+	"Address/Command parity error",
+	"Write data parity error",
+	"DCQ SRAM ECC error",
+	"Reserved",
+	"Read data parity error",
+	"Rdb SRAM ECC error",
+	"RdRsp SRAM ECC error",
+	"LM32 MP errors",
+};

...

Quoted 20 lines
drivers/edac/mce_amd.c +20 -0
+static const char * const smca_xgmipcs_mce_desc[] = {
+	"DataLossErr",
+	"TrainingErr",
+	"FlowCtrlAckErr",
+	"RxFifoUnderflowErr",
+	"RxFifoOverflowErr",
+	"CRCErr",
+	"BERExceededErr",
+	"TxVcidDataErr",
+	"ReplayBufParityErr",
+	"DataParityErr",
+	"ReplayFifoOverflowErr",
+	"ReplayFIfoUnderflowErr",
+	"ElasticFifoOverflowErr",
+	"DeskewErr",
+	"FlowCtrlCRCErr",
+	"DataStartupLimitErr",
+	"FCInitTimeoutErr",
+	"RecoveryTimeoutErr",
+	"ReadySerialTimeoutErr",

drivers/edac/mce_amd.c static const char * const smca_pcie_mce_desc[] = { · line 451

Quoted 10 lines
drivers/edac/mce_amd.c +10 -0
+	"ReadySerialAttemptErr",
+	"RecoveryAttemptErr",
+	"RecoveryRelockAttemptErr",
+	"ReplayAttemptErr",
+	"SyncHdrErr",
+	"TxReplayTimeoutErr",
+	"RxReplayTimeoutErr",
+	"LinkSubTxTimeoutErr",
+	"LinkSubRxTimeoutErr",
+	"RxCMDPktErr",

What happened to those and why aren't they proper words like the other error descriptions?

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#28 lore raw

[AMD Official Use Only]

Hi Boris

My apologies for delayed response. Thanks for your review comments, will submit a v2 shortly.

Regards,
Naveenk

-----Original Message-----
From: Borislav Petkov <[email protected]>
Sent: Tuesday, May 11, 2021 10:57 PM
To: Chatradhi, Naveen Krishna <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; M K, Muralidhara <[email protected]>
Subject: Re: [PATCH 1/3] x86/MCE/AMD, EDAC/mce_amd: Add new SMCA bank types.

[CAUTION: External Email]

arch/x86/kernel/cpu/mce/amd.c static struct smca_bank_name smca_names[] = { · line 93

Quoted 10 lines · Naveen Krishna Chatradhi
(quoted diff) +0 -0

b/arch/x86/kernel/cpu/mce/amd.c index e486f96b3cb3..055f3a0acf5e 100644

arch/x86/kernel/cpu/mce/amd.c +1 -0
@@ -90,6 +90,7 @@ static struct smca_bank_name smca_names[] = {
      [SMCA_CS_V2]    = { "coherent_slave",   "Coherent Slave" },
      [SMCA_PIE]      = { "pie",              "Power, Interrupts, etc." },
      [SMCA_UMC]      = { "umc",              "Unified Memory Controller" },
+     [SMCA_UMC_V2]   = { "umc_v2",           "Unified Memory Controller" },

So this is called "umc_v2" but the other V2 FUs's strings are the same.
Why?
[naveenk:] There is a possibility for a heterogenous system with both the SMCA_UMC and SMCA_UMC_V2 variant of controllers to exist. I will update the long name to describe accordingly.

Also, if you're going to repeat strings, you can just as well group all those which are the same this way:

[ SMCA_UMC ... SMCA_UMC_V2 ] = { "umc", "Unified Memory Controller" },

and do that for all which have V1 and V2.

I mean, gcc is smart enough to do that behind the scenes for identical strings but you should do that in C too. [naveenk:] thanks for the suggestion, I can do this for the other units.

drivers/edac/mce_amd.c static const char * const smca_umc_mce_desc[] = { · line 326

Quoted 9 lines
drivers/edac/mce_amd.c index renamed from drivers/edac/mce_amd.c +0 -0

5dd905a3f30c..5515fd9336b1 100644

drivers/edac/mce_amd.c +1 -0
@@ -323,6 +323,21 @@ static const char * const smca_umc_mce_desc[] = {
      "AES SRAM ECC error",
 };
 
+static const char * const smca_umc2_mce_desc[] = {

Ok, gcc reuses the identical string pointers from smca_umc_mce_desc[] so we should be ok wrt duplication.

Quoted 13 lines
drivers/edac/mce_amd.c +13 -0
+     "DRAM ECC error",
+     "Data poison error",
+     "SDP parity error",
+     "Reserved",
+     "Address/Command parity error",
+     "Write data parity error",
+     "DCQ SRAM ECC error",
+     "Reserved",
+     "Read data parity error",
+     "Rdb SRAM ECC error",
+     "RdRsp SRAM ECC error",
+     "LM32 MP errors",
+};

...

Quoted 20 lines
drivers/edac/mce_amd.c +20 -0
+static const char * const smca_xgmipcs_mce_desc[] = {
+     "DataLossErr",
+     "TrainingErr",
+     "FlowCtrlAckErr",
+     "RxFifoUnderflowErr",
+     "RxFifoOverflowErr",
+     "CRCErr",
+     "BERExceededErr",
+     "TxVcidDataErr",
+     "ReplayBufParityErr",
+     "DataParityErr",
+     "ReplayFifoOverflowErr",
+     "ReplayFIfoUnderflowErr",
+     "ElasticFifoOverflowErr",
+     "DeskewErr",
+     "FlowCtrlCRCErr",
+     "DataStartupLimitErr",
+     "FCInitTimeoutErr",
+     "RecoveryTimeoutErr",
+     "ReadySerialTimeoutErr",

drivers/edac/mce_amd.c static const char * const smca_pcie_mce_desc[] = { · line 451

Quoted 10 lines
drivers/edac/mce_amd.c +10 -0
+     "ReadySerialAttemptErr",
+     "RecoveryAttemptErr",
+     "RecoveryRelockAttemptErr",
+     "ReplayAttemptErr",
+     "SyncHdrErr",
+     "TxReplayTimeoutErr",
+     "RxReplayTimeoutErr",
+     "LinkSubTxTimeoutErr",
+     "LinkSubRxTimeoutErr",
+     "RxCMDPktErr",

What happened to those and why aren't they proper words like the other error descriptions? [naveenk:] Will change these into proper words.

Thx.

--
Regards/Gruss,
Boris.

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpeople.kernel.org%2Ftglx%2Fnotes-about-netiquette&amp;data=04%7C01%7CNaveenKrishna.Chatradhi%40amd.com%7C9159e5c1aebd47969c2508d914a20789%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637563508427766424%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=%2FiHUZDkg99NnGdDrOCK%2FQWsui2yA1dADCfG%2F4xFr%2B7I%3D&amp;reserved=0

maintainer
#29 lore raw
Quoted 2 lines · Naveen Krishna

[naveenk:] There is a possibility for a heterogenous system with both the SMCA_UMC and SMCA_UMC_V2 variant of controllers to exist.

Wait, what? You can have systems with *both* UMCs in the same coherent fabric and thus the OS can see UMCs of both types on the same system?

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
maintainer
#30 lore raw
Quoted 7 lines · Borislav Petkov
Quoted 2 lines · Naveen Krishna

[naveenk:] There is a possibility for a heterogenous system with both the SMCA_UMC and SMCA_UMC_V2 variant of controllers to exist.

Wait, what? You can have systems with *both* UMCs in the same coherent fabric and thus the OS can see UMCs of both types on the same system?

Yep, that's right. The UMCs are the only case of this so far and in the foreseeable future. Though we may be moving towards more cases like this.

Thanks,
Yazen

maintainer
#31 lore raw
Quoted 3 lines · Yazen Ghannam

Yep, that's right. The UMCs are the only case of this so far and in the foreseeable future. Though we may be moving towards more cases like this.

Ok, then you guys really need to make sure those strings are unique because they're in sysfs:

/sys/devices/system/machinecheck/machinecheck...

AFAIR, so we can't have duplicates there.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#32 lore raw

PATCH v2 1/1 x86/MCE/AMD, EDAC/mce_amd: Add new SMCA bank types.

In reply to Naveen Krishna Chatradhi

From: Muralidhara M K <[email protected]>

Add the (HWID, MCATYPE) tuples and names for new
SMCA bank types.

Also, add their respective error descriptions to the MCE decoding module edac_mce_amd.
Also while at it, optimize the string names for some SMCA banks.

---
 arch/x86/include/asm/mce.h    |  5 +++
 arch/x86/kernel/cpu/mce/amd.c | 55 ++++++++++++++++-----------
 drivers/edac/mce_amd.c        | 70 +++++++++++++++++++++++++++++++++++
 3 files changed, 109 insertions(+), 21 deletions(-)
arch/x86/include/asm/mce.h +5 -0
index ddfb3cad8dff..691a9985cb95 100644
@@ -317,6 +317,7 @@ enum smca_bank_types {
 	SMCA_CS_V2,	/* Coherent Slave */
 	SMCA_PIE,	/* Power, Interrupts, etc. */
 	SMCA_UMC,	/* Unified Memory Controller */
+	SMCA_UMC_V2,	/* Unified Memory Controller V2 */
 	SMCA_PB,	/* Parameter Block */
 	SMCA_PSP,	/* Platform Security Processor */
 	SMCA_PSP_V2,	/* Platform Security Processor */
@@ -325,6 +326,10 @@ enum smca_bank_types {
 	SMCA_MP5,	/* Microprocessor 5 Unit */
 	SMCA_NBIO,	/* Northbridge IO Unit */
 	SMCA_PCIE,	/* PCI Express Unit */
+	SMCA_PCIE_V2,	/* PCI Express Unit */
+	SMCA_XGMI_PCS,	/* xGMI PCS Unit */
+	SMCA_XGMI_PHY,	/* xGMI PHY Unit */
+	SMCA_WAFL_PHY,	/* WAFL PHY Unit */
 	N_SMCA_BANK_TYPES
 };
 
arch/x86/kernel/cpu/mce/amd.c +34 -21

73 lines not on this page · raw message

drivers/edac/mce_amd.c +70 -0

94 lines not on this page · raw message

Signature · 1 line
2.26.2
#33 lore raw

[tip: ras/core] x86/MCE/AMD, EDAC/mce_amd: Add new SMCA bank types

The following commit has been merged into the ras/core branch of tip:

The following commit has been merged into the ras/core branch of tip:

Commit-ID:     94a311ce248e0b53c76e110fd00511af47b72ffb
Gitweb:        https://git.kernel.org/tip/94a311ce248e0b53c76e110fd00511af47b72ffb
Author:        Muralidhara M K <[email protected]>
AuthorDate:    Wed, 26 May 2021 22:16:01 +05:30
Committer:     Borislav Petkov <[email protected]>
CommitterDate: Thu, 27 May 2021 20:08:14 +02:00

x86/MCE/AMD, EDAC/mce_amd: Add new SMCA bank types

Add the (HWID, MCATYPE) tuples and names for new SMCA bank types.

Also, add their respective error descriptions to the MCE decoding module edac_mce_amd. Also while at it, optimize the string names for some SMCA banks.

[ bp: Drop repeated comments, explain why UMC_V2 is a separate entry. ]

---
 arch/x86/include/asm/mce.h    | 13 ++++--
 arch/x86/kernel/cpu/mce/amd.c | 55 ++++++++++++++++-----------
 drivers/edac/mce_amd.c        | 70 ++++++++++++++++++++++++++++++++++-
 3 files changed, 113 insertions(+), 25 deletions(-)
arch/x86/include/asm/mce.h +9 -4
index ddfb3ca..0607ec4 100644
@@ -305,7 +305,7 @@ extern void apei_mce_report_mem_error(int corrected,
 /* These may be used by multiple smca_hwid_mcatypes */
 enum smca_bank_types {
 	SMCA_LS = 0,	/* Load Store */
-	SMCA_LS_V2,	/* Load Store */
+	SMCA_LS_V2,
 	SMCA_IF,	/* Instruction Fetch */
 	SMCA_L2_CACHE,	/* L2 Cache */
 	SMCA_DE,	/* Decoder Unit */
@@ -314,17 +314,22 @@ enum smca_bank_types {
 	SMCA_FP,	/* Floating Point */
 	SMCA_L3_CACHE,	/* L3 Cache */
 	SMCA_CS,	/* Coherent Slave */
-	SMCA_CS_V2,	/* Coherent Slave */
+	SMCA_CS_V2,
 	SMCA_PIE,	/* Power, Interrupts, etc. */
 	SMCA_UMC,	/* Unified Memory Controller */
+	SMCA_UMC_V2,
 	SMCA_PB,	/* Parameter Block */
 	SMCA_PSP,	/* Platform Security Processor */
-	SMCA_PSP_V2,	/* Platform Security Processor */
+	SMCA_PSP_V2,
 	SMCA_SMU,	/* System Management Unit */
-	SMCA_SMU_V2,	/* System Management Unit */
+	SMCA_SMU_V2,
 	SMCA_MP5,	/* Microprocessor 5 Unit */
 	SMCA_NBIO,	/* Northbridge IO Unit */
 	SMCA_PCIE,	/* PCI Express Unit */
+	SMCA_PCIE_V2,
+	SMCA_XGMI_PCS,	/* xGMI PCS Unit */
+	SMCA_XGMI_PHY,	/* xGMI PHY Unit */
+	SMCA_WAFL_PHY,	/* WAFL PHY Unit */
 	N_SMCA_BANK_TYPES
 };
 
arch/x86/kernel/cpu/mce/amd.c +34 -21

73 lines not on this page · raw message

drivers/edac/mce_amd.c +70 -0

94 lines not on this page · raw message