Skip to contentSkip to conversation

drm/amdgpu: Update smu driver interface for aldebaran

PATCH In review Stanley.Yang 2 participants 14 messages Nov 17, 2021 – Nov 18, 2021

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

PATCH 1/4 drm/amdgpu: Update smu driver interface for aldebaran

update smu driver if version to 0x08 to avoid mismatch log A version mismatch can still happen with an older FW

Change-Id I97f2bc4ed9a9cba313b744e2ff6812c90b244935
---
 .../drm/amd/pm/inc/smu13_driver_if_aldebaran.h | 18 +++++++++++++++++-
 drivers/gpu/drm/amd/pm/inc/smu_v13_0.h         |  2 +-
 2 files changed, 18 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/inc/smu13_driver_if_aldebaran.h +17 -1
index a017983ff1fa..0f67c56c2863 100644
@@ -140,6 +140,8 @@
 
 #define MAX_SW_I2C_COMMANDS                24
 
+#define ALDEBARAN_UMC_CHANNEL_NUM    32
+
 typedef enum {
   I2C_CONTROLLER_PORT_0, //CKSVII2C0
   I2C_CONTROLLER_PORT_1, //CKSVII2C1
@@ -507,6 +509,19 @@ typedef struct {
   uint32_t MmHubPadding[8]; // SMU internal use
 } AvfsDebugTable_t;
 
+typedef struct {
+	uint64_t mca_umc_status;
+	uint64_t mca_umc_addr;
+	uint16_t ce_count_lo_chip;
+	uint16_t ce_count_hi_chip;
+
+	uint32_t eccPadding;
+} EccInfo_t;
+
+typedef struct {
+	EccInfo_t  EccInfo[ALDEBARAN_UMC_CHANNEL_NUM];
+} EccInfoTable_t;
+
 // These defines are used with the following messages:
 // SMC_MSG_TransferTableDram2Smu
 // SMC_MSG_TransferTableSmu2Dram
@@ -517,6 +532,7 @@ typedef struct {
 #define TABLE_SMU_METRICS             4
 #define TABLE_DRIVER_SMU_CONFIG       5
 #define TABLE_I2C_COMMANDS            6
-#define TABLE_COUNT                   7
+#define TABLE_ECCINFO                 7
+#define TABLE_COUNT                   8
 
 #endif
drivers/gpu/drm/amd/pm/inc/smu_v13_0.h +1 -1
index bbc608c990b0..44af23ae059e 100644
@@ -27,7 +27,7 @@
 
 #define SMU13_DRIVER_IF_VERSION_INV 0xFFFFFFFF
 #define SMU13_DRIVER_IF_VERSION_YELLOW_CARP 0x04
-#define SMU13_DRIVER_IF_VERSION_ALDE 0x07
+#define SMU13_DRIVER_IF_VERSION_ALDE 0x08
 
 #define SMU13_MODE1_RESET_WAIT_TIME_IN_MS 500  //500ms
 
Signature · 1 line
2.17.1
#1 lore raw

PATCH 2/4 drm/amdgpu: add new query interface for umc block

add message smu to query error information

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h |  16 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h |   4 +
 drivers/gpu/drm/amd/amdgpu/umc_v6_7.c   | 161 ++++++++++++++++++++++++
 3 files changed, 181 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +16 -0
index cdd0010a5389..bcbf3264d92f 100644
@@ -320,6 +320,19 @@ struct ras_common_if {
 	char name[32];
 };
 
+#define MAX_UMC_CHANNEL_NUM 32
+
+struct ecc_info_per_ch {
+	uint16_t ce_count_lo_chip;
+	uint16_t ce_count_hi_chip;
+	uint64_t mca_umc_status;
+	uint64_t mca_umc_addr;
+};
+
+struct umc_ecc_info {
+	struct ecc_info_per_ch ecc[MAX_UMC_CHANNEL_NUM];
+};
+
 struct amdgpu_ras {
 	/* ras infrastructure */
 	/* for ras itself. */
@@ -359,6 +372,9 @@ struct amdgpu_ras {
 	struct delayed_work ras_counte_delay_work;
 	atomic_t ras_ue_count;
 	atomic_t ras_ce_count;
+
+	/* record umc error info queried from smu */
+	struct umc_ecc_info umc_ecc;
 };
 
 struct ras_fs_data {
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +4 -0
index 1f5fe2315236..7aa9b21eb906 100644
@@ -49,6 +49,10 @@ struct amdgpu_umc_ras_funcs {
 	void (*query_ras_error_address)(struct amdgpu_device *adev,
 					void *ras_error_status);
 	bool (*query_ras_poison_mode)(struct amdgpu_device *adev);
+	void (*message_smu_query_ras_error_count)(struct amdgpu_device *adev,
+				      void *ras_error_status);
+	void (*message_smu_query_ras_error_address)(struct amdgpu_device *adev,
+					void *ras_error_status);
 };
 
 struct amdgpu_umc_funcs {
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +161 -0

171 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH Review 2/4] drm/amdgpu: add new query interface for umc block

Quoted 48 lines · Stanley.Yang

add message smu to query error information

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h |  16 +++
  drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h |   4 +
  drivers/gpu/drm/amd/amdgpu/umc_v6_7.c   | 161 ++++++++++++++++++++++++
  3 files changed, 181 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +16 -0
index cdd0010a5389..bcbf3264d92f 100644
@@ -320,6 +320,19 @@ struct ras_common_if {
  	char name[32];
  };
 
+#define MAX_UMC_CHANNEL_NUM 32
+
+struct ecc_info_per_ch {
+	uint16_t ce_count_lo_chip;
+	uint16_t ce_count_hi_chip;
+	uint64_t mca_umc_status;
+	uint64_t mca_umc_addr;
+};
+
+struct umc_ecc_info {
+	struct ecc_info_per_ch ecc[MAX_UMC_CHANNEL_NUM];
+};
+
  struct amdgpu_ras {
  	/* ras infrastructure */
  	/* for ras itself. */
@@ -359,6 +372,9 @@ struct amdgpu_ras {
  	struct delayed_work ras_counte_delay_work;
  	atomic_t ras_ue_count;
  	atomic_t ras_ce_count;
+
+	/* record umc error info queried from smu */
+	struct umc_ecc_info umc_ecc;
  };
 
  struct ras_fs_data {
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +0 -0
index 1f5fe2315236..7aa9b21eb906 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h struct amdgpu_umc_ras_funcs { · line 55

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +4 -0
@@ -49,6 +49,10 @@ struct amdgpu_umc_ras_funcs {
  	void (*query_ras_error_address)(struct amdgpu_device *adev,
  					void *ras_error_status);
  	bool (*query_ras_poison_mode)(struct amdgpu_device *adev);
+	void (*message_smu_query_ras_error_count)(struct amdgpu_device *adev,
+				      void *ras_error_status);
+	void (*message_smu_query_ras_error_address)(struct amdgpu_device *adev,
+					void *ras_error_status);

Maybe rename message_smu to ecc_info. These methods fetch the error from umc_ecc_info table. They don't deal with smu or care about how the information gets filled. As long as ecc_info_table is filled, they could get the info.

Thanks,
Lijo

Quoted 181 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +0 -0
  };
 
  struct amdgpu_umc_funcs {
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +161 -0
index f7ec3fe134e5..cd96e8b734cb 100644
@@ -50,6 +50,165 @@ static inline uint32_t get_umc_v6_7_reg_offset(struct amdgpu_device *adev,
  	return adev->umc.channel_offs * ch_inst + UMC_V6_7_INST_DIST * umc_inst;
  }
 
+static inline uint32_t get_umc_v6_7_channel_index(struct amdgpu_device *adev,
+					      uint32_t umc_inst,
+					      uint32_t ch_inst)
+{
+	return adev->umc.channel_idx_tbl[umc_inst * adev->umc.channel_inst_num + ch_inst];
+}
+
+static void umc_v6_7_message_smu_query_correctable_error_count(struct amdgpu_device *adev,
+						   uint32_t channel_index,
+						   unsigned long *error_count)
+{
+	uint32_t ecc_err_cnt;
+	uint64_t mc_umc_status;
+	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
+
+	/*
+	 * select the lower chip and check the error count
+	 * skip add error count, calc error counter only from mca_umc_status
+	 */
+	ecc_err_cnt = ras->umc_ecc.ecc[channel_index].ce_count_lo_chip;
+
+	/*
+	 * select the higher chip and check the err counter
+	 * skip add error count, calc error counter only from mca_umc_status
+	 */
+	ecc_err_cnt = ras->umc_ecc.ecc[channel_index].ce_count_hi_chip;
+
+	/* check for SRAM correctable error
+	  MCUMC_STATUS is a 64 bit register */
+	mc_umc_status = ras->umc_ecc.ecc[channel_index].mca_umc_status;
+	if (REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, Val) == 1 &&
+	    REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, CECC) == 1)
+		*error_count += 1;
+}
+
+static void umc_v6_7_message_smu_querry_uncorrectable_error_count(struct amdgpu_device *adev,
+						      uint32_t channel_index,
+						      unsigned long *error_count)
+{
+	uint64_t mc_umc_status;
+	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
+
+	/* check the MCUMC_STATUS */
+	mc_umc_status = ras->umc_ecc.ecc[channel_index].mca_umc_status;
+	if ((REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, Val) == 1) &&
+	    (REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, Deferred) == 1 ||
+	    REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, UECC) == 1 ||
+	    REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, PCC) == 1 ||
+	    REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, UC) == 1 ||
+	    REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, TCC) == 1))
+		*error_count += 1;
+}
+
+static void umc_v6_7_message_smu_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        = 0;
+	uint32_t ch_inst         = 0;
+	uint32_t umc_reg_offset  = 0;
+	uint32_t channel_index	 = 0;
+
+	/*TODO: driver needs to toggle DF Cstate to ensure
+	 * safe access of UMC registers. Will add the protection */
+	LOOP_UMC_INST_AND_CH(umc_inst, ch_inst) {
+		umc_reg_offset = get_umc_v6_7_reg_offset(adev,
+							 umc_inst,
+							 ch_inst);
+		channel_index = get_umc_v6_7_channel_index(adev,
+							 umc_inst,
+							 ch_inst);
+		umc_v6_7_message_smu_query_correctable_error_count(adev,
+						      channel_index,
+						      &(err_data->ce_count));
+		umc_v6_7_message_smu_querry_uncorrectable_error_count(adev,
+							  channel_index,
+							  &(err_data->ue_count));
+	}
+}
+
+static void umc_v6_7_message_smu_query_error_address(struct amdgpu_device *adev,
+					 struct ras_err_data *err_data,
+					 uint32_t umc_reg_offset,
+					 uint32_t ch_inst,
+					 uint32_t umc_inst)
+{
+	uint64_t mc_umc_status, err_addr, retired_page;
+	struct eeprom_table_record *err_rec;
+	uint32_t channel_index;
+	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
+
+	channel_index =
+		adev->umc.channel_idx_tbl[umc_inst * adev->umc.channel_inst_num + ch_inst];
+
+	mc_umc_status = ras->umc_ecc.ecc[channel_index].mca_umc_status;
+
+	if (mc_umc_status == 0)
+		return;
+
+	if (!err_data->err_addr)
+		return;
+
+	err_rec = &err_data->err_addr[err_data->err_addr_cnt];
+
+	/* calculate error address if ue/ce error is detected */
+	if (REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, Val) == 1 &&
+	    (REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, UECC) == 1 ||
+	    REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, CECC) == 1)) {
+
+		err_addr = ras->umc_ecc.ecc[channel_index].mca_umc_addr;
+		err_addr = REG_GET_FIELD(err_addr, MCA_UMC_UMC0_MCUMC_ADDRT0, ErrorAddr);
+
+		/* translate umc channel address to soc pa, 3 parts are included */
+		retired_page = ADDR_OF_8KB_BLOCK(err_addr) |
+				ADDR_OF_256B_BLOCK(channel_index) |
+				OFFSET_IN_256B_BLOCK(err_addr);
+
+		/* we only save ue error information currently, ce is skipped */
+		if (REG_GET_FIELD(mc_umc_status, MCA_UMC_UMC0_MCUMC_STATUST0, UECC)
+				== 1) {
+			err_rec->address = err_addr;
+			/* page frame address is saved */
+			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_cnt++;
+		}
+	}
+}
+
+static void umc_v6_7_message_smu_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        = 0;
+	uint32_t ch_inst         = 0;
+	uint32_t umc_reg_offset  = 0;
+
+	/*TODO: driver needs to toggle DF Cstate to ensure
+	 * safe access of UMC resgisters. Will add the protection
+	 * when firmware interface is ready */
+	LOOP_UMC_INST_AND_CH(umc_inst, ch_inst) {
+		umc_reg_offset = get_umc_v6_7_reg_offset(adev,
+							 umc_inst,
+							 ch_inst);
+		umc_v6_7_message_smu_query_error_address(adev,
+					     err_data,
+					     umc_reg_offset,
+					     ch_inst,
+					     umc_inst);
+	}
+}
+
  static void umc_v6_7_query_correctable_error_count(struct amdgpu_device *adev,
  						   uint32_t umc_reg_offset,
  						   unsigned long *error_count)
@@ -327,4 +486,6 @@ const struct amdgpu_umc_ras_funcs umc_v6_7_ras_funcs = {
  	.query_ras_error_count = umc_v6_7_query_ras_error_count,
  	.query_ras_error_address = umc_v6_7_query_ras_error_address,
  	.query_ras_poison_mode = umc_v6_7_query_ras_poison_mode,
+	.message_smu_query_ras_error_count = umc_v6_7_message_smu_query_ras_error_count,
+	.message_smu_query_ras_error_address = umc_v6_7_message_smu_query_ras_error_address,
  };
#3 lore raw

回复: [PATCH Review 2/4] drm/amdgpu: add new query interface for umc block

[AMD Official Use Only]

Quoted 71 lines

-----邮件原件-----
发件人: Lazar, Lijo <[email protected]>
发送时间: Wednesday, November 17, 2021 7:36 PM
收件人: Yang, Stanley <[email protected]>; amd- [email protected]; Zhang, Hawking <[email protected]>; Clements, John <[email protected]>; Quan, Evan <[email protected]>; Wang, Yang(Kevin) <[email protected]> 主题: Re: [PATCH Review 2/4] drm/amdgpu: add new query interface for umc block

Quoted 7 lines · Stanley.Yang

add message smu to query error information

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h |  16 +++
  drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h |   4 +
  drivers/gpu/drm/amd/amdgpu/umc_v6_7.c   | 161

++++++++++++++++++++++++

Quoted 42 lines
  3 files changed, 181 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +15 -0
index cdd0010a5389..bcbf3264d92f 100644
@@ -320,6 +320,19 @@ struct ras_common_if {
  	char name[32];
  };
 
