Skip to contentSkip to conversation

drm/amdgpu: add umc retire unit element

PATCH In review Tao Zhou 3 participants 4 messages Feb 17, 2023

Subsystems (2)
lore
Share & tools
lore

Tao Zhou

author
#0 lore raw

PATCH 1/2 drm/amdgpu: add umc retire unit element

It records how many bad pages are retired in one uncorrectable error.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h | 2 ++
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c  | 1 +
 drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c  | 1 +
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   | 3 +++
 4 files changed, 7 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +2 -0
index a6951160f13a..f2bf979af588 100644
@@ -74,6 +74,8 @@ struct amdgpu_umc {
 
 	/* UMC regiser per channel offset */
 	uint32_t channel_offs;
+	/* how many pages are retired in one UE */
+	uint32_t retire_unit;
 	/* channel index table of interleaved memory */
 	const uint32_t *channel_idx_tbl;
 	struct ras_common_if *ras_if;
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -0
index fe2c15f598b8..c59c2332d191 100644
@@ -696,6 +696,7 @@ static void gmc_v10_0_set_umc_funcs(struct amdgpu_device *adev)
 		adev->umc.channel_inst_num = UMC_V8_7_CHANNEL_INSTANCE_NUM;
 		adev->umc.umc_inst_num = UMC_V8_7_UMC_INSTANCE_NUM;
 		adev->umc.channel_offs = UMC_V8_7_PER_CHANNEL_OFFSET_SIENNA;
+		adev->umc.retire_unit = 1;
 		adev->umc.channel_idx_tbl = &umc_v8_7_channel_idx_tbl[0][0];
 		adev->umc.ras = &umc_v8_7_ras;
 		break;
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +1 -0
index 0a31a341aa43..85e0afc3d4f7 100644
@@ -570,6 +570,7 @@ static void gmc_v11_0_set_umc_funcs(struct amdgpu_device *adev)
 		adev->umc.node_inst_num = adev->gmc.num_umc;
 		adev->umc.max_ras_err_cnt_per_query = UMC_V8_10_TOTAL_CHANNEL_NUM(adev);
 		adev->umc.channel_offs = UMC_V8_10_PER_CHANNEL_OFFSET;
+		adev->umc.retire_unit = UMC_V8_10_NA_COL_2BITS_POWER_OF_2_NUM;
 		if (adev->umc.node_inst_num == 4)
 			adev->umc.channel_idx_tbl = &umc_v8_10_channel_idx_tbl_ext0[0][0][0];
 		else
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +3 -0
index d65c6cea3445..b06170c00dfc 100644
@@ -1288,6 +1288,7 @@ static void gmc_v9_0_set_umc_funcs(struct amdgpu_device *adev)
 		adev->umc.channel_inst_num = UMC_V6_1_CHANNEL_INSTANCE_NUM;
 		adev->umc.umc_inst_num = UMC_V6_1_UMC_INSTANCE_NUM;
 		adev->umc.channel_offs = UMC_V6_1_PER_CHANNEL_OFFSET_VG20;
+		adev->umc.retire_unit = 1;
 		adev->umc.channel_idx_tbl = &umc_v6_1_channel_idx_tbl[0][0];
 		adev->umc.ras = &umc_v6_1_ras;
 		break;
@@ -1296,6 +1297,7 @@ static void gmc_v9_0_set_umc_funcs(struct amdgpu_device *adev)
 		adev->umc.channel_inst_num = UMC_V6_1_CHANNEL_INSTANCE_NUM;
 		adev->umc.umc_inst_num = UMC_V6_1_UMC_INSTANCE_NUM;
 		adev->umc.channel_offs = UMC_V6_1_PER_CHANNEL_OFFSET_ARCT;
+		adev->umc.retire_unit = 1;
 		adev->umc.channel_idx_tbl = &umc_v6_1_channel_idx_tbl[0][0];
 		adev->umc.ras = &umc_v6_1_ras;
 		break;
@@ -1305,6 +1307,7 @@ static void gmc_v9_0_set_umc_funcs(struct amdgpu_device *adev)
 		adev->umc.channel_inst_num = UMC_V6_7_CHANNEL_INSTANCE_NUM;
 		adev->umc.umc_inst_num = UMC_V6_7_UMC_INSTANCE_NUM;
 		adev->umc.channel_offs = UMC_V6_7_PER_CHANNEL_OFFSET;
+		adev->umc.retire_unit = (UMC_V6_7_NA_MAP_PA_NUM * 2);
 		if (!adev->gmc.xgmi.connected_to_cpu)
 			adev->umc.ras = &umc_v6_7_ras;
 		if (1 & adev->smuio.funcs->get_die_id(adev))
Signature · 1 line
2.35.1
author
#1 lore raw

PATCH 2/2 drm/amdgpu: exclude duplicate pages from UMC RAS UE count

If a UMC bad page is reserved but not freed by an application, the application may trigger uncorrectable error repeatly by accessing the page.

v2: add specific function to do the check.
v3: remove duplicate pages, calculate new added bad page number.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 23 +++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h |  2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c |  2 ++
 3 files changed, 27 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +23 -0
index 6e543558386d..777f85f3e5eb 100644
@@ -2115,6 +2115,29 @@ int amdgpu_ras_save_bad_pages(struct amdgpu_device *adev)
 	return 0;
 }
 
