Skip to content

Commit 9ce015e

Browse files
Gangliang Xiealexdeucher
authored andcommitted
drm/amdgpu: adapt reset function for pmfw eeprom
adapt reset function for pmfw eeprom Signed-off-by: Gangliang Xie <ganglxie@amd.com> Reviewed-by: Tao Zhou <tao.zhou1@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent f903b85 commit 9ce015e

1 file changed

Lines changed: 36 additions & 25 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -444,40 +444,51 @@ int amdgpu_ras_eeprom_reset_table(struct amdgpu_ras_eeprom_control *control)
444444
struct amdgpu_ras_eeprom_table_header *hdr = &control->tbl_hdr;
445445
struct amdgpu_ras_eeprom_table_ras_info *rai = &control->tbl_rai;
446446
struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
447+
u32 erase_res = 0;
447448
u8 csum;
448449
int res;
449450

450451
mutex_lock(&control->ras_tbl_mutex);
451452

452-
hdr->header = RAS_TABLE_HDR_VAL;
453-
amdgpu_ras_set_eeprom_table_version(control);
453+
if (!amdgpu_ras_smu_eeprom_supported(adev)) {
454+
hdr->header = RAS_TABLE_HDR_VAL;
455+
amdgpu_ras_set_eeprom_table_version(control);
454456

455-
if (hdr->version >= RAS_TABLE_VER_V2_1) {
456-
hdr->first_rec_offset = RAS_RECORD_START_V2_1;
457-
hdr->tbl_size = RAS_TABLE_HEADER_SIZE +
458-
RAS_TABLE_V2_1_INFO_SIZE;
459-
rai->rma_status = GPU_HEALTH_USABLE;
460-
/**
461-
* GPU health represented as a percentage.
462-
* 0 means worst health, 100 means fully health.
463-
*/
464-
rai->health_percent = 100;
465-
/* ecc_page_threshold = 0 means disable bad page retirement */
466-
rai->ecc_page_threshold = con->bad_page_cnt_threshold;
457+
if (hdr->version >= RAS_TABLE_VER_V2_1) {
458+
hdr->first_rec_offset = RAS_RECORD_START_V2_1;
459+
hdr->tbl_size = RAS_TABLE_HEADER_SIZE +
460+
RAS_TABLE_V2_1_INFO_SIZE;
461+
rai->rma_status = GPU_HEALTH_USABLE;
462+
/**
463+
* GPU health represented as a percentage.
464+
* 0 means worst health, 100 means fully health.
465+
*/
466+
rai->health_percent = 100;
467+
/* ecc_page_threshold = 0 means disable bad page retirement */
468+
rai->ecc_page_threshold = con->bad_page_cnt_threshold;
469+
} else {
470+
hdr->first_rec_offset = RAS_RECORD_START;
471+
hdr->tbl_size = RAS_TABLE_HEADER_SIZE;
472+
}
473+
474+
csum = __calc_hdr_byte_sum(control);
475+
if (hdr->version >= RAS_TABLE_VER_V2_1)
476+
csum += __calc_ras_info_byte_sum(control);
477+
csum = -csum;
478+
hdr->checksum = csum;
479+
res = __write_table_header(control);
480+
if (!res && hdr->version > RAS_TABLE_VER_V1)
481+
res = __write_table_ras_info(control);
467482
} else {
468-
hdr->first_rec_offset = RAS_RECORD_START;
469-
hdr->tbl_size = RAS_TABLE_HEADER_SIZE;
483+
res = amdgpu_ras_smu_erase_ras_table(adev, &erase_res);
484+
if (res || erase_res) {
485+
dev_warn(adev->dev, "RAS EEPROM reset failed, res:%d result:%d",
486+
res, erase_res);
487+
if (!res)
488+
res = -EIO;
489+
}
470490
}
471491

472-
csum = __calc_hdr_byte_sum(control);
473-
if (hdr->version >= RAS_TABLE_VER_V2_1)
474-
csum += __calc_ras_info_byte_sum(control);
475-
csum = -csum;
476-
hdr->checksum = csum;
477-
res = __write_table_header(control);
478-
if (!res && hdr->version > RAS_TABLE_VER_V1)
479-
res = __write_table_ras_info(control);
480-
481492
control->ras_num_recs = 0;
482493
control->ras_num_bad_pages = 0;
483494
control->ras_num_mca_recs = 0;

0 commit comments

Comments
 (0)