+#define MAX_UMC_CHANNEL_NUM 32
+
+struct ecc_info_per_ch {
+	uint16_t ce_count_lo_chip;
+	uint16_t ce_count_hi_chip;
+	uint64_t mca_umc_status;
+	uint64_t mca_umc_addr;
+};
+
+struct umc_ecc_info {
+	struct ecc_info_per_ch ecc[MAX_UMC_CHANNEL_NUM]; };
+
  struct amdgpu_ras {
  	/* ras infrastructure */
  	/* for ras itself. */
@@ -359,6 +372,9 @@ struct amdgpu_ras {
  	struct delayed_work ras_counte_delay_work;
  	atomic_t ras_ue_count;
  	atomic_t ras_ce_count;
+
+	/* record umc error info queried from smu */
+	struct umc_ecc_info umc_ecc;
  };
 
  struct ras_fs_data {
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +0 -0
index 1f5fe2315236..7aa9b21eb906 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h struct amdgpu_umc_ras_funcs { · line 52

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +1 -0
@@ -49,6 +49,10 @@ struct amdgpu_umc_ras_funcs {
  	void (*query_ras_error_address)(struct amdgpu_device *adev,
  					void *ras_error_status);
  	bool (*query_ras_poison_mode)(struct amdgpu_device *adev);
+	void (*message_smu_query_ras_error_count)(struct

amdgpu_device *adev,

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h struct amdgpu_umc_ras_funcs { · line 54

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +2 -0
+				      void *ras_error_status);
+	void (*message_smu_query_ras_error_address)(struct

amdgpu_device *adev,

Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h struct amdgpu_umc_ras_funcs { · line 55

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +1 -0
+					void *ras_error_status);

Maybe rename message_smu to ecc_info. These methods fetch the error from umc_ecc_info table. They don't deal with smu or care about how the information gets filled. As long as ecc_info_table is filled, they could get the info.

[Yang, Stanley] yeah, it seems rename message_smu to ecc_info is better since ecc_table has been update before this call.

Quoted 230 lines

Thanks,
Lijo

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c static inline uint32_t

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +0 -0
  };
 
  struct amdgpu_umc_funcs {
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +0 -0
index f7ec3fe134e5..cd96e8b734cb 100644
@@ -50,6 +50,165 @@ static inline uint32_t

get_umc_v6_7_reg_offset(struct amdgpu_device *adev,

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c static inline uint32_t · line 50

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +0 -0
  	return adev->umc.channel_offs * ch_inst + UMC_V6_7_INST_DIST *

umc_inst;

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c static inline uint32_t · line 53

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +1 -0
  }
 
+static inline uint32_t get_umc_v6_7_channel_index(struct

amdgpu_device *adev,

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c static inline uint32_t get_umc_v6_7_reg_offset(struct amdgpu_device *adev,

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +7 -0
+					      uint32_t umc_inst,
+					      uint32_t ch_inst)
+{
+	return adev->umc.channel_idx_tbl[umc_inst *
+adev->umc.channel_inst_num + ch_inst]; }
+
+static void

umc_v6_7_message_smu_query_correctable_error_count(struct amdgpu_device *adev,

Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +14 -0
+						   uint32_t channel_index,
+						   unsigned long *error_count)
+{
+	uint32_t ecc_err_cnt;
+	uint64_t mc_umc_status;
+	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
+
+	/*
+	 * select the lower chip and check the error count
+	 * skip add error count, calc error counter only from mca_umc_status
+	 */
+	ecc_err_cnt = ras->umc_ecc.ecc[channel_index].ce_count_lo_chip;
+
+	/*

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c static inline uint32_t get_umc_v6_7_reg_offset(struct amdgpu_device *adev,

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +9 -0
+	 * select the higher chip and check the err counter
+	 * skip add error count, calc error counter only from mca_umc_status
+	 */
+	ecc_err_cnt = ras->umc_ecc.ecc[channel_index].ce_count_hi_chip;
+
+	/* check for SRAM correctable error
+	  MCUMC_STATUS is a 64 bit register */
+	mc_umc_status = ras-
 umc_ecc.ecc[channel_index].mca_umc_status;
+	if (REG_GET_FIELD(mc_umc_status,

MCA_UMC_UMC0_MCUMC_STATUST0, Val) == 1 &&

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c static inline uint32_t · line 85

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +1 -0
+	    REG_GET_FIELD(mc_umc_status,

MCA_UMC_UMC0_MCUMC_STATUST0, CECC) == 1)

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c static inline uint32_t get_umc_v6_7_reg_offset(struct amdgpu_device *adev,

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +4 -0
+		*error_count += 1;
+}
+
+static void

umc_v6_7_message_smu_querry_uncorrectable_error_count(struct amdgpu_device *adev,

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c static inline uint32_t · line 91

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +2 -0
+						      uint32_t channel_index,
+						      unsigned long

*error_count) {

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c static inline uint32_t get_umc_v6_7_reg_offset(struct amdgpu_device *adev,

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +6 -0
+	uint64_t mc_umc_status;
+	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
+
+	/* check the MCUMC_STATUS */
+	mc_umc_status = ras-
 umc_ecc.ecc[channel_index].mca_umc_status;
+	if ((REG_GET_FIELD(mc_umc_status,

MCA_UMC_UMC0_MCUMC_STATUST0, Val) == 1) &&

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c static inline uint32_t · line 99

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +1 -0
+	    (REG_GET_FIELD(mc_umc_status,

MCA_UMC_UMC0_MCUMC_STATUST0, Deferred) == 1 ||

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c static inline uint32_t · line 100

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +1 -0
+	    REG_GET_FIELD(mc_umc_status,

MCA_UMC_UMC0_MCUMC_STATUST0, UECC) == 1 ||

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c static inline uint32_t · line 101

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +1 -0
+	    REG_GET_FIELD(mc_umc_status,

MCA_UMC_UMC0_MCUMC_STATUST0, PCC) == 1 ||

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c static inline uint32_t · line 102

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +1 -0
+	    REG_GET_FIELD(mc_umc_status,

MCA_UMC_UMC0_MCUMC_STATUST0, UC) == 1 ||

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c static inline uint32_t · line 103

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +1 -0
+	    REG_GET_FIELD(mc_umc_status,

MCA_UMC_UMC0_MCUMC_STATUST0, TCC) == 1))

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c static inline uint32_t get_umc_v6_7_reg_offset(struct amdgpu_device *adev,

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +4 -0
+		*error_count += 1;
+}
+
+static void umc_v6_7_message_smu_query_ras_error_count(struct

amdgpu_device *adev,

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +10 -0
+					   void *ras_error_status)
+{
+	struct ras_err_data *err_data = (struct ras_err_data
+*)ras_error_status;
+
+	uint32_t umc_inst        = 0;
+	uint32_t ch_inst         = 0;
+	uint32_t umc_reg_offset  = 0;
+	uint32_t channel_index	 = 0;
+

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c static inline uint32_t get_umc_v6_7_reg_offset(struct amdgpu_device *adev, · line 133

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +10 -0
+	/*TODO: driver needs to toggle DF Cstate to ensure
+	 * safe access of UMC registers. Will add the protection */
+	LOOP_UMC_INST_AND_CH(umc_inst, ch_inst) {
+		umc_reg_offset = get_umc_v6_7_reg_offset(adev,
+							 umc_inst,
+							 ch_inst);
+		channel_index = get_umc_v6_7_channel_index(adev,
+							 umc_inst,
+							 ch_inst);
+

umc_v6_7_message_smu_query_correctable_error_count(adev,

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c static inline uint32_t get_umc_v6_7_reg_offset(struct amdgpu_device *adev, · line 133

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +3 -0
+						      channel_index,
+						      &(err_data->ce_count));
+

umc_v6_7_message_smu_querry_uncorrectable_error_count(adev,

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c static inline uint32_t get_umc_v6_7_reg_offset(struct amdgpu_device *adev,

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +6 -0
+							  channel_index,
+							  &(err_data-
 ue_count));
+	}
+}
+
+static void umc_v6_7_message_smu_query_error_address(struct

amdgpu_device *adev,

Quoted 18 lines
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +12 -0
+					 struct ras_err_data *err_data,
+					 uint32_t umc_reg_offset,
+					 uint32_t ch_inst,
+					 uint32_t umc_inst)
+{
+	uint64_t mc_umc_status, err_addr, retired_page;
+	struct eeprom_table_record *err_rec;
+	uint32_t channel_index;
+	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
+
+	channel_index =
+		adev->umc.channel_idx_tbl[umc_inst * adev-

umc.channel_inst_num +

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +3 -0
+ch_inst];
+
+	mc_umc_status = ras-

umc_ecc.ecc[channel_index].mca_umc_status;

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +1 -0
+

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c static inline uint32_t get_umc_v6_7_reg_offset(struct amdgpu_device *adev,

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +10 -0
+	if (mc_umc_status == 0)
+		return;
+
+	if (!err_data->err_addr)
+		return;
+
+	err_rec = &err_data->err_addr[err_data->err_addr_cnt];
+
+	/* calculate error address if ue/ce error is detected */
+	if (REG_GET_FIELD(mc_umc_status,

MCA_UMC_UMC0_MCUMC_STATUST0, Val) == 1 &&

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +1 -0
+	    (REG_GET_FIELD(mc_umc_status,

MCA_UMC_UMC0_MCUMC_STATUST0, UECC) == 1 ||

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +1 -0
+	    REG_GET_FIELD(mc_umc_status,

MCA_UMC_UMC0_MCUMC_STATUST0, CECC)

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c

Quoted 5 lines

+== 1)) {

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +2 -0
+
+		err_addr = ras-

umc_ecc.ecc[channel_index].mca_umc_addr;

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +1 -0
+		err_addr = REG_GET_FIELD(err_addr,

MCA_UMC_UMC0_MCUMC_ADDRT0,

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +3 -0
+ErrorAddr);
+
+		/* translate umc channel address to soc pa, 3 parts are

included */

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c static inline uint32_t get_umc_v6_7_reg_offset(struct amdgpu_device *adev,

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +5 -0
+		retired_page = ADDR_OF_8KB_BLOCK(err_addr) |
+				ADDR_OF_256B_BLOCK(channel_index) |
+				OFFSET_IN_256B_BLOCK(err_addr);
+
+		/* we only save ue error information currently, ce is skipped

*/

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +1 -0
+		if (REG_GET_FIELD(mc_umc_status,

MCA_UMC_UMC0_MCUMC_STATUST0, UECC)

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c static inline uint32_t get_umc_v6_7_reg_offset(struct amdgpu_device *adev,

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +4 -0
+				== 1) {
+			err_rec->address = err_addr;
+			/* page frame address is saved */
+			err_rec->retired_page = retired_page >>

AMDGPU_GPU_PAGE_SHIFT;

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +2 -0
+			err_rec->ts = (uint64_t)ktime_get_real_seconds();
+			err_rec->err_type =

AMDGPU_RAS_EEPROM_ERR_NON_RECOVERABLE;

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c static inline uint32_t get_umc_v6_7_reg_offset(struct amdgpu_device *adev,

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +10 -0
+			err_rec->cu = 0;
+			err_rec->mem_channel = channel_index;
+			err_rec->mcumc_id = umc_inst;
+
+			err_data->err_addr_cnt++;
+		}
+	}
+}
+
+static void umc_v6_7_message_smu_query_ras_error_address(struct

amdgpu_device *adev,

Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +15 -0
+					     void *ras_error_status)
+{
+	struct ras_err_data *err_data = (struct ras_err_data
+*)ras_error_status;
+
+	uint32_t umc_inst        = 0;
+	uint32_t ch_inst         = 0;
+	uint32_t umc_reg_offset  = 0;
+
+	/*TODO: driver needs to toggle DF Cstate to ensure
+	 * safe access of UMC resgisters. Will add the protection
+	 * when firmware interface is ready */
+	LOOP_UMC_INST_AND_CH(umc_inst, ch_inst) {
+		umc_reg_offset = get_umc_v6_7_reg_offset(adev,
+							 umc_inst,

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c static inline uint32_t get_umc_v6_7_reg_offset(struct amdgpu_device *adev,

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +9 -0
+							 ch_inst);
+		umc_v6_7_message_smu_query_error_address(adev,
+					     err_data,
+					     umc_reg_offset,
+					     ch_inst,
+					     umc_inst);
+	}
+}
+
  static void umc_v6_7_query_correctable_error_count(struct

amdgpu_device *adev,

Quoted 2 lines

uint32_t umc_reg_offset, unsigned long *error_count)

(quoted diff) +0 -0
@@ -327,4 +486,6 @@ const
 > struct amdgpu_umc_ras_funcs umc_v6_7_ras_funcs = {
 >   	.query_ras_error_count = umc_v6_7_query_ras_error_count,
 >   	.query_ras_error_address = umc_v6_7_query_ras_error_address,
 >   	.query_ras_poison_mode = umc_v6_7_query_ras_poison_mode,

drivers/gpu/drm/amd/amdgpu/umc_v6_7.c

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +1 -0
+	.message_smu_query_ras_error_count =

umc_v6_7_message_smu_query_ras_error_count,

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/umc_v6_7.c +2 -0
+	.message_smu_query_ras_error_address =
+umc_v6_7_message_smu_query_ras_error_address,
  };
#4 lore raw

PATCH 3/4 drm/amdgpu: add message smu to get ecc_table

In reply to Stanley.Yang

support ECC TABLE message, this table include unc ras error count and error address

---
 drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h       |  7 ++++
 .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c    | 38 +++++++++++++++++++
 .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c    |  2 +
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c        | 24 ++++++++++++
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h        |  3 ++
 5 files changed, 74 insertions(+)
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +7 -0
index 3557f4e7fc30..ea65de0160c3 100644
@@ -324,6 +324,7 @@ enum smu_table_id
 	SMU_TABLE_OVERDRIVE,
 	SMU_TABLE_I2C_COMMANDS,
 	SMU_TABLE_PACE,
+	SMU_TABLE_ECCINFO,
 	SMU_TABLE_COUNT,
 };
 
@@ -340,6 +341,7 @@ struct smu_table_context
 	void				*max_sustainable_clocks;
 	struct smu_bios_boot_up_values	boot_values;
 	void                            *driver_pptable;
+	void                            *ecc_table;
 	struct smu_table		tables[SMU_TABLE_COUNT];
 	/*
 	 * The driver table is just a staging buffer for
@@ -1261,6 +1263,11 @@ struct pptable_funcs {
 	 *										of SMUBUS table.
 	 */
 	int (*send_hbm_bad_pages_num)(struct smu_context *smu, uint32_t size);
+
+	/**
+	 * @get_ecc_table:  message SMU to get ECC INFO table.
+	 */
+	ssize_t (*get_ecc_info)(struct smu_context *smu, void *table);
 };
 
 typedef enum {
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +38 -0
index f835d86cc2f5..5e4ba0e14a91 100644
@@ -190,6 +190,7 @@ static const struct cmn2asic_mapping aldebaran_table_map[SMU_TABLE_COUNT] = {
 	TAB_MAP(SMU_METRICS),
 	TAB_MAP(DRIVER_SMU_CONFIG),
 	TAB_MAP(I2C_COMMANDS),
+	TAB_MAP(ECCINFO),
 };
 
 static const uint8_t aldebaran_throttler_map[] = {
@@ -223,6 +224,9 @@ static int aldebaran_tables_init(struct smu_context *smu)
 	SMU_TABLE_INIT(tables, SMU_TABLE_I2C_COMMANDS, sizeof(SwI2cRequest_t),
 		       PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);
 
+	SMU_TABLE_INIT(tables, SMU_TABLE_ECCINFO, sizeof(EccInfoTable_t),
+		       PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);
+
 	smu_table->metrics_table = kzalloc(sizeof(SmuMetrics_t), GFP_KERNEL);
 	if (!smu_table->metrics_table)
 		return -ENOMEM;
@@ -235,6 +239,10 @@ static int aldebaran_tables_init(struct smu_context *smu)
 		return -ENOMEM;
 	}
 
+	smu_table->ecc_table = kzalloc(tables[SMU_TABLE_ECCINFO].size, GFP_KERNEL);
+	if (!smu_table->ecc_table)
+		return -ENOMEM;
+
 	return 0;
 }
 
@@ -1765,6 +1773,35 @@ static ssize_t aldebaran_get_gpu_metrics(struct smu_context *smu,
 	return sizeof(struct gpu_metrics_v1_3);
 }
 
+static ssize_t aldebaran_get_ecc_info(struct smu_context *smu,
+					 void *table)
+{
+	struct smu_table_context *smu_table = &smu->smu_table;
+	EccInfoTable_t ecc_table;
+	struct ecc_info_per_ch *ecc_info_per_channel = NULL;
+	int i, ret = 0;
+	struct umc_ecc_info *eccinfo = (struct umc_ecc_info *)table;
+
+	ret = smu_cmn_get_ecc_info_table(smu,
+					&ecc_table);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < ALDEBARAN_UMC_CHANNEL_NUM; i++) {
+		ecc_info_per_channel = &(eccinfo->ecc[i]);
+		ecc_info_per_channel->ce_count_lo_chip =
+			ecc_table.EccInfo[i].ce_count_lo_chip;
+		ecc_info_per_channel->ce_count_hi_chip =
+			ecc_table.EccInfo[i].ce_count_hi_chip;
+		ecc_info_per_channel->mca_umc_status =
+			ecc_table.EccInfo[i].mca_umc_status;
+		ecc_info_per_channel->mca_umc_addr =
+			ecc_table.EccInfo[i].mca_umc_addr;
+	}
+
+	return ret;
+}
+
 static int aldebaran_mode1_reset(struct smu_context *smu)
 {
 	u32 smu_version, fatal_err, param;
@@ -1967,6 +2004,7 @@ static const struct pptable_funcs aldebaran_ppt_funcs = {
 	.i2c_init = aldebaran_i2c_control_init,
 	.i2c_fini = aldebaran_i2c_control_fini,
 	.send_hbm_bad_pages_num = aldebaran_smu_send_hbm_bad_page_num,
+	.get_ecc_info = aldebaran_get_ecc_info,
 };
 
 void aldebaran_set_ppt_funcs(struct smu_context *smu)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +2 -0
index 4d96099a9bb1..55421ea622fb 100644
@@ -428,8 +428,10 @@ int smu_v13_0_fini_smc_tables(struct smu_context *smu)
 	kfree(smu_table->hardcode_pptable);
 	smu_table->hardcode_pptable = NULL;
 
+	kfree(smu_table->ecc_table);
 	kfree(smu_table->metrics_table);
 	kfree(smu_table->watermarks_table);
+	smu_table->ecc_table = NULL;
 	smu_table->metrics_table = NULL;
 	smu_table->watermarks_table = NULL;
 	smu_table->metrics_time = 0;
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +24 -0
index 843d2cbfc71d..e229c9b09d80 100644
@@ -983,6 +983,30 @@ int smu_cmn_get_metrics_table(struct smu_context *smu,
 	return ret;
 }
 
+int smu_cmn_get_ecc_info_table(struct smu_context *smu,
+				     void *ecc_table)
+{
+	struct smu_table_context *smu_table= &smu->smu_table;
+	uint32_t table_size =
+		smu_table->tables[SMU_TABLE_ECCINFO].size;
+	int ret = 0;
+
+	ret = smu_cmn_update_table(smu,
+			       SMU_TABLE_ECCINFO,
+			       0,
+			       smu_table->ecc_table,
+			       false);
+	if (ret) {
+		dev_info(smu->adev->dev, "Failed to export SMU ecc table!\n");
+		return ret;
+	}
+
+	if (ecc_table)
+		memcpy(ecc_table, smu_table->ecc_table, table_size);
+
+	return 0;
+}
+
 void smu_cmn_init_soft_gpu_metrics(void *table, uint8_t frev, uint8_t crev)
 {
 	struct metrics_table_header *header = (struct metrics_table_header *)table;
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +3 -0
index beea03810bca..0adc5451373b 100644
@@ -105,6 +105,9 @@ int smu_cmn_get_metrics_table(struct smu_context *smu,
 			      void *metrics_table,
 			      bool bypass_cache);
 
+int smu_cmn_get_ecc_info_table(struct smu_context *smu,
+			      void *table);
+
 void smu_cmn_init_soft_gpu_metrics(void *table, uint8_t frev, uint8_t crev);
 
 int smu_cmn_set_mp1_state(struct smu_context *smu,
Signature · 1 line
2.17.1
#5 lore raw

Re: [PATCH Review 3/4] drm/amdgpu: add message smu to get ecc_table

Quoted 154 lines · Stanley.Yang

support ECC TABLE message, this table include unc ras error count and error address

---
  drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h       |  7 ++++
  .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c    | 38 +++++++++++++++++++
  .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c    |  2 +
  drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c        | 24 ++++++++++++
  drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h        |  3 ++
  5 files changed, 74 insertions(+)
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +7 -0
index 3557f4e7fc30..ea65de0160c3 100644
@@ -324,6 +324,7 @@ enum smu_table_id
  	SMU_TABLE_OVERDRIVE,
  	SMU_TABLE_I2C_COMMANDS,
  	SMU_TABLE_PACE,
+	SMU_TABLE_ECCINFO,
  	SMU_TABLE_COUNT,
  };
 
@@ -340,6 +341,7 @@ struct smu_table_context
  	void				*max_sustainable_clocks;
  	struct smu_bios_boot_up_values	boot_values;
  	void                            *driver_pptable;
+	void                            *ecc_table;
  	struct smu_table		tables[SMU_TABLE_COUNT];
  	/*
  	 * The driver table is just a staging buffer for
@@ -1261,6 +1263,11 @@ struct pptable_funcs {
  	 *										of SMUBUS table.
  	 */
  	int (*send_hbm_bad_pages_num)(struct smu_context *smu, uint32_t size);
+
+	/**
+	 * @get_ecc_table:  message SMU to get ECC INFO table.
+	 */
+	ssize_t (*get_ecc_info)(struct smu_context *smu, void *table);
  };
 
  typedef enum {
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +38 -0
index f835d86cc2f5..5e4ba0e14a91 100644
@@ -190,6 +190,7 @@ static const struct cmn2asic_mapping aldebaran_table_map[SMU_TABLE_COUNT] = {
  	TAB_MAP(SMU_METRICS),
  	TAB_MAP(DRIVER_SMU_CONFIG),
  	TAB_MAP(I2C_COMMANDS),
+	TAB_MAP(ECCINFO),
  };
 
  static const uint8_t aldebaran_throttler_map[] = {
@@ -223,6 +224,9 @@ static int aldebaran_tables_init(struct smu_context *smu)
  	SMU_TABLE_INIT(tables, SMU_TABLE_I2C_COMMANDS, sizeof(SwI2cRequest_t),
  		       PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);
 
+	SMU_TABLE_INIT(tables, SMU_TABLE_ECCINFO, sizeof(EccInfoTable_t),
+		       PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);
+
  	smu_table->metrics_table = kzalloc(sizeof(SmuMetrics_t), GFP_KERNEL);
  	if (!smu_table->metrics_table)
  		return -ENOMEM;
@@ -235,6 +239,10 @@ static int aldebaran_tables_init(struct smu_context *smu)
  		return -ENOMEM;
  	}
 
+	smu_table->ecc_table = kzalloc(tables[SMU_TABLE_ECCINFO].size, GFP_KERNEL);
+	if (!smu_table->ecc_table)
+		return -ENOMEM;
+
  	return 0;
  }
 
@@ -1765,6 +1773,35 @@ static ssize_t aldebaran_get_gpu_metrics(struct smu_context *smu,
  	return sizeof(struct gpu_metrics_v1_3);
  }
 
+static ssize_t aldebaran_get_ecc_info(struct smu_context *smu,
+					 void *table)
+{
+	struct smu_table_context *smu_table = &smu->smu_table;
+	EccInfoTable_t ecc_table;
+	struct ecc_info_per_ch *ecc_info_per_channel = NULL;
+	int i, ret = 0;
+	struct umc_ecc_info *eccinfo = (struct umc_ecc_info *)table;
+
+	ret = smu_cmn_get_ecc_info_table(smu,
+					&ecc_table);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < ALDEBARAN_UMC_CHANNEL_NUM; i++) {
+		ecc_info_per_channel = &(eccinfo->ecc[i]);
+		ecc_info_per_channel->ce_count_lo_chip =
+			ecc_table.EccInfo[i].ce_count_lo_chip;
+		ecc_info_per_channel->ce_count_hi_chip =
+			ecc_table.EccInfo[i].ce_count_hi_chip;
+		ecc_info_per_channel->mca_umc_status =
+			ecc_table.EccInfo[i].mca_umc_status;
+		ecc_info_per_channel->mca_umc_addr =
+			ecc_table.EccInfo[i].mca_umc_addr;
+	}
+
+	return ret;
+}
+
  static int aldebaran_mode1_reset(struct smu_context *smu)
  {
  	u32 smu_version, fatal_err, param;
@@ -1967,6 +2004,7 @@ static const struct pptable_funcs aldebaran_ppt_funcs = {
  	.i2c_init = aldebaran_i2c_control_init,
  	.i2c_fini = aldebaran_i2c_control_fini,
  	.send_hbm_bad_pages_num = aldebaran_smu_send_hbm_bad_page_num,
+	.get_ecc_info = aldebaran_get_ecc_info,
  };
 
  void aldebaran_set_ppt_funcs(struct smu_context *smu)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +2 -0
index 4d96099a9bb1..55421ea622fb 100644
@@ -428,8 +428,10 @@ int smu_v13_0_fini_smc_tables(struct smu_context *smu)
  	kfree(smu_table->hardcode_pptable);
  	smu_table->hardcode_pptable = NULL;
 
+	kfree(smu_table->ecc_table);
  	kfree(smu_table->metrics_table);
  	kfree(smu_table->watermarks_table);
+	smu_table->ecc_table = NULL;
  	smu_table->metrics_table = NULL;
  	smu_table->watermarks_table = NULL;
  	smu_table->metrics_time = 0;
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +10 -0
index 843d2cbfc71d..e229c9b09d80 100644
@@ -983,6 +983,30 @@ int smu_cmn_get_metrics_table(struct smu_context *smu,
  	return ret;
  }
 
+int smu_cmn_get_ecc_info_table(struct smu_context *smu,
+				     void *ecc_table)
+{
+	struct smu_table_context *smu_table= &smu->smu_table;
+	uint32_t table_size =
+		smu_table->tables[SMU_TABLE_ECCINFO].size;
+	int ret = 0;
+
+	ret = smu_cmn_update_table(smu,
+			       SMU_TABLE_ECCINFO,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_get_metrics_table(struct smu_context *smu, · line 1005

Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +10 -0
+			       0,
+			       smu_table->ecc_table,
+			       false);
+	if (ret) {
+		dev_info(smu->adev->dev, "Failed to export SMU ecc table!\n");
+		return ret;
+	}
+
+	if (ecc_table)
+		memcpy(ecc_table, smu_table->ecc_table, table_size);

This copy to another buffer is redundant. You may use ecc_table directly in the callback, then this method itself looks unnecessary. Instead of calling smu_cmn_get_ecc_info_table(), call smu_cmn_update_table() and copy directly from ecc_table.

Thanks,
Lijo

Quoted 22 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4 -0
+
+	return 0;
+}
+
  void smu_cmn_init_soft_gpu_metrics(void *table, uint8_t frev, uint8_t crev)
  {
  	struct metrics_table_header *header = (struct metrics_table_header *)table;
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +3 -0
index beea03810bca..0adc5451373b 100644
@@ -105,6 +105,9 @@ int smu_cmn_get_metrics_table(struct smu_context *smu,
  			      void *metrics_table,
  			      bool bypass_cache);
 
+int smu_cmn_get_ecc_info_table(struct smu_context *smu,
+			      void *table);
+
  void smu_cmn_init_soft_gpu_metrics(void *table, uint8_t frev, uint8_t crev);
 
  int smu_cmn_set_mp1_state(struct smu_context *smu,
#6 lore raw

回复: [PATCH Review 3/4] drm/amdgpu: add message smu to get ecc_table

[AMD Official Use Only]

Quoted 192 lines

-----邮件原件-----
发件人: Lazar, Lijo <[email protected]>
发送时间: Wednesday, November 17, 2021 7:24 PM
收件人: Yang, Stanley <[email protected]>; amd- [email protected]; Zhang, Hawking <[email protected]>; Clements, John <[email protected]>; Quan, Evan <[email protected]>; Wang, Yang(Kevin) <[email protected]> 主题: Re: [PATCH Review 3/4] drm/amdgpu: add message smu to get ecc_table

Quoted 7 lines · Stanley.Yang

support ECC TABLE message, this table include unc ras error count and error address

---
  drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h       |  7 ++++
  .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c    | 38

+++++++++++++++++++

Quoted 19 lines
  .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c    |  2 +
  drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c        | 24 ++++++++++++
  drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h        |  3 ++
  5 files changed, 74 insertions(+)
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +1 -0
index 3557f4e7fc30..ea65de0160c3 100644
@@ -324,6 +324,7 @@ enum smu_table_id
  	SMU_TABLE_OVERDRIVE,
  	SMU_TABLE_I2C_COMMANDS,
  	SMU_TABLE_PACE,
+	SMU_TABLE_ECCINFO,
  	SMU_TABLE_COUNT,
  };
 

drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h struct smu_table_context

Quoted 9 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +2 -0
@@ -340,6 +341,7 @@ struct smu_table_context
  	void				*max_sustainable_clocks;
  	struct smu_bios_boot_up_values	boot_values;
  	void                            *driver_pptable;
+	void                            *ecc_table;
  	struct smu_table		tables[SMU_TABLE_COUNT];
  	/*
  	 * The driver table is just a staging buffer for @@ -1261,6
+1263,11 @@ struct pptable_funcs {
  	 *

of SMUBUS table.

Quoted 2 lines

*/
int (*send_hbm_bad_pages_num)(struct smu_context *smu,

uint32_t

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static const struct cmn2asic_mapping

Quoted 15 lines

size);

drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +5 -0
+
+	/**
+	 * @get_ecc_table:  message SMU to get ECC INFO table.
+	 */
+	ssize_t (*get_ecc_info)(struct smu_context *smu, void *table);
  };
 
  typedef enum {
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0 -0
index f835d86cc2f5..5e4ba0e14a91 100644
@@ -190,6 +190,7 @@ static const struct cmn2asic_mapping

aldebaran_table_map[SMU_TABLE_COUNT] = {

Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +1 -0
  	TAB_MAP(SMU_METRICS),
  	TAB_MAP(DRIVER_SMU_CONFIG),
  	TAB_MAP(I2C_COMMANDS),
+	TAB_MAP(ECCINFO),
  };
 
  static const uint8_t aldebaran_throttler_map[] = { @@ -223,6 +224,9

@@ static int aldebaran_tables_init(struct smu_context *smu)
SMU_TABLE_INIT(tables, SMU_TABLE_I2C_COMMANDS,

sizeof(SwI2cRequest_t),

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c

Quoted 3 lines

PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +1 -0
+	SMU_TABLE_INIT(tables, SMU_TABLE_ECCINFO,

sizeof(EccInfoTable_t),

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static int aldebaran_tables_init(struct smu_context *smu)

Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +2 -0
+		       PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);
+
  	smu_table->metrics_table = kzalloc(sizeof(SmuMetrics_t),

GFP_KERNEL);

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static int aldebaran_tables_init(struct smu_context

Quoted 3 lines

if (!smu_table->metrics_table)
return -ENOMEM;

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0 -0
@@ -235,6 +239,10 @@ static int aldebaran_tables_init(struct smu_context

*smu)

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static int aldebaran_tables_init(struct smu_context *smu)

Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +1 -0
  		return -ENOMEM;
  	}
 
+	smu_table->ecc_table = kzalloc(tables[SMU_TABLE_ECCINFO].size,

GFP_KERNEL);

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static ssize_t aldebaran_get_gpu_metrics(struct

Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +3 -0
+	if (!smu_table->ecc_table)
+		return -ENOMEM;
+
  	return 0;
  }
 
@@ -1765,6 +1773,35 @@ static ssize_t aldebaran_get_gpu_metrics(struct

smu_context *smu,

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static const struct pptable_funcs

Quoted 36 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +29 -0
  	return sizeof(struct gpu_metrics_v1_3);
  }
 
+static ssize_t aldebaran_get_ecc_info(struct smu_context *smu,
+					 void *table)
+{
+	struct smu_table_context *smu_table = &smu->smu_table;
+	EccInfoTable_t ecc_table;
+	struct ecc_info_per_ch *ecc_info_per_channel = NULL;
+	int i, ret = 0;
+	struct umc_ecc_info *eccinfo = (struct umc_ecc_info *)table;
+
+	ret = smu_cmn_get_ecc_info_table(smu,
+					&ecc_table);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < ALDEBARAN_UMC_CHANNEL_NUM; i++) {
+		ecc_info_per_channel = &(eccinfo->ecc[i]);
+		ecc_info_per_channel->ce_count_lo_chip =
+			ecc_table.EccInfo[i].ce_count_lo_chip;
+		ecc_info_per_channel->ce_count_hi_chip =
+			ecc_table.EccInfo[i].ce_count_hi_chip;
+		ecc_info_per_channel->mca_umc_status =
+			ecc_table.EccInfo[i].mca_umc_status;
+		ecc_info_per_channel->mca_umc_addr =
+			ecc_table.EccInfo[i].mca_umc_addr;
+	}
+
+	return ret;
+}
+
  static int aldebaran_mode1_reset(struct smu_context *smu)
  {
  	u32 smu_version, fatal_err, param;
@@ -1967,6 +2004,7 @@ static const struct pptable_funcs

aldebaran_ppt_funcs = {

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static const struct pptable_funcs aldebaran_ppt_funcs = {

Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0 -0
  	.i2c_init = aldebaran_i2c_control_init,
  	.i2c_fini = aldebaran_i2c_control_fini,
  	.send_hbm_bad_pages_num =

aldebaran_smu_send_hbm_bad_page_num,

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_fini_smc_tables(struct

Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +1 -0
+	.get_ecc_info = aldebaran_get_ecc_info,
  };
 
  void aldebaran_set_ppt_funcs(struct smu_context *smu) diff --git

a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c
b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c
index 4d96099a9bb1..55421ea622fb 100644

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +0 -0
@@ -428,8 +428,10 @@ int smu_v13_0_fini_smc_tables(struct

smu_context *smu)

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_get_metrics_table(struct

Quoted 16 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +2 -0
  	kfree(smu_table->hardcode_pptable);
  	smu_table->hardcode_pptable = NULL;
 
+	kfree(smu_table->ecc_table);
  	kfree(smu_table->metrics_table);
  	kfree(smu_table->watermarks_table);
+	smu_table->ecc_table = NULL;
  	smu_table->metrics_table = NULL;
  	smu_table->watermarks_table = NULL;
  	smu_table->metrics_time = 0;
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0 -0
index 843d2cbfc71d..e229c9b09d80 100644
@@ -983,6 +983,30 @@ int smu_cmn_get_metrics_table(struct

smu_context *smu,

Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5 -0
  	return ret;
  }
 
+int smu_cmn_get_ecc_info_table(struct smu_context *smu,
+				     void *ecc_table)
+{
+	struct smu_table_context *smu_table= &smu->smu_table;
+	uint32_t table_size =

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_get_metrics_table(struct smu_context *smu,

Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +10 -0
+		smu_table->tables[SMU_TABLE_ECCINFO].size;
+	int ret = 0;
+
+	ret = smu_cmn_update_table(smu,
+			       SMU_TABLE_ECCINFO,
+			       0,
+			       smu_table->ecc_table,
+			       false);
+	if (ret) {
+		dev_info(smu->adev->dev, "Failed to export SMU ecc

table!\n");

Quoted 10 lines

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_get_metrics_table(struct smu_context *smu, · line 1005

Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5 -0
+		return ret;
+	}
+
+	if (ecc_table)
+		memcpy(ecc_table, smu_table->ecc_table, table_size);

This copy to another buffer is redundant. You may use ecc_table directly in the callback, then this method itself looks unnecessary. Instead of calling smu_cmn_get_ecc_info_table(), call smu_cmn_update_table() and copy directly from ecc_table.

[Yang, Stanley] This design consider to protect ecc_table in further if multi-thread call smu_cmn_get_ecc_info_table same time, it should add mutex lock just like metrics table handle if it is necessary, but now test case is simple I didn't do that.

Quoted 30 lines

Thanks,
Lijo

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_get_metrics_table(struct smu_context *smu,

Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4 -0
+
+	return 0;
+}
+
  void smu_cmn_init_soft_gpu_metrics(void *table, uint8_t frev, uint8_t

crev)

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h int smu_cmn_get_metrics_table(struct

Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0 -0
  {
  	struct metrics_table_header *header = (struct metrics_table_header

*)table; diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h
index beea03810bca..0adc5451373b 100644

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +0 -0
@@ -105,6 +105,9 @@ int smu_cmn_get_metrics_table(struct

smu_context *smu,

Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +3 -0
  			      void *metrics_table,
  			      bool bypass_cache);
 
+int smu_cmn_get_ecc_info_table(struct smu_context *smu,
+			      void *table);
+
  void smu_cmn_init_soft_gpu_metrics(void *table, uint8_t frev,
 uint8_t crev);
 

int smu_cmn_set_mp1_state(struct smu_context *smu,

#7 lore raw

Re: 回复: [PATCH Review 3/4] drm/amdgpu: add message smu to get ecc_table

Quoted 206 lines · Stanley

[AMD Official Use Only]

Quoted 192 lines

-----邮件原件-----
发件人: Lazar, Lijo <[email protected]>
发送时间: Wednesday, November 17, 2021 7:24 PM
收件人: Yang, Stanley <[email protected]>; amd- [email protected]; Zhang, Hawking <[email protected]>; Clements, John <[email protected]>; Quan, Evan <[email protected]>; Wang, Yang(Kevin) <[email protected]> 主题: Re: [PATCH Review 3/4] drm/amdgpu: add message smu to get ecc_table

Quoted 7 lines · Stanley.Yang

support ECC TABLE message, this table include unc ras error count and error address

---
   drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h       |  7 ++++
   .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c    | 38

+++++++++++++++++++

Quoted 19 lines
   .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c    |  2 +
   drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c        | 24 ++++++++++++
   drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h        |  3 ++
   5 files changed, 74 insertions(+)
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +1 -0
index 3557f4e7fc30..ea65de0160c3 100644
@@ -324,6 +324,7 @@ enum smu_table_id
   	SMU_TABLE_OVERDRIVE,
   	SMU_TABLE_I2C_COMMANDS,
   	SMU_TABLE_PACE,
+	SMU_TABLE_ECCINFO,
   	SMU_TABLE_COUNT,
   };
 

drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h struct smu_table_context

Quoted 9 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +2 -0
@@ -340,6 +341,7 @@ struct smu_table_context
   	void				*max_sustainable_clocks;
   	struct smu_bios_boot_up_values	boot_values;
   	void                            *driver_pptable;
+	void                            *ecc_table;
   	struct smu_table		tables[SMU_TABLE_COUNT];
   	/*
   	 * The driver table is just a staging buffer for @@ -1261,6
+1263,11 @@ struct pptable_funcs {
   	 *

of SMUBUS table.

Quoted 2 lines

*/
int (*send_hbm_bad_pages_num)(struct smu_context *smu,

uint32_t

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static const struct cmn2asic_mapping

Quoted 15 lines

size);

drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +5 -0
+
+	/**
+	 * @get_ecc_table:  message SMU to get ECC INFO table.
+	 */
+	ssize_t (*get_ecc_info)(struct smu_context *smu, void *table);
   };
 
   typedef enum {
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0 -0
index f835d86cc2f5..5e4ba0e14a91 100644
@@ -190,6 +190,7 @@ static const struct cmn2asic_mapping

aldebaran_table_map[SMU_TABLE_COUNT] = {

Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +1 -0
   	TAB_MAP(SMU_METRICS),
   	TAB_MAP(DRIVER_SMU_CONFIG),
   	TAB_MAP(I2C_COMMANDS),
+	TAB_MAP(ECCINFO),
   };
 
   static const uint8_t aldebaran_throttler_map[] = { @@ -223,6 +224,9

@@ static int aldebaran_tables_init(struct smu_context *smu)
SMU_TABLE_INIT(tables, SMU_TABLE_I2C_COMMANDS,

sizeof(SwI2cRequest_t),

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c

Quoted 3 lines
   		       PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +1 -0
+	SMU_TABLE_INIT(tables, SMU_TABLE_ECCINFO,

sizeof(EccInfoTable_t),

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static int aldebaran_tables_init(struct smu_context *smu)

Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +2 -0
+		       PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);
+
   	smu_table->metrics_table = kzalloc(sizeof(SmuMetrics_t),

GFP_KERNEL);

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static int aldebaran_tables_init(struct smu_context

Quoted 3 lines
   	if (!smu_table->metrics_table)
   		return -ENOMEM;
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0 -0
@@ -235,6 +239,10 @@ static int aldebaran_tables_init(struct smu_context

*smu)

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static int aldebaran_tables_init(struct smu_context *smu)

Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +1 -0
   		return -ENOMEM;
   	}
 
+	smu_table->ecc_table = kzalloc(tables[SMU_TABLE_ECCINFO].size,

GFP_KERNEL);

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static ssize_t aldebaran_get_gpu_metrics(struct

Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +3 -0
+	if (!smu_table->ecc_table)
+		return -ENOMEM;
+
   	return 0;
   }
 
@@ -1765,6 +1773,35 @@ static ssize_t aldebaran_get_gpu_metrics(struct

smu_context *smu,

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static const struct pptable_funcs

Quoted 36 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +29 -0
   	return sizeof(struct gpu_metrics_v1_3);
   }
 
+static ssize_t aldebaran_get_ecc_info(struct smu_context *smu,
+					 void *table)
+{
+	struct smu_table_context *smu_table = &smu->smu_table;
+	EccInfoTable_t ecc_table;
+	struct ecc_info_per_ch *ecc_info_per_channel = NULL;
+	int i, ret = 0;
+	struct umc_ecc_info *eccinfo = (struct umc_ecc_info *)table;
+
+	ret = smu_cmn_get_ecc_info_table(smu,
+					&ecc_table);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < ALDEBARAN_UMC_CHANNEL_NUM; i++) {
+		ecc_info_per_channel = &(eccinfo->ecc[i]);
+		ecc_info_per_channel->ce_count_lo_chip =
+			ecc_table.EccInfo[i].ce_count_lo_chip;
+		ecc_info_per_channel->ce_count_hi_chip =
+			ecc_table.EccInfo[i].ce_count_hi_chip;
+		ecc_info_per_channel->mca_umc_status =
+			ecc_table.EccInfo[i].mca_umc_status;
+		ecc_info_per_channel->mca_umc_addr =
+			ecc_table.EccInfo[i].mca_umc_addr;
+	}
+
+	return ret;
+}
+
   static int aldebaran_mode1_reset(struct smu_context *smu)
   {
   	u32 smu_version, fatal_err, param;
@@ -1967,6 +2004,7 @@ static const struct pptable_funcs

aldebaran_ppt_funcs = {

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static const struct pptable_funcs aldebaran_ppt_funcs = {

Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0 -0
   	.i2c_init = aldebaran_i2c_control_init,
   	.i2c_fini = aldebaran_i2c_control_fini,
   	.send_hbm_bad_pages_num =

aldebaran_smu_send_hbm_bad_page_num,

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_fini_smc_tables(struct

Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +1 -0
+	.get_ecc_info = aldebaran_get_ecc_info,
   };
 
   void aldebaran_set_ppt_funcs(struct smu_context *smu) diff --git

a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c
b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c
index 4d96099a9bb1..55421ea622fb 100644

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +0 -0
@@ -428,8 +428,10 @@ int smu_v13_0_fini_smc_tables(struct

smu_context *smu)

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_get_metrics_table(struct

Quoted 16 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +2 -0
   	kfree(smu_table->hardcode_pptable);
   	smu_table->hardcode_pptable = NULL;
 
+	kfree(smu_table->ecc_table);
   	kfree(smu_table->metrics_table);
   	kfree(smu_table->watermarks_table);
+	smu_table->ecc_table = NULL;
   	smu_table->metrics_table = NULL;
   	smu_table->watermarks_table = NULL;
   	smu_table->metrics_time = 0;
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0 -0
index 843d2cbfc71d..e229c9b09d80 100644
@@ -983,6 +983,30 @@ int smu_cmn_get_metrics_table(struct

smu_context *smu,

Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5 -0
   	return ret;
   }
 
+int smu_cmn_get_ecc_info_table(struct smu_context *smu,
+				     void *ecc_table)
+{
+	struct smu_table_context *smu_table= &smu->smu_table;
+	uint32_t table_size =

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_get_metrics_table(struct smu_context *smu,

Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +10 -0
+		smu_table->tables[SMU_TABLE_ECCINFO].size;
+	int ret = 0;
+
+	ret = smu_cmn_update_table(smu,
+			       SMU_TABLE_ECCINFO,
+			       0,
+			       smu_table->ecc_table,
+			       false);
+	if (ret) {
+		dev_info(smu->adev->dev, "Failed to export SMU ecc

table!\n");

Quoted 10 lines

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_get_metrics_table(struct smu_context *smu, · line 1005

Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5 -0
+		return ret;
+	}
+
+	if (ecc_table)
+		memcpy(ecc_table, smu_table->ecc_table, table_size);

This copy to another buffer is redundant. You may use ecc_table directly in the callback, then this method itself looks unnecessary. Instead of calling smu_cmn_get_ecc_info_table(), call smu_cmn_update_table() and copy directly from ecc_table.

Quoted 1 line

[Yang, Stanley] This design consider to protect ecc_table in further if multi-thread call smu_cmn_get_ecc_info_table same time, it should add mutex lock just like metrics table handle if it is necessary, but now test case is simple I didn't do that.

This is not like a metrics table use case. RAS error harvesting is not a multithread case. The error registers are cleared after reading, so I thought it's always expected to be one user at a time. Besides, I don't know if there is a case where driver needs to report errors from multiple threads.

Thanks,
Lijo

Quoted 31 lines
Quoted 31 lines

Thanks,
Lijo

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_get_metrics_table(struct smu_context *smu,

Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4 -0
+
+	return 0;
+}
+
   void smu_cmn_init_soft_gpu_metrics(void *table, uint8_t frev, uint8_t

crev)

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h int smu_cmn_get_metrics_table(struct

Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0 -0
   {
   	struct metrics_table_header *header = (struct metrics_table_header

*)table; diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h
index beea03810bca..0adc5451373b 100644

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +0 -0
@@ -105,6 +105,9 @@ int smu_cmn_get_metrics_table(struct

smu_context *smu,

Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +3 -0
   			      void *metrics_table,
   			      bool bypass_cache);
 
+int smu_cmn_get_ecc_info_table(struct smu_context *smu,
+			      void *table);
+
   void smu_cmn_init_soft_gpu_metrics(void *table, uint8_t frev,
 uint8_t crev);
 

int smu_cmn_set_mp1_state(struct smu_context *smu,

#8 lore raw

回复: 回复: [PATCH Review 3/4] drm/amdgpu: add message smu to get ecc_table

[AMD Official Use Only]

Quoted 222 lines

-----邮件原件-----
发件人: Lazar, Lijo <[email protected]>
发送时间: Thursday, November 18, 2021 12:04 PM
收件人: Yang, Stanley <[email protected]>; amd- [email protected]; Zhang, Hawking <[email protected]>; Clements, John <[email protected]>; Quan, Evan <[email protected]>; Wang, Yang(Kevin) <[email protected]> 主题: Re: 回复: [PATCH Review 3/4] drm/amdgpu: add message smu to get ecc_table

Quoted 11 lines · Stanley

[AMD Official Use Only]

Quoted 7 lines

-----邮件原件-----
发件人: Lazar, Lijo <[email protected]>
发送时间: Wednesday, November 17, 2021 7:24 PM
收件人: Yang, Stanley <[email protected]>; amd- [email protected]; Zhang, Hawking <[email protected]>; Clements, John <[email protected]>; Quan, Evan <[email protected]>; Wang, Yang(Kevin)

<[email protected]>

Quoted 197 lines
Quoted 197 lines

主题: Re: [PATCH Review 3/4] drm/amdgpu: add message smu to get ecc_table

Quoted 7 lines · Stanley.Yang

support ECC TABLE message, this table include unc ras error count and error address

---
   drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h       |  7 ++++
   .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c    | 38

+++++++++++++++++++

Quoted 19 lines
   .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c    |  2 +
   drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c        | 24 ++++++++++++
   drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h        |  3 ++
   5 files changed, 74 insertions(+)
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +1 -0
index 3557f4e7fc30..ea65de0160c3 100644
@@ -324,6 +324,7 @@ enum smu_table_id
   	SMU_TABLE_OVERDRIVE,
   	SMU_TABLE_I2C_COMMANDS,
   	SMU_TABLE_PACE,
+	SMU_TABLE_ECCINFO,
   	SMU_TABLE_COUNT,
   };
 

drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h struct smu_table_context

Quoted 9 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +2 -0
@@ -340,6 +341,7 @@ struct smu_table_context
   	void				*max_sustainable_clocks;
   	struct smu_bios_boot_up_values	boot_values;
   	void                            *driver_pptable;
+	void                            *ecc_table;
   	struct smu_table		tables[SMU_TABLE_COUNT];
   	/*
   	 * The driver table is just a staging buffer for @@ -1261,6
+1263,11 @@ struct pptable_funcs {
   	 *

of SMUBUS table.

Quoted 2 lines

*/
int (*send_hbm_bad_pages_num)(struct smu_context *smu,

uint32_t

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static const struct cmn2asic_mapping

Quoted 15 lines

size);

drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +5 -0
+
+	/**
+	 * @get_ecc_table:  message SMU to get ECC INFO table.
+	 */
+	ssize_t (*get_ecc_info)(struct smu_context *smu, void *table);
   };
 
   typedef enum {
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0 -0
index f835d86cc2f5..5e4ba0e14a91 100644
@@ -190,6 +190,7 @@ static const struct cmn2asic_mapping

aldebaran_table_map[SMU_TABLE_COUNT] = {

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static const struct cmn2asic_mapping aldebaran_table_map[SMU_TABLE_COUNT] = {

Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +2 -0
   	TAB_MAP(SMU_METRICS),
   	TAB_MAP(DRIVER_SMU_CONFIG),
   	TAB_MAP(I2C_COMMANDS),
+	TAB_MAP(ECCINFO),
   };
 
   static const uint8_t aldebaran_throttler_map[] = { @@ -223,6
+224,9 @@ static int aldebaran_tables_init(struct smu_context *smu)
   	SMU_TABLE_INIT(tables, SMU_TABLE_I2C_COMMANDS,

sizeof(SwI2cRequest_t),

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c

Quoted 3 lines
   		       PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +1 -0
+	SMU_TABLE_INIT(tables, SMU_TABLE_ECCINFO,

sizeof(EccInfoTable_t),

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static int aldebaran_tables_init(struct smu_context *smu)

Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +2 -0
+		       PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);
+
   	smu_table->metrics_table = kzalloc(sizeof(SmuMetrics_t),

GFP_KERNEL);

Quoted 4 lines
   	if (!smu_table->metrics_table)
   		return -ENOMEM;
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0 -0
@@ -235,6 +239,10 @@ static int aldebaran_tables_init(struct

smu_context

*smu)

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c

Quoted 4 lines
   		return -ENOMEM;
   	}
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +1 -0
+	smu_table->ecc_table = kzalloc(tables[SMU_TABLE_ECCINFO].size,

GFP_KERNEL);

Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +3 -0
+	if (!smu_table->ecc_table)
+		return -ENOMEM;
+
   	return 0;
   }
@@ -1765,6 +1773,35 @@ static ssize_t

aldebaran_get_gpu_metrics(struct

smu_context *smu,

Quoted 35 lines
   	return sizeof(struct gpu_metrics_v1_3);
   }
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +29 -0
+static ssize_t aldebaran_get_ecc_info(struct smu_context *smu,
+					 void *table)
+{
+	struct smu_table_context *smu_table = &smu->smu_table;
+	EccInfoTable_t ecc_table;
+	struct ecc_info_per_ch *ecc_info_per_channel = NULL;
+	int i, ret = 0;
+	struct umc_ecc_info *eccinfo = (struct umc_ecc_info *)table;
+
+	ret = smu_cmn_get_ecc_info_table(smu,
+					&ecc_table);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < ALDEBARAN_UMC_CHANNEL_NUM; i++) {
+		ecc_info_per_channel = &(eccinfo->ecc[i]);
+		ecc_info_per_channel->ce_count_lo_chip =
+			ecc_table.EccInfo[i].ce_count_lo_chip;
+		ecc_info_per_channel->ce_count_hi_chip =
+			ecc_table.EccInfo[i].ce_count_hi_chip;
+		ecc_info_per_channel->mca_umc_status =
+			ecc_table.EccInfo[i].mca_umc_status;
+		ecc_info_per_channel->mca_umc_addr =
+			ecc_table.EccInfo[i].mca_umc_addr;
+	}
+
+	return ret;
+}
+
   static int aldebaran_mode1_reset(struct smu_context *smu)
   {
   	u32 smu_version, fatal_err, param; @@ -1967,6 +2004,7 @@ static
Quoted 1 line

const struct pptable_funcs

aldebaran_ppt_funcs = {

Quoted 3 lines

.i2c_init = aldebaran_i2c_control_init,
.i2c_fini = aldebaran_i2c_control_fini,
.send_hbm_bad_pages_num =

aldebaran_smu_send_hbm_bad_page_num,

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_fini_smc_tables(struct

Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +1 -0
+	.get_ecc_info = aldebaran_get_ecc_info,
   };
 
   void aldebaran_set_ppt_funcs(struct smu_context *smu) diff --git

a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c
b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c
index 4d96099a9bb1..55421ea622fb 100644

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +0 -0
@@ -428,8 +428,10 @@ int smu_v13_0_fini_smc_tables(struct

smu_context *smu)

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_get_metrics_table(struct

Quoted 16 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +2 -0
   	kfree(smu_table->hardcode_pptable);
   	smu_table->hardcode_pptable = NULL;
 
+	kfree(smu_table->ecc_table);
   	kfree(smu_table->metrics_table);
   	kfree(smu_table->watermarks_table);
+	smu_table->ecc_table = NULL;
   	smu_table->metrics_table = NULL;
   	smu_table->watermarks_table = NULL;
   	smu_table->metrics_time = 0;
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0 -0
index 843d2cbfc71d..e229c9b09d80 100644
@@ -983,6 +983,30 @@ int smu_cmn_get_metrics_table(struct

smu_context *smu,

Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5 -0
   	return ret;
   }
 
+int smu_cmn_get_ecc_info_table(struct smu_context *smu,
+				     void *ecc_table)
+{
+	struct smu_table_context *smu_table= &smu->smu_table;
+	uint32_t table_size =

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_get_metrics_table(struct smu_context *smu,

Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +10 -0
+		smu_table->tables[SMU_TABLE_ECCINFO].size;
+	int ret = 0;
+
+	ret = smu_cmn_update_table(smu,
+			       SMU_TABLE_ECCINFO,
+			       0,
+			       smu_table->ecc_table,
+			       false);
+	if (ret) {
+		dev_info(smu->adev->dev, "Failed to export SMU ecc

table!\n");

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_get_metrics_table(struct smu_context *smu, · line 1005

Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5 -0
+		return ret;
+	}
+
+	if (ecc_table)
+		memcpy(ecc_table, smu_table->ecc_table, table_size);

This copy to another buffer is redundant. You may use ecc_table directly in the callback, then this method itself looks unnecessary. Instead of calling smu_cmn_get_ecc_info_table(), call smu_cmn_update_table() and copy directly from ecc_table.

Quoted 8 lines
Quoted 1 line

[Yang, Stanley] This design consider to protect ecc_table in further if multi-

thread call smu_cmn_get_ecc_info_table same time, it should add mutex lock just like metrics table handle if it is necessary, but now test case is simple I didn't do that.
This is not like a metrics table use case. RAS error harvesting is not a multithread case. The error registers are cleared after reading, so I thought it's always expected to be one user at a time. Besides, I don't know if there is a case where driver needs to report errors from multiple threads.

[Yang, Stanley] not ras error harvesting, considering debugfs node file umc_error_cnt and sysfs node file umc_error_cnt, is there any mechanism ensure user read them only one thread on time?

Quoted 36 lines

Thanks,
Lijo

Quoted 33 lines
Quoted 33 lines

Thanks,
Lijo

Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4 -0
+
+	return 0;
+}
+
   void smu_cmn_init_soft_gpu_metrics(void *table, uint8_t frev,

uint8_t

crev)

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h int smu_cmn_get_metrics_table(struct

Quoted 9 lines

{
struct metrics_table_header *header = (struct
metrics_table_header *)table; diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h index beea03810bca..0adc5451373b 100644

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +0 -0
@@ -105,6 +105,9 @@ int smu_cmn_get_metrics_table(struct

smu_context *smu,

Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +3 -0
   			      void *metrics_table,
   			      bool bypass_cache);
 
+int smu_cmn_get_ecc_info_table(struct smu_context *smu,
+			      void *table);
+
   void smu_cmn_init_soft_gpu_metrics(void *table, uint8_t frev,
 uint8_t crev);
 

int smu_cmn_set_mp1_state(struct smu_context *smu,

#9 lore raw

Re: 回复: 回复: [PATCH Review 3/4] drm/amdgpu: add message smu to get ecc_table

Quoted 235 lines · Stanley

[AMD Official Use Only]

Quoted 222 lines

-----邮件原件-----
发件人: Lazar, Lijo <[email protected]>
发送时间: Thursday, November 18, 2021 12:04 PM
收件人: Yang, Stanley <[email protected]>; amd- [email protected]; Zhang, Hawking <[email protected]>; Clements, John <[email protected]>; Quan, Evan <[email protected]>; Wang, Yang(Kevin) <[email protected]> 主题: Re: 回复: [PATCH Review 3/4] drm/amdgpu: add message smu to get ecc_table

Quoted 11 lines · Stanley

[AMD Official Use Only]

Quoted 7 lines

-----邮件原件-----
发件人: Lazar, Lijo <[email protected]>
发送时间: Wednesday, November 17, 2021 7:24 PM
收件人: Yang, Stanley <[email protected]>; amd- [email protected]; Zhang, Hawking <[email protected]>; Clements, John <[email protected]>; Quan, Evan <[email protected]>; Wang, Yang(Kevin)

<[email protected]>

Quoted 197 lines
Quoted 197 lines

主题: Re: [PATCH Review 3/4] drm/amdgpu: add message smu to get ecc_table

Quoted 7 lines · Stanley.Yang

support ECC TABLE message, this table include unc ras error count and error address

---
    drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h       |  7 ++++
    .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c    | 38

+++++++++++++++++++

Quoted 19 lines
    .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c    |  2 +
    drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c        | 24 ++++++++++++
    drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h        |  3 ++
    5 files changed, 74 insertions(+)
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +1 -0
index 3557f4e7fc30..ea65de0160c3 100644
@@ -324,6 +324,7 @@ enum smu_table_id
    	SMU_TABLE_OVERDRIVE,
    	SMU_TABLE_I2C_COMMANDS,
    	SMU_TABLE_PACE,
+	SMU_TABLE_ECCINFO,
    	SMU_TABLE_COUNT,
    };
 

drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h struct smu_table_context

Quoted 9 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +2 -0
@@ -340,6 +341,7 @@ struct smu_table_context
    	void				*max_sustainable_clocks;
    	struct smu_bios_boot_up_values	boot_values;
    	void                            *driver_pptable;
+	void                            *ecc_table;
    	struct smu_table		tables[SMU_TABLE_COUNT];
    	/*
    	 * The driver table is just a staging buffer for @@ -1261,6
+1263,11 @@ struct pptable_funcs {
    	 *

of SMUBUS table.

Quoted 2 lines

*/
int (*send_hbm_bad_pages_num)(struct smu_context *smu,

uint32_t

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static const struct cmn2asic_mapping

Quoted 15 lines

size);

drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +5 -0
+
+	/**
+	 * @get_ecc_table:  message SMU to get ECC INFO table.
+	 */
+	ssize_t (*get_ecc_info)(struct smu_context *smu, void *table);
    };
 
    typedef enum {
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0 -0
index f835d86cc2f5..5e4ba0e14a91 100644
@@ -190,6 +190,7 @@ static const struct cmn2asic_mapping

aldebaran_table_map[SMU_TABLE_COUNT] = {

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static const struct cmn2asic_mapping aldebaran_table_map[SMU_TABLE_COUNT] = {

Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +2 -0
    	TAB_MAP(SMU_METRICS),
    	TAB_MAP(DRIVER_SMU_CONFIG),
    	TAB_MAP(I2C_COMMANDS),
+	TAB_MAP(ECCINFO),
    };
 
    static const uint8_t aldebaran_throttler_map[] = { @@ -223,6
+224,9 @@ static int aldebaran_tables_init(struct smu_context *smu)
    	SMU_TABLE_INIT(tables, SMU_TABLE_I2C_COMMANDS,

sizeof(SwI2cRequest_t),

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c

Quoted 3 lines
    		       PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +1 -0
+	SMU_TABLE_INIT(tables, SMU_TABLE_ECCINFO,

sizeof(EccInfoTable_t),

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static int aldebaran_tables_init(struct smu_context *smu)

Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +2 -0
+		       PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);
+
    	smu_table->metrics_table = kzalloc(sizeof(SmuMetrics_t),

GFP_KERNEL);

Quoted 4 lines
    	if (!smu_table->metrics_table)
    		return -ENOMEM;
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0 -0
@@ -235,6 +239,10 @@ static int aldebaran_tables_init(struct

smu_context

*smu)

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c

Quoted 4 lines
    		return -ENOMEM;
    	}
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +1 -0
+	smu_table->ecc_table = kzalloc(tables[SMU_TABLE_ECCINFO].size,

GFP_KERNEL);

Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +3 -0
+	if (!smu_table->ecc_table)
+		return -ENOMEM;
+
    	return 0;
    }
@@ -1765,6 +1773,35 @@ static ssize_t

aldebaran_get_gpu_metrics(struct

smu_context *smu,

Quoted 35 lines
    	return sizeof(struct gpu_metrics_v1_3);
    }
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +29 -0
+static ssize_t aldebaran_get_ecc_info(struct smu_context *smu,
+					 void *table)
+{
+	struct smu_table_context *smu_table = &smu->smu_table;
+	EccInfoTable_t ecc_table;
+	struct ecc_info_per_ch *ecc_info_per_channel = NULL;
+	int i, ret = 0;
+	struct umc_ecc_info *eccinfo = (struct umc_ecc_info *)table;
+
+	ret = smu_cmn_get_ecc_info_table(smu,
+					&ecc_table);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < ALDEBARAN_UMC_CHANNEL_NUM; i++) {
+		ecc_info_per_channel = &(eccinfo->ecc[i]);
+		ecc_info_per_channel->ce_count_lo_chip =
+			ecc_table.EccInfo[i].ce_count_lo_chip;
+		ecc_info_per_channel->ce_count_hi_chip =
+			ecc_table.EccInfo[i].ce_count_hi_chip;
+		ecc_info_per_channel->mca_umc_status =
+			ecc_table.EccInfo[i].mca_umc_status;
+		ecc_info_per_channel->mca_umc_addr =
+			ecc_table.EccInfo[i].mca_umc_addr;
+	}
+
+	return ret;
+}
+
    static int aldebaran_mode1_reset(struct smu_context *smu)
    {
    	u32 smu_version, fatal_err, param; @@ -1967,6 +2004,7 @@ static
Quoted 1 line

const struct pptable_funcs

aldebaran_ppt_funcs = {

Quoted 3 lines

.i2c_init = aldebaran_i2c_control_init,
.i2c_fini = aldebaran_i2c_control_fini,
.send_hbm_bad_pages_num =

aldebaran_smu_send_hbm_bad_page_num,

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_fini_smc_tables(struct

Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +1 -0
+	.get_ecc_info = aldebaran_get_ecc_info,
    };
 
    void aldebaran_set_ppt_funcs(struct smu_context *smu) diff --git

a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c
b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c
index 4d96099a9bb1..55421ea622fb 100644

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +0 -0
@@ -428,8 +428,10 @@ int smu_v13_0_fini_smc_tables(struct

smu_context *smu)

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_get_metrics_table(struct

Quoted 16 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +2 -0
    	kfree(smu_table->hardcode_pptable);
    	smu_table->hardcode_pptable = NULL;
 
+	kfree(smu_table->ecc_table);
    	kfree(smu_table->metrics_table);
    	kfree(smu_table->watermarks_table);
+	smu_table->ecc_table = NULL;
    	smu_table->metrics_table = NULL;
    	smu_table->watermarks_table = NULL;
    	smu_table->metrics_time = 0;
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0 -0
index 843d2cbfc71d..e229c9b09d80 100644
@@ -983,6 +983,30 @@ int smu_cmn_get_metrics_table(struct

smu_context *smu,

Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5 -0
    	return ret;
    }
 
+int smu_cmn_get_ecc_info_table(struct smu_context *smu,
+				     void *ecc_table)
+{
+	struct smu_table_context *smu_table= &smu->smu_table;
+	uint32_t table_size =

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_get_metrics_table(struct smu_context *smu,

Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +10 -0
+		smu_table->tables[SMU_TABLE_ECCINFO].size;
+	int ret = 0;
+
+	ret = smu_cmn_update_table(smu,
+			       SMU_TABLE_ECCINFO,
+			       0,
+			       smu_table->ecc_table,
+			       false);
+	if (ret) {
+		dev_info(smu->adev->dev, "Failed to export SMU ecc

table!\n");

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_get_metrics_table(struct smu_context *smu, · line 1005

Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5 -0
+		return ret;
+	}
+
+	if (ecc_table)
+		memcpy(ecc_table, smu_table->ecc_table, table_size);

This copy to another buffer is redundant. You may use ecc_table directly in the callback, then this method itself looks unnecessary. Instead of calling smu_cmn_get_ecc_info_table(), call smu_cmn_update_table() and copy directly from ecc_table.

Quoted 8 lines
Quoted 1 line

[Yang, Stanley] This design consider to protect ecc_table in further if multi-

thread call smu_cmn_get_ecc_info_table same time, it should add mutex lock just like metrics table handle if it is necessary, but now test case is simple I didn't do that.
This is not like a metrics table use case. RAS error harvesting is not a multithread case. The error registers are cleared after reading, so I thought it's always expected to be one user at a time. Besides, I don't know if there is a case where driver needs to report errors from multiple threads.

Quoted 1 line

[Yang, Stanley] not ras error harvesting, considering debugfs node file umc_error_cnt and sysfs node file umc_error_cnt, is there any mechanism ensure user read them only one thread on time?

I see. For that, suggest to protect smu_get_ecc_info() with

	mutex_lock(&smu->mutex);

Usually we do that for swsmu APIs and that seems reasonable for sys/debugfs cases.

Thanks,
Lijo

Quoted 36 lines
Quoted 36 lines

Thanks,
Lijo

Quoted 33 lines
Quoted 33 lines

Thanks,
Lijo

Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4 -0
+
+	return 0;
+}
+
    void smu_cmn_init_soft_gpu_metrics(void *table, uint8_t frev,

uint8_t

crev)

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h int smu_cmn_get_metrics_table(struct

Quoted 9 lines

{
struct metrics_table_header *header = (struct
metrics_table_header *)table; diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h index beea03810bca..0adc5451373b 100644

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +0 -0
@@ -105,6 +105,9 @@ int smu_cmn_get_metrics_table(struct

smu_context *smu,

Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +3 -0
    			      void *metrics_table,
    			      bool bypass_cache);
 
+int smu_cmn_get_ecc_info_table(struct smu_context *smu,
+			      void *table);
+
    void smu_cmn_init_soft_gpu_metrics(void *table, uint8_t frev,
 uint8_t crev);
 

int smu_cmn_set_mp1_state(struct smu_context *smu,

#10 lore raw

PATCH 4/4 query umc error info from ecc_table

In reply to Stanley.Yang

if smu support ECCTABLE, driver can message smu to get ecc_table then query umc error info from ECCTABLE
apply pmfw version check to ensure backward compatibility

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c       | 42 ++++++++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h       |  7 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c       | 71 +++++++++++++------
 drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h       |  1 +
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 12 ++++
 .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c    |  4 ++
 6 files changed, 107 insertions(+), 30 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +33 -9
index 90f0db3b4f65..6b0f2ba1e420 100644
@@ -888,6 +888,38 @@ void amdgpu_ras_mca_query_error_status(struct amdgpu_device *adev,
 	}
 }
 
+static void amdgpu_ras_get_ecc_info(struct amdgpu_device *adev, struct ras_err_data *err_data)
+{
+	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
+
+	/*
+	 * choosing right query method according to
+	 * whether smu support query error information
+	 */
+	if ((ras->smu_version >= SUPPORT_ECCTABLE_SMU_VERSION) &&
+			!smu_get_ecc_info(&adev->smu, (void *)&(ras->umc_ecc))) {
+
+		if (adev->umc.ras_funcs &&
+			adev->umc.ras_funcs->message_smu_query_ras_error_count)
+			adev->umc.ras_funcs->message_smu_query_ras_error_count(adev, err_data);
+
+		if (adev->umc.ras_funcs &&
+			adev->umc.ras_funcs->message_smu_query_ras_error_address)
+			adev->umc.ras_funcs->message_smu_query_ras_error_address(adev, err_data);
+	} else {
+		if (adev->umc.ras_funcs &&
+			adev->umc.ras_funcs->query_ras_error_count)
+			adev->umc.ras_funcs->query_ras_error_count(adev, err_data);
+
+		/* umc query_ras_error_address is also responsible for clearing
+		 * error status
+		 */
+		if (adev->umc.ras_funcs &&
+		    adev->umc.ras_funcs->query_ras_error_address)
+			adev->umc.ras_funcs->query_ras_error_address(adev, err_data);
+	}
+}
+
 /* query/inject/cure begin */
 int amdgpu_ras_query_error_status(struct amdgpu_device *adev,
 				  struct ras_query_if *info)
@@ -901,15 +933,7 @@ int amdgpu_ras_query_error_status(struct amdgpu_device *adev,
 
 	switch (info->head.block) {
 	case AMDGPU_RAS_BLOCK__UMC:
-		if (adev->umc.ras_funcs &&
-		    adev->umc.ras_funcs->query_ras_error_count)
-			adev->umc.ras_funcs->query_ras_error_count(adev, &err_data);
-		/* umc query_ras_error_address is also responsible for clearing
-		 * error status
-		 */
-		if (adev->umc.ras_funcs &&
-		    adev->umc.ras_funcs->query_ras_error_address)
-			adev->umc.ras_funcs->query_ras_error_address(adev, &err_data);
+		amdgpu_ras_get_ecc_info(adev, &err_data);
 		break;
 	case AMDGPU_RAS_BLOCK__SDMA:
 		if (adev->sdma.funcs->query_ras_error_count) {
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +7 -0
index bcbf3264d92f..3f0de0cc8403 100644
@@ -322,6 +322,12 @@ struct ras_common_if {
 
 #define MAX_UMC_CHANNEL_NUM 32
 
+/*
+ * SMU support ECCTABLE since version 68.42.0,
+ * use this to decide query umc error info method
+ */
+#define SUPPORT_ECCTABLE_SMU_VERSION 0x00442a00
+
 struct ecc_info_per_ch {
 	uint16_t ce_count_lo_chip;
 	uint16_t ce_count_hi_chip;
@@ -375,6 +381,7 @@ struct amdgpu_ras {
 
 	/* record umc error info queried from smu */
 	struct umc_ecc_info umc_ecc;
+	uint32_t smu_version;
 };
 
 struct ras_fs_data {
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +50 -21

78 lines not on this page · raw message

drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +1 -0
index ea65de0160c3..7a06021a58f0 100644
@@ -1404,6 +1404,7 @@ int smu_set_light_sbr(struct smu_context *smu, bool enable);
 
 int smu_wait_for_event(struct amdgpu_device *adev, enum smu_event_type event,
 		       uint64_t event_arg);
+int smu_get_ecc_info(struct smu_context *smu, void *umc_ecc);
 
 #endif
 #endif
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +12 -0
index 01168b8955bf..6340c079f35e 100644
@@ -3072,6 +3072,18 @@ int smu_set_light_sbr(struct smu_context *smu, bool enable)
 	return ret;
 }
 
+int smu_get_ecc_info(struct smu_context *smu, void *umc_ecc)
+{
+	int ret = -1;
+
+	if (smu->ppt_funcs &&
+		smu->ppt_funcs->get_ecc_info)
+		ret = smu->ppt_funcs->get_ecc_info(smu, umc_ecc);
+
+	return ret;
+
+}
+
 static int smu_get_prv_buffer_details(void *handle, void **addr, size_t *size)
 {
 	struct smu_context *smu = handle;
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +4 -0
index 55421ea622fb..55ef10ca684a 100644
@@ -200,11 +200,15 @@ int smu_v13_0_check_fw_version(struct smu_context *smu)
 	uint16_t smu_major;
 	uint8_t smu_minor, smu_debug;
 	int ret = 0;
+	struct amdgpu_ras *ras = amdgpu_ras_get_context(smu->adev);
 
 	ret = smu_cmn_get_smc_version(smu, &if_version, &smu_version);
 	if (ret)
 		return ret;
 
+	/* record smu interface version, help umc query error method */
+	ras->smu_version = smu_version;
+
 	smu_major = (smu_version >> 16) & 0xffff;
 	smu_minor = (smu_version >> 8) & 0xff;
 	smu_debug = (smu_version >> 0) & 0xff;
Signature · 1 line
2.17.1
#11 lore raw

Re: [PATCH Review 4/4] query umc error info from ecc_table

Quoted 23 lines · Stanley.Yang

if smu support ECCTABLE, driver can message smu to get ecc_table then query umc error info from ECCTABLE
apply pmfw version check to ensure backward compatibility

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c       | 42 ++++++++---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h       |  7 ++
  drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c       | 71 +++++++++++++------
  drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h       |  1 +
  drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 12 ++++
  .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c    |  4 ++
  6 files changed, 107 insertions(+), 30 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -0
index 90f0db3b4f65..6b0f2ba1e420 100644
@@ -888,6 +888,38 @@ void amdgpu_ras_mca_query_error_status(struct amdgpu_device *adev,
  	}
  }
 
+static void amdgpu_ras_get_ecc_info(struct amdgpu_device *adev, struct ras_err_data *err_data)

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c void amdgpu_ras_mca_query_error_status(struct amdgpu_device *adev, · line 901

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +10 -0
+{
+	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
+
+	/*
+	 * choosing right query method according to
+	 * whether smu support query error information
+	 */
+	if ((ras->smu_version >= SUPPORT_ECCTABLE_SMU_VERSION) &&
+			!smu_get_ecc_info(&adev->smu, (void *)&(ras->umc_ecc))) {
+

This version check should be in aldebaran_ppt implementation. In general the callback will check the FW version that supports ECC table for the corresponding ASIC. It may return ENOTSUPP or similar if the FW version doesn't support ECC table and that may be checked here. Keeping smu_version in ras context is not needed.

Quoted 89 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +22 -9
+		if (adev->umc.ras_funcs &&
+			adev->umc.ras_funcs->message_smu_query_ras_error_count)
+			adev->umc.ras_funcs->message_smu_query_ras_error_count(adev, err_data);
+
+		if (adev->umc.ras_funcs &&
+			adev->umc.ras_funcs->message_smu_query_ras_error_address)
+			adev->umc.ras_funcs->message_smu_query_ras_error_address(adev, err_data);
+	} else {
+		if (adev->umc.ras_funcs &&
+			adev->umc.ras_funcs->query_ras_error_count)
+			adev->umc.ras_funcs->query_ras_error_count(adev, err_data);
+
+		/* umc query_ras_error_address is also responsible for clearing
+		 * error status
+		 */
+		if (adev->umc.ras_funcs &&
+		    adev->umc.ras_funcs->query_ras_error_address)
+			adev->umc.ras_funcs->query_ras_error_address(adev, err_data);
+	}
+}
+
  /* query/inject/cure begin */
  int amdgpu_ras_query_error_status(struct amdgpu_device *adev,
  				  struct ras_query_if *info)
@@ -901,15 +933,7 @@ int amdgpu_ras_query_error_status(struct amdgpu_device *adev,
 
  	switch (info->head.block) {
  	case AMDGPU_RAS_BLOCK__UMC:
-		if (adev->umc.ras_funcs &&
-		    adev->umc.ras_funcs->query_ras_error_count)
-			adev->umc.ras_funcs->query_ras_error_count(adev, &err_data);
-		/* umc query_ras_error_address is also responsible for clearing
-		 * error status
-		 */
-		if (adev->umc.ras_funcs &&
-		    adev->umc.ras_funcs->query_ras_error_address)
-			adev->umc.ras_funcs->query_ras_error_address(adev, &err_data);
+		amdgpu_ras_get_ecc_info(adev, &err_data);
  		break;
  	case AMDGPU_RAS_BLOCK__SDMA:
  		if (adev->sdma.funcs->query_ras_error_count) {
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +7 -0
index bcbf3264d92f..3f0de0cc8403 100644
@@ -322,6 +322,12 @@ struct ras_common_if {
 
  #define MAX_UMC_CHANNEL_NUM 32
 
+/*
+ * SMU support ECCTABLE since version 68.42.0,
+ * use this to decide query umc error info method
+ */
+#define SUPPORT_ECCTABLE_SMU_VERSION 0x00442a00
+
  struct ecc_info_per_ch {
  	uint16_t ce_count_lo_chip;
  	uint16_t ce_count_hi_chip;
@@ -375,6 +381,7 @@ struct amdgpu_ras {
 
  	/* record umc error info queried from smu */
  	struct umc_ecc_info umc_ecc;
+	uint32_t smu_version;
  };
 
  struct ras_fs_data {
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +0 -14
index 0c7c56a91b25..2c3e97c9410b 100644
@@ -97,28 +97,57 @@ int amdgpu_umc_process_ras_data_cb(struct amdgpu_device *adev,
  	struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
 
  	kgd2kfd_set_sram_ecc_flag(adev->kfd.dev);
-	if (adev->umc.ras_funcs &&
-	    adev->umc.ras_funcs->query_ras_error_count)
-	    adev->umc.ras_funcs->query_ras_error_count(adev, ras_error_status);
 
-	if (adev->umc.ras_funcs &&
-	    adev->umc.ras_funcs->query_ras_error_address &&
-	    adev->umc.max_ras_err_cnt_per_query) {
-		err_data->err_addr =
-			kcalloc(adev->umc.max_ras_err_cnt_per_query,
-				sizeof(struct eeprom_table_record), GFP_KERNEL);
-
-		/* still call query_ras_error_address to clear error status
-		 * even NOMEM error is encountered
-		 */
-		if(!err_data->err_addr)

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_process_ras_data_cb(struct amdgpu_device *adev, · line 103

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +3 -7
-			dev_warn(adev->dev, "Failed to alloc memory for "
-					"umc error address record!\n");
-
-		/* umc query_ras_error_address is also responsible for clearing
-		 * error status
-		 */
-		adev->umc.ras_funcs->query_ras_error_address(adev, ras_error_status);
+	if ((con->smu_version >= SUPPORT_ECCTABLE_SMU_VERSION) &&
+			!smu_get_ecc_info(&adev->smu, (void *)&(con->umc_ecc))) {
+

Same comment as above.

Quoted 68 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +47 -0
+		if (adev->umc.ras_funcs &&
+		    adev->umc.ras_funcs->message_smu_query_ras_error_count)
+		    adev->umc.ras_funcs->message_smu_query_ras_error_count(adev, ras_error_status);
+
+		if (adev->umc.ras_funcs &&
+		    adev->umc.ras_funcs->message_smu_query_ras_error_address &&
+		    adev->umc.max_ras_err_cnt_per_query) {
+			err_data->err_addr =
+				kcalloc(adev->umc.max_ras_err_cnt_per_query,
+					sizeof(struct eeprom_table_record), GFP_KERNEL);
+
+			/* still call query_ras_error_address to clear error status
+			 * even NOMEM error is encountered
+			 */
+			if(!err_data->err_addr)
+				dev_warn(adev->dev, "Failed to alloc memory for "
+						"umc error address record!\n");
+
+			/* umc query_ras_error_address is also responsible for clearing
+			 * error status
+			 */
+			adev->umc.ras_funcs->message_smu_query_ras_error_address(adev, ras_error_status);
+		}
+	} else {
+		if (adev->umc.ras_funcs &&
+		    adev->umc.ras_funcs->query_ras_error_count)
+		    adev->umc.ras_funcs->query_ras_error_count(adev, ras_error_status);
+
+		if (adev->umc.ras_funcs &&
+		    adev->umc.ras_funcs->query_ras_error_address &&
+		    adev->umc.max_ras_err_cnt_per_query) {
+			err_data->err_addr =
+				kcalloc(adev->umc.max_ras_err_cnt_per_query,
+					sizeof(struct eeprom_table_record), GFP_KERNEL);
+
+			/* still call query_ras_error_address to clear error status
+			 * even NOMEM error is encountered
+			 */
+			if(!err_data->err_addr)
+				dev_warn(adev->dev, "Failed to alloc memory for "
+						"umc error address record!\n");
+
+			/* umc query_ras_error_address is also responsible for clearing
+			 * error status
+			 */
+			adev->umc.ras_funcs->query_ras_error_address(adev, ras_error_status);
+		}
  	}
 
  	/* only uncorrectable error needs gpu reset */
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +1 -0
index ea65de0160c3..7a06021a58f0 100644
@@ -1404,6 +1404,7 @@ int smu_set_light_sbr(struct smu_context *smu, bool enable);
 
  int smu_wait_for_event(struct amdgpu_device *adev, enum smu_event_type event,
  		       uint64_t event_arg);
+int smu_get_ecc_info(struct smu_context *smu, void *umc_ecc);
 
  #endif
  #endif
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0 -0
index 01168b8955bf..6340c079f35e 100644
@@ -3072,6 +3072,18 @@ int smu_set_light_sbr(struct smu_context *smu, bool enable)
  	return ret;

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c int smu_set_light_sbr(struct smu_context *smu, bool enable) · line 3082

Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +8 -0
  }
 
+int smu_get_ecc_info(struct smu_context *smu, void *umc_ecc)
+{
+	int ret = -1;
+
+	if (smu->ppt_funcs &&
+		smu->ppt_funcs->get_ecc_info)
+		ret = smu->ppt_funcs->get_ecc_info(smu, umc_ecc);
+

Shouldn't return -1 if ppt func is not present. If ppt func is not present, that means this method is not supported for the SOC; return ENOTSUPP.

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c int smu_set_light_sbr(struct smu_context *smu, bool enable) · line 3086

Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4 -0
+	return ret;
+
+}
+

Probably the above function should be clubbed with patch 3 - smu support for getting ras ecc info.

Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0 -0
  static int smu_get_prv_buffer_details(void *handle, void **addr, size_t *size)
  {
  	struct smu_context *smu = handle;
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +0 -0
index 55421ea622fb..55ef10ca684a 100644
@@ -200,11 +200,15 @@ int smu_v13_0_check_fw_version(struct smu_context *smu)
  	uint16_t smu_major;
  	uint8_t smu_minor, smu_debug;

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_check_fw_version(struct smu_context *smu) · line 211

Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +4 -0
  	int ret = 0;
+	struct amdgpu_ras *ras = amdgpu_ras_get_context(smu->adev);
 
  	ret = smu_cmn_get_smc_version(smu, &if_version, &smu_version);
  	if (ret)
  		return ret;
 
+	/* record smu interface version, help umc query error method */
+	ras->smu_version = smu_version;
+

This is not needed. ASIC specific functions can check the FW version for ECC table support.

Thanks,
Lijo

Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +0 -0
  	smu_major = (smu_version >> 16) & 0xffff;
  	smu_minor = (smu_version >> 8) & 0xff;
  	smu_debug = (smu_version >> 0) & 0xff;
#12 lore raw

回复: [PATCH Review 4/4] query umc error info from ecc_table

[AMD Official Use Only]

Quoted 47 lines

-----邮件原件-----
发件人: Lazar, Lijo <[email protected]>
发送时间: Wednesday, November 17, 2021 7:15 PM
收件人: Yang, Stanley <[email protected]>; amd- [email protected]; Zhang, Hawking <[email protected]>; Clements, John <[email protected]>; Quan, Evan <[email protected]>; Wang, Yang(Kevin) <[email protected]> 主题: Re: [PATCH Review 4/4] query umc error info from ecc_table

Quoted 9 lines · Stanley.Yang

if smu support ECCTABLE, driver can message smu to get ecc_table then query umc error info from ECCTABLE apply pmfw version check to ensure backward compatibility

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c       | 42 ++++++++---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h       |  7 ++
  drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c       | 71 +++++++++++++--

----

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c void amdgpu_ras_mca_query_error_status(struct

Quoted 11 lines
  drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h       |  1 +
  drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 12 ++++
  .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c    |  4 ++
  6 files changed, 107 insertions(+), 30 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -0
index 90f0db3b4f65..6b0f2ba1e420 100644
@@ -888,6 +888,38 @@ void amdgpu_ras_mca_query_error_status(struct

amdgpu_device *adev,

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +10 -0
  	}
  }
 
+static void amdgpu_ras_get_ecc_info(struct amdgpu_device *adev,
+struct ras_err_data *err_data) {
+	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
+
+	/*
+	 * choosing right query method according to
+	 * whether smu support query error information
+	 */
+	if ((ras->smu_version >= SUPPORT_ECCTABLE_SMU_VERSION) &&
+			!smu_get_ecc_info(&adev->smu, (void *)&(ras-
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c void amdgpu_ras_mca_query_error_status(struct · line 902

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -0
 umc_ecc))) {
+

This version check should be in aldebaran_ppt implementation. In general the callback will check the FW version that supports ECC table for the corresponding ASIC. It may return ENOTSUPP or similar if the FW version doesn't support ECC table and that may be checked here. Keeping smu_version in ras context is not needed.

[Yang, Stanley] I think just check Aldebaran_ppt callback function is not enough here, considering this scenario using amdgpu driver with get_ecc_info callback function but the pmfw is an older one without ecctable feature. PMFW support ecctable since 68.42.0 for Aldebaran.

Quoted 215 lines
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +7 -0
+		if (adev->umc.ras_funcs &&
+			adev->umc.ras_funcs-
 message_smu_query_ras_error_count)
+			adev->umc.ras_funcs-
 message_smu_query_ras_error_count(adev,
+err_data);
+
+		if (adev->umc.ras_funcs &&
+			adev->umc.ras_funcs-

message_smu_query_ras_error_address)

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -0
+			adev->umc.ras_funcs-

message_smu_query_ras_error_address(adev, err_data);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c void amdgpu_ras_mca_query_error_status(struct amdgpu_device *adev,

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +4 -0
+	} else {
+		if (adev->umc.ras_funcs &&
+			adev->umc.ras_funcs->query_ras_error_count)
+			adev->umc.ras_funcs->query_ras_error_count(adev,

err_data);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2 -0
+
+		/* umc query_ras_error_address is also responsible for

clearing

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +5 -0
+		 * error status
+		 */
+		if (adev->umc.ras_funcs &&
+		    adev->umc.ras_funcs->query_ras_error_address)
+			adev->umc.ras_funcs-

query_ras_error_address(adev, err_data);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +3 -0
+	}
+}
+
  /* query/inject/cure begin */
  int amdgpu_ras_query_error_status(struct amdgpu_device *adev,
  				  struct ras_query_if *info)

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c int amdgpu_ras_query_error_status(struct · line 907

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -3
@@ -901,15 +933,7 @@ int amdgpu_ras_query_error_status(struct
 amdgpu_device *adev,
 
  	switch (info->head.block) {
  	case AMDGPU_RAS_BLOCK__UMC:
-		if (adev->umc.ras_funcs &&
-		    adev->umc.ras_funcs->query_ras_error_count)
-			adev->umc.ras_funcs->query_ras_error_count(adev,

&err_data);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c int amdgpu_ras_query_error_status(struct · line 908

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -1
-		/* umc query_ras_error_address is also responsible for

clearing

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_process_ras_data_cb(struct

Quoted 41 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -5
-		 * error status
-		 */
-		if (adev->umc.ras_funcs &&
-		    adev->umc.ras_funcs->query_ras_error_address)
-			adev->umc.ras_funcs-
 query_ras_error_address(adev, &err_data);
+		amdgpu_ras_get_ecc_info(adev, &err_data);
  		break;

case AMDGPU_RAS_BLOCK__SDMA:
if (adev->sdma.funcs->query_ras_error_count) { diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h
index bcbf3264d92f..3f0de0cc8403 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +6 -0
@@ -322,6 +322,12 @@ struct ras_common_if {
 
  #define MAX_UMC_CHANNEL_NUM 32
 
+/*
+ * SMU support ECCTABLE since version 68.42.0,
+ * use this to decide query umc error info method  */ #define
+SUPPORT_ECCTABLE_SMU_VERSION 0x00442a00
+
  struct ecc_info_per_ch {
  	uint16_t ce_count_lo_chip;
  	uint16_t ce_count_hi_chip;
@@ -375,6 +381,7 @@ struct amdgpu_ras {
 
  	/* record umc error info queried from smu */
  	struct umc_ecc_info umc_ecc;
+	uint32_t smu_version;
  };
 
  struct ras_fs_data {
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +0 -0
index 0c7c56a91b25..2c3e97c9410b 100644
@@ -97,28 +97,57 @@ int amdgpu_umc_process_ras_data_cb(struct

amdgpu_device *adev,

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_process_ras_data_cb(struct amdgpu_device *adev,

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +0 -3
  	struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
 
  	kgd2kfd_set_sram_ecc_flag(adev->kfd.dev);
-	if (adev->umc.ras_funcs &&
-	    adev->umc.ras_funcs->query_ras_error_count)
-	    adev->umc.ras_funcs->query_ras_error_count(adev,

ras_error_status);

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_process_ras_data_cb(struct amdgpu_device *adev,

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +0 -6
-	if (adev->umc.ras_funcs &&
-	    adev->umc.ras_funcs->query_ras_error_address &&
-	    adev->umc.max_ras_err_cnt_per_query) {
-		err_data->err_addr =
-			kcalloc(adev->umc.max_ras_err_cnt_per_query,
-				sizeof(struct eeprom_table_record),

GFP_KERNEL);

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_process_ras_data_cb(struct amdgpu_device *adev,

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +0 -9
-
-		/* still call query_ras_error_address to clear error status
-		 * even NOMEM error is encountered
-		 */
-		if(!err_data->err_addr)
-			dev_warn(adev->dev, "Failed to alloc memory for "
-					"umc error address record!\n");
-
-		/* umc query_ras_error_address is also responsible for

clearing

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_process_ras_data_cb(struct · line 120

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +0 -3
-		 * error status
-		 */
-		adev->umc.ras_funcs->query_ras_error_address(adev,

ras_error_status);

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_process_ras_data_cb(struct amdgpu_device *adev, · line 103

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +3 -0
+	if ((con->smu_version >= SUPPORT_ECCTABLE_SMU_VERSION) &&
+			!smu_get_ecc_info(&adev->smu, (void *)&(con-
 umc_ecc))) {
+

Same comment as above.

Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +7 -0
+		if (adev->umc.ras_funcs &&
+		    adev->umc.ras_funcs-
 message_smu_query_ras_error_count)
+		    adev->umc.ras_funcs-
 message_smu_query_ras_error_count(adev,
+ras_error_status);
+
+		if (adev->umc.ras_funcs &&
+		    adev->umc.ras_funcs-

message_smu_query_ras_error_address &&

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +3 -0
+		    adev->umc.max_ras_err_cnt_per_query) {
+			err_data->err_addr =
+				kcalloc(adev-

umc.max_ras_err_cnt_per_query,

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +1 -0
+					sizeof(struct eeprom_table_record),

GFP_KERNEL);

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +2 -0
+
+			/* still call query_ras_error_address to clear error

status

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_process_ras_data_cb(struct amdgpu_device *adev,

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +4 -0
+			 * even NOMEM error is encountered
+			 */
+			if(!err_data->err_addr)
+				dev_warn(adev->dev, "Failed to alloc

memory for "

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +1 -0
+						"umc error address

record!\n");

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +2 -0
+
+			/* umc query_ras_error_address is also responsible

for clearing

Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +3 -0
+			 * error status
+			 */
+			adev->umc.ras_funcs-

message_smu_query_ras_error_address(adev, ras_error_status);

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +12 -0
+		}
+	} else {
+		if (adev->umc.ras_funcs &&
+		    adev->umc.ras_funcs->query_ras_error_count)
+		    adev->umc.ras_funcs->query_ras_error_count(adev,
+ras_error_status);
+
+		if (adev->umc.ras_funcs &&
+		    adev->umc.ras_funcs->query_ras_error_address &&
+		    adev->umc.max_ras_err_cnt_per_query) {
+			err_data->err_addr =
+				kcalloc(adev-

umc.max_ras_err_cnt_per_query,

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +1 -0
+					sizeof(struct eeprom_table_record),

GFP_KERNEL);

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +2 -0
+
+			/* still call query_ras_error_address to clear error

status

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_process_ras_data_cb(struct amdgpu_device *adev,

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +4 -0
+			 * even NOMEM error is encountered
+			 */
+			if(!err_data->err_addr)
+				dev_warn(adev->dev, "Failed to alloc

memory for "

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +1 -0
+						"umc error address

record!\n");

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +2 -0
+
+			/* umc query_ras_error_address is also responsible

for clearing

Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +3 -0
+			 * error status
+			 */
+			adev->umc.ras_funcs-

query_ras_error_address(adev, ras_error_status);

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +1 -0
+		}
  	}
 
  	/* only uncorrectable error needs gpu reset */ diff --git

a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
index ea65de0160c3..7a06021a58f0 100644

drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h int smu_set_light_sbr(struct smu_context *smu, · line 1406

Quoted 3 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0 -0
@@ -1404,6 +1404,7 @@ int smu_set_light_sbr(struct smu_context *smu,
 bool enable);
 
  int smu_wait_for_event(struct amdgpu_device *adev, enum

smu_event_type event,

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c int smu_set_light_sbr(struct smu_context *smu,

Quoted 11 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +1 -0
  		       uint64_t event_arg);
+int smu_get_ecc_info(struct smu_context *smu, void *umc_ecc);
 
  #endif
  #endif
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0 -0
index 01168b8955bf..6340c079f35e 100644
@@ -3072,6 +3072,18 @@ int smu_set_light_sbr(struct smu_context *smu,

bool enable)

Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0 -0
  	return ret;
  }
 
Quoted 10 lines

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c int smu_set_light_sbr(struct smu_context *smu, bool enable) · line 3082

Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +7 -0
+int smu_get_ecc_info(struct smu_context *smu, void *umc_ecc) {
+	int ret = -1;
+
+	if (smu->ppt_funcs &&
+		smu->ppt_funcs->get_ecc_info)
+		ret = smu->ppt_funcs->get_ecc_info(smu, umc_ecc);
+

Shouldn't return -1 if ppt func is not present. If ppt func is not present, that means this method is not supported for the SOC; return ENOTSUPP.

[Yang, Stanley] thanks, return -ENOTSUPP is more reasonable.

Quoted 43 lines

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c int smu_set_light_sbr(struct smu_context *smu, bool enable) · line 3086

Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4 -0
+	return ret;
+
+}
+

Probably the above function should be clubbed with patch 3 - smu support for getting ras ecc info.

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c int smu_set_light_sbr(struct smu_context *smu, · line 3086

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0 -0
  static int smu_get_prv_buffer_details(void *handle, void **addr, size_t

*size)

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_check_fw_version(struct

Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0 -0
  {
  	struct smu_context *smu = handle;
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +0 -0
index 55421ea622fb..55ef10ca684a 100644
@@ -200,11 +200,15 @@ int smu_v13_0_check_fw_version(struct

smu_context *smu)

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_check_fw_version(struct smu_context *smu) · line 211

Quoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +4 -0
  	uint16_t smu_major;
  	uint8_t smu_minor, smu_debug;
  	int ret = 0;
+	struct amdgpu_ras *ras = amdgpu_ras_get_context(smu->adev);
 
  	ret = smu_cmn_get_smc_version(smu, &if_version, &smu_version);
  	if (ret)
  		return ret;
 
+	/* record smu interface version, help umc query error method */
+	ras->smu_version = smu_version;
+

This is not needed. ASIC specific functions can check the FW version for ECC table support.

Thanks,
Lijo

Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +0 -0
  	smu_major = (smu_version >> 16) & 0xffff;
  	smu_minor = (smu_version >> 8) & 0xff;
  	smu_debug = (smu_version >> 0) & 0xff;
#13 lore raw

Re: 回复: [PATCH Review 4/4] query umc error info from ecc_table

Quoted 59 lines · Stanley

[AMD Official Use Only]

Quoted 47 lines

-----邮件原件-----
发件人: Lazar, Lijo <[email protected]>
发送时间: Wednesday, November 17, 2021 7:15 PM
收件人: Yang, Stanley <[email protected]>; amd- [email protected]; Zhang, Hawking <[email protected]>; Clements, John <[email protected]>; Quan, Evan <[email protected]>; Wang, Yang(Kevin) <[email protected]> 主题: Re: [PATCH Review 4/4] query umc error info from ecc_table

Quoted 9 lines · Stanley.Yang

if smu support ECCTABLE, driver can message smu to get ecc_table then query umc error info from ECCTABLE apply pmfw version check to ensure backward compatibility

---
   drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c       | 42 ++++++++---
   drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h       |  7 ++
   drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c       | 71 +++++++++++++--

----

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c void amdgpu_ras_mca_query_error_status(struct

Quoted 11 lines
   drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h       |  1 +
   drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 12 ++++
   .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c    |  4 ++
   6 files changed, 107 insertions(+), 30 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -0
index 90f0db3b4f65..6b0f2ba1e420 100644
@@ -888,6 +888,38 @@ void amdgpu_ras_mca_query_error_status(struct

amdgpu_device *adev,

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +10 -0
   	}
   }
 
+static void amdgpu_ras_get_ecc_info(struct amdgpu_device *adev,
+struct ras_err_data *err_data) {
+	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
+
+	/*
+	 * choosing right query method according to
+	 * whether smu support query error information
+	 */
+	if ((ras->smu_version >= SUPPORT_ECCTABLE_SMU_VERSION) &&
+			!smu_get_ecc_info(&adev->smu, (void *)&(ras-
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c void amdgpu_ras_mca_query_error_status(struct · line 902

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -0
 umc_ecc))) {
+

This version check should be in aldebaran_ppt implementation. In general the callback will check the FW version that supports ECC table for the corresponding ASIC. It may return ENOTSUPP or similar if the FW version doesn't support ECC table and that may be checked here. Keeping smu_version in ras context is not needed.

Quoted 1 line

[Yang, Stanley] I think just check Aldebaran_ppt callback function is not enough here, considering this scenario using amdgpu driver with get_ecc_info callback function but the pmfw is an older one without ecctable feature. PMFW support ecctable since 68.42.0 for Aldebaran.

What I meant is the FW version check code should be part of aldebaran_get_ecc_info() function, and it shouldn't be here. That function checks if the FW supports ecc_info for aldebaran, if ont returns ENOTSUPP.

Similarly for a newer ASIC, the corresponding ppt_func checks compatibility. That is one of the purposes of ASIC specific callbacks.

Thanks,
Lijo

Quoted 270 lines
Quoted 216 lines
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +7 -0
+		if (adev->umc.ras_funcs &&
+			adev->umc.ras_funcs-
 message_smu_query_ras_error_count)
+			adev->umc.ras_funcs-
 message_smu_query_ras_error_count(adev,
+err_data);
+
+		if (adev->umc.ras_funcs &&
+			adev->umc.ras_funcs-

message_smu_query_ras_error_address)

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -0
+			adev->umc.ras_funcs-

message_smu_query_ras_error_address(adev, err_data);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c void amdgpu_ras_mca_query_error_status(struct amdgpu_device *adev,

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +4 -0
+	} else {
+		if (adev->umc.ras_funcs &&
+			adev->umc.ras_funcs->query_ras_error_count)
+			adev->umc.ras_funcs->query_ras_error_count(adev,

err_data);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2 -0
+
+		/* umc query_ras_error_address is also responsible for

clearing

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +5 -0
+		 * error status
+		 */
+		if (adev->umc.ras_funcs &&
+		    adev->umc.ras_funcs->query_ras_error_address)
+			adev->umc.ras_funcs-

query_ras_error_address(adev, err_data);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +3 -0
+	}
+}
+
   /* query/inject/cure begin */
   int amdgpu_ras_query_error_status(struct amdgpu_device *adev,
   				  struct ras_query_if *info)

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c int amdgpu_ras_query_error_status(struct · line 907

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -3
@@ -901,15 +933,7 @@ int amdgpu_ras_query_error_status(struct
 amdgpu_device *adev,
 
   	switch (info->head.block) {
   	case AMDGPU_RAS_BLOCK__UMC:
-		if (adev->umc.ras_funcs &&
-		    adev->umc.ras_funcs->query_ras_error_count)
-			adev->umc.ras_funcs->query_ras_error_count(adev,

&err_data);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c int amdgpu_ras_query_error_status(struct · line 908

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -1
-		/* umc query_ras_error_address is also responsible for

clearing

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_process_ras_data_cb(struct

Quoted 41 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -5
-		 * error status
-		 */
-		if (adev->umc.ras_funcs &&
-		    adev->umc.ras_funcs->query_ras_error_address)
-			adev->umc.ras_funcs-
 query_ras_error_address(adev, &err_data);
+		amdgpu_ras_get_ecc_info(adev, &err_data);
   		break;
   	case AMDGPU_RAS_BLOCK__SDMA:
   		if (adev->sdma.funcs->query_ras_error_count) { diff --git

a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h
index bcbf3264d92f..3f0de0cc8403 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +6 -0
@@ -322,6 +322,12 @@ struct ras_common_if {
 
   #define MAX_UMC_CHANNEL_NUM 32
 
+/*
+ * SMU support ECCTABLE since version 68.42.0,
+ * use this to decide query umc error info method  */ #define
+SUPPORT_ECCTABLE_SMU_VERSION 0x00442a00
+
   struct ecc_info_per_ch {
   	uint16_t ce_count_lo_chip;
   	uint16_t ce_count_hi_chip;
@@ -375,6 +381,7 @@ struct amdgpu_ras {
 
   	/* record umc error info queried from smu */
   	struct umc_ecc_info umc_ecc;
+	uint32_t smu_version;
   };
 
   struct ras_fs_data {
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +0 -0
index 0c7c56a91b25..2c3e97c9410b 100644
@@ -97,28 +97,57 @@ int amdgpu_umc_process_ras_data_cb(struct

amdgpu_device *adev,

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_process_ras_data_cb(struct amdgpu_device *adev,

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +0 -3
   	struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
 
   	kgd2kfd_set_sram_ecc_flag(adev->kfd.dev);
-	if (adev->umc.ras_funcs &&
-	    adev->umc.ras_funcs->query_ras_error_count)
-	    adev->umc.ras_funcs->query_ras_error_count(adev,

ras_error_status);

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_process_ras_data_cb(struct amdgpu_device *adev,

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +0 -6
-	if (adev->umc.ras_funcs &&
-	    adev->umc.ras_funcs->query_ras_error_address &&
-	    adev->umc.max_ras_err_cnt_per_query) {
-		err_data->err_addr =
-			kcalloc(adev->umc.max_ras_err_cnt_per_query,
-				sizeof(struct eeprom_table_record),

GFP_KERNEL);

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_process_ras_data_cb(struct amdgpu_device *adev,

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +0 -9
-
-		/* still call query_ras_error_address to clear error status
-		 * even NOMEM error is encountered
-		 */
-		if(!err_data->err_addr)
-			dev_warn(adev->dev, "Failed to alloc memory for "
-					"umc error address record!\n");
-
-		/* umc query_ras_error_address is also responsible for

clearing

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_process_ras_data_cb(struct · line 120

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +0 -3
-		 * error status
-		 */
-		adev->umc.ras_funcs->query_ras_error_address(adev,

ras_error_status);

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_process_ras_data_cb(struct amdgpu_device *adev, · line 103

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +3 -0
+	if ((con->smu_version >= SUPPORT_ECCTABLE_SMU_VERSION) &&
+			!smu_get_ecc_info(&adev->smu, (void *)&(con-
 umc_ecc))) {
+

Same comment as above.

Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +7 -0
+		if (adev->umc.ras_funcs &&
+		    adev->umc.ras_funcs-
 message_smu_query_ras_error_count)
+		    adev->umc.ras_funcs-
 message_smu_query_ras_error_count(adev,
+ras_error_status);
+
+		if (adev->umc.ras_funcs &&
+		    adev->umc.ras_funcs-

message_smu_query_ras_error_address &&

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +3 -0
+		    adev->umc.max_ras_err_cnt_per_query) {
+			err_data->err_addr =
+				kcalloc(adev-

umc.max_ras_err_cnt_per_query,

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +1 -0
+					sizeof(struct eeprom_table_record),

GFP_KERNEL);

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +2 -0
+
+			/* still call query_ras_error_address to clear error

status

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_process_ras_data_cb(struct amdgpu_device *adev,

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +4 -0
+			 * even NOMEM error is encountered
+			 */
+			if(!err_data->err_addr)
+				dev_warn(adev->dev, "Failed to alloc

memory for "

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +1 -0
+						"umc error address

record!\n");

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +2 -0
+
+			/* umc query_ras_error_address is also responsible

for clearing

Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +3 -0
+			 * error status
+			 */
+			adev->umc.ras_funcs-

message_smu_query_ras_error_address(adev, ras_error_status);

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +12 -0
+		}
+	} else {
+		if (adev->umc.ras_funcs &&
+		    adev->umc.ras_funcs->query_ras_error_count)
+		    adev->umc.ras_funcs->query_ras_error_count(adev,
+ras_error_status);
+
+		if (adev->umc.ras_funcs &&
+		    adev->umc.ras_funcs->query_ras_error_address &&
+		    adev->umc.max_ras_err_cnt_per_query) {
+			err_data->err_addr =
+				kcalloc(adev-

umc.max_ras_err_cnt_per_query,

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +1 -0
+					sizeof(struct eeprom_table_record),

GFP_KERNEL);

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +2 -0
+
+			/* still call query_ras_error_address to clear error

status

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_process_ras_data_cb(struct amdgpu_device *adev,

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +4 -0
+			 * even NOMEM error is encountered
+			 */
+			if(!err_data->err_addr)
+				dev_warn(adev->dev, "Failed to alloc

memory for "

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +1 -0
+						"umc error address

record!\n");

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +2 -0
+
+			/* umc query_ras_error_address is also responsible

for clearing

Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +3 -0
+			 * error status
+			 */
+			adev->umc.ras_funcs-

query_ras_error_address(adev, ras_error_status);

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +1 -0
+		}
   	}
 
   	/* only uncorrectable error needs gpu reset */ diff --git

a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
index ea65de0160c3..7a06021a58f0 100644

drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h int smu_set_light_sbr(struct smu_context *smu, · line 1406

Quoted 3 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0 -0
@@ -1404,6 +1404,7 @@ int smu_set_light_sbr(struct smu_context *smu,
 bool enable);
 
   int smu_wait_for_event(struct amdgpu_device *adev, enum

smu_event_type event,

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c int smu_set_light_sbr(struct smu_context *smu,

Quoted 11 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +1 -0
   		       uint64_t event_arg);
+int smu_get_ecc_info(struct smu_context *smu, void *umc_ecc);
 
   #endif
   #endif
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0 -0
index 01168b8955bf..6340c079f35e 100644
@@ -3072,6 +3072,18 @@ int smu_set_light_sbr(struct smu_context *smu,

bool enable)

Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0 -0
   	return ret;
   }
 
Quoted 10 lines

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c int smu_set_light_sbr(struct smu_context *smu, bool enable) · line 3082

Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +7 -0
+int smu_get_ecc_info(struct smu_context *smu, void *umc_ecc) {
+	int ret = -1;
+
+	if (smu->ppt_funcs &&
+		smu->ppt_funcs->get_ecc_info)
+		ret = smu->ppt_funcs->get_ecc_info(smu, umc_ecc);
+

Shouldn't return -1 if ppt func is not present. If ppt func is not present, that means this method is not supported for the SOC; return ENOTSUPP.

[Yang, Stanley] thanks, return -ENOTSUPP is more reasonable.

Quoted 43 lines

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c int smu_set_light_sbr(struct smu_context *smu, bool enable) · line 3086

Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4 -0
+	return ret;
+
+}
+

Probably the above function should be clubbed with patch 3 - smu support for getting ras ecc info.

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c int smu_set_light_sbr(struct smu_context *smu, · line 3086

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0 -0
   static int smu_get_prv_buffer_details(void *handle, void **addr, size_t

*size)

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_check_fw_version(struct

Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0 -0
   {
   	struct smu_context *smu = handle;
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +0 -0
index 55421ea622fb..55ef10ca684a 100644
@@ -200,11 +200,15 @@ int smu_v13_0_check_fw_version(struct

smu_context *smu)

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_check_fw_version(struct smu_context *smu) · line 211

Quoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +4 -0
   	uint16_t smu_major;
   	uint8_t smu_minor, smu_debug;
   	int ret = 0;
+	struct amdgpu_ras *ras = amdgpu_ras_get_context(smu->adev);
 
   	ret = smu_cmn_get_smc_version(smu, &if_version, &smu_version);
   	if (ret)
   		return ret;
 
+	/* record smu interface version, help umc query error method */
+	ras->smu_version = smu_version;
+

This is not needed. ASIC specific functions can check the FW version for ECC table support.

Thanks,
Lijo

Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +0 -0
   	smu_major = (smu_version >> 16) & 0xffff;
   	smu_minor = (smu_version >> 8) & 0xff;
   	smu_debug = (smu_version >> 0) & 0xff;