Skip to contentSkip to conversation

umc ras code refinement

PATCH In review Tao Zhou 3 participants 12 messages Aug 1, 2019 5 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Tao Zhou

author
#0 lore raw

cover umc ras code refinement

The series refines umc ras code, no functional change.

Tao Zhou (6):
drm/amdgpu: remove the clear of MCA_ADDR
drm/amdgpu: add more parameters and functions to amdgpu_umc structure drm/amdgpu: initialize new parameters and functions for amdgpu_umc
structure
drm/amdgpu: add macro of umc for each channel
drm/amdgpu: apply umc_for_each_channel macro to umc_6_1 drm/amdgpu: add error address query for umc ras

 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c |  5 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h | 36 ++++++++++
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   | 12 +++-
 drivers/gpu/drm/amd/amdgpu/umc_v6_1.c   | 92 ++++++++++---------------
 drivers/gpu/drm/amd/amdgpu/umc_v6_1.h   |  5 ++
 5 files changed, 91 insertions(+), 59 deletions(-)
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

author
#2 lore raw

PATCH 1/6 drm/amdgpu: remove the clear of MCA_ADDR

clearing MCA_STATUS is enough to reset the whole MCA, writing zero to MCA_ADDR is unnecessary

---
 drivers/gpu/drm/amd/amdgpu/umc_v6_1.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/umc_v6_1.c +0 -2
index bff1a12f2cc9..035e4fea472c 100644
@@ -229,8 +229,6 @@ static void umc_v6_1_query_ras_error_address(struct amdgpu_device *adev,
 
 			/* clear umc status */
 			WREG64(mc_umc_status_addr + umc_reg_offset, 0x0ULL);
-			/* clear error address register */
-			WREG64_PCIE(smnMCA_UMC0_MCUMC_ADDRT0 + umc_reg_offset * 4, 0x0ULL);
 		}
 	}
 
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

Reviewed-by
#4 lore raw

Re: [PATCH 1/6] drm/amdgpu: remove the clear of MCA_ADDR

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Tao Zhou <[email protected]>
Sent: Thursday, August 1, 2019 2:43 AM
To: [email protected] <[email protected]>; Zhang, Hawking <[email protected]>; Li, Dennis <[email protected]>; Chen, Guchun <[email protected]>; Pan, Xinhui <[email protected]>
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 1/6] drm/amdgpu: remove the clear of MCA_ADDR

clearing MCA_STATUS is enough to reset the whole MCA, writing zero to MCA_ADDR is unnecessary

---
 drivers/gpu/drm/amd/amdgpu/umc_v6_1.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/umc_v6_1.c +0 -2
index bff1a12f2cc9..035e4fea472c 100644
@@ -229,8 +229,6 @@ static void umc_v6_1_query_ras_error_address(struct amdgpu_device *adev,
 
                         /* clear umc status */
                         WREG64(mc_umc_status_addr + umc_reg_offset, 0x0ULL);
-                       /* clear error address register */
-                       WREG64_PCIE(smnMCA_UMC0_MCUMC_ADDRT0 + umc_reg_offset * 4, 0x0ULL);
                 }
         }
 

--
2.17.1

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author
#5 lore raw

PATCH 2/6 drm/amdgpu: add more parameters and functions to amdgpu_umc structure

In reply to a message not in the archive
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h | 13 +++++++++++++
 drivers/gpu/drm/amd/amdgpu/umc_v6_1.h   |  2 ++
 2 files changed, 15 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +13 -0
index dfa1a39e57af..2604f5076867 100644
@@ -22,15 +22,28 @@
 #define __AMDGPU_UMC_H__
 
 struct amdgpu_umc_funcs {
+	void (*ras_init)(struct amdgpu_device *adev);
 	void (*query_ras_error_count)(struct amdgpu_device *adev,
 					void *ras_error_status);
 	void (*query_ras_error_address)(struct amdgpu_device *adev,
 					void *ras_error_status);
+	void (*enable_umc_index_mode)(struct amdgpu_device *adev,
+					uint32_t umc_instance);
+	void (*disable_umc_index_mode)(struct amdgpu_device *adev);
 };
 
 struct amdgpu_umc {
 	/* max error count in one ras query call */
 	uint32_t max_ras_err_cnt_per_query;
+	/* number of umc channel instance with memory map register access */
+	uint32_t channel_inst_num;
+	/* number of umc instance with memory map register access */
+	uint32_t umc_inst_num;
+	/* UMC regiser per channel offset */
+	uint32_t channel_offs;
+	/* channel index table of interleaved memory */
+	const uint32_t *channel_idx_tbl;
+
 	const struct amdgpu_umc_funcs *funcs;
 };
 
