drm/amdgpu: add RAS page retirement functions for MCA
Subsystems (3)
PATCH 1/4 drm/amdgpu: add RAS page retirement functions for MCA
Define page retirement functions for MCA platform.
v2: remove page retirement handling from MCA poison handler,
let MCA notifier do page retirement.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 67 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h | 2 + 2 files changed, 69 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +67 -0
@@ -22,6 +22,73 @@*/ #include "amdgpu.h" +#include "umc_v6_7.h" + +static int amdgpu_umc_convert_error_address (struct amdgpu_device *adev, +struct ras_err_data *err_data,uint64_t err_addr, +uint32_t ch_inst,uint32_t umc_inst) +{ +switch (adev->ip_versions[UMC_HWIP ][0 ]) { +case IP_VERSION (6 ,7 ,0 ): +umc_v6_7_convert_error_address (adev, + err_data, err_addr, ch_inst, umc_inst); +break ; +default : +dev_warn (adev->dev, +"UMC address to Physical address translation is not supported\n" ); +return AMDGPU_RAS_FAIL ; + } + +return AMDGPU_RAS_SUCCESS ; +} + +int amdgpu_umc_page_retirement_mca (struct amdgpu_device *adev, +uint64_t err_addr,uint32_t ch_inst,uint32_t umc_inst) +{ +struct ras_err_data err_data = {0 ,0 ,0 ,NULL }; +int ret =AMDGPU_RAS_FAIL ; + + err_data.err_addr = +kcalloc (adev->umc.max_ras_err_cnt_per_query, +sizeof (struct eeprom_table_record ),GFP_KERNEL ); +if (!err_data.err_addr) { +dev_warn (adev->dev, +"Failed to alloc memory for umc error record in MCA notifier!\n" ); +return AMDGPU_RAS_FAIL ; + } + +/* +* Translate UMC channel address to Physical address +*/ + ret =amdgpu_umc_convert_error_address (adev, &err_data, err_addr, + ch_inst, umc_inst); +if (ret) + goto out; + +if (amdgpu_bad_page_threshold !=0 ) { +amdgpu_ras_add_bad_pages (adev, err_data.err_addr, + err_data.err_addr_cnt); +amdgpu_ras_save_bad_pages (adev); + } + +out: +kfree (err_data.err_addr); +return ret; +} + +static int amdgpu_umc_poison_handler_mca (struct amdgpu_device *adev, +struct ras_err_data *err_data,bool reset) +{ +/* MCA poison handler is only responsible for GPU reset, +* let MCA notifier do page retirement. +*/ +if (reset) { +kgd2kfd_set_sram_ecc_flag (adev->kfd.dev); +amdgpu_ras_reset_gpu (adev); + } + +return AMDGPU_RAS_SUCCESS ; +} static int amdgpu_umc_do_page_retirement(struct amdgpu_device *adev, void *ras_error_status,
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +2 -0
@@ -98,4 +98,6 @@ void amdgpu_umc_fill_error_record(struct ras_err_data *err_data,int amdgpu_umc_process_ras_data_cb (struct amdgpu_device *adev,void *ras_error_status,struct amdgpu_iv_entry *entry); +int amdgpu_umc_page_retirement_mca (struct amdgpu_device *adev, +uint64_t err_addr,uint32_t ch_inst,uint32_t umc_inst);#endif
Signature · 1 line
2.35.1
PATCH 2/4 drm/amdgpu: use page retirement API in MCA notifier
Make the code more readable.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 36 +++---------------------- 1 file changed, 3 insertions(+), 33 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +3 -33
@@ -36,7 +36,6 @@#include "ivsrcid/nbio/irqsrcs_nbif_7_4.h" #include "atom.h" #include "amdgpu_reset.h" -#include "umc_v6_7.h" #ifdef CONFIG_X86_MCE_AMD #include <asm/mce.h>
@@ -2849,7 +2848,6 @@ static int amdgpu_bad_page_notifier(struct notifier_block *nb,struct amdgpu_device *adev =NULL ;uint32_t gpu_id =0 ;uint32_t umc_inst =0 , ch_inst =0 ; -struct ras_err_data err_data = {0 ,0 ,0 ,NULL };/* * If the error was generated in UMC_V2, which belongs to GPU UMCs,
@@ -2888,38 +2886,10 @@ static int amdgpu_bad_page_notifier(struct notifier_block *nb,dev_info (adev->dev,"Uncorrectable error detected in UMC inst: %d, chan_idx: %d" , umc_inst, ch_inst); - err_data.err_addr = -kcalloc (adev->umc.max_ras_err_cnt_per_query, -sizeof (struct eeprom_table_record ),GFP_KERNEL ); -if (!err_data.err_addr) { -dev_warn (adev->dev, -"Failed to alloc memory for umc error record in mca notifier!\n" ); -return NOTIFY_DONE ; - } - -/* -* Translate UMC channel address to Physical address -*/ -switch (adev->ip_versions[UMC_HWIP ][0 ]) { -case IP_VERSION (6 ,7 ,0 ): -umc_v6_7_convert_error_address (adev, - &err_data, m->addr, ch_inst, umc_inst); -break ; -default : -dev_warn (adev->dev, -"UMC address to Physical address translation is not supported\n" ); -kfree (err_data.err_addr); +if (!amdgpu_umc_page_retirement_mca (adev, m->addr, ch_inst, umc_inst)) +return NOTIFY_OK ; +else return NOTIFY_DONE ; - } - -if (amdgpu_bad_page_threshold !=0 ) { -amdgpu_ras_add_bad_pages (adev, err_data.err_addr, - err_data.err_addr_cnt); -amdgpu_ras_save_bad_pages (adev); - } - -kfree (err_data.err_addr); -return NOTIFY_OK ; }static struct notifier_block amdgpu_bad_page_nb = {
Signature · 1 line
2.35.1
PATCH 3/4 drm/amdgpu: add RAS poison handling for MCA
In reply to Tao ZhouFor MCA poison, if unmap queue fails, only gpu reset should be triggered without page retirement handling, MCA notifier will do it.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 27 +++++++++++++++---------- 1 file changed, 16 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +16 -11
@@ -184,18 +184,23 @@ int amdgpu_umc_poison_handler(struct amdgpu_device *adev, bool reset) {int ret; -struct ras_err_data *err_data = (struct ras_err_data *)ras_error_status; -struct ras_common_if head = { - .block =AMDGPU_RAS_BLOCK__UMC , - }; -struct ras_manager *obj =amdgpu_ras_find_obj (adev, &head); - ret = -amdgpu_umc_do_page_retirement (adev, ras_error_status,NULL , reset); - -if (ret ==AMDGPU_RAS_SUCCESS && obj) { - obj->err_data.ue_count += err_data->ue_count; - obj->err_data.ce_count += err_data->ce_count; +if (adev->gmc.xgmi.connected_to_cpu) { + ret =amdgpu_umc_poison_handler_mca (adev, ras_error_status, reset); + }else { +struct ras_err_data *err_data = (struct ras_err_data *)ras_error_status; +struct ras_common_if head = { + .block =AMDGPU_RAS_BLOCK__UMC , + }; +struct ras_manager *obj =amdgpu_ras_find_obj (adev, &head); + + ret = +amdgpu_umc_do_page_retirement (adev, ras_error_status,NULL , reset); + +if (ret ==AMDGPU_RAS_SUCCESS && obj) { + obj->err_data.ue_count += err_data->ue_count; + obj->err_data.ce_count += err_data->ce_count; + } }return ret;
Signature · 1 line
2.35.1
PATCH 4/4 drm/amdgpu: remove ras_error_status parameter for UMC poison handler
In reply to Tao ZhouMake the code more simple.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 4 +--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 3 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 16 ++++++---------- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h | 4 +--- 4 files changed, 9 insertions(+), 18 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +1 -3
@@ -753,9 +753,7 @@ bool amdgpu_amdkfd_have_atomics_support(struct amdgpu_device *adev)void amdgpu_amdkfd_ras_poison_consumption_handler (struct amdgpu_device *adev,bool reset) { -struct ras_err_data err_data = {0 ,0 ,0 ,NULL }; - -amdgpu_umc_poison_handler (adev, &err_data, reset); +amdgpu_umc_poison_handler (adev, reset); }bool amdgpu_amdkfd_ras_query_utcl2_poison_status (struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -2
@@ -1561,7 +1561,6 @@ static void amdgpu_ras_interrupt_poison_consumption_handler(struct ras_manager * {bool poison_stat = false;struct amdgpu_device *adev = obj->adev; -struct ras_err_data err_data = {0 ,0 ,0 ,NULL };struct amdgpu_ras_block_object *block_obj =amdgpu_ras_get_ras_block (adev, obj->head.block,0 );
@@ -1584,7 +1583,7 @@ static void amdgpu_ras_interrupt_poison_consumption_handler(struct ras_manager * }if (!adev->gmc.xgmi.connected_to_cpu) -amdgpu_umc_poison_handler (adev, &err_data, false); +amdgpu_umc_poison_handler (adev, false);if (block_obj->hw_ops->handle_poison_consumption) poison_stat = block_obj->hw_ops->handle_poison_consumption (adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +6 -10
@@ -179,27 +179,23 @@ static int amdgpu_umc_do_page_retirement(struct amdgpu_device *adev,return AMDGPU_RAS_SUCCESS ; } -int amdgpu_umc_poison_handler (struct amdgpu_device *adev, -void *ras_error_status, -bool reset) +int amdgpu_umc_poison_handler (struct amdgpu_device *adev,bool reset) { +struct ras_err_data err_data = {0 ,0 ,0 ,NULL };int ret;if (adev->gmc.xgmi.connected_to_cpu) { - ret =amdgpu_umc_poison_handler_mca (adev, ras_error_status, reset); + ret =amdgpu_umc_poison_handler_mca (adev, &err_data, reset); }else { -struct ras_err_data *err_data = (struct ras_err_data *)ras_error_status;struct ras_common_if head = { .block =AMDGPU_RAS_BLOCK__UMC , };struct ras_manager *obj =amdgpu_ras_find_obj (adev, &head); - ret = -amdgpu_umc_do_page_retirement (adev, ras_error_status,NULL , reset); - + ret =amdgpu_umc_do_page_retirement (adev, &err_data,NULL , reset);if (ret ==AMDGPU_RAS_SUCCESS && obj) { - obj->err_data.ue_count += err_data->ue_count; - obj->err_data.ce_count += err_data->ce_count; + obj->err_data.ue_count += err_data.ue_count; + obj->err_data.ce_count += err_data.ce_count; } }
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +1 -3
@@ -83,9 +83,7 @@ struct amdgpu_umc { };int amdgpu_umc_ras_late_init (struct amdgpu_device *adev,struct ras_common_if *ras_block); -int amdgpu_umc_poison_handler (struct amdgpu_device *adev, -void *ras_error_status, -bool reset); +int amdgpu_umc_poison_handler (struct amdgpu_device *adev,bool reset);int amdgpu_umc_process_ecc_irq (struct amdgpu_device *adev,struct amdgpu_irq_src *source,struct amdgpu_iv_entry *entry);
Signature · 1 line
2.35.1
RE: [PATCH 4/4] drm/amdgpu: remove ras_error_status parameter for UMC poison handler
[AMD Official Use Only - General]
Might squash this with patch 1
Regards,
Hawking
-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Wednesday, October 19, 2022 16:12
To: [email protected]; Zhang, Hawking <[email protected]>; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 4/4] drm/amdgpu: remove ras_error_status parameter for UMC poison handler
Make the code more simple.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 4 +--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 3 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 16 ++++++---------- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h | 4 +--- 4 files changed, 9 insertions(+), 18 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +1 -3
@@ -753,9 +753,7 @@ bool amdgpu_amdkfd_have_atomics_support(struct amdgpu_device *adev)void amdgpu_amdkfd_ras_poison_consumption_handler (struct amdgpu_device *adev,bool reset) { -struct ras_err_data err_data = {0 ,0 ,0 ,NULL }; - -amdgpu_umc_poison_handler (adev, &err_data, reset); +amdgpu_umc_poison_handler (adev, reset); } bool amdgpu_amdkfd_ras_query_utcl2_poison_status(struct amdgpu_device *adev) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index 28463b47ce33..693bce07eb46 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -2
@@ -1561,7 +1561,6 @@ static void amdgpu_ras_interrupt_poison_consumption_handler(struct ras_manager * {bool poison_stat = false;struct amdgpu_device *adev = obj->adev; -struct ras_err_data err_data = {0 ,0 ,0 ,NULL };struct amdgpu_ras_block_object *block_obj =amdgpu_ras_get_ras_block (adev, obj->head.block,0 );
@@ -1584,7 +1583,7 @@ static void amdgpu_ras_interrupt_poison_consumption_handler(struct ras_manager * }if (!adev->gmc.xgmi.connected_to_cpu) -amdgpu_umc_poison_handler (adev, &err_data, false); +amdgpu_umc_poison_handler (adev, false);if (block_obj->hw_ops->handle_poison_consumption) poison_stat = block_obj->hw_ops->handle_poison_consumption (adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +6 -10
@@ -179,27 +179,23 @@ static int amdgpu_umc_do_page_retirement(struct amdgpu_device *adev,return AMDGPU_RAS_SUCCESS ; } -int amdgpu_umc_poison_handler (struct amdgpu_device *adev, -void *ras_error_status, -bool reset) +int amdgpu_umc_poison_handler (struct amdgpu_device *adev,bool reset) { +struct ras_err_data err_data = {0 ,0 ,0 ,NULL };int ret;if (adev->gmc.xgmi.connected_to_cpu) { - ret =amdgpu_umc_poison_handler_mca (adev, ras_error_status, reset); + ret =amdgpu_umc_poison_handler_mca (adev, &err_data, reset); }else { -struct ras_err_data *err_data = (struct ras_err_data *)ras_error_status;struct ras_common_if head = { .block =AMDGPU_RAS_BLOCK__UMC , };struct ras_manager *obj =amdgpu_ras_find_obj (adev, &head); - ret = -amdgpu_umc_do_page_retirement (adev, ras_error_status,NULL , reset); - + ret =amdgpu_umc_do_page_retirement (adev, &err_data,NULL , reset);if (ret ==AMDGPU_RAS_SUCCESS && obj) { - obj->err_data.ue_count += err_data->ue_count; - obj->err_data.ce_count += err_data->ce_count; + obj->err_data.ue_count += err_data.ue_count; + obj->err_data.ce_count += err_data.ce_count; } }
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +1 -3
@@ -83,9 +83,7 @@ struct amdgpu_umc { }; int amdgpu_umc_ras_late_init(struct amdgpu_device *adev, struct ras_common_if *ras_block); -int amdgpu_umc_poison_handler(struct amdgpu_device *adev, - void *ras_error_status, - bool reset); +int amdgpu_umc_poison_handler(struct amdgpu_device *adev, bool reset);int amdgpu_umc_process_ecc_irq (struct amdgpu_device *adev,struct amdgpu_irq_src *source,struct amdgpu_iv_entry *entry); --
2.35.1
RE: [PATCH 4/4] drm/amdgpu: remove ras_error_status parameter for UMC poison handler
[AMD Official Use Only - General]
Quoted 9 lines
-----Original Message-----
From: Zhang, Hawking <[email protected]>
Sent: Thursday, October 20, 2022 5:30 PM
To: Zhou1, Tao <[email protected]>; [email protected]; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>
Subject: RE: [PATCH 4/4] drm/amdgpu: removeras_error_statusparameter for UMC poison handler
Quoted 3 lines
[AMD Official Use Only - General]
Might squash this with patch 1
[Tao] This is a refinement different from patch#1. Both ways are OK but I prefer leaving the patch alone.
Quoted 129 lines
Regards,
Hawking-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Wednesday, October 19, 2022 16:12
To: [email protected]; Zhang, Hawking <[email protected]>; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 4/4] drm/amdgpu: removeras_error_statusparameter for UMC poison handlerMake the code more simple.
Signed-off-by Tao Zhou <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 4 +--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 3 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 16 ++++++---------- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h | 4 +--- 4 files changed, 9 insertions(+), 18 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +1
-3@@ -753,9 +753,7 @@ bool amdgpu_amdkfd_have_atomics_support(struct amdgpu_device *adev)void amdgpu_amdkfd_ras_poison_consumption_handler (struct amdgpu_device *adev,bool reset) { -struct ras_err_data err_data = {0 ,0 ,0 ,NULL }; - -amdgpu_umc_poison_handler (adev, &err_data, reset); +amdgpu_umc_poison_handler (adev, reset); }bool amdgpu_amdkfd_ras_query_utcl2_poison_status(struct
amdgpu_device
*adev) diff --gita/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index28463b47ce33..693bce07eb46100644drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0
-1@@ -1561,7 +1561,6 @@ static void amdgpu_ras_interrupt_poison_consumption_handler(struct ras_manager * {bool poison_stat = false;struct amdgpu_device *adev = obj->adev; -struct ras_err_data err_data = {0 ,0 ,0 ,NULL };struct amdgpu_ras_block_object *block_obj =amdgpu_ras_get_ras_block (adev, obj->head.block,0 );@@ -1584,7 +1583,7 @@ static voidamdgpu_ras_interrupt_poison_consumption_handler(struct
ras_manager*drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1
-1}if (!adev->gmc.xgmi.connected_to_cpu) -amdgpu_umc_poison_handler (adev, &err_data, false); +amdgpu_umc_poison_handler (adev, false);if (block_obj->hw_ops->handle_poison_consumption) poison_stat = block_obj->hw_ops-Quoted 1 line
handle_poison_consumption(adev);drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +4
-8@@ -179,27 +179,23 @@ static int amdgpu_umc_do_page_retirement(structamdgpu_device *adev, return AMDGPU_RAS_SUCCESS; } -int amdgpu_umc_poison_handler (struct amdgpu_device *adev, -void *ras_error_status, -bool reset) +int amdgpu_umc_poison_handler (struct amdgpu_device *adev,bool reset) { +struct ras_err_data err_data = {0 ,0 ,0 ,NULL };int ret;if (adev->gmc.xgmi.connected_to_cpu) { - ret =amdgpu_umc_poison_handler_mca (adev, ras_error_status, reset); + ret =amdgpu_umc_poison_handler_mca (adev, &err_data, reset); }else { -struct ras_err_data *err_data = (struct ras_err_data *)ras_error_status;struct ras_common_if head = { .block =AMDGPU_RAS_BLOCK__UMC , };struct ras_manager *obj =amdgpu_ras_find_obj (adev, &head); - ret = -amdgpu_umc_do_page_retirement (adev, ras_error_status, NULL, reset); - + ret =amdgpu_umc_do_page_retirement (adev, &err_data,NULL , reset);drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +2
-2if (ret ==AMDGPU_RAS_SUCCESS && obj) { - obj->err_data.ue_count += err_data->ue_count; - obj->err_data.ce_count += err_data->ce_count; + obj->err_data.ue_count += err_data.ue_count; + obj->err_data.ce_count += err_data.ce_count; } }drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +0
-0@@ -83,9 +83,7 @@ struct amdgpu_umc { }; int amdgpu_umc_ras_late_init(struct amdgpu_device *adev, struct
ras_common_if*ras_block); -int amdgpu_umc_poison_handler(structamdgpu_device*adev,drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +1
-3-void *ras_error_status, - bool reset); +int amdgpu_umc_poison_handler (struct amdgpu_device *adev,bool reset);int amdgpu_umc_process_ecc_irq (struct amdgpu_device *adev,struct amdgpu_irq_src *source,struct amdgpu_iv_entry *entry); --2.35.1
[AMD Official Use Only - General]
+static int amdgpu_umc_poison_handler_mca(struct amdgpu_device *adev,
+ struct ras_err_data *err_data, bool reset)
+ if (adev->gmc.xgmi.connected_to_cpu) {
+ ret = amdgpu_umc_poison_handler_mca(adev, ras_error_status, reset);
The input parameters "reset" and "err_data" can be dropped since amdgpu_umc_poison_handler_mca is dedicated to MCA platform
Regards,
Hawking
-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Wednesday, October 19, 2022 16:12
To: [email protected]; Zhang, Hawking <[email protected]>; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 1/4] drm/amdgpu: add RAS page retirement functions for MCA
Define page retirement functions for MCA platform.
v2: remove page retirement handling from MCA poison handler,
let MCA notifier do page retirement.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 67 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h | 2 + 2 files changed, 69 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +64 -0
@@ -22,6 +22,73 @@*/ #include "amdgpu.h" +#include "umc_v6_7.h" + +static int amdgpu_umc_convert_error_address (struct amdgpu_device *adev, +struct ras_err_data *err_data,uint64_t err_addr, +uint32_t ch_inst,uint32_t umc_inst) { +switch (adev->ip_versions[UMC_HWIP ][0 ]) { +case IP_VERSION (6 ,7 ,0 ): +umc_v6_7_convert_error_address (adev, + err_data, err_addr, ch_inst, umc_inst); +break ; +default : +dev_warn (adev->dev, +"UMC address to Physical address translation is not supported\n" ); +return AMDGPU_RAS_FAIL ; + } + +return AMDGPU_RAS_SUCCESS ; +} + +int amdgpu_umc_page_retirement_mca (struct amdgpu_device *adev, +uint64_t err_addr,uint32_t ch_inst,uint32_t umc_inst) { +struct ras_err_data err_data = {0 ,0 ,0 ,NULL }; +int ret =AMDGPU_RAS_FAIL ; + + err_data.err_addr = +kcalloc (adev->umc.max_ras_err_cnt_per_query, +sizeof (struct eeprom_table_record ),GFP_KERNEL ); +if (!err_data.err_addr) { +dev_warn (adev->dev, +"Failed to alloc memory for umc error record in MCA notifier!\n" ); +return AMDGPU_RAS_FAIL ; + } + +/* +* Translate UMC channel address to Physical address +*/ + ret =amdgpu_umc_convert_error_address (adev, &err_data, err_addr, + ch_inst, umc_inst); +if (ret) + goto out; + +if (amdgpu_bad_page_threshold !=0 ) { +amdgpu_ras_add_bad_pages (adev, err_data.err_addr, + err_data.err_addr_cnt); +amdgpu_ras_save_bad_pages (adev); + } + +out: +kfree (err_data.err_addr); +return ret; +} + +static int amdgpu_umc_poison_handler_mca (struct amdgpu_device *adev, +struct ras_err_data *err_data,bool reset) { +/* MCA poison handler is only responsible for GPU reset, +* let MCA notifier do page retirement. +*/ +if (reset) { +kgd2kfd_set_sram_ecc_flag (adev->kfd.dev); +amdgpu_ras_reset_gpu (adev); + } + +return AMDGPU_RAS_SUCCESS ; +} static int amdgpu_umc_do_page_retirement(struct amdgpu_device *adev, void *ras_error_status,
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +2 -1
@@ -98,4 +98,6 @@ void amdgpu_umc_fill_error_record(struct ras_err_data *err_data, int amdgpu_umc_process_ras_data_cb(struct amdgpu_device *adev,void *ras_error_status, struct amdgpu_iv_entry *entry); +int amdgpu_umc_page_retirement_mca (struct amdgpu_device *adev, +uint64_t err_addr,uint32_t ch_inst,uint32_t umc_inst);#endif --
2.35.1
[AMD Official Use Only - General]
Quoted 19 lines
-----Original Message-----
From: Zhang, Hawking <[email protected]>
Sent: Thursday, October 20, 2022 5:13 PM
To: Zhou1, Tao <[email protected]>; [email protected]; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>
Subject: RE: [PATCH 1/4] drm/amdgpu: add RAS page retirement functions for MCA[AMD Official Use Only - General]
(quoted diff) +4
-0+static int amdgpu_umc_poison_handler_mca(struct amdgpu_device *adev, + struct ras_err_data *err_data, bool reset) + if (adev->gmc.xgmi.connected_to_cpu) { + ret = amdgpu_umc_poison_handler_mca(adev,
ras_error_status, reset);
Quoted 2 lines
The input parameters "reset" and "
err_data" can be dropped sinceamdgpu_umc_poison_handler_mcais dedicated to MCA platform
[Tao] whether need to do gpu reset is determined by unmap queue status, so reset parameter can't be dropped. For "err_data", it can be removed currently, but I'm afraid we may need it on other ASICs in the future.
Quoted 119 lines
Regards,
Hawking-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Wednesday, October 19, 2022 16:12
To: [email protected]; Zhang, Hawking <[email protected]>; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 1/4] drm/amdgpu: add RAS page retirement functions for MCADefine page retirement functions for MCA platform.
v2: remove page retirement handling from MCA poison handler,
let MCA notifier do page retirement.Signed-off-by Tao Zhou <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 67 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h | 2 + 2 files changed, 69 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +30
-0@@ -22,6 +22,73 @@*/ #include "amdgpu.h" +#include "umc_v6_7.h" + +static int amdgpu_umc_convert_error_address (struct amdgpu_device *adev, +struct ras_err_data *err_data,uint64_t err_addr, +uint32_t ch_inst,uint32_t umc_inst) { +switch (adev->ip_versions[UMC_HWIP ][0 ]) { +case IP_VERSION (6 ,7 ,0 ): +umc_v6_7_convert_error_address (adev, + err_data, err_addr, ch_inst, umc_inst); +break ; +default : +dev_warn (adev->dev, +"UMC address to Physical address translation is not supported\n"); +return AMDGPU_RAS_FAIL ; + } + +return AMDGPU_RAS_SUCCESS ; +} + +int amdgpu_umc_page_retirement_mca (struct amdgpu_device *adev, +uint64_t err_addr,uint32_t ch_inst,uint32_t umc_inst) { +struct ras_err_data err_data = {0 ,0 ,0 ,NULL }; +int ret =AMDGPU_RAS_FAIL ; + + err_data.err_addr = +kcalloc (adev->umc.max_ras_err_cnt_per_query, +sizeof (struct eeprom_table_record ),GFP_KERNEL ); +if (!err_data.err_addr) { + dev_warn(adev->dev, + "Failed to alloc memory for umc error record in MCAnotifier!\n");
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +34
-0+return AMDGPU_RAS_FAIL ; + } + +/* +* Translate UMC channel address to Physical address +*/ + ret =amdgpu_umc_convert_error_address (adev, &err_data, err_addr, + ch_inst, umc_inst); +if (ret) + goto out; + +if (amdgpu_bad_page_threshold !=0 ) { +amdgpu_ras_add_bad_pages (adev, err_data.err_addr, + err_data.err_addr_cnt); +amdgpu_ras_save_bad_pages (adev); + } + +out: +kfree (err_data.err_addr); +return ret; +} + +static int amdgpu_umc_poison_handler_mca (struct amdgpu_device *adev, +struct ras_err_data *err_data,bool reset) { +/* MCA poison handler is only responsible for GPU reset, +* let MCA notifier do page retirement. +*/ +if (reset) { +kgd2kfd_set_sram_ecc_flag (adev->kfd.dev); +amdgpu_ras_reset_gpu (adev); + } + +return AMDGPU_RAS_SUCCESS ; +} static int amdgpu_umc_do_page_retirement(struct amdgpu_device *adev, void *ras_error_status,drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +2
-1@@ -98,4 +98,6 @@ void amdgpu_umc_fill_error_record(struct ras_err_data *err_data, int amdgpu_umc_process_ras_data_cb(struct amdgpu_device *adev, void *ras_error_status, struct amdgpu_iv_entry *entry); +int amdgpu_umc_page_retirement_mca (struct amdgpu_device *adev, +uint64_t err_addr,uint32_t ch_inst,uint32_t umc_inst);#endif --2.35.1
[AMD Official Use Only - General]
Re - whether need to do gpu reset is determined by unmap queue status, so reset parameter can't be dropped
+ if (adev->gmc.xgmi.connected_to_cpu) {
+ ret = amdgpu_umc_poison_handler_mca(adev, ras_error_status, reset);
I think amdgpu_umc_poison_handler_mca is fallback handler specific for MCA platform, right?
I noticed there is platform check already in amdgpu_umc_poison_handler with the reset flag. so driver already knows whether the reset is needed, right. That's why I think "ras_error_status", "reset" are all not necessary. You can either call the followings directly by checking connected_to_cpu && reset,
+ kgd2kfd_set_sram_ecc_flag(adev->kfd.dev);
+ amdgpu_ras_reset_gpu(adev);
Or still provide a wrapper like amdgpu_umc_poison_handler_mca for above two calls.
The latter seems redundant as well. I mean, we don't need to maintain a specific API for poison handling fallback on MCA platform - Aldebaran is the last SOC that supports this A + A RAS design. I can confirm we'll move to a new design going forward.
Regards,
Hawking
-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Friday, October 21, 2022 10:54
To: Zhang, Hawking <[email protected]>; [email protected]; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>
Subject: RE: [PATCH 1/4] drm/amdgpu: add RAS page retirement functions for MCA
[AMD Official Use Only - General]
Quoted 19 lines
-----Original Message-----
From: Zhang, Hawking <[email protected]>
Sent: Thursday, October 20, 2022 5:13 PM
To: Zhou1, Tao <[email protected]>; [email protected]; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>
Subject: RE: [PATCH 1/4] drm/amdgpu: add RAS page retirement functions for MCA[AMD Official Use Only - General]
(quoted diff) +4
-0+static int amdgpu_umc_poison_handler_mca(struct amdgpu_device *adev, + struct ras_err_data *err_data, bool reset) + if (adev->gmc.xgmi.connected_to_cpu) { + ret = amdgpu_umc_poison_handler_mca(adev,
ras_error_status, reset);
Quoted 2 lines
The input parameters "reset" and "
err_data" can be dropped sinceamdgpu_umc_poison_handler_mcais dedicated to MCA platform
[Tao] whether need to do gpu reset is determined by unmap queue status, so reset parameter can't be dropped. For "err_data", it can be removed currently, but I'm afraid we may need it on other ASICs in the future.
Quoted 120 lines
Regards,
Hawking-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Wednesday, October 19, 2022 16:12
To: [email protected]; Zhang, Hawking <[email protected]>; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 1/4] drm/amdgpu: add RAS page retirement functions for MCADefine page retirement functions for MCA platform.
v2: remove page retirement handling from MCA poison handler,
let MCA notifier do page retirement.Signed-off-by Tao Zhou <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 67 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h | 2 + 2 files changed, 69 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +30
-0@@ -22,6 +22,73 @@*/ #include "amdgpu.h" +#include "umc_v6_7.h" + +static int amdgpu_umc_convert_error_address (struct amdgpu_device *adev, +struct ras_err_data *err_data,uint64_t err_addr, +uint32_t ch_inst,uint32_t umc_inst) { +switch (adev->ip_versions[UMC_HWIP ][0 ]) { +case IP_VERSION (6 ,7 ,0 ): +umc_v6_7_convert_error_address (adev, + err_data, err_addr, ch_inst, umc_inst); +break ; +default : +dev_warn (adev->dev, +"UMC address to Physical address translation is not supported\n"); +return AMDGPU_RAS_FAIL ; + } + +return AMDGPU_RAS_SUCCESS ; +} + +int amdgpu_umc_page_retirement_mca (struct amdgpu_device *adev, +uint64_t err_addr,uint32_t ch_inst,uint32_t umc_inst) { +struct ras_err_data err_data = {0 ,0 ,0 ,NULL }; +int ret =AMDGPU_RAS_FAIL ; + + err_data.err_addr = +kcalloc (adev->umc.max_ras_err_cnt_per_query, +sizeof (struct eeprom_table_record ),GFP_KERNEL ); +if (!err_data.err_addr) { + dev_warn(adev->dev, + "Failed to alloc memory for umc error record in MCAnotifier!\n");
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +34
-0+return AMDGPU_RAS_FAIL ; + } + +/* +* Translate UMC channel address to Physical address +*/ + ret =amdgpu_umc_convert_error_address (adev, &err_data, err_addr, + ch_inst, umc_inst); +if (ret) + goto out; + +if (amdgpu_bad_page_threshold !=0 ) { +amdgpu_ras_add_bad_pages (adev, err_data.err_addr, + err_data.err_addr_cnt); +amdgpu_ras_save_bad_pages (adev); + } + +out: +kfree (err_data.err_addr); +return ret; +} + +static int amdgpu_umc_poison_handler_mca (struct amdgpu_device *adev, +struct ras_err_data *err_data,bool reset) { +/* MCA poison handler is only responsible for GPU reset, +* let MCA notifier do page retirement. +*/ +if (reset) { +kgd2kfd_set_sram_ecc_flag (adev->kfd.dev); +amdgpu_ras_reset_gpu (adev); + } + +return AMDGPU_RAS_SUCCESS ; +} static int amdgpu_umc_do_page_retirement(struct amdgpu_device *adev, void *ras_error_status,drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +2
-1@@ -98,4 +98,6 @@ void amdgpu_umc_fill_error_record(struct ras_err_data *err_data, int amdgpu_umc_process_ras_data_cb(struct amdgpu_device *adev,void *ras_error_status,struct amdgpu_iv_entry *entry); +int amdgpu_umc_page_retirement_mca (struct amdgpu_device *adev, +uint64_t err_addr,uint32_t ch_inst,uint32_t umc_inst);#endif --2.35.1
[AMD Official Use Only - General]
Quoted 32 lines
-----Original Message-----
From: Zhang, Hawking <[email protected]>
Sent: Friday, October 21, 2022 12:15 PM
To: Zhou1, Tao <[email protected]>; [email protected]; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>
Subject: RE: [PATCH 1/4] drm/amdgpu: add RAS page retirement functions for MCA[AMD Official Use Only - General]
Re - whether need to do gpu reset is determined by unmap queue status, so reset parameter can't be dropped
(quoted diff) +2
-0+ if (adev->gmc.xgmi.connected_to_cpu) { + ret = amdgpu_umc_poison_handler_mca(adev,
ras_error_status, reset);I think
amdgpu_umc_poison_handler_mcais fallback handler specific for MCA platform, right?I noticed there is platform check already in
amdgpu_umc_poison_handlerwith the reset flag. so driver already knows whether the reset is needed, right. That's why I think "ras_error_status", "reset" are all not necessary. You can either call the followings directly by checkingconnected_to_cpu&& reset,drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +2
-0+kgd2kfd_set_sram_ecc_flag (adev->kfd.dev); +amdgpu_ras_reset_gpu (adev);Or still provide a wrapper like
amdgpu_umc_poison_handler_mcafor above two calls.
Quoted 7 lines
The latter seems redundant as well. I mean, we don't need to maintain a specific API for poison handling fallback on MCA platform - Aldebaran is the last SOC that supports this A + A RAS design. I can confirm we'll move to a new design going forward.
Regards,
Hawking
[Tao] adding amdgpu_umc_poison_handler_mca is for better extension, although it only calls gpu reset right now. But since A + A RAS design will change dramatically, I'll remove amdgpu_umc_poison_handler_mca as you suggested.
Quoted 162 lines
-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Friday, October 21, 2022 10:54
To: Zhang, Hawking <[email protected]>; amd- [email protected]; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>
Subject: RE: [PATCH 1/4] drm/amdgpu: add RAS page retirement functions for MCA[AMD Official Use Only - General]
Quoted 19 lines
-----Original Message-----
From: Zhang, Hawking <[email protected]>
Sent: Thursday, October 20, 2022 5:13 PM
To: Zhou1, Tao <[email protected]>; [email protected]; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>
Subject: RE: [PATCH 1/4] drm/amdgpu: add RAS page retirement functions for MCA[AMD Official Use Only - General]
(quoted diff) +4
-0+static int amdgpu_umc_poison_handler_mca(struct amdgpu_device *adev, + struct ras_err_data *err_data, bool reset) + if (adev->gmc.xgmi.connected_to_cpu) { + ret = amdgpu_umc_poison_handler_mca(adev,
ras_error_status, reset);Quoted 2 lines
The input parameters "reset" and "
err_data" can be dropped sinceamdgpu_umc_poison_handler_mcais dedicated to MCA platform[Tao] whether need to do gpu reset is determined by unmap queue status, so reset parameter can't be dropped.
For "err_data", it can be removed currently, but I'm afraid we may need it on other ASICs in the future.Quoted 16 lines
Regards,
Hawking-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Wednesday, October 19, 2022 16:12
To: [email protected]; Zhang, Hawking <[email protected]>; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 1/4] drm/amdgpu: add RAS page retirement functions for MCADefine page retirement functions for MCA platform.
Quoted 7 lines
v2: remove page retirement handling from MCA poison handler,
let MCA notifier do page retirement.Signed-off-by Tao Zhou <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 67+++++++++++++++++++++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.hQuoted 89 lines
| 2 +
2 files changed, 69 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +30
-0@@ -22,6 +22,73 @@*/ #include "amdgpu.h" +#include "umc_v6_7.h" + +static int amdgpu_umc_convert_error_address (struct amdgpu_device *adev, +struct ras_err_data *err_data,uint64_t err_addr, +uint32_t ch_inst,uint32_t umc_inst) { +switch (adev->ip_versions[UMC_HWIP ][0 ]) { +case IP_VERSION (6 ,7 ,0 ): +umc_v6_7_convert_error_address (adev, + err_data, err_addr, ch_inst, umc_inst); +break ; +default : +dev_warn (adev->dev, +"UMC address to Physical address translation is not supported\n"); +return AMDGPU_RAS_FAIL ; + } + +return AMDGPU_RAS_SUCCESS ; +} + +int amdgpu_umc_page_retirement_mca (struct amdgpu_device *adev, +uint64_t err_addr,uint32_t ch_inst,uint32_t umc_inst) { +struct ras_err_data err_data = {0 ,0 ,0 ,NULL }; +int ret =AMDGPU_RAS_FAIL ; + + err_data.err_addr = +kcalloc (adev->umc.max_ras_err_cnt_per_query, +sizeof (struct eeprom_table_record ),GFP_KERNEL ); +if (!err_data.err_addr) { + dev_warn(adev->dev, + "Failed to alloc memory for umc error record in MCAnotifier!\n");
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +34
-0+return AMDGPU_RAS_FAIL ; + } + +/* +* Translate UMC channel address to Physical address +*/ + ret =amdgpu_umc_convert_error_address (adev, &err_data, err_addr, + ch_inst, umc_inst); +if (ret) + goto out; + +if (amdgpu_bad_page_threshold !=0 ) { +amdgpu_ras_add_bad_pages (adev, err_data.err_addr, + err_data.err_addr_cnt); +amdgpu_ras_save_bad_pages (adev); + } + +out: +kfree (err_data.err_addr); +return ret; +} + +static int amdgpu_umc_poison_handler_mca (struct amdgpu_device *adev, +struct ras_err_data *err_data,bool reset) { +/* MCA poison handler is only responsible for GPU reset, +* let MCA notifier do page retirement. +*/ +if (reset) { +kgd2kfd_set_sram_ecc_flag (adev->kfd.dev); +amdgpu_ras_reset_gpu (adev); + } + +return AMDGPU_RAS_SUCCESS ; +} static int amdgpu_umc_do_page_retirement(struct amdgpu_device *adev, void *ras_error_status,drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +0
-0@@ -98,4 +98,6 @@ void amdgpu_umc_fill_error_record(structQuoted 1 line
ras_err_data*err_data, int amdgpu_umc_process_ras_data_cb(struct
amdgpu_device*adev,Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +2
-1void *ras_error_status, struct amdgpu_iv_entry *entry); +int amdgpu_umc_page_retirement_mca (struct amdgpu_device *adev, +uint64_t err_addr,uint32_t ch_inst,uint32_t umc_inst);#endif --2.35.1