+/* Remove duplicate pages, calculate new added bad page number.
+ * Note: the function should be called between amdgpu_ras_add_bad_pages
+ * and amdgpu_ras_save_bad_pages.
+ */
+int amdgpu_ras_umc_new_ue_count(struct amdgpu_device *adev)
+{
+	struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
+	struct ras_err_handler_data *data;
+	struct amdgpu_ras_eeprom_control *control;
+	int save_count;
+
+	if (!con || !con->eh_data)
+		return 0;
+
+	mutex_lock(&con->recovery_lock);
+	control = &con->eeprom_control;
+	data = con->eh_data;
+	save_count = data->count - control->ras_num_recs;
+	mutex_unlock(&con->recovery_lock);
+
+	return (save_count / adev->umc.retire_unit);
+}
+
 /*
  * read error record array in eeprom and reserve enough space for
  * storing new bad pages
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +2 -0
index f2ad999993f6..e89c95438a88 100644
@@ -549,6 +549,8 @@ int amdgpu_ras_add_bad_pages(struct amdgpu_device *adev,
 
 int amdgpu_ras_save_bad_pages(struct amdgpu_device *adev);
 
+int amdgpu_ras_umc_new_ue_count(struct amdgpu_device *adev);
+
 static inline enum ta_ras_block
 amdgpu_ras_block_to_ta(enum amdgpu_ras_block block) {
 	switch (block) {
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +2 -0
index 1c7fcb4f2380..45b6be7277dd 100644
@@ -147,6 +147,8 @@ static int amdgpu_umc_do_page_retirement(struct amdgpu_device *adev,
 			err_data->err_addr_cnt) {
 			amdgpu_ras_add_bad_pages(adev, err_data->err_addr,
 						err_data->err_addr_cnt);
+			err_data->ue_count = amdgpu_ras_umc_new_ue_count(adev);
+
 			amdgpu_ras_save_bad_pages(adev);
 
 			amdgpu_dpm_send_hbm_bad_pages_num(adev, con->eeprom_control.ras_num_recs);
Signature · 1 line
2.35.1
#2 lore raw

RE: [PATCH 2/2] drm/amdgpu: exclude duplicate pages from UMC RAS UE count

[AMD Official Use Only - General]

Quoted 46 lines

-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Friday, February 17, 2023 11:53 AM
To: [email protected]; Zhang, Hawking <[email protected]>; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>; Lazar, Lijo <[email protected]>
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu: exclude duplicate pages from UMC RAS UE count

If a UMC bad page is reserved but not freed by an application, the application may trigger uncorrectable error repeatly by accessing the page.

v2: add specific function to do the check.
v3: remove duplicate pages, calculate new added bad page number.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 23
+++++++++++++++++++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h |  2 ++
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c |  2 ++
 3 files changed, 27 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2 -0
index 6e543558386d..777f85f3e5eb 100644
@@ -2115,6 +2115,29 @@ int amdgpu_ras_save_bad_pages(struct
 amdgpu_device *adev)
 	return 0;
 }
 
+/* Remove duplicate pages, calculate new added bad page number.
+ * Note: the function should be called between

amdgpu_ras_add_bad_pages
+ * and amdgpu_ras_save_bad_pages.
+ */

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +6 -0
+int amdgpu_ras_umc_new_ue_count(struct amdgpu_device *adev) {
+	struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
+	struct ras_err_handler_data *data;
+	struct amdgpu_ras_eeprom_control *control;
+	int save_count;
+

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c int amdgpu_ras_save_bad_pages(struct amdgpu_device *adev)

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +10 -0
+	if (!con || !con->eh_data)
+		return 0;
+
+	mutex_lock(&con->recovery_lock);
+	control = &con->eeprom_control;
+	data = con->eh_data;
+	save_count = data->count - control->ras_num_recs;
+	mutex_unlock(&con->recovery_lock);
+
+	return (save_count / adev->umc.retire_unit); }

Stanley: It's better add comments about the return value.
Without above concern the patch is Reviewed-by: Stanley.Yang <[email protected]>