drivers/gpu/drm/amd/amdgpu/umc_v6_1.h +2 -0
index d25ae414f4d8..bddaf14a77f9 100644
@@ -31,6 +31,8 @@
 #define UMC_V6_1_CHANNEL_INSTANCE_NUM		4
 /* number of umc instance with memory map register access */
 #define UMC_V6_1_UMC_INSTANCE_NUM		8
+/* total channel instances in one umc block */
+#define UMC_V6_1_TOTAL_CHANNEL_NUM	(UMC_V6_1_CHANNEL_INSTANCE_NUM * UMC_V6_1_UMC_INSTANCE_NUM)
 /* UMC regiser per channel offset */
 #define UMC_V6_1_PER_CHANNEL_OFFSET		0x800
 
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

#7 lore raw

Re: [PATCH 2/6] drm/amdgpu: add more parameters and functions to amdgpu_umc structure

Please include a patch description. Explain why you need the new interface.

Alex
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Tao Zhou <[email protected]>
Sent: Thursday, August 1, 2019 2:43 AM
To: [email protected] <[email protected]>; Zhang, Hawking <[email protected]>; Li, Dennis <[email protected]>; Chen, Guchun <[email protected]>; Pan, Xinhui <[email protected]>
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 2/6] drm/amdgpu: add more parameters and functions to amdgpu_umc structure

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h | 13 +++++++++++++
 drivers/gpu/drm/amd/amdgpu/umc_v6_1.h   |  2 ++
 2 files changed, 15 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +13 -0
index dfa1a39e57af..2604f5076867 100644
@@ -22,15 +22,28 @@
 #define __AMDGPU_UMC_H__
 
 struct amdgpu_umc_funcs {
+       void (*ras_init)(struct amdgpu_device *adev);
         void (*query_ras_error_count)(struct amdgpu_device *adev,
                                         void *ras_error_status);
         void (*query_ras_error_address)(struct amdgpu_device *adev,
                                         void *ras_error_status);
+       void (*enable_umc_index_mode)(struct amdgpu_device *adev,
+                                       uint32_t umc_instance);
+       void (*disable_umc_index_mode)(struct amdgpu_device *adev);
 };
 
 struct amdgpu_umc {
         /* max error count in one ras query call */
         uint32_t max_ras_err_cnt_per_query;
+       /* number of umc channel instance with memory map register access */
+       uint32_t channel_inst_num;
+       /* number of umc instance with memory map register access */
+       uint32_t umc_inst_num;
+       /* UMC regiser per channel offset */
+       uint32_t channel_offs;
+       /* channel index table of interleaved memory */
+       const uint32_t *channel_idx_tbl;
+
         const struct amdgpu_umc_funcs *funcs;
 };
 
drivers/gpu/drm/amd/amdgpu/umc_v6_1.h +2 -0
index d25ae414f4d8..bddaf14a77f9 100644
@@ -31,6 +31,8 @@
 #define UMC_V6_1_CHANNEL_INSTANCE_NUM           4
 /* number of umc instance with memory map register access */
 #define UMC_V6_1_UMC_INSTANCE_NUM               8
+/* total channel instances in one umc block */
+#define UMC_V6_1_TOTAL_CHANNEL_NUM     (UMC_V6_1_CHANNEL_INSTANCE_NUM * UMC_V6_1_UMC_INSTANCE_NUM)
 /* UMC regiser per channel offset */
 #define UMC_V6_1_PER_CHANNEL_OFFSET             0x800
 

--
2.17.1

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author
#8 lore raw

PATCH 3/6 drm/amdgpu: initialize new parameters and functions for amdgpu_umc structure

In reply to a message not in the archive
---
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c |  7 +++++--
 drivers/gpu/drm/amd/amdgpu/umc_v6_1.c | 10 +++++++++-
 drivers/gpu/drm/amd/amdgpu/umc_v6_1.h |  3 +++
 3 files changed, 17 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +5 -2
