]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
drm/amdgpu: Calculate EEPROM table ras info bytes sum
authorStanley.Yang <Stanley.Yang@amd.com>
Mon, 29 May 2023 02:17:59 +0000 (10:17 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 9 Jun 2023 16:44:38 +0000 (12:44 -0400)
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>
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c

index 7f134c3b0b145b5cf212612318388ee9332b91ba..9eceb3bc10583a7ecd2c1c70002ef0ad52991a28 100644 (file)
@@ -355,6 +355,21 @@ static u8 __calc_hdr_byte_sum(const struct amdgpu_ras_eeprom_control *control)
        return csum;
 }
 
+static u8 __calc_ras_info_byte_sum(const struct amdgpu_ras_eeprom_control *control)
+{
+       int ii;
+       u8  *pp, csum;
+       size_t sz;
+
+       sz = sizeof(control->tbl_rai);
+       pp = (u8 *) &control->tbl_rai;
+       csum = 0;
+       for (ii = 0; ii < sz; ii++, pp++)
+               csum += *pp;
+
+       return csum;
+}
+
 static int amdgpu_ras_eeprom_correct_header_tag(
        struct amdgpu_ras_eeprom_control *control,
        uint32_t header)
@@ -414,6 +429,8 @@ 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)
+               csum += __calc_ras_info_byte_sum(control);
        csum = -csum;
        hdr->checksum = csum;
        res = __write_table_header(control);
@@ -739,6 +756,8 @@ 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)
+               csum += __calc_ras_info_byte_sum(control);
        /* avoid sign extension when assigning to "checksum" */
        csum = -csum;
        control->tbl_hdr.checksum = csum;