Quoted 39 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -0
+
 /*
  * read error record array in eeprom and reserve enough space for
  * storing new bad pages
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +2 -0
index f2ad999993f6..e89c95438a88 100644
@@ -549,6 +549,8 @@ int amdgpu_ras_add_bad_pages(struct
 amdgpu_device *adev,
 
 int amdgpu_ras_save_bad_pages(struct amdgpu_device *adev);
 
+int amdgpu_ras_umc_new_ue_count(struct amdgpu_device *adev);
+
 static inline enum ta_ras_block
 amdgpu_ras_block_to_ta(enum amdgpu_ras_block block) {
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +0 -0
 	switch (block) {
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +2 -0
index 1c7fcb4f2380..45b6be7277dd 100644
@@ -147,6 +147,8 @@ static int amdgpu_umc_do_page_retirement(struct
 amdgpu_device *adev,
 			err_data->err_addr_cnt) {
 			amdgpu_ras_add_bad_pages(adev, err_data-
 >err_addr,
 						err_data->err_addr_cnt);
+			err_data->ue_count =
 amdgpu_ras_umc_new_ue_count(adev);
+
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +0 -0
 			amdgpu_ras_save_bad_pages(adev);
 
 			amdgpu_dpm_send_hbm_bad_pages_num(adev,

con->eeprom_control.ras_num_recs);
--
2.35.1

#3 lore raw

RE: [PATCH 2/2] drm/amdgpu: exclude duplicate pages from UMC RAS UE count

In reply to Tao Zhou

[AMD Official Use Only - General]

Instead of adding another function, why not make pages param as in/out.

In = number of pages to be added
Out = number of pages actually added.

int amdgpu_ras_add_bad_pages(struct amdgpu_device *adev,
struct eeprom_table_record *bps, int *pages)

Thanks,
Lijo

-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Friday, February 17, 2023 9:23 AM
To: [email protected]; Zhang, Hawking <[email protected]>; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>; Lazar, Lijo <[email protected]>
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu: exclude duplicate pages from UMC RAS UE count

If a UMC bad page is reserved but not freed by an application, the application may trigger uncorrectable error repeatly by accessing the page.

v2: add specific function to do the check.
v3: remove duplicate pages, calculate new added bad page number.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 23 +++++++++++++++++++++++  drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h |  2 ++  drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c |  2 ++
 3 files changed, 27 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +21 -0
index 6e543558386d..777f85f3e5eb 100644
@@ -2115,6 +2115,29 @@ int amdgpu_ras_save_bad_pages(struct amdgpu_device *adev)
 	return 0;
 }
 
+/* Remove duplicate pages, calculate new added bad page number.
+ * Note: the function should be called between amdgpu_ras_add_bad_pages
+ * and amdgpu_ras_save_bad_pages.
+ */
+int amdgpu_ras_umc_new_ue_count(struct amdgpu_device *adev) {
+	struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
+	struct ras_err_handler_data *data;
+	struct amdgpu_ras_eeprom_control *control;
+	int save_count;
+
+	if (!con || !con->eh_data)
+		return 0;
+
+	mutex_lock(&con->recovery_lock);
+	control = &con->eeprom_control;
+	data = con->eh_data;
+	save_count = data->count - control->ras_num_recs;
+	mutex_unlock(&con->recovery_lock);
+
+	return (save_count / adev->umc.retire_unit); }
+
 /*
  * read error record array in eeprom and reserve enough space for
  * storing new bad pages
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +2 -0
index f2ad999993f6..e89c95438a88 100644
@@ -549,6 +549,8 @@ int amdgpu_ras_add_bad_pages(struct amdgpu_device *adev,
 
 int amdgpu_ras_save_bad_pages(struct amdgpu_device *adev);
 
+int amdgpu_ras_umc_new_ue_count(struct amdgpu_device *adev);
+
 static inline enum ta_ras_block
 amdgpu_ras_block_to_ta(enum amdgpu_ras_block block) {
 	switch (block) {
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +2 -0
index 1c7fcb4f2380..45b6be7277dd 100644
@@ -147,6 +147,8 @@ static int amdgpu_umc_do_page_retirement(struct amdgpu_device *adev,
 			err_data->err_addr_cnt) {
 			amdgpu_ras_add_bad_pages(adev, err_data->err_addr,
 						err_data->err_addr_cnt);
+			err_data->ue_count = amdgpu_ras_umc_new_ue_count(adev);
+
 			amdgpu_ras_save_bad_pages(adev);
 
 			amdgpu_dpm_send_hbm_bad_pages_num(adev, con->eeprom_control.ras_num_recs);

--
2.35.1