Currently dmesg doesn't warn when the number of bad pages approaches the threshold for page retirement. WARN when the number of bad pages is at 90% or greater for easier checks and planning, instead of waiting until the GPU is full of bad pages
Cc: Luben Tuikov <luben.tui...@amd.com> Cc: Mukul Joshi <mukul.jo...@amd.com> Signed-off-by: Kent Russell <kent.russ...@amd.com> --- drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c index f4c05ff4b26c..1ede0f0d6f55 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c @@ -1071,12 +1071,29 @@ int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control, control->ras_fri = RAS_OFFSET_TO_INDEX(control, hdr->first_rec_offset); if (hdr->header == RAS_TABLE_HDR_VAL) { + int threshold = 0; DRM_DEBUG_DRIVER("Found existing EEPROM table with %d records", control->ras_num_recs); res = __verify_ras_table_checksum(control); if (res) DRM_ERROR("RAS table incorrect checksum or error:%d\n", res); + + /* threshold = 0 means that page retirement is disabled, while + * threshold = -1 means default behaviour + */ + if (amdgpu_bad_page_threshold == -1) + threshold = ras->bad_page_cnt_threshold; + else if (amdgpu_bad_page_threshold > 0) + threshold = amdgpu_bad_page_threshold; + + /* Since multiplcation is transitive, a = 9b/10 is the same + * as 10a = 9b. Use this for our 90% limit to avoid rounding + */ + if (threshold > 0 && ((control->ras_num_recs * 10) >= (threshold * 9))) + DRM_WARN("RAS records:%u exceeds 90%% of threshold:%d", + control->ras_num_recs, + threshold); } else if (hdr->header == RAS_TABLE_HDR_BAD && amdgpu_bad_page_threshold != 0) { res = __verify_ras_table_checksum(control); -- 2.25.1