index ee06cbe2a7e7..3486b4ce7770 100644
@@ -631,8 +631,11 @@ static void gmc_v9_0_set_umc_funcs(struct amdgpu_device *adev)
 {
 	switch (adev->asic_type) {
 	case CHIP_VEGA20:
-		adev->umc.max_ras_err_cnt_per_query =
-			UMC_V6_1_UMC_INSTANCE_NUM * UMC_V6_1_CHANNEL_INSTANCE_NUM;
+		adev->umc.max_ras_err_cnt_per_query = UMC_V6_1_TOTAL_CHANNEL_NUM;
+		adev->umc.channel_inst_num = UMC_V6_1_CHANNEL_INSTANCE_NUM;
+		adev->umc.umc_inst_num = UMC_V6_1_UMC_INSTANCE_NUM;
+		adev->umc.channel_offs = UMC_V6_1_PER_CHANNEL_OFFSET;
+		adev->umc.channel_idx_tbl = &umc_v6_1_channel_idx_tbl[0][0];
 		adev->umc.funcs = &umc_v6_1_funcs;
 		break;
 	default:
drivers/gpu/drm/amd/amdgpu/umc_v6_1.c +9 -1
index 035e4fea472c..9ba015d7eb57 100644
@@ -41,7 +41,7 @@
 /* offset in 256B block */
 #define OFFSET_IN_256B_BLOCK(addr)		((addr) & 0xffULL)
 
-static uint32_t
+const uint32_t
 	umc_v6_1_channel_idx_tbl[UMC_V6_1_UMC_INSTANCE_NUM][UMC_V6_1_CHANNEL_INSTANCE_NUM] = {
 		{2, 18, 11, 27},	{4, 20, 13, 29},
 		{1, 17, 8, 24},		{7, 23, 14, 30},
@@ -235,7 +235,15 @@ static void umc_v6_1_query_ras_error_address(struct amdgpu_device *adev,
 	umc_v6_1_disable_umc_index_mode(adev);
 }
 
+static void umc_v6_1_ras_init(struct amdgpu_device *adev)
+{
+
+}
+
 const struct amdgpu_umc_funcs umc_v6_1_funcs = {
+	.ras_init = umc_v6_1_ras_init,
 	.query_ras_error_count = umc_v6_1_query_ras_error_count,
 	.query_ras_error_address = umc_v6_1_query_ras_error_address,
+	.enable_umc_index_mode = umc_v6_1_enable_umc_index_mode,
+	.disable_umc_index_mode = umc_v6_1_disable_umc_index_mode,
 };
drivers/gpu/drm/amd/amdgpu/umc_v6_1.h +3 -0
index bddaf14a77f9..ad4598c0e495 100644
@@ -24,6 +24,7 @@
 #define __UMC_V6_1_H__
 
 #include "soc15_common.h"
+#include "amdgpu.h"
 
 /* HBM  Memory Channel Width */
 #define UMC_V6_1_HBM_MEMORY_CHANNEL_WIDTH	128
@@ -37,5 +38,7 @@
 #define UMC_V6_1_PER_CHANNEL_OFFSET		0x800
 
 extern const struct amdgpu_umc_funcs umc_v6_1_funcs;
+extern const uint32_t
+	umc_v6_1_channel_idx_tbl[UMC_V6_1_UMC_INSTANCE_NUM][UMC_V6_1_CHANNEL_INSTANCE_NUM];
 
 #endif
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

#10 lore raw

Re: [PATCH 3/6] drm/amdgpu: initialize new parameters and functions for amdgpu_umc structure

Please include a patch description.

Alex
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Tao Zhou <[email protected]>
Sent: Thursday, August 1, 2019 2:43 AM
To: [email protected] <[email protected]>; Zhang, Hawking <[email protected]>; Li, Dennis <[email protected]>; Chen, Guchun <[email protected]>; Pan, Xinhui <[email protected]>
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 3/6] drm/amdgpu: initialize new parameters and functions for amdgpu_umc structure

---
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c |  7 +++++--
 drivers/gpu/drm/amd/amdgpu/umc_v6_1.c | 10 +++++++++-
 drivers/gpu/drm/amd/amdgpu/umc_v6_1.h |  3 +++
 3 files changed, 17 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +5 -2
index ee06cbe2a7e7..3486b4ce7770 100644
@@ -631,8 +631,11 @@ static void gmc_v9_0_set_umc_funcs(struct amdgpu_device *adev)
 {
         switch (adev->asic_type) {
         case CHIP_VEGA20:
-               adev->umc.max_ras_err_cnt_per_query =
-                       UMC_V6_1_UMC_INSTANCE_NUM * UMC_V6_1_CHANNEL_INSTANCE_NUM;
+               adev->umc.max_ras_err_cnt_per_query = UMC_V6_1_TOTAL_CHANNEL_NUM;
+               adev->umc.channel_inst_num = UMC_V6_1_CHANNEL_INSTANCE_NUM;
+               adev->umc.umc_inst_num = UMC_V6_1_UMC_INSTANCE_NUM;
+               adev->umc.channel_offs = UMC_V6_1_PER_CHANNEL_OFFSET;
+               adev->umc.channel_idx_tbl = &umc_v6_1_channel_idx_tbl[0][0];
                 adev->umc.funcs = &umc_v6_1_funcs;
                 break;
         default:
drivers/gpu/drm/amd/amdgpu/umc_v6_1.c +9 -1
index 035e4fea472c..9ba015d7eb57 100644
@@ -41,7 +41,7 @@
 /* offset in 256B block */
 #define OFFSET_IN_256B_BLOCK(addr)              ((addr) & 0xffULL)
 
-static uint32_t
+const uint32_t
         umc_v6_1_channel_idx_tbl[UMC_V6_1_UMC_INSTANCE_NUM][UMC_V6_1_CHANNEL_INSTANCE_NUM] = {
                 {2, 18, 11, 27},        {4, 20, 13, 29},
                 {1, 17, 8, 24},         {7, 23, 14, 30},
@@ -235,7 +235,15 @@ static void umc_v6_1_query_ras_error_address(struct amdgpu_device *adev,
         umc_v6_1_disable_umc_index_mode(adev);
 }
 
+static void umc_v6_1_ras_init(struct amdgpu_device *adev)
+{
+
+}
+
 const struct amdgpu_umc_funcs umc_v6_1_funcs = {
+       .ras_init = umc_v6_1_ras_init,
         .query_ras_error_count = umc_v6_1_query_ras_error_count,
         .query_ras_error_address = umc_v6_1_query_ras_error_address,
+       .enable_umc_index_mode = umc_v6_1_enable_umc_index_mode,
+       .disable_umc_index_mode = umc_v6_1_disable_umc_index_mode,
 };
drivers/gpu/drm/amd/amdgpu/umc_v6_1.h +3 -0
index bddaf14a77f9..ad4598c0e495 100644
@@ -24,6 +24,7 @@
 #define __UMC_V6_1_H__
 
 #include "soc15_common.h"
+#include "amdgpu.h"
 
 /* HBM  Memory Channel Width */
 #define UMC_V6_1_HBM_MEMORY_CHANNEL_WIDTH       128
@@ -37,5 +38,7 @@
 #define UMC_V6_1_PER_CHANNEL_OFFSET             0x800
 
 extern const struct amdgpu_umc_funcs umc_v6_1_funcs;
+extern const uint32_t
+       umc_v6_1_channel_idx_tbl[UMC_V6_1_UMC_INSTANCE_NUM][UMC_V6_1_CHANNEL_INSTANCE_NUM];
 
 #endif

--
2.17.1

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author
#11 lore raw

PATCH 4/6 drm/amdgpu: add macro of umc for each channel

In reply to a message not in the archive

common function for all umc versions

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +23 -0
index 2604f5076867..9efdd66279e5 100644
@@ -21,6 +21,29 @@
 #ifndef __AMDGPU_UMC_H__
 #define __AMDGPU_UMC_H__
 
+/*
+ * void (*func)(struct amdgpu_device *adev, struct ras_err_data *err_data,
+ *				uint32_t umc_reg_offset, uint32_t channel_index)
+ */
+#define amdgpu_umc_for_each_channel(func)	\
+	struct ras_err_data *err_data = (struct ras_err_data *)ras_error_status;	\
+	uint32_t umc_inst, channel_inst, umc_reg_offset, channel_index;	\
+	for (umc_inst = 0; umc_inst < adev->umc.umc_inst_num; umc_inst++) {	\
+		/* enable the index mode to query eror count per channel */	\
+		adev->umc.funcs->enable_umc_index_mode(adev, umc_inst);	\
+		for (channel_inst = 0;	\
+			channel_inst < adev->umc.channel_inst_num;	\
+			channel_inst++) {	\
+			/* calc the register offset according to channel instance */	\
+			umc_reg_offset = adev->umc.channel_offs * channel_inst;	\
+			/* get channel index of interleaved memory */	\
+			channel_index = adev->umc.channel_idx_tbl[	\
+				umc_inst * adev->umc.channel_inst_num + channel_inst];	\
+			(func)(adev, err_data, umc_reg_offset, channel_index);	\
+		}	\
+	}	\
+	adev->umc.funcs->disable_umc_index_mode(adev);
+
 struct amdgpu_umc_funcs {
 	void (*ras_init)(struct amdgpu_device *adev);
 	void (*query_ras_error_count)(struct amdgpu_device *adev,
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

#13 lore raw

Re: [PATCH 4/6] drm/amdgpu: add macro of umc for each channel

Please include a patch description. Explain why you need the new helper function.

Alex
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Tao Zhou <[email protected]>
Sent: Thursday, August 1, 2019 2:43 AM
To: [email protected] <[email protected]>; Zhang, Hawking <[email protected]>; Li, Dennis <[email protected]>; Chen, Guchun <[email protected]>; Pan, Xinhui <[email protected]>
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 4/6] drm/amdgpu: add macro of umc for each channel

common function for all umc versions

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +23 -0
index 2604f5076867..9efdd66279e5 100644
@@ -21,6 +21,29 @@
 #ifndef __AMDGPU_UMC_H__
 #define __AMDGPU_UMC_H__
 
+/*
+ * void (*func)(struct amdgpu_device *adev, struct ras_err_data *err_data,
+ *                             uint32_t umc_reg_offset, uint32_t channel_index)
+ */
+#define amdgpu_umc_for_each_channel(func)      \
+       struct ras_err_data *err_data = (struct ras_err_data *)ras_error_status;        \
+       uint32_t umc_inst, channel_inst, umc_reg_offset, channel_index; \
+       for (umc_inst = 0; umc_inst < adev->umc.umc_inst_num; umc_inst++) {     \
+               /* enable the index mode to query eror count per channel */     \
+               adev->umc.funcs->enable_umc_index_mode(adev, umc_inst); \
+               for (channel_inst = 0;  \
+                       channel_inst < adev->umc.channel_inst_num;      \
+                       channel_inst++) {       \
+                       /* calc the register offset according to channel instance */    \
+                       umc_reg_offset = adev->umc.channel_offs * channel_inst; \
+                       /* get channel index of interleaved memory */   \
+                       channel_index = adev->umc.channel_idx_tbl[      \
+                               umc_inst * adev->umc.channel_inst_num + channel_inst];  \
+                       (func)(adev, err_data, umc_reg_offset, channel_index);  \
+               }       \
+       }       \
+       adev->umc.funcs->disable_umc_index_mode(adev);
+
 struct amdgpu_umc_funcs {
         void (*ras_init)(struct amdgpu_device *adev);
         void (*query_ras_error_count)(struct amdgpu_device *adev,

--
2.17.1

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author
#14 lore raw

PATCH 5/6 drm/amdgpu: apply umc_for_each_channel macro to umc_6_1

In reply to a message not in the archive

use umc_for_each_channel to make code simpler

---
 drivers/gpu/drm/amd/amdgpu/umc_v6_1.c | 84 +++++++++------------------
 1 file changed, 28 insertions(+), 56 deletions(-)
drivers/gpu/drm/amd/amdgpu/umc_v6_1.c +28 -56
index 9ba015d7eb57..5747a0252624 100644
@@ -142,46 +142,39 @@ static void umc_v6_1_querry_uncorrectable_error_count(struct amdgpu_device *adev
 		*error_count += 1;
 }
 
+static void umc_v6_1_query_error_count(struct amdgpu_device *adev,
+					   struct ras_err_data *err_data, uint32_t umc_reg_offset,
+					   uint32_t channel_index)
+{
+	umc_v6_1_query_correctable_error_count(adev, umc_reg_offset,
+						   &(err_data->ce_count));
+	umc_v6_1_querry_uncorrectable_error_count(adev, umc_reg_offset,
+						  &(err_data->ue_count));
+}
+
 static void umc_v6_1_query_ras_error_count(struct amdgpu_device *adev,
 					   void *ras_error_status)
 {
-	struct ras_err_data *err_data = (struct ras_err_data *)ras_error_status;
-	uint32_t umc_inst, channel_inst, umc_reg_offset, mc_umc_status_addr;
-
-	mc_umc_status_addr =
-		SOC15_REG_OFFSET(UMC, 0, mmMCA_UMC_UMC0_MCUMC_STATUST0);
-
-	for (umc_inst = 0; umc_inst < UMC_V6_1_UMC_INSTANCE_NUM; umc_inst++) {
-		/* enable the index mode to query eror count per channel */
-		umc_v6_1_enable_umc_index_mode(adev, umc_inst);
-		for (channel_inst = 0; channel_inst < UMC_V6_1_CHANNEL_INSTANCE_NUM; channel_inst++) {
-			/* calc the register offset according to channel instance */
-			umc_reg_offset = UMC_V6_1_PER_CHANNEL_OFFSET * channel_inst;
-			umc_v6_1_query_correctable_error_count(adev, umc_reg_offset,
-							       &(err_data->ce_count));
-			umc_v6_1_querry_uncorrectable_error_count(adev, umc_reg_offset,
-								  &(err_data->ue_count));
-			/* clear umc status */
-			WREG64(mc_umc_status_addr + umc_reg_offset, 0x0ULL);
-		}
-	}
-	umc_v6_1_disable_umc_index_mode(adev);
+	amdgpu_umc_for_each_channel(umc_v6_1_query_error_count);
 }
 
 static void umc_v6_1_query_error_address(struct amdgpu_device *adev,
-					 uint32_t umc_reg_offset, uint32_t channel_index,
-					 struct ras_err_data *err_data)
+					 struct ras_err_data *err_data,
+					 uint32_t umc_reg_offset, uint32_t channel_index)
 {
-	uint32_t lsb;
+	uint32_t lsb, mc_umc_status_addr;
 	uint64_t mc_umc_status, err_addr;
-	uint32_t mc_umc_status_addr;
+
+	mc_umc_status_addr =
+		SOC15_REG_OFFSET(UMC, 0, mmMCA_UMC_UMC0_MCUMC_STATUST0);
 
 	/* skip error address process if -ENOMEM */
-	if (!err_data->err_addr)
+	if (!err_data->err_addr) {
+		/* clear umc status */
+		WREG64(mc_umc_status_addr + umc_reg_offset, 0x0ULL);
 		return;
+	}
 
-	mc_umc_status_addr =
-		SOC15_REG_OFFSET(UMC, 0, mmMCA_UMC_UMC0_MCUMC_STATUST0);
 	mc_umc_status = RREG64(mc_umc_status_addr + umc_reg_offset);
 
 	/* calculate error address if ue/ce error is detected */
@@ -197,42 +190,21 @@ static void umc_v6_1_query_error_address(struct amdgpu_device *adev,
 
 		/* translate umc channel address to soc pa, 3 parts are included */
 		err_data->err_addr[err_data->err_addr_cnt] =
-						ADDR_OF_8KB_BLOCK(err_addr)
-						| ADDR_OF_256B_BLOCK(channel_index)
-						| OFFSET_IN_256B_BLOCK(err_addr);
+						ADDR_OF_8KB_BLOCK(err_addr) |
+						ADDR_OF_256B_BLOCK(channel_index) |
+						OFFSET_IN_256B_BLOCK(err_addr);
 
 		err_data->err_addr_cnt++;
 	}
+
+	/* clear umc status */
+	WREG64(mc_umc_status_addr + umc_reg_offset, 0x0ULL);
 }
 
 static void umc_v6_1_query_ras_error_address(struct amdgpu_device *adev,
 					     void *ras_error_status)
 {
-	struct ras_err_data *err_data = (struct ras_err_data *)ras_error_status;
-	uint32_t umc_inst, channel_inst, umc_reg_offset;
-	uint32_t channel_index, mc_umc_status_addr;
-
-	mc_umc_status_addr =
-		SOC15_REG_OFFSET(UMC, 0, mmMCA_UMC_UMC0_MCUMC_STATUST0);
-
-	for (umc_inst = 0; umc_inst < UMC_V6_1_UMC_INSTANCE_NUM; umc_inst++) {
-		/* enable the index mode to query eror count per channel */
-		umc_v6_1_enable_umc_index_mode(adev, umc_inst);
-		for (channel_inst = 0; channel_inst < UMC_V6_1_CHANNEL_INSTANCE_NUM; channel_inst++) {
-			/* calc the register offset according to channel instance */
-			umc_reg_offset = UMC_V6_1_PER_CHANNEL_OFFSET * channel_inst;
-			/* get channel index of interleaved memory */
-			channel_index = umc_v6_1_channel_idx_tbl[umc_inst][channel_inst];
-
-			umc_v6_1_query_error_address(adev, umc_reg_offset,
-						     channel_index, err_data);
-
-			/* clear umc status */
-			WREG64(mc_umc_status_addr + umc_reg_offset, 0x0ULL);
-		}
-	}
-
-	umc_v6_1_disable_umc_index_mode(adev);
+	amdgpu_umc_for_each_channel(umc_v6_1_query_error_address);
 }
 
 static void umc_v6_1_ras_init(struct amdgpu_device *adev)
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#15 lore raw

PATCH 6/6 drm/amdgpu: add error address query for umc ras

In reply to a message not in the archive

umc error address query can get ce/ue error address and clear error status

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 5 +++++
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   | 5 +++++
 2 files changed, 10 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +5 -0
index a96b0f17c619..094c27000b83 100644
@@ -599,6 +599,11 @@ int amdgpu_ras_error_query(struct amdgpu_device *adev,
 	case AMDGPU_RAS_BLOCK__UMC:
 		if (adev->umc.funcs->query_ras_error_count)
 			adev->umc.funcs->query_ras_error_count(adev, &err_data);
+		/* umc query_ras_error_address is also responsible for clearing
+		 * error status
+		 */
+		if (adev->umc.funcs->query_ras_error_address)
+			adev->umc.funcs->query_ras_error_address(adev, &err_data);
 		break;
 	case AMDGPU_RAS_BLOCK__GFX:
 		if (adev->gfx.funcs->query_ras_error_count)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +5 -0
index 3486b4ce7770..05cbd90d9b6c 100644
@@ -245,6 +245,11 @@ static int gmc_v9_0_process_ras_data_cb(struct amdgpu_device *adev,
 	kgd2kfd_set_sram_ecc_flag(adev->kfd.dev);
 	if (adev->umc.funcs->query_ras_error_count)
 		adev->umc.funcs->query_ras_error_count(adev, err_data);
+	/* umc query_ras_error_address is also responsible for clearing
+	 * error status
+	 */
+	if (adev->umc.funcs->query_ras_error_address)
+		adev->umc.funcs->query_ras_error_address(adev, err_data);
 	amdgpu_ras_reset_gpu(adev, 0);
 	return AMDGPU_RAS_UE;
 }
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by Hawking Zhang
#16 lore raw
In reply to a message not in the archive

Please add one line description for patch #2 & 3. Other than that, the series is

Regards,
Hawking
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Tao Zhou
Sent: 2019年8月1日 14:43
To: [email protected]; Zhang, Hawking <[email protected]>; Li, Dennis <[email protected]>; Chen, Guchun <[email protected]>; Pan, Xinhui <[email protected]>
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 0/6] umc ras code refinement

The series refines umc ras code, no functional change.

Tao Zhou (6):
drm/amdgpu: remove the clear of MCA_ADDR
drm/amdgpu: add more parameters and functions to amdgpu_umc structure drm/amdgpu: initialize new parameters and functions for amdgpu_umc
structure
drm/amdgpu: add macro of umc for each channel
drm/amdgpu: apply umc_for_each_channel macro to umc_6_1 drm/amdgpu: add error address query for umc ras

 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c |  5 ++  drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h | 36 ++++++++++
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   | 12 +++-
 drivers/gpu/drm/amd/amdgpu/umc_v6_1.c   | 92 ++++++++++---------------
 drivers/gpu/drm/amd/amdgpu/umc_v6_1.h   |  5 ++
 5 files changed, 91 insertions(+), 59 deletions(-)

--
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx