Skip to contentSkip to conversation

drm/amd/ras: add set_debug_mode function for uniras

PATCH Superseded Ce Sun 3 participants 4 messages Jun 22 1 message not in the archive

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Ce Sun

author
#1 lore raw

PATCH 1/2 drm/amd/ras: add set_debug_mode function for uniras

add set_debug_mode function for uniras

---
 drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_mgr.c | 10 ++++++++++
 drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_mgr.h |  1 +
 .../drm/amd/ras/ras_mgr/amdgpu_ras_mp1_v13_0.c   | 14 ++++++++++++++
 drivers/gpu/drm/amd/ras/rascore/ras.h            |  3 +++
 drivers/gpu/drm/amd/ras/rascore/ras_core.c       |  5 +++++
 drivers/gpu/drm/amd/ras/rascore/ras_mp1.c        | 16 +++++++++++++++-
 drivers/gpu/drm/amd/ras/rascore/ras_mp1.h        |  3 +++
 drivers/gpu/drm/amd/ras/rascore/ras_mp1_v13_0.c  | 13 +++++++++++++
 8 files changed, 64 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_mgr.c +10 -0
index f627a97797ed..2ce7b88544c3 100644
@@ -773,3 +773,13 @@ int amdgpu_ras_mgr_lookup_bad_pages_in_a_row(struct amdgpu_device *adev,
 	return ras_core_convert_soc_pa_to_cur_nps_pages(ras_mgr->ras_core,
 			addr, nps_page_addr, max_page_count);
 }
+
+int amdgpu_ras_mgr_set_debug_mode(struct amdgpu_device *adev, bool enable)
+{
+	struct amdgpu_ras_mgr *ras_mgr = amdgpu_ras_mgr_get_context(adev);
+
+	if (!ras_mgr || !ras_mgr->ras_core || !ras_mgr->ras_is_ready)
+		return false;
+
+	return ras_core_set_debug_mode(ras_mgr->ras_core, enable);
+}
drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_mgr.h +1 -0
index 4f44a917d48b..a757ec15125e 100644
@@ -84,4 +84,5 @@ int amdgpu_ras_mgr_pre_reset(struct amdgpu_device *adev);
 int amdgpu_ras_mgr_post_reset(struct amdgpu_device *adev);
 int amdgpu_ras_mgr_lookup_bad_pages_in_a_row(struct amdgpu_device *adev,
 		uint64_t addr, uint64_t *nps_page_addr, uint32_t max_page_count);
+int amdgpu_ras_mgr_set_debug_mode(struct amdgpu_device *adev, bool enable);
 #endif
drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_mp1_v13_0.c +14 -0
index 2098f24d4940..ee59184f7eee 100644
@@ -24,6 +24,7 @@
 #include "amdgpu_smu.h"
 #include "amdgpu_reset.h"
 #include "amdgpu_ras_mp1_v13_0.h"
+#include "smu13_driver_if_v13_0_6.h"
 
 #define RAS_MP1_MSG_QueryValidMcaCeCount  0x3A
 #define RAS_MP1_MSG_McaBankCeDumpDW       0x3B
@@ -131,10 +132,23 @@ static int mp1_v13_0_get_ras_enabled_mask(struct ras_core_context *ras_core,
 	return ret;
 }
 
+static int mp1_v13_0_set_debug_mode(struct ras_core_context *ras_core, bool enable)
+{
+	struct amdgpu_device *adev = (struct amdgpu_device *)ras_core->dev;
+	int ret;
+	u32 smu_msg = SMU_MSG_ClearMcaOnRead;
+
+	ret = amdgpu_smu_ras_send_msg(adev, smu_msg,
+				      enable ? 0 : ClearMcaOnRead_UE_FLAG_MASK | ClearMcaOnRead_CE_POLL_MASK,
+				      NULL);
+	return ret;
+}
+
 const struct ras_mp1_sys_func amdgpu_ras_mp1_sys_func_v13_0 = {
 	.mp1_get_valid_bank_count = mp1_v13_0_get_valid_bank_count,
 	.mp1_dump_valid_bank = mp1_v13_0_dump_valid_bank,
 	.mp1_send_eeprom_msg = mp1_v13_0_eeprom_send_msg,
 	.mp1_get_ras_enabled_mask = mp1_v13_0_get_ras_enabled_mask,
+	.mp1_set_debug_mode = mp1_v13_0_set_debug_mode,
 };
 
drivers/gpu/drm/amd/ras/rascore/ras.h +3 -0
index 5869bad978b0..371d1061d8f4 100644
@@ -167,6 +167,7 @@ struct ras_mp1_sys_func {
 			enum ras_fw_eeprom_cmd index, uint32_t param, uint32_t *read_arg);
 	int (*mp1_get_ras_enabled_mask)(struct ras_core_context *ras_core,
 			uint64_t *enabled_mask);
+	int (*mp1_set_debug_mode)(struct ras_core_context *ras_core, bool enable);
 };
 
 struct ras_eeprom_sys_func {
@@ -400,4 +401,6 @@ int ras_core_get_device_system_info(struct ras_core_context *ras_core,
 int ras_core_convert_soc_pa_to_cur_nps_pages(struct ras_core_context *ras_core,
 		uint64_t soc_pa, uint64_t *page_pfn, uint32_t max_pages);
 int ras_core_check_address_sanity(struct ras_core_context *ras_core, uint64_t addr);
+
+int ras_core_set_debug_mode(struct ras_core_context *ras_core,bool enable);
 #endif
drivers/gpu/drm/amd/ras/rascore/ras_core.c +5 -0
index 61d100b074b9..08e17a83ad5b 100644
@@ -151,6 +151,11 @@ bool ras_core_gpu_is_rma(struct ras_core_context *ras_core)
 	return ras_core->is_rma;
 }
 
+int ras_core_set_debug_mode(struct ras_core_context *ras_core, bool enable)
+{
+	return ras_mp1_set_debug_mode(ras_core, enable);
+}
+
 static int ras_core_seqno_fifo_write(struct ras_core_context *ras_core,
 		enum ras_seqno_fifo fifo_type, uint64_t seqno)
 {
drivers/gpu/drm/amd/ras/rascore/ras_mp1.c +15 -1
index f3321df85021..15b605a23aa5 100644
@@ -59,9 +59,17 @@ int ras_mp1_dump_bank(struct ras_core_context *ras_core,
 	return mp1->ip_func->dump_valid_bank(ras_core, type, idx, reg_idx, val);
 }
 
+int ras_mp1_set_debug_mode(struct ras_core_context *ras_core,bool enable)
+{
+	struct ras_mp1 *mp1 = &ras_core->ras_mp1;
+
+	return mp1->ip_func->set_debug_mode(ras_core, enable);
+}
+
 int ras_mp1_hw_init(struct ras_core_context *ras_core)
 {
 	struct ras_mp1 *mp1 = &ras_core->ras_mp1;
+	int ret = 0;
 
 	mp1->mp1_ip_version = ras_core->config->mp1_ip_version;
 	mp1->sys_func = ras_core->config->mp1_cfg.mp1_sys_fn;
@@ -71,8 +79,14 @@ int ras_mp1_hw_init(struct ras_core_context *ras_core)
 	}
 
 	mp1->ip_func = ras_mp1_get_ip_funcs(ras_core, mp1->mp1_ip_version);
+	if (!mp1->ip_func)
+		return -EINVAL;
+
+	ret = ras_mp1_set_debug_mode(ras_core, false);
+	if (ret)
+		return -EINVAL;
 
-	return mp1->ip_func ? RAS_CORE_OK : -EINVAL;
+	return ret;
 }
 
 int ras_mp1_hw_fini(struct ras_core_context *ras_core)
drivers/gpu/drm/amd/ras/rascore/ras_mp1.h +3 -0
index de1d08286f41..0b618f6b8b9e 100644
@@ -31,6 +31,7 @@ struct ras_mp1_ip_func {
 			enum ras_err_type type, u32 *count);
 	int (*dump_valid_bank)(struct ras_core_context *ras_core,
 		enum ras_err_type type, u32 idx, u32 reg_idx, u64 *val);
+	int (*set_debug_mode)(struct ras_core_context *ras_core,bool enable);
 };
 
 struct ras_mp1 {
@@ -47,4 +48,6 @@ int ras_mp1_get_bank_count(struct ras_core_context *ras_core,
 
 int ras_mp1_dump_bank(struct ras_core_context *ras_core,
 		u32 ecc_type, u32 idx, u32 reg_idx, u64 *val);
+
+int ras_mp1_set_debug_mode(struct ras_core_context *ras_core,bool enable);
 #endif
drivers/gpu/drm/amd/ras/rascore/ras_mp1_v13_0.c +13 -0
index 310d39fc816b..1fcfc1995ad3 100644
@@ -99,7 +99,20 @@ static int mp1_v13_0_dump_bank(struct ras_core_context *ras_core,
 	return sys_func->mp1_dump_valid_bank(ras_core, msg, idx, reg_idx, val);
 }
 
+static int mp1_v13_0_set_debug_mode(struct ras_core_context *ras_core, bool enable)
+{
+	struct ras_mp1 *mp1 = &ras_core->ras_mp1;
+	const struct ras_mp1_sys_func *sys_func = mp1->sys_func;
+
+	if (!sys_func || !sys_func->mp1_set_debug_mode)
+		return -RAS_CORE_NOT_SUPPORTED;
+
+	return sys_func->mp1_set_debug_mode(ras_core, enable);
+}
+
+
 const struct ras_mp1_ip_func mp1_ras_func_v13_0 = {
 	.get_valid_bank_count = mp1_v13_0_get_bank_count,
 	.dump_valid_bank = mp1_v13_0_dump_bank,
+	.set_debug_mode = mp1_v13_0_set_debug_mode,
 };
Signature · 1 line
2.34.1
#2 lore raw

AMD General

+int ras_mp1_set_debug_mode(struct ras_core_context *ras_core,bool +enable) {
+ struct ras_mp1 *mp1 = &ras_core->ras_mp1;
+
+ return mp1->ip_func->set_debug_mode(ras_core, enable); }
+

Please check the availability of set_debug_mode call as it is not a mandatory function for all generations

Regards,
Hawking

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Ce Sun
Sent: Monday, June 22, 2026 12:50 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Chai, Thomas <[email protected]>; Zhou1, Tao <[email protected]>; Sun, Ce(Overlord) <[email protected]>
Subject: [PATCH v1 1/2] drm/amd/ras: add set_debug_mode function for uniras

add set_debug_mode function for uniras

---
 drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_mgr.c | 10 ++++++++++  drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_mgr.h |  1 +
 .../drm/amd/ras/ras_mgr/amdgpu_ras_mp1_v13_0.c   | 14 ++++++++++++++
 drivers/gpu/drm/amd/ras/rascore/ras.h            |  3 +++
 drivers/gpu/drm/amd/ras/rascore/ras_core.c       |  5 +++++
 drivers/gpu/drm/amd/ras/rascore/ras_mp1.c        | 16 +++++++++++++++-
 drivers/gpu/drm/amd/ras/rascore/ras_mp1.h        |  3 +++
 drivers/gpu/drm/amd/ras/rascore/ras_mp1_v13_0.c  | 13 +++++++++++++
 8 files changed, 64 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_mgr.c +9 -0
index f627a97797ed..2ce7b88544c3 100644
@@ -773,3 +773,13 @@ int amdgpu_ras_mgr_lookup_bad_pages_in_a_row(struct amdgpu_device *adev,
        return ras_core_convert_soc_pa_to_cur_nps_pages(ras_mgr->ras_core,
                        addr, nps_page_addr, max_page_count);  }
+
+int amdgpu_ras_mgr_set_debug_mode(struct amdgpu_device *adev, bool
+enable) {
+       struct amdgpu_ras_mgr *ras_mgr = amdgpu_ras_mgr_get_context(adev);
+
+       if (!ras_mgr || !ras_mgr->ras_core || !ras_mgr->ras_is_ready)
+               return false;
+
+       return ras_core_set_debug_mode(ras_mgr->ras_core, enable); }
drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_mgr.h +2 -0
index 4f44a917d48b..a757ec15125e 100644
@@ -84,4 +84,5 @@ int amdgpu_ras_mgr_pre_reset(struct amdgpu_device *adev);  int amdgpu_ras_mgr_post_reset(struct amdgpu_device *adev);  int amdgpu_ras_mgr_lookup_bad_pages_in_a_row(struct amdgpu_device *adev,
                uint64_t addr, uint64_t *nps_page_addr, uint32_t max_page_count);
+int amdgpu_ras_mgr_set_debug_mode(struct amdgpu_device *adev, bool
+enable);
 #endif
drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_mp1_v13_0.c +14 -0
index 2098f24d4940..ee59184f7eee 100644
@@ -24,6 +24,7 @@
 #include "amdgpu_smu.h"
 #include "amdgpu_reset.h"
 #include "amdgpu_ras_mp1_v13_0.h"
+#include "smu13_driver_if_v13_0_6.h"
 
 #define RAS_MP1_MSG_QueryValidMcaCeCount  0x3A
 #define RAS_MP1_MSG_McaBankCeDumpDW       0x3B
@@ -131,10 +132,23 @@ static int mp1_v13_0_get_ras_enabled_mask(struct ras_core_context *ras_core,
        return ret;
 }
 
+static int mp1_v13_0_set_debug_mode(struct ras_core_context *ras_core,
+bool enable) {
+       struct amdgpu_device *adev = (struct amdgpu_device *)ras_core->dev;
+       int ret;
+       u32 smu_msg = SMU_MSG_ClearMcaOnRead;
+
+       ret = amdgpu_smu_ras_send_msg(adev, smu_msg,
+                                     enable ? 0 : ClearMcaOnRead_UE_FLAG_MASK | ClearMcaOnRead_CE_POLL_MASK,
+                                     NULL);
+       return ret;
+}
+
 const struct ras_mp1_sys_func amdgpu_ras_mp1_sys_func_v13_0 = {
        .mp1_get_valid_bank_count = mp1_v13_0_get_valid_bank_count,
        .mp1_dump_valid_bank = mp1_v13_0_dump_valid_bank,
        .mp1_send_eeprom_msg = mp1_v13_0_eeprom_send_msg,
        .mp1_get_ras_enabled_mask = mp1_v13_0_get_ras_enabled_mask,
+       .mp1_set_debug_mode = mp1_v13_0_set_debug_mode,
 };
 
drivers/gpu/drm/amd/ras/rascore/ras.h +2 -0
index 5869bad978b0..371d1061d8f4 100644
@@ -167,6 +167,7 @@ struct ras_mp1_sys_func {
                        enum ras_fw_eeprom_cmd index, uint32_t param, uint32_t *read_arg);
        int (*mp1_get_ras_enabled_mask)(struct ras_core_context *ras_core,
                        uint64_t *enabled_mask);
+       int (*mp1_set_debug_mode)(struct ras_core_context *ras_core, bool
+enable);
 };
 

struct ras_eeprom_sys_func {
@@ -400,4 +401,6 @@ int ras_core_get_device_system_info(struct ras_core_context *ras_core, int ras_core_convert_soc_pa_to_cur_nps_pages(struct ras_core_context *ras_core,

                uint64_t soc_pa, uint64_t *page_pfn, uint32_t max_pages);  int ras_core_check_address_sanity(struct ras_core_context *ras_core, uint64_t addr);

+
+int ras_core_set_debug_mode(struct ras_core_context *ras_core,bool +enable);
#endif

drivers/gpu/drm/amd/ras/rascore/ras_core.c +4 -0
index 61d100b074b9..08e17a83ad5b 100644
@@ -151,6 +151,11 @@ bool ras_core_gpu_is_rma(struct ras_core_context *ras_core)
        return ras_core->is_rma;
 }
 
+int ras_core_set_debug_mode(struct ras_core_context *ras_core, bool
+enable) {
+       return ras_mp1_set_debug_mode(ras_core, enable); }
+
 static int ras_core_seqno_fifo_write(struct ras_core_context *ras_core,
                enum ras_seqno_fifo fifo_type, uint64_t seqno)  { diff --git a/drivers/gpu/drm/amd/ras/rascore/ras_mp1.c b/drivers/gpu/drm/amd/ras/rascore/ras_mp1.c

index f3321df85021..15b605a23aa5 100644

drivers/gpu/drm/amd/ras/rascore/ras_mp1.c +14 -1
@@ -59,9 +59,17 @@ int ras_mp1_dump_bank(struct ras_core_context *ras_core,
        return mp1->ip_func->dump_valid_bank(ras_core, type, idx, reg_idx, val);  }
 
+int ras_mp1_set_debug_mode(struct ras_core_context *ras_core,bool
+enable) {
+       struct ras_mp1 *mp1 = &ras_core->ras_mp1;
+
+       return mp1->ip_func->set_debug_mode(ras_core, enable); }
+
 int ras_mp1_hw_init(struct ras_core_context *ras_core)  {
        struct ras_mp1 *mp1 = &ras_core->ras_mp1;
+       int ret = 0;
 
        mp1->mp1_ip_version = ras_core->config->mp1_ip_version;
        mp1->sys_func = ras_core->config->mp1_cfg.mp1_sys_fn;
@@ -71,8 +79,14 @@ int ras_mp1_hw_init(struct ras_core_context *ras_core)
        }
 
        mp1->ip_func = ras_mp1_get_ip_funcs(ras_core, mp1->mp1_ip_version);
+       if (!mp1->ip_func)
+               return -EINVAL;
+
+       ret = ras_mp1_set_debug_mode(ras_core, false);
+       if (ret)
+               return -EINVAL;
 
-       return mp1->ip_func ? RAS_CORE_OK : -EINVAL;
+       return ret;
 }
 
 int ras_mp1_hw_fini(struct ras_core_context *ras_core) diff --git a/drivers/gpu/drm/amd/ras/rascore/ras_mp1.h b/drivers/gpu/drm/amd/ras/rascore/ras_mp1.h

index de1d08286f41..0b618f6b8b9e 100644

drivers/gpu/drm/amd/ras/rascore/ras_mp1.h +4 -0
@@ -31,6 +31,7 @@ struct ras_mp1_ip_func {
                        enum ras_err_type type, u32 *count);
        int (*dump_valid_bank)(struct ras_core_context *ras_core,
                enum ras_err_type type, u32 idx, u32 reg_idx, u64 *val);
+       int (*set_debug_mode)(struct ras_core_context *ras_core,bool enable);
 };
 
 struct ras_mp1 {
@@ -47,4 +48,6 @@ int ras_mp1_get_bank_count(struct ras_core_context *ras_core,
 
 int ras_mp1_dump_bank(struct ras_core_context *ras_core,
                u32 ecc_type, u32 idx, u32 reg_idx, u64 *val);
+
+int ras_mp1_set_debug_mode(struct ras_core_context *ras_core,bool
+enable);

#endif

drivers/gpu/drm/amd/ras/rascore/ras_mp1_v13_0.c +12 -1
index 310d39fc816b..1fcfc1995ad3 100644
@@ -99,7 +99,20 @@ static int mp1_v13_0_dump_bank(struct ras_core_context *ras_core,
        return sys_func->mp1_dump_valid_bank(ras_core, msg, idx, reg_idx, val);  }
 
+static int mp1_v13_0_set_debug_mode(struct ras_core_context *ras_core,
+bool enable) {
+       struct ras_mp1 *mp1 = &ras_core->ras_mp1;
+       const struct ras_mp1_sys_func *sys_func = mp1->sys_func;
+
+       if (!sys_func || !sys_func->mp1_set_debug_mode)
+               return -RAS_CORE_NOT_SUPPORTED;
+
+       return sys_func->mp1_set_debug_mode(ras_core, enable); }
+
+
 const struct ras_mp1_ip_func mp1_ras_func_v13_0 = {
        .get_valid_bank_count = mp1_v13_0_get_bank_count,
        .dump_valid_bank = mp1_v13_0_dump_bank,
+       .set_debug_mode = mp1_v13_0_set_debug_mode,
 };
--

2.34.1

#3 lore raw

AMD General

Hi Hawking,

Thanks for the review,I will revise ras_mp1_set_debug_mode with below fix in v2 patch set:
1. Add validation for mp1->ip_func and mp1->ip_func->set_debug_mode
2. Return -ENOTSUPP error code if the callback is missing

Regards,
Sun,Ce
________________________________
From: Zhang, Hawking <[email protected]>
Sent: Monday, June 22, 2026 3:51 PM
To: Sun, Ce(Overlord) <[email protected]>; [email protected] <[email protected]>
Cc: Chai, Thomas <[email protected]>; Zhou1, Tao <[email protected]>; Sun, Ce(Overlord) <[email protected]>
Subject: RE: [PATCH v1 1/2] drm/amd/ras: add set_debug_mode function for uniras

AMD General

+int ras_mp1_set_debug_mode(struct ras_core_context *ras_core,bool +enable) {
+ struct ras_mp1 *mp1 = &ras_core->ras_mp1;
+
+ return mp1->ip_func->set_debug_mode(ras_core, enable); }
+

Please check the availability of set_debug_mode call as it is not a mandatory function for all generations

Regards,
Hawking

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Ce Sun
Sent: Monday, June 22, 2026 12:50 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Chai, Thomas <[email protected]>; Zhou1, Tao <[email protected]>; Sun, Ce(Overlord) <[email protected]>
Subject: [PATCH v1 1/2] drm/amd/ras: add set_debug_mode function for uniras

add set_debug_mode function for uniras

---
 drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_mgr.c | 10 ++++++++++  drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_mgr.h |  1 +
 .../drm/amd/ras/ras_mgr/amdgpu_ras_mp1_v13_0.c   | 14 ++++++++++++++
 drivers/gpu/drm/amd/ras/rascore/ras.h            |  3 +++
 drivers/gpu/drm/amd/ras/rascore/ras_core.c       |  5 +++++
 drivers/gpu/drm/amd/ras/rascore/ras_mp1.c        | 16 +++++++++++++++-
 drivers/gpu/drm/amd/ras/rascore/ras_mp1.h        |  3 +++
 drivers/gpu/drm/amd/ras/rascore/ras_mp1_v13_0.c  | 13 +++++++++++++
 8 files changed, 64 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_mgr.c +9 -0
index f627a97797ed..2ce7b88544c3 100644
@@ -773,3 +773,13 @@ int amdgpu_ras_mgr_lookup_bad_pages_in_a_row(struct amdgpu_device *adev,
        return ras_core_convert_soc_pa_to_cur_nps_pages(ras_mgr->ras_core,
                        addr, nps_page_addr, max_page_count);  }
+
+int amdgpu_ras_mgr_set_debug_mode(struct amdgpu_device *adev, bool
+enable) {
+       struct amdgpu_ras_mgr *ras_mgr = amdgpu_ras_mgr_get_context(adev);
+
+       if (!ras_mgr || !ras_mgr->ras_core || !ras_mgr->ras_is_ready)
+               return false;
+
+       return ras_core_set_debug_mode(ras_mgr->ras_core, enable); }
drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_mgr.h +2 -0
index 4f44a917d48b..a757ec15125e 100644
@@ -84,4 +84,5 @@ int amdgpu_ras_mgr_pre_reset(struct amdgpu_device *adev);  int amdgpu_ras_mgr_post_reset(struct amdgpu_device *adev);  int amdgpu_ras_mgr_lookup_bad_pages_in_a_row(struct amdgpu_device *adev,
                uint64_t addr, uint64_t *nps_page_addr, uint32_t max_page_count);
+int amdgpu_ras_mgr_set_debug_mode(struct amdgpu_device *adev, bool
+enable);
 #endif
drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_mp1_v13_0.c +14 -0
index 2098f24d4940..ee59184f7eee 100644
@@ -24,6 +24,7 @@
 #include "amdgpu_smu.h"
 #include "amdgpu_reset.h"
 #include "amdgpu_ras_mp1_v13_0.h"
+#include "smu13_driver_if_v13_0_6.h"
 
 #define RAS_MP1_MSG_QueryValidMcaCeCount  0x3A
 #define RAS_MP1_MSG_McaBankCeDumpDW       0x3B
@@ -131,10 +132,23 @@ static int mp1_v13_0_get_ras_enabled_mask(struct ras_core_context *ras_core,
        return ret;
 }
 
+static int mp1_v13_0_set_debug_mode(struct ras_core_context *ras_core,
+bool enable) {
+       struct amdgpu_device *adev = (struct amdgpu_device *)ras_core->dev;
+       int ret;
+       u32 smu_msg = SMU_MSG_ClearMcaOnRead;
+
+       ret = amdgpu_smu_ras_send_msg(adev, smu_msg,
+                                     enable ? 0 : ClearMcaOnRead_UE_FLAG_MASK | ClearMcaOnRead_CE_POLL_MASK,
+                                     NULL);
+       return ret;
+}
+
 const struct ras_mp1_sys_func amdgpu_ras_mp1_sys_func_v13_0 = {
        .mp1_get_valid_bank_count = mp1_v13_0_get_valid_bank_count,
        .mp1_dump_valid_bank = mp1_v13_0_dump_valid_bank,
        .mp1_send_eeprom_msg = mp1_v13_0_eeprom_send_msg,
        .mp1_get_ras_enabled_mask = mp1_v13_0_get_ras_enabled_mask,
+       .mp1_set_debug_mode = mp1_v13_0_set_debug_mode,
 };
 
drivers/gpu/drm/amd/ras/rascore/ras.h +2 -0
index 5869bad978b0..371d1061d8f4 100644
@@ -167,6 +167,7 @@ struct ras_mp1_sys_func {
                        enum ras_fw_eeprom_cmd index, uint32_t param, uint32_t *read_arg);
        int (*mp1_get_ras_enabled_mask)(struct ras_core_context *ras_core,
                        uint64_t *enabled_mask);
+       int (*mp1_set_debug_mode)(struct ras_core_context *ras_core, bool
+enable);
 };
 

struct ras_eeprom_sys_func {
@@ -400,4 +401,6 @@ int ras_core_get_device_system_info(struct ras_core_context *ras_core, int ras_core_convert_soc_pa_to_cur_nps_pages(struct ras_core_context *ras_core,

                uint64_t soc_pa, uint64_t *page_pfn, uint32_t max_pages);  int ras_core_check_address_sanity(struct ras_core_context *ras_core, uint64_t addr);

+
+int ras_core_set_debug_mode(struct ras_core_context *ras_core,bool +enable);
#endif

drivers/gpu/drm/amd/ras/rascore/ras_core.c +4 -0
index 61d100b074b9..08e17a83ad5b 100644
@@ -151,6 +151,11 @@ bool ras_core_gpu_is_rma(struct ras_core_context *ras_core)
        return ras_core->is_rma;
 }
 
+int ras_core_set_debug_mode(struct ras_core_context *ras_core, bool
+enable) {
+       return ras_mp1_set_debug_mode(ras_core, enable); }
+
 static int ras_core_seqno_fifo_write(struct ras_core_context *ras_core,
                enum ras_seqno_fifo fifo_type, uint64_t seqno)  { diff --git a/drivers/gpu/drm/amd/ras/rascore/ras_mp1.c b/drivers/gpu/drm/amd/ras/rascore/ras_mp1.c

index f3321df85021..15b605a23aa5 100644

drivers/gpu/drm/amd/ras/rascore/ras_mp1.c +14 -1
@@ -59,9 +59,17 @@ int ras_mp1_dump_bank(struct ras_core_context *ras_core,
        return mp1->ip_func->dump_valid_bank(ras_core, type, idx, reg_idx, val);  }
 
+int ras_mp1_set_debug_mode(struct ras_core_context *ras_core,bool
+enable) {
+       struct ras_mp1 *mp1 = &ras_core->ras_mp1;
+
+       return mp1->ip_func->set_debug_mode(ras_core, enable); }
+
 int ras_mp1_hw_init(struct ras_core_context *ras_core)  {
        struct ras_mp1 *mp1 = &ras_core->ras_mp1;
+       int ret = 0;
 
        mp1->mp1_ip_version = ras_core->config->mp1_ip_version;
        mp1->sys_func = ras_core->config->mp1_cfg.mp1_sys_fn;
@@ -71,8 +79,14 @@ int ras_mp1_hw_init(struct ras_core_context *ras_core)
        }
 
        mp1->ip_func = ras_mp1_get_ip_funcs(ras_core, mp1->mp1_ip_version);
+       if (!mp1->ip_func)
+               return -EINVAL;
+
+       ret = ras_mp1_set_debug_mode(ras_core, false);
+       if (ret)
+               return -EINVAL;
 
-       return mp1->ip_func ? RAS_CORE_OK : -EINVAL;
+       return ret;
 }
 
 int ras_mp1_hw_fini(struct ras_core_context *ras_core) diff --git a/drivers/gpu/drm/amd/ras/rascore/ras_mp1.h b/drivers/gpu/drm/amd/ras/rascore/ras_mp1.h

index de1d08286f41..0b618f6b8b9e 100644

drivers/gpu/drm/amd/ras/rascore/ras_mp1.h +4 -0
@@ -31,6 +31,7 @@ struct ras_mp1_ip_func {
                        enum ras_err_type type, u32 *count);
        int (*dump_valid_bank)(struct ras_core_context *ras_core,
                enum ras_err_type type, u32 idx, u32 reg_idx, u64 *val);
+       int (*set_debug_mode)(struct ras_core_context *ras_core,bool enable);
 };
 
 struct ras_mp1 {
@@ -47,4 +48,6 @@ int ras_mp1_get_bank_count(struct ras_core_context *ras_core,
 
 int ras_mp1_dump_bank(struct ras_core_context *ras_core,
                u32 ecc_type, u32 idx, u32 reg_idx, u64 *val);
+
+int ras_mp1_set_debug_mode(struct ras_core_context *ras_core,bool
+enable);

#endif

drivers/gpu/drm/amd/ras/rascore/ras_mp1_v13_0.c +12 -1
index 310d39fc816b..1fcfc1995ad3 100644
@@ -99,7 +99,20 @@ static int mp1_v13_0_dump_bank(struct ras_core_context *ras_core,
        return sys_func->mp1_dump_valid_bank(ras_core, msg, idx, reg_idx, val);  }
 
+static int mp1_v13_0_set_debug_mode(struct ras_core_context *ras_core,
+bool enable) {
+       struct ras_mp1 *mp1 = &ras_core->ras_mp1;
+       const struct ras_mp1_sys_func *sys_func = mp1->sys_func;
+
+       if (!sys_func || !sys_func->mp1_set_debug_mode)
+               return -RAS_CORE_NOT_SUPPORTED;
+
+       return sys_func->mp1_set_debug_mode(ras_core, enable); }
+
+
 const struct ras_mp1_ip_func mp1_ras_func_v13_0 = {
        .get_valid_bank_count = mp1_v13_0_get_bank_count,
        .dump_valid_bank = mp1_v13_0_dump_bank,
+       .set_debug_mode = mp1_v13_0_set_debug_mode,
 };
--

2.34.1

author
#4 lore raw

PATCH 2/2 drm/amdgpu: re-set ClearMcaOnRead CE/UE in late init for uniras

In reply to a message not in the archive

Re-set the ClearMcaOnRead flags for UE and CE errors during RAS late init to maintain correct MCA error handling behavior

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +3 -0
index 465f82c660f2..953a35ec93fd 100644
@@ -3903,6 +3903,9 @@ int amdgpu_ras_late_init(struct amdgpu_device *adev)
 	if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_ras_telemetry_en(adev))
 		return 0;
 
+	if (amdgpu_uniras_enabled(adev))
+		amdgpu_ras_mgr_set_debug_mode(adev, false);
+
 	list_for_each_entry_safe(node, tmp, &adev->ras_list, node) {
 		obj = node->ras_obj;
 		if (!obj) {
Signature · 1 line
2.34.1