]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amdgpu: skip writing eeprom when PMFW manages RAS data
authorTao Zhou <tao.zhou1@amd.com>
Mon, 8 Sep 2025 12:39:49 +0000 (20:39 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 6 Nov 2025 15:02:15 +0000 (10:02 -0500)
Only update bad page number in legacy eeprom write path.

v2: add null pointer check for con.

Signed-off-by: Tao Zhou <tao.zhou1@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
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h

index 9854238ce7bfa83d7162b054ed522b82d946d900..670c0dedf4e92ee7892fdd60f80ab35b8f9e8c7c 100644 (file)
@@ -871,6 +871,18 @@ Out:
        return res;
 }
 
+int amdgpu_ras_eeprom_update_record_num(struct amdgpu_ras_eeprom_control *control)
+{
+       struct amdgpu_device *adev = to_amdgpu_device(control);
+
+       if (!amdgpu_ras_smu_eeprom_supported(adev))
+               return 0;
+
+       control->ras_num_recs_old = control->ras_num_recs;
+       return amdgpu_ras_smu_get_badpage_count(adev,
+                       &(control->ras_num_recs), 12);
+}
+
 /**
  * amdgpu_ras_eeprom_append -- append records to the EEPROM RAS table
  * @control: pointer to control structure
@@ -889,12 +901,18 @@ int amdgpu_ras_eeprom_append(struct amdgpu_ras_eeprom_control *control,
                             const u32 num)
 {
        struct amdgpu_device *adev = to_amdgpu_device(control);
+       struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
        int res, i;
        uint64_t nps = AMDGPU_NPS1_PARTITION_MODE;
 
-       if (!__is_ras_eeprom_supported(adev))
+       if (!__is_ras_eeprom_supported(adev) || !con)
                return 0;
 
+       if (amdgpu_ras_smu_eeprom_supported(adev)) {
+               control->ras_num_bad_pages = con->bad_page_num;
+               return 0;
+       }
+
        if (num == 0) {
                dev_err(adev->dev, "will not append 0 records\n");
                return -EINVAL;
index e881007f715b0f8ee967951045080fd72aeddf2f..2e5d63957e714336f4a1c10452843c3550a2d79f 100644 (file)
@@ -82,6 +82,7 @@ struct amdgpu_ras_eeprom_control {
        /* Number of records in the table.
         */
        u32 ras_num_recs;
+       u32 ras_num_recs_old;
 
        /* the bad page number is ras_num_recs or
         * ras_num_recs * umc.retire_unit
@@ -190,6 +191,8 @@ int amdgpu_ras_eeprom_read_idx(struct amdgpu_ras_eeprom_control *control,
                        struct eeprom_table_record *record, u32 rec_idx,
                        const u32 num);
 
+int amdgpu_ras_eeprom_update_record_num(struct amdgpu_ras_eeprom_control *control);
+
 extern const struct file_operations amdgpu_ras_debugfs_eeprom_size_ops;
 extern const struct file_operations amdgpu_ras_debugfs_eeprom_table_ops;