Skip to content

Commit 7c2551f

Browse files
Stanley.Yangalexdeucher
authored andcommitted
drm/amdgpu: Calculate EEPROM table ras info bytes sum
It's more reasonable to check EEPROM table ras info bytes. Signed-off-by: Stanley.Yang <Stanley.Yang@amd.com> Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 7f599fe commit 7c2551f

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,21 @@ static u8 __calc_hdr_byte_sum(const struct amdgpu_ras_eeprom_control *control)
355355
return csum;
356356
}
357357

358+
static u8 __calc_ras_info_byte_sum(const struct amdgpu_ras_eeprom_control *control)
359+
{
360+
int ii;
361+
u8 *pp, csum;
362+
size_t sz;
363+
364+
sz = sizeof(control->tbl_rai);
365+
pp = (u8 *) &control->tbl_rai;
366+
csum = 0;
367+
for (ii = 0; ii < sz; ii++, pp++)
368+
csum += *pp;
369+
370+
return csum;
371+
}
372+
358373
static int amdgpu_ras_eeprom_correct_header_tag(
359374
struct amdgpu_ras_eeprom_control *control,
360375
uint32_t header)
@@ -414,6 +429,8 @@ int amdgpu_ras_eeprom_reset_table(struct amdgpu_ras_eeprom_control *control)
414429
}
415430

416431
csum = __calc_hdr_byte_sum(control);
432+
if (hdr->version == RAS_TABLE_VER_V2_1)
433+
csum += __calc_ras_info_byte_sum(control);
417434
csum = -csum;
418435
hdr->checksum = csum;
419436
res = __write_table_header(control);
@@ -739,6 +756,8 @@ amdgpu_ras_eeprom_update_header(struct amdgpu_ras_eeprom_control *control)
739756
csum += *pp;
740757

741758
csum += __calc_hdr_byte_sum(control);
759+
if (control->tbl_hdr.version == RAS_TABLE_VER_V2_1)
760+
csum += __calc_ras_info_byte_sum(control);
742761
/* avoid sign extension when assigning to "checksum" */
743762
csum = -csum;
744763
control->tbl_hdr.checksum = csum;

0 commit comments

Comments
 (0)