Re: [PATCH v2] drm/xe/ras: Validate sysctrl response
"Tauro, Riana" <[email protected]> Mon, 3 Aug 2026 15:21:29 +0530
| Newsgroups | org.freedesktop.lists.intel-xe |
|---|---|
| Message-ID | <[email protected]> |
On 23-07-2026 19:59, Tauro, Riana wrote: > > On 22-07-2026 20:01, Raag Jadav wrote: >> Validate errors raised by sysctrl firmware instead of blindly trusting >> them. >> >> Signed-off-by: Raag Jadav <[email protected]> > > > Looks good to me > > Reviewed-by: Riana Tauro <[email protected]> Thank you for the patch. Pushed to drm-xe-next. > > >> --- >> v2: Continue invalid uncorrectable error case (Riana) >> s/error/counter (Riana) >> --- >> drivers/gpu/drm/xe/xe_ras.c | 30 ++++++++++++++++++++++++++++++ >> 1 file changed, 30 insertions(+) >> >> diff --git a/drivers/gpu/drm/xe/xe_ras.c b/drivers/gpu/drm/xe/xe_ras.c >> index 5e294e9f8f99..28123f08e513 100644 >> --- a/drivers/gpu/drm/xe/xe_ras.c >> +++ b/drivers/gpu/drm/xe/xe_ras.c >> @@ -156,6 +156,24 @@ static inline const char *comp_to_str(u8 component) >> return xe_ras_components[component]; >> } >> +static bool ras_counter_is_valid(struct xe_device *xe, struct >> xe_ras_error_class *counter) >> +{ >> + u8 severity = counter->common.severity; >> + u8 component = counter->common.component; >> + >> + if (!in_range(severity, XE_RAS_SEV_NOT_SUPPORTED + 1, >> XE_RAS_SEV_MAX - 1)) { >> + xe_err(xe, "sysctrl: unexpected severity %u\n", severity); >> + return false; >> + } >> + >> + if (!in_range(component, XE_RAS_COMP_NOT_SUPPORTED + 1, >> XE_RAS_COMP_MAX - 1)) { >> + xe_err(xe, "sysctrl: unexpected component %u\n", component); >> + return false; >> + } >> + >> + return true; >> +} >> + >> static struct pci_dev *find_usp_dev(struct pci_dev *pdev) >> { >> struct pci_dev *vsp; >> @@ -327,6 +345,9 @@ void xe_ras_counter_threshold_crossed(struct >> xe_device *xe, >> severity = errors[id].common.severity; >> component = errors[id].common.component; >> + if (!ras_counter_is_valid(xe, &errors[id])) >> + continue; >> + >> xe_warn(xe, "[RAS]: %s %s detected\n", >> comp_to_str(component), sev_to_str(severity)); >> } >> @@ -358,6 +379,9 @@ static int get_counter(struct xe_device *xe, >> struct xe_ras_error_class *counter, >> return -EIO; >> } >> + if (!ras_counter_is_valid(xe, &response.counter)) >> + return -EBADMSG; >> + >> common = &response.counter.common; >> *value = response.value; >> @@ -422,6 +446,9 @@ enum xe_ras_recovery_action >> xe_ras_process_errors(struct xe_device *xe) >> component = arr->counter.common.component; >> severity = arr->counter.common.severity; >> + if (!ras_counter_is_valid(xe, &arr->counter)) >> + continue; >> + >> xe_info(xe, "[RAS]: %s %s detected\n", >> comp_to_str(component), >> sev_to_str(severity)); >> @@ -532,6 +559,9 @@ int xe_ras_clear_counter(struct xe_device *xe, >> u8 severity, u8 component) >> counter = &response.counter; >> + if (!ras_counter_is_valid(xe, counter)) >> + return -EBADMSG; >> + >> xe_dbg(xe, "[RAS]: clear counter for %s %s\n", >> comp_to_str(counter->common.component), >> sev_to_str(counter->common.severity));