Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/amdgpu: split ras_eeprom_init into init and check functions

Init function is for ras table header read and check function is
responsible for the validation of the header. Call them in different
stages.

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>

authored by

Tao Zhou and committed by
Alex Deucher
1f06e7f3 ea5d4934

+33 -4
+11 -4
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
··· 3015 3015 control->rec_type = AMDGPU_RAS_EEPROM_REC_MCA; 3016 3016 } 3017 3017 3018 + ret = amdgpu_ras_eeprom_check(control); 3019 + if (ret) 3020 + goto out; 3021 + 3022 + /* HW not usable */ 3023 + if (amdgpu_ras_is_rma(adev)) { 3024 + ret = -EHWPOISON; 3025 + goto out; 3026 + } 3027 + 3018 3028 ret = amdgpu_ras_add_bad_pages(adev, bps, control->ras_num_recs, true); 3019 3029 } 3020 3030 3031 + out: 3021 3032 kfree(bps); 3022 3033 return ret; 3023 3034 } ··· 3418 3407 ret = amdgpu_ras_eeprom_init(control); 3419 3408 if (ret) 3420 3409 return ret; 3421 - 3422 - /* HW not usable */ 3423 - if (amdgpu_ras_is_rma(adev)) 3424 - return -EHWPOISON; 3425 3410 3426 3411 if (!adev->umc.ras || !adev->umc.ras->convert_ras_err_addr) 3427 3412 control->rec_type = AMDGPU_RAS_EEPROM_REC_PA;
+20
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
··· 1382 1382 } 1383 1383 control->ras_fri = RAS_OFFSET_TO_INDEX(control, hdr->first_rec_offset); 1384 1384 1385 + return res < 0 ? res : 0; 1386 + } 1387 + 1388 + int amdgpu_ras_eeprom_check(struct amdgpu_ras_eeprom_control *control) 1389 + { 1390 + struct amdgpu_device *adev = to_amdgpu_device(control); 1391 + struct amdgpu_ras_eeprom_table_header *hdr = &control->tbl_hdr; 1392 + struct amdgpu_ras *ras = amdgpu_ras_get_context(adev); 1393 + int res; 1394 + 1395 + if (!__is_ras_eeprom_supported(adev)) 1396 + return 0; 1397 + 1398 + /* Verify i2c adapter is initialized */ 1399 + if (!adev->pm.ras_eeprom_i2c_bus || !adev->pm.ras_eeprom_i2c_bus->algo) 1400 + return -ENOENT; 1401 + 1402 + if (!__get_eeprom_i2c_addr(adev, control)) 1403 + return -EINVAL; 1404 + 1385 1405 if (hdr->header == RAS_TABLE_HDR_VAL) { 1386 1406 DRM_DEBUG_DRIVER("Found existing EEPROM table with %d records", 1387 1407 control->ras_num_recs);
+2
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h
··· 159 159 160 160 void amdgpu_ras_debugfs_set_ret_size(struct amdgpu_ras_eeprom_control *control); 161 161 162 + int amdgpu_ras_eeprom_check(struct amdgpu_ras_eeprom_control *control); 163 + 162 164 extern const struct file_operations amdgpu_ras_debugfs_eeprom_size_ops; 163 165 extern const struct file_operations amdgpu_ras_debugfs_eeprom_table_ops; 164 166