drm/amdgpu: add RAS is_rma flag
Subsystems (2)
PATCH 1/2 drm/amdgpu: add RAS is_rma flag
Set the flag to true if bad page number reaches threshold.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 7 +++---- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 10 ++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h | 3 +-- 4 files changed, 11 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +3 -4
@@ -2940,7 +2940,6 @@ int amdgpu_ras_recovery_init(struct amdgpu_device *adev)struct amdgpu_ras *con =amdgpu_ras_get_context (adev);struct ras_err_handler_data **data;u32 max_eeprom_records_count =0 ; -bool exc_err_limit = false;int ret;if (!con ||amdgpu_sriov_vf (adev))
@@ -2977,12 +2976,12 @@ int amdgpu_ras_recovery_init(struct amdgpu_device *adev)*/ if (adev->gmc.xgmi.pending_reset)return 0 ; - ret =amdgpu_ras_eeprom_init (&con->eeprom_control, &exc_err_limit); + ret =amdgpu_ras_eeprom_init (&con->eeprom_control);/* * This calling fails when exc_err_limit is true or * ret != 0. */ -if (exc_err_limit || ret) +if (con->is_rma || ret) goto free;if (con->eeprom_control.ras_num_recs) {
@@ -3033,7 +3032,7 @@ int amdgpu_ras_recovery_init(struct amdgpu_device *adev)* Except error threshold exceeding case, other failure cases in this * function would not fail amdgpu driver init. */ -if (!exc_err_limit) +if (!con->is_rma) ret =0 ;else ret = -EINVAL ;
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +1 -0
@@ -521,6 +521,7 @@ struct amdgpu_ras {bool update_channel_flag;/* Record status of smu mca debug mode */ bool is_aca_debug_mode; +bool is_rma;/* Record special requirements of gpu reset caller */ uint32_t gpu_reset_flags;
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +6 -4
@@ -750,6 +750,9 @@ amdgpu_ras_eeprom_update_header(struct amdgpu_ras_eeprom_control *control) control->tbl_rai.health_percent =0 ; } +if (amdgpu_bad_page_threshold !=-1 ) + ras->is_rma = true; +/* ignore the -ENOTSUPP return value */ amdgpu_dpm_send_rma_reason (adev); }
@@ -1321,8 +1324,7 @@ static int __read_table_ras_info(struct amdgpu_ras_eeprom_control *control)return res ==RAS_TABLE_V2_1_INFO_SIZE ?0 : res; } -int amdgpu_ras_eeprom_init (struct amdgpu_ras_eeprom_control *control, -bool *exceed_err_limit) +int amdgpu_ras_eeprom_init (struct amdgpu_ras_eeprom_control *control) {struct amdgpu_device *adev =to_amdgpu_device (control);unsigned char buf[RAS_TABLE_HEADER_SIZE ] = {0 };
@@ -1330,7 +1332,7 @@ int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control,struct amdgpu_ras *ras =amdgpu_ras_get_context (adev);int res; - *exceed_err_limit = false; + ras->is_rma = false;if (!__is_ras_eeprom_supported (adev))return 0 ;
@@ -1422,7 +1424,7 @@ int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control,dev_warn (adev->dev,"GPU will be initialized due to bad_page_threshold = -1." ); res =0 ; }else { - *exceed_err_limit = true; + ras->is_rma = true; dev_err(adev->dev, "RAS records:%d exceed threshold:%d, " "GPU will not be initialized. Replace this GPU or increase the threshold",
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h +1 -2
@@ -129,8 +129,7 @@ struct eeprom_table_record {unsigned char mcumc_id; } __packed; -int amdgpu_ras_eeprom_init (struct amdgpu_ras_eeprom_control *control, -bool *exceed_err_limit); +int amdgpu_ras_eeprom_init (struct amdgpu_ras_eeprom_control *control);int amdgpu_ras_eeprom_reset_table (struct amdgpu_ras_eeprom_control *control);
Signature · 1 line
2.34.1
PATCH 2/2 drm/amdgpu: trigger mode1 reset for RAS RMA status
Check RMA status in bad page retirement flow.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 16 +++++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 7 +++---- 2 files changed, 16 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +13 -3
@@ -2049,8 +2049,9 @@ static void amdgpu_ras_interrupt_poison_consumption_handler(struct ras_manager *struct amdgpu_device *adev = obj->adev;struct amdgpu_ras_block_object *block_obj =amdgpu_ras_get_ras_block (adev, obj->head.block,0 ); +struct amdgpu_ras *con =amdgpu_ras_get_context (adev); -if (!block_obj) +if (!block_obj || !con)return ;/* both query_poison_status and handle_poison_consumption are optional,
@@ -2074,7 +2075,7 @@ static void amdgpu_ras_interrupt_poison_consumption_handler(struct ras_manager * poison_stat = block_obj->hw_ops->handle_poison_consumption (adev);/* gpu reset is fallback for failed and default cases */ -if (poison_stat) { +if (poison_stat || con->is_rma) {dev_info (adev->dev,"GPU reset for %s RAS poison consumption is issued!\n" , block_obj->ras_comm.name);amdgpu_ras_reset_gpu (adev);
@@ -2817,6 +2818,9 @@ static void amdgpu_ras_do_page_retirement(struct work_struct *work)schedule_delayed_work (&con->page_retirement_dwork,msecs_to_jiffies (AMDGPU_RAS_RETIRE_PAGE_INTERVAL ));mutex_unlock (&con->umc_ecc_log.lock); + +if (err_data->err_addr_cnt && con->is_rma) +amdgpu_ras_reset_gpu (adev); } static void amdgpu_ras_poison_creation_handler(struct amdgpu_device *adev,
@@ -2867,7 +2871,7 @@ static int amdgpu_ras_poison_consumption_handler(struct amdgpu_device *adev,if (poison_msg->pasid_fn) poison_msg->pasid_fn (adev, pasid, poison_msg->data); -if (reset) { +if (reset && !con->is_rma) {flush_delayed_work (&con->page_retirement_dwork); con->gpu_reset_flags |= reset;
@@ -3983,6 +3987,12 @@ int amdgpu_ras_reset_gpu(struct amdgpu_device *adev) {struct amdgpu_ras *ras =amdgpu_ras_get_context (adev); +/* mode1 is the only selection for RMA status */ +if (ras->is_rma) { + ras->gpu_reset_flags =0 ; + ras->gpu_reset_flags |=AMDGPU_RAS_GPU_RESET_MODE1_RESET ; + } +if (atomic_cmpxchg (&ras->in_recovery,0 ,1 ) ==0 )amdgpu_reset_domain_schedule (ras->adev->reset_domain, &ras->recovery_work);return 0 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +3 -4
@@ -195,7 +195,7 @@ static int amdgpu_umc_do_page_retirement(struct amdgpu_device *adev,kgd2kfd_set_sram_ecc_flag (adev->kfd.dev);amdgpu_umc_handle_bad_pages (adev, ras_error_status); -if (err_data->ue_count && reset) { + if ((err_data->ue_count && (reset || con->is_rma)) { con->gpu_reset_flags |= reset;amdgpu_ras_reset_gpu (adev); }
@@ -211,6 +211,7 @@ int amdgpu_umc_bad_page_polling_timeout(struct amdgpu_device *adev, .block = AMDGPU_RAS_BLOCK__UMC, };struct ras_manager *obj =amdgpu_ras_find_obj (adev, &head); +struct amdgpu_ras *con =amdgpu_ras_get_context (adev);uint32_t timeout = timeout_ms;memset (&err_data,0 ,sizeof (err_data));
@@ -243,9 +244,7 @@ int amdgpu_umc_bad_page_polling_timeout(struct amdgpu_device *adev,kgd2kfd_set_sram_ecc_flag (adev->kfd.dev); -if (reset) { -struct amdgpu_ras *con =amdgpu_ras_get_context (adev); - + if (reset || (err_data.err_addr_cnt && con->is_rma) { con->gpu_reset_flags |= reset;amdgpu_ras_reset_gpu (adev); }
Signature · 1 line
2.34.1
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 51 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Tao Zhou
Sent: Thursday, May 23, 2024 6:02 PM
To: [email protected]
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: add RASis_rmaflagSet the flag to true if bad page number reaches threshold.
Signed-off-by Tao Zhou <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 7 +++---- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 10 ++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h | 3 +-- 4 files changed, 11 insertions(+), 10 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0
-1@@ -2940,7 +2940,6 @@ int amdgpu_ras_recovery_init(struct amdgpu_device *adev)struct amdgpu_ras *con =amdgpu_ras_get_context (adev);struct ras_err_handler_data **data;u32 max_eeprom_records_count =0 ; -bool exc_err_limit = false;int ret;if (!con || amdgpu_sriov_vf(adev))drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2
-2@@ -2977,12 +2976,12 @@ int amdgpu_ras_recovery_init(structamdgpu_device *adev) */ if (adev->gmc.xgmi.pending_reset)return 0 ; - ret =amdgpu_ras_eeprom_init (&con->eeprom_control, &exc_err_limit); + ret =amdgpu_ras_eeprom_init (&con->eeprom_control);/* * This calling fails when exc_err_limit is true or * ret != 0. */ -if (exc_err_limit || ret) +if (con->is_rma || ret) goto free;if (con->eeprom_control.ras_num_recs) { @@ -3033,7 +3032,7 @@ int
amdgpu_ras_recovery_init(struct amdgpu_device *adev)
* Except error threshold exceeding case, other failure cases in this
* function would not fail amdgpu driver init.
*/
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c int amdgpu_ras_recovery_init(struct amdgpu_device *adev) · line 3038
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1
-1-if (!exc_err_limit) +if (!con->is_rma) ret =0 ;else ret = -EINVAL ;
[Stanley]: Should stop device service if device is under RMA during running? the amdgpu_ras_recovery_init function only be called during the process of loading driver.
Regards,
Stanley
Quoted 79 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +1
-0@@ -521,6 +521,7 @@ struct amdgpu_ras {bool update_channel_flag;/* Record status of smu mca debug mode */ bool is_aca_debug_mode; +bool is_rma;/* Record special requirements of gpu reset caller */ uint32_t gpu_reset_flags;drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +3
-0@@ -750,6 +750,9 @@ amdgpu_ras_eeprom_update_header(struct amdgpu_ras_eeprom_control *control) control->tbl_rai.health_percent = 0; } +if (amdgpu_bad_page_threshold !=-1 ) + ras->is_rma = true; +/* ignore the -ENOTSUPP return value */ amdgpu_dpm_send_rma_reason (adev);}drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +2
-2@@ -1321,8 +1324,7 @@ static int __read_table_ras_info(struct amdgpu_ras_eeprom_control *control)return res ==RAS_TABLE_V2_1_INFO_SIZE ?0 : res; } -int amdgpu_ras_eeprom_init (struct amdgpu_ras_eeprom_control *control, -bool *exceed_err_limit) +int amdgpu_ras_eeprom_init (struct amdgpu_ras_eeprom_control *control) {struct amdgpu_device *adev =to_amdgpu_device (control); unsigned char buf[RAS_TABLE_HEADER_SIZE] = { 0 }; @@ -1330,7 +1332,7 @@ int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control*control,
struct amdgpu_ras *ras = amdgpu_ras_get_context(adev); int res;drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +2
-2- *exceed_err_limit = false; + ras->is_rma = false;if (!__is_ras_eeprom_supported (adev))return 0 ;@@ -1422,7 +1424,7 @@ int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control, dev_warn(adev->dev, "GPU will be initialized due to bad_page_threshold = -1."); res =0 ; }else { - *exceed_err_limit = true; + ras->is_rma = true; dev_err(adev->dev,"RAS records:%d exceed threshold:%d, " "GPU will not be initialized. Replace this
GPU or increase the threshold", diff --gita/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.hb/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h
index6dfd667f3013..b9ebda577797100644drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h +1
-3@@ -129,8 +129,7 @@ struct eeprom_table_record {unsigned char mcumc_id; } __packed; -int amdgpu_ras_eeprom_init (struct amdgpu_ras_eeprom_control *control, -bool *exceed_err_limit); +int amdgpu_ras_eeprom_init (struct amdgpu_ras_eeprom_control *control);int amdgpu_ras_eeprom_reset_table (struct amdgpu_ras_eeprom_control *control); --2.34.1
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 56 lines
-----Original Message-----
From: Yang, Stanley <[email protected]>
Sent: Thursday, May 23, 2024 9:57 PM
To: Zhou1, Tao <[email protected]>; [email protected]
Cc: Zhou1, Tao <[email protected]>
Subject: RE: [PATCH 1/2] drm/amdgpu: add RASis_rmaflag[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 47 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Tao Zhou
Sent: Thursday, May 23, 2024 6:02 PM
To: [email protected]
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: add RASis_rmaflagSet the flag to true if bad page number reaches threshold.
Signed-off-by Tao Zhou <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 7 +++---- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 10 ++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h | 3 +-- 4 files changed, 11 insertions(+), 10 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0
-0@@ -2940,7 +2940,6 @@ int amdgpu_ras_recovery_init(struct
amdgpu_device
*adev)struct amdgpu_ras *con = amdgpu_ras_get_context(adev); struct ras_err_handler_data **data; u32 max_eeprom_records_count = 0; - bool exc_err_limit = false; int ret; if (!con || amdgpu_sriov_vf(adev)) @@ -2977,12 +2976,12 @@ int amdgpu_ras_recovery_init(struct amdgpu_device *adev) */ if (adev->gmc.xgmi.pending_reset) return 0;drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2
-2- ret =amdgpu_ras_eeprom_init (&con->eeprom_control, &exc_err_limit); + ret =amdgpu_ras_eeprom_init (&con->eeprom_control);/* * This calling fails when exc_err_limit is true or * ret != 0. */ -if (exc_err_limit || ret) +if (con->is_rma || ret) goto free;
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c int amdgpu_ras_recovery_init(struct amdgpu_device *adev) · line 3038
Quoted 10 lines
if (con->eeprom_control.ras_num_recs) { @@ -3033,7 +3032,7 @@int
amdgpu_ras_recovery_init(struct amdgpu_device *adev)
* Except error threshold exceeding case, other failure cases in this
* function would not fail amdgpu driver init.
*/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1
-1-if (!exc_err_limit) +if (!con->is_rma) ret =0 ;else ret = -EINVAL ;[Stanley]: Should stop device service if device is under RMA during running? the
amdgpu_ras_recovery_initfunction only be called during the process of loading driver.
[Tao] yes, I plan to stop service in resume stage after mode-1 if run-time RMA is reported. But I have no environment to verify the design right now, so this is TODO temporarily.
Quoted 84 lines
Regards,
StanleyQuoted 80 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +1
-0@@ -521,6 +521,7 @@ struct amdgpu_ras {bool update_channel_flag;/* Record status of smu mca debug mode */ bool is_aca_debug_mode; +bool is_rma;/* Record special requirements of gpu reset caller */ uint32_t gpu_reset_flags;drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +3
-0@@ -750,6 +750,9 @@ amdgpu_ras_eeprom_update_header(struct amdgpu_ras_eeprom_control *control) control->tbl_rai.health_percent = 0; } +if (amdgpu_bad_page_threshold !=-1 ) + ras->is_rma = true; +/* ignore the -ENOTSUPP return value */ amdgpu_dpm_send_rma_reason (adev);}drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +2
-2@@ -1321,8 +1324,7 @@ static int __read_table_ras_info(struct amdgpu_ras_eeprom_control *control)return res ==RAS_TABLE_V2_1_INFO_SIZE ?0 : res; } -int amdgpu_ras_eeprom_init (struct amdgpu_ras_eeprom_control *control, -bool *exceed_err_limit) +int amdgpu_ras_eeprom_init (struct amdgpu_ras_eeprom_control *control) {struct amdgpu_device *adev =to_amdgpu_device (control); unsigned char buf[RAS_TABLE_HEADER_SIZE] = { 0 }; @@ -1330,7 +1332,7 @@ int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control*control,
struct amdgpu_ras *ras = amdgpu_ras_get_context(adev); int res;drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +2
-2- *exceed_err_limit = false; + ras->is_rma = false;if (!__is_ras_eeprom_supported (adev))return 0 ;@@ -1422,7 +1424,7 @@ int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control, dev_warn(adev->dev, "GPU will be initialized due to bad_page_threshold = -1."); res =0 ; }else { - *exceed_err_limit = true; + ras->is_rma = true; dev_err(adev->dev,"RAS records:%d exceed threshold:%d, " "GPU will not be initialized.
Replace this GPU or increase the threshold", diff --gita/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.hb/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h
index6dfd667f3013..b9ebda577797100644drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h +2
-2@@ -129,8 +129,7 @@ struct eeprom_table_record {unsigned char mcumc_id; } __packed; -int amdgpu_ras_eeprom_init (struct amdgpu_ras_eeprom_control *control, -bool *exceed_err_limit); +int amdgpu_ras_eeprom_init (struct amdgpu_ras_eeprom_control +*control); int amdgpu_ras_eeprom_reset_table(struct amdgpu_ras_eeprom_control*control);
--
2.34.1