drm/amdgpu: refine eeprom data check
Subsystems (2)
PATCH 1/2 drm/amdgpu: refine eeprom data check
add eeprom data checksum check before driver unload. reset eeprom and save correct data to eeprom when check failed
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 1 + .../gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 25 +++++++++++++++++++ .../gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h | 2 ++ 3 files changed, 28 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -0
@@ -2560,6 +2560,7 @@ amdgpu_pci_remove(struct pci_dev *pdev)struct drm_device *dev =pci_get_drvdata (pdev);struct amdgpu_device *adev =drm_to_adev (dev); +amdgpu_ras_eeprom_check_and_recover (adev);amdgpu_xcp_dev_unplug (adev);amdgpu_gmc_prepare_nps_mode_change (adev);drm_dev_unplug (dev);
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +25 -0
@@ -1522,3 +1522,28 @@ int amdgpu_ras_eeprom_check(struct amdgpu_ras_eeprom_control *control)return res <0 ? res :0 ; } + +void amdgpu_ras_eeprom_check_and_recover (struct amdgpu_device *adev) +{ +struct amdgpu_ras *ras =amdgpu_ras_get_context (adev); +struct amdgpu_ras_eeprom_control *control = &ras->eeprom_control; +int res =0 ; + +if (!control->is_eeprom_valid) +return ; + res =__verify_ras_table_checksum (control); +if (res) { +dev_warn (adev->dev, +"RAS table incorrect checksum or error:%d, try to recover\n" , + res); +if (!amdgpu_ras_eeprom_reset_table (control)) +if (!amdgpu_ras_save_bad_pages (adev,NULL )) +if (!__verify_ras_table_checksum (control)) { +dev_info (adev->dev,"RAS table recovery succeed\n" ); +return ; + } +dev_err (adev->dev,"RAS table recovery failed\n" ); + control->is_eeprom_valid = false; + } +return ; +}
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h +2 -0
@@ -161,6 +161,8 @@ void amdgpu_ras_debugfs_set_ret_size(struct amdgpu_ras_eeprom_control *control);int amdgpu_ras_eeprom_check (struct amdgpu_ras_eeprom_control *control); +void amdgpu_ras_eeprom_check_and_recover (struct amdgpu_device *adev); +extern const struct file_operations amdgpu_ras_debugfs_eeprom_size_ops;extern const struct file_operations amdgpu_ras_debugfs_eeprom_table_ops;
Signature · 1 line
2.34.1
PATCH 2/2 drm/amdgpu: refine bad page loading when in the same nps mode
when loading bad page in the same nps mode, need to set the other fields in eeprom records manually besides retired_page
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +15 -0
@@ -2860,6 +2860,13 @@ static int __amdgpu_ras_convert_rec_array_from_rom(struct amdgpu_device *adev,if (amdgpu_umc_pages_in_a_row (adev, err_data, bps[0 ].retired_page <<AMDGPU_GPU_PAGE_SHIFT ))return -EINVAL ; +for (i =0 ; i < adev->umc.retire_unit; i++) { + err_data->err_addr[i].address = bps[0 ].address; + err_data->err_addr[i].mem_channel = bps[0 ].mem_channel; + err_data->err_addr[i].bank = bps[0 ].bank; + err_data->err_addr[i].err_type = bps[0 ].err_type; + err_data->err_addr[i].mcumc_id = bps[0 ].mcumc_id; + } }else {if (amdgpu_ras_mca2pa_by_idx (adev, &bps[0 ], err_data))return -EINVAL ;
@@ -2891,6 +2898,7 @@ static int __amdgpu_ras_convert_rec_from_rom(struct amdgpu_device *adev, struct eeprom_table_record *bps, struct ras_err_data *err_data, enum amdgpu_memory_partition nps) { + int i = 0;enum amdgpu_memory_partition save_nps; save_nps = (bps->retired_page >>UMC_NPS_SHIFT ) &UMC_NPS_MASK ;
@@ -2900,6 +2908,13 @@ static int __amdgpu_ras_convert_rec_from_rom(struct amdgpu_device *adev,if (amdgpu_umc_pages_in_a_row (adev, err_data, bps->retired_page <<AMDGPU_GPU_PAGE_SHIFT ))return -EINVAL ; +for (i =0 ; i < adev->umc.retire_unit; i++) { + err_data->err_addr[i].address = bps->address; + err_data->err_addr[i].mem_channel = bps->mem_channel; + err_data->err_addr[i].bank = bps->bank; + err_data->err_addr[i].err_type = bps->err_type; + err_data->err_addr[i].mcumc_id = bps->mcumc_id; + } }else {if (bps->address) {if (amdgpu_ras_mca2pa_by_idx (adev, bps, err_data))
Signature · 1 line
2.34.1
Quoted 27 lines · ganglxie
add eeprom data checksum check before driver unload. reset eeprom and save correct data to eeprom when check failed
Signed-off-by ganglxie <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 1 + .../gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 25 +++++++++++++++++++ .../gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h | 2 ++ 3 files changed, 28 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1
-0@@ -2560,6 +2560,7 @@ amdgpu_pci_remove(struct pci_dev *pdev)struct drm_device *dev =pci_get_drvdata (pdev);struct amdgpu_device *adev =drm_to_adev (dev); +amdgpu_ras_eeprom_check_and_recover (adev);amdgpu_xcp_dev_unplug (adev);amdgpu_gmc_prepare_nps_mode_change (adev);drm_dev_unplug (dev);drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c int amdgpu_ras_eeprom_check(struct amdgpu_ras_eeprom_control *control) · line 1528
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +4
-0@@ -1522,3 +1522,28 @@ int amdgpu_ras_eeprom_check(struct amdgpu_ras_eeprom_control *control)return res <0 ? res :0 ; } + +void amdgpu_ras_eeprom_check_and_recover (struct amdgpu_device *adev) +{ +struct amdgpu_ras *ras =amdgpu_ras_get_context (adev);
Doesn't this require a NULL check?
Thanks,
Lijo
Quoted 35 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +21
-0+struct amdgpu_ras_eeprom_control *control = &ras->eeprom_control; +int res =0 ; + +if (!control->is_eeprom_valid) +return ; + res =__verify_ras_table_checksum (control); +if (res) { +dev_warn (adev->dev, +"RAS table incorrect checksum or error:%d, try to recover\n" , + res); +if (!amdgpu_ras_eeprom_reset_table (control)) +if (!amdgpu_ras_save_bad_pages (adev,NULL )) +if (!__verify_ras_table_checksum (control)) { +dev_info (adev->dev,"RAS table recovery succeed\n" ); +return ; + } +dev_err (adev->dev,"RAS table recovery failed\n" ); + control->is_eeprom_valid = false; + } +return ; +}drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h +2
-0@@ -161,6 +161,8 @@ void amdgpu_ras_debugfs_set_ret_size(struct amdgpu_ras_eeprom_control *control);int amdgpu_ras_eeprom_check (struct amdgpu_ras_eeprom_control *control); +void amdgpu_ras_eeprom_check_and_recover (struct amdgpu_device *adev); +extern const struct file_operations amdgpu_ras_debugfs_eeprom_size_ops;extern const struct file_operations amdgpu_ras_debugfs_eeprom_table_ops;
[AMD Official Use Only - AMD Internal Distribution Only]
Thanks, will add this NULL check
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Friday, July 11, 2025 3:17 PM
To: Xie, Patrick <[email protected]>; [email protected]
Cc: Zhou1, Tao <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: refine eeprom data check
Quoted 29 lines · ganglxie
add eeprom data checksum check before driver unload. reset eeprom and save correct data to eeprom when check failed
Signed-off-by ganglxie <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 1 + .../gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 25 +++++++++++++++++++ .../gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h | 2 ++ 3 files changed, 28 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1
-0@@ -2560,6 +2560,7 @@ amdgpu_pci_remove(struct pci_dev *pdev)struct drm_device *dev =pci_get_drvdata (pdev);struct amdgpu_device *adev =drm_to_adev (dev); +amdgpu_ras_eeprom_check_and_recover (adev);amdgpu_xcp_dev_unplug (adev);amdgpu_gmc_prepare_nps_mode_change (adev);drm_dev_unplug (dev);drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c int amdgpu_ras_eeprom_check(struct · line 1528
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +4
-0@@ -1522,3 +1522,28 @@ int amdgpu_ras_eeprom_check(struct amdgpu_ras_eeprom_control *control)return res <0 ? res :0 ; } + +void amdgpu_ras_eeprom_check_and_recover (struct amdgpu_device *adev) +{ +struct amdgpu_ras *ras =amdgpu_ras_get_context (adev);
Doesn't this require a NULL check?
Thanks,
Lijo
Quoted 40 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +21
-0+struct amdgpu_ras_eeprom_control *control = &ras->eeprom_control; +int res =0 ; + +if (!control->is_eeprom_valid) +return ; + res =__verify_ras_table_checksum (control); +if (res) { +dev_warn (adev->dev, +"RAS table incorrect checksum or error:%d, try to recover\n" , + res); +if (!amdgpu_ras_eeprom_reset_table (control)) +if (!amdgpu_ras_save_bad_pages (adev,NULL )) +if (!__verify_ras_table_checksum (control)) { +dev_info (adev->dev,"RAS table recovery succeed\n" ); +return ; + } +dev_err (adev->dev,"RAS table recovery failed\n" ); + control->is_eeprom_valid = false; + } +return ; +}drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h +2
-0@@ -161,6 +161,8 @@ void amdgpu_ras_debugfs_set_ret_size(struct amdgpu_ras_eeprom_control *control);int amdgpu_ras_eeprom_check (struct amdgpu_ras_eeprom_control *control); +void amdgpu_ras_eeprom_check_and_recover (struct amdgpu_device *adev); + extern const struct file_operations
amdgpu_ras_debugfs_eeprom_size_ops;
extern const structfile_operationsamdgpu_ras_debugfs_eeprom_table_ops;
[AMD Official Use Only - AMD Internal Distribution Only]
It's better to add ras support check, ras is not supported on any ASIC.
Tao
Quoted 105 lines
-----Original Message-----
From: Xie, Patrick <[email protected]>
Sent: Friday, July 11, 2025 3:47 PM
To: Lazar, Lijo <[email protected]>; [email protected]
Cc: Zhou1, Tao <[email protected]>
Subject: RE: [PATCH 1/2] drm/amdgpu: refine eeprom data check[AMD Official Use Only - AMD Internal Distribution Only]
Thanks, will add this NULL check
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Friday, July 11, 2025 3:17 PM
To: Xie, Patrick <[email protected]>; [email protected]
Cc: Zhou1, Tao <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: refine eeprom data checkQuoted 29 lines · ganglxie
add eeprom data checksum check before driver unload. reset eeprom and save correct data to eeprom when check failed
Signed-off-by ganglxie <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 1 + .../gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 25 +++++++++++++++++++ .../gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h | 2 ++ 3 files changed, 28 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1
-0@@ -2560,6 +2560,7 @@ amdgpu_pci_remove(struct pci_dev *pdev)struct drm_device *dev =pci_get_drvdata (pdev);struct amdgpu_device *adev =drm_to_adev (dev); +amdgpu_ras_eeprom_check_and_recover (adev);amdgpu_xcp_dev_unplug (adev);amdgpu_gmc_prepare_nps_mode_change (adev);drm_dev_unplug (dev);drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c int amdgpu_ras_eeprom_check(struct · line 1528
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +4
-0@@ -1522,3 +1522,28 @@ int amdgpu_ras_eeprom_check(struct amdgpu_ras_eeprom_control *control)return res <0 ? res :0 ; } + +void amdgpu_ras_eeprom_check_and_recover (struct amdgpu_device *adev) +{ +struct amdgpu_ras *ras =amdgpu_ras_get_context (adev);Doesn't this require a NULL check?
Thanks,
LijoQuoted 40 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +21
-0+struct amdgpu_ras_eeprom_control *control = &ras->eeprom_control; +int res =0 ; + +if (!control->is_eeprom_valid) +return ; + res =__verify_ras_table_checksum (control); +if (res) { +dev_warn (adev->dev, +"RAS table incorrect checksum or error:%d, try to recover\n" , + res); +if (!amdgpu_ras_eeprom_reset_table (control)) +if (!amdgpu_ras_save_bad_pages (adev,NULL )) +if (!__verify_ras_table_checksum (control)) { +dev_info (adev->dev,"RAS table recovery succeed\n" ); +return ; + } +dev_err (adev->dev,"RAS table recovery failed\n" ); + control->is_eeprom_valid = false; + } +return ; +}drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h +2
-0@@ -161,6 +161,8 @@ void amdgpu_ras_debugfs_set_ret_size(struct amdgpu_ras_eeprom_control *control);int amdgpu_ras_eeprom_check (struct amdgpu_ras_eeprom_control *control); +void amdgpu_ras_eeprom_check_and_recover (struct amdgpu_device *adev); + extern const struct file_operations
amdgpu_ras_debugfs_eeprom_size_ops;
extern const structfile_operationsamdgpu_ras_debugfs_eeprom_table_ops;