drm/amdgpu: format old RAS eeprom data into V3 version
Subsystems (2)
PATCH 1/1 drm/amdgpu: format old RAS eeprom data into V3 version
Clear old data and save it in V3 format.
v2: only format eeprom data for new ASICs.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 7 +++++ .../gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 26 ++++++++++--------- .../gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h | 1 + 3 files changed, 22 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +7 -0
@@ -3465,6 +3465,13 @@ int amdgpu_ras_init_badpage_info(struct amdgpu_device *adev) adev, control->bad_channel_bitmap); con->update_channel_flag = false; } + +/* The format action is only applied to new ASICs */ +if (IP_VERSION_MAJ (amdgpu_ip_version (adev,UMC_HWIP ,0 )) >=12 && + control->tbl_hdr.version <RAS_TABLE_VER_V3 ) +if (!amdgpu_ras_eeprom_reset_table (control)) +if (amdgpu_ras_save_bad_pages (adev,NULL )) +dev_warn (adev->dev,"Failed to format RAS EEPROM data in V3 version!\n" ); }return ret;
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +14 -12
@@ -413,9 +413,11 @@ static void amdgpu_ras_set_eeprom_table_version(struct amdgpu_ras_eeprom_controlswitch (amdgpu_ip_version (adev,UMC_HWIP ,0 )) {case IP_VERSION (8 ,10 ,0 ): -case IP_VERSION (12 ,0 ,0 ): hdr->version =RAS_TABLE_VER_V2_1 ;return ; +case IP_VERSION (12 ,0 ,0 ): + hdr->version =RAS_TABLE_VER_V3 ; +return ;default : hdr->version =RAS_TABLE_VER_V1 ;return ;
@@ -443,7 +445,7 @@ int amdgpu_ras_eeprom_reset_table(struct amdgpu_ras_eeprom_control *control) hdr->header =RAS_TABLE_HDR_VAL ;amdgpu_ras_set_eeprom_table_version (control); -if (hdr->version ==RAS_TABLE_VER_V2_1 ) { +if (hdr->version >=RAS_TABLE_VER_V2_1 ) { hdr->first_rec_offset =RAS_RECORD_START_V2_1 ; hdr->tbl_size =RAS_TABLE_HEADER_SIZE +RAS_TABLE_V2_1_INFO_SIZE ;
@@ -461,7 +463,7 @@ int amdgpu_ras_eeprom_reset_table(struct amdgpu_ras_eeprom_control *control) } csum =__calc_hdr_byte_sum (control); -if (hdr->version ==RAS_TABLE_VER_V2_1 ) +if (hdr->version >=RAS_TABLE_VER_V2_1 ) csum +=__calc_ras_info_byte_sum (control); csum = -csum; hdr->checksum = csum;
@@ -752,7 +754,7 @@ amdgpu_ras_eeprom_update_header(struct amdgpu_ras_eeprom_control *control)"Saved bad pages %d reaches threshold value %d\n" , control->ras_num_bad_pages, ras->bad_page_cnt_threshold); control->tbl_hdr.header =RAS_TABLE_HDR_BAD ; -if (control->tbl_hdr.version ==RAS_TABLE_VER_V2_1 ) { +if (control->tbl_hdr.version >=RAS_TABLE_VER_V2_1 ) { control->tbl_rai.rma_status =GPU_RETIRED__ECC_REACH_THRESHOLD ; control->tbl_rai.health_percent =0 ; }
@@ -765,7 +767,7 @@ amdgpu_ras_eeprom_update_header(struct amdgpu_ras_eeprom_control *control)amdgpu_dpm_send_rma_reason (adev); } -if (control->tbl_hdr.version ==RAS_TABLE_VER_V2_1 ) +if (control->tbl_hdr.version >=RAS_TABLE_VER_V2_1 ) control->tbl_hdr.tbl_size =RAS_TABLE_HEADER_SIZE +RAS_TABLE_V2_1_INFO_SIZE + control->ras_num_recs *RAS_TABLE_RECORD_SIZE ;
@@ -805,7 +807,7 @@ amdgpu_ras_eeprom_update_header(struct amdgpu_ras_eeprom_control *control)* now calculate gpu health percent */ if (amdgpu_bad_page_threshold !=0 && - control->tbl_hdr.version ==RAS_TABLE_VER_V2_1 && + control->tbl_hdr.version >=RAS_TABLE_VER_V2_1 && control->ras_num_bad_pages <= ras->bad_page_cnt_threshold) control->tbl_rai.health_percent = ((ras->bad_page_cnt_threshold - control->ras_num_bad_pages) * 100) /
@@ -818,7 +820,7 @@ amdgpu_ras_eeprom_update_header(struct amdgpu_ras_eeprom_control *control) csum += *pp; csum +=__calc_hdr_byte_sum (control); -if (control->tbl_hdr.version ==RAS_TABLE_VER_V2_1 ) +if (control->tbl_hdr.version >=RAS_TABLE_VER_V2_1 ) csum +=__calc_ras_info_byte_sum (control);/* avoid sign extension when assigning to "checksum" */ csum = -csum;
@@ -1035,7 +1037,7 @@ uint32_t amdgpu_ras_eeprom_max_record_count(struct amdgpu_ras_eeprom_control *co/* get available eeprom table version first before eeprom table init */ amdgpu_ras_set_eeprom_table_version (control); -if (control->tbl_hdr.version ==RAS_TABLE_VER_V2_1 ) +if (control->tbl_hdr.version >=RAS_TABLE_VER_V2_1 )return RAS_MAX_RECORD_COUNT_V2_1 ;else return RAS_MAX_RECORD_COUNT ;
@@ -1280,7 +1282,7 @@ static int __verify_ras_table_checksum(struct amdgpu_ras_eeprom_control *controlint buf_size, res;u8 csum, *buf, *pp; -if (control->tbl_hdr.version ==RAS_TABLE_VER_V2_1 ) +if (control->tbl_hdr.version >=RAS_TABLE_VER_V2_1 ) buf_size =RAS_TABLE_HEADER_SIZE +RAS_TABLE_V2_1_INFO_SIZE + control->ras_num_recs *RAS_TABLE_RECORD_SIZE ;
@@ -1383,7 +1385,7 @@ int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control)__decode_table_header_from_buf (hdr, buf); -if (hdr->version ==RAS_TABLE_VER_V2_1 ) { +if (hdr->version >=RAS_TABLE_VER_V2_1 ) { control->ras_num_recs =RAS_NUM_RECS_V2_1 (hdr); control->ras_record_offset =RAS_RECORD_START_V2_1 ; control->ras_max_record_count =RAS_MAX_RECORD_COUNT_V2_1 ;
@@ -1423,7 +1425,7 @@ int amdgpu_ras_eeprom_check(struct amdgpu_ras_eeprom_control *control)DRM_DEBUG_DRIVER ("Found existing EEPROM table with %d records" , control->ras_num_bad_pages); -if (hdr->version ==RAS_TABLE_VER_V2_1 ) { +if (hdr->version >=RAS_TABLE_VER_V2_1 ) { res =__read_table_ras_info (control);if (res)return res;
@@ -1443,7 +1445,7 @@ int amdgpu_ras_eeprom_check(struct amdgpu_ras_eeprom_control *control) ras->bad_page_cnt_threshold); }else if (hdr->header ==RAS_TABLE_HDR_BAD && amdgpu_bad_page_threshold !=0 ) { -if (hdr->version ==RAS_TABLE_VER_V2_1 ) { +if (hdr->version >=RAS_TABLE_VER_V2_1 ) { res =__read_table_ras_info (control);if (res)return res;
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h +1 -0
@@ -28,6 +28,7 @@#define RAS_TABLE_VER_V1 0x00010000#define RAS_TABLE_VER_V2_1 0x00021000 +#define RAS_TABLE_VER_V3 0x00030000struct amdgpu_device ;
Signature · 1 line
2.34.1
[AMD Official Use Only - AMD Internal Distribution Only]
Regards,
Hawking
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Tao Zhou
Sent: Wednesday, March 12, 2025 18:06
To: [email protected]
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH] drm/amdgpu: format old RAS eeprom data into V3 version
Clear old data and save it in V3 format.
v2: only format eeprom data for new ASICs.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 7 +++++ .../gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 26 ++++++++++--------- .../gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h | 1 + 3 files changed, 22 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +8 -0
@@ -3465,6 +3465,13 @@ int amdgpu_ras_init_badpage_info(struct amdgpu_device *adev) adev, control->bad_channel_bitmap); con->update_channel_flag = false; } + +/* The format action is only applied to new ASICs */ +if (IP_VERSION_MAJ (amdgpu_ip_version (adev,UMC_HWIP ,0 )) >=12 && + control->tbl_hdr.version <RAS_TABLE_VER_V3 ) +if (!amdgpu_ras_eeprom_reset_table (control)) +if (amdgpu_ras_save_bad_pages (adev,NULL )) +dev_warn (adev->dev,"Failed to format RAS EEPROM data in V3 +version!\n"); }
return ret;
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +7 -5
@@ -413,9 +413,11 @@ static void amdgpu_ras_set_eeprom_table_version(struct amdgpu_ras_eeprom_controlswitch (amdgpu_ip_version (adev,UMC_HWIP ,0 )) {case IP_VERSION (8 ,10 ,0 ): -case IP_VERSION (12 ,0 ,0 ): hdr->version =RAS_TABLE_VER_V2_1 ;return ; +case IP_VERSION (12 ,0 ,0 ): + hdr->version =RAS_TABLE_VER_V3 ; +return ;default : hdr->version =RAS_TABLE_VER_V1 ;return ;
@@ -443,7 +445,7 @@ int amdgpu_ras_eeprom_reset_table(struct amdgpu_ras_eeprom_control *control) hdr->header =RAS_TABLE_HDR_VAL ;amdgpu_ras_set_eeprom_table_version (control); -if (hdr->version ==RAS_TABLE_VER_V2_1 ) { +if (hdr->version >=RAS_TABLE_VER_V2_1 ) { hdr->first_rec_offset =RAS_RECORD_START_V2_1 ; hdr->tbl_size =RAS_TABLE_HEADER_SIZE +RAS_TABLE_V2_1_INFO_SIZE ;
@@ -461,7 +463,7 @@ int amdgpu_ras_eeprom_reset_table(struct amdgpu_ras_eeprom_control *control) } csum =__calc_hdr_byte_sum (control); -if (hdr->version ==RAS_TABLE_VER_V2_1 ) +if (hdr->version >=RAS_TABLE_VER_V2_1 ) csum +=__calc_ras_info_byte_sum (control); csum = -csum; hdr->checksum = csum;
@@ -752,7 +754,7 @@ amdgpu_ras_eeprom_update_header(struct amdgpu_ras_eeprom_control *control)"Saved bad pages %d reaches threshold value %d\n" , control->ras_num_bad_pages, ras->bad_page_cnt_threshold); control->tbl_hdr.header =RAS_TABLE_HDR_BAD ; -if (control->tbl_hdr.version ==RAS_TABLE_VER_V2_1 ) { +if (control->tbl_hdr.version >=RAS_TABLE_VER_V2_1 ) { control->tbl_rai.rma_status =GPU_RETIRED__ECC_REACH_THRESHOLD ; control->tbl_rai.health_percent =0 ; }
@@ -765,7 +767,7 @@ amdgpu_ras_eeprom_update_header(struct amdgpu_ras_eeprom_control *control)amdgpu_dpm_send_rma_reason (adev); } -if (control->tbl_hdr.version ==RAS_TABLE_VER_V2_1 ) +if (control->tbl_hdr.version >=RAS_TABLE_VER_V2_1 ) control->tbl_hdr.tbl_size =RAS_TABLE_HEADER_SIZE +RAS_TABLE_V2_1_INFO_SIZE + control->ras_num_recs * RAS_TABLE_RECORD_SIZE; @@ -805,7 +807,7 @@ amdgpu_ras_eeprom_update_header(struct amdgpu_ras_eeprom_control *control)
* now calculate gpu health percent
*/
if (amdgpu_bad_page_threshold != 0 &&
- control->tbl_hdr.version == RAS_TABLE_VER_V2_1 &&
+ control->tbl_hdr.version >= RAS_TABLE_VER_V2_1 &&
control->ras_num_bad_pages <= ras->bad_page_cnt_threshold)
control->tbl_rai.health_percent = ((ras->bad_page_cnt_threshold -
control->ras_num_bad_pages) * 100) / @@ -818,7 +820,7 @@ amdgpu_ras_eeprom_update_header(struct amdgpu_ras_eeprom_control *control)
csum += *pp;
csum += __calc_hdr_byte_sum(control);
- if (control->tbl_hdr.version == RAS_TABLE_VER_V2_1)
+ if (control->tbl_hdr.version >= RAS_TABLE_VER_V2_1)
csum += __calc_ras_info_byte_sum(control);
/* avoid sign extension when assigning to "checksum" */
csum = -csum;
@@ -1035,7 +1037,7 @@ uint32_t amdgpu_ras_eeprom_max_record_count(struct amdgpu_ras_eeprom_control *co
/* get available eeprom table version first before eeprom table init */
amdgpu_ras_set_eeprom_table_version(control);- if (control->tbl_hdr.version == RAS_TABLE_VER_V2_1)
+ if (control->tbl_hdr.version >= RAS_TABLE_VER_V2_1)
return RAS_MAX_RECORD_COUNT_V2_1;
else
return RAS_MAX_RECORD_COUNT;
@@ -1280,7 +1282,7 @@ static int __verify_ras_table_checksum(struct amdgpu_ras_eeprom_control *control
int buf_size, res;
u8 csum, *buf, *pp;- if (control->tbl_hdr.version == RAS_TABLE_VER_V2_1)
+ if (control->tbl_hdr.version >= RAS_TABLE_VER_V2_1)
buf_size = RAS_TABLE_HEADER_SIZE +
RAS_TABLE_V2_1_INFO_SIZE +
control->ras_num_recs * RAS_TABLE_RECORD_SIZE; @@ -1383,7 +1385,7 @@ int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control)
__decode_table_header_from_buf(hdr, buf);- if (hdr->version == RAS_TABLE_VER_V2_1) {
+ if (hdr->version >= RAS_TABLE_VER_V2_1) {
control->ras_num_recs = RAS_NUM_RECS_V2_1(hdr);
control->ras_record_offset = RAS_RECORD_START_V2_1;
control->ras_max_record_count = RAS_MAX_RECORD_COUNT_V2_1; @@ -1423,7 +1425,7 @@ int amdgpu_ras_eeprom_check(struct amdgpu_ras_eeprom_control *control)
DRM_DEBUG_DRIVER("Found existing EEPROM table with %d records",
control->ras_num_bad_pages);- if (hdr->version == RAS_TABLE_VER_V2_1) {
+ if (hdr->version >= RAS_TABLE_VER_V2_1) {
res = __read_table_ras_info(control);
if (res)
return res;
@@ -1443,7 +1445,7 @@ int amdgpu_ras_eeprom_check(struct amdgpu_ras_eeprom_control *control)
ras->bad_page_cnt_threshold);
} else if (hdr->header == RAS_TABLE_HDR_BAD &&
amdgpu_bad_page_threshold != 0) {
- if (hdr->version == RAS_TABLE_VER_V2_1) {
+ if (hdr->version >= RAS_TABLE_VER_V2_1) {
res = __read_table_ras_info(control);
if (res)
return res;drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h +1 -0
@@ -28,6 +28,7 @@#define RAS_TABLE_VER_V1 0x00010000#define RAS_TABLE_VER_V2_1 0x00021000 +#define RAS_TABLE_VER_V3 0x00030000struct amdgpu_device ;
--
2.34.1