Thank you for your contribution! Sashiko AI review found 2 potential issue(s) 
to consider:
- [High] Calling `xe_device_declare_wedged()` during driver probe silently 
drops the `WEDGED` uevent because the DRM device is not yet registered in 
sysfs, and `xe_ras_init()` ignores the disconnect return value, leaving 
userspace unaware of a permanently wedged device.
- [High] Unprotected writes to `xe->wedged.method` cause a data race with 
concurrent wedge events, which can overwrite the critical 
`DRM_WEDGE_RECOVERY_COLD_RESET` recovery method, and lack of state checking 
leads to redundant uevent flooding.
--

--- Patch [3]: [PATCH v12 3/4] drm/xe: Handle PUNIT errors by requesting 
cold-reset recovery ---
commit 340a6fc7bdb22fd2c21615ec29270c2b330f42ea
Author: Mallesh Koujalagi <[email protected]>

drm/xe: Handle PUNIT errors by requesting cold-reset recovery

This commit handles PUNIT errors by setting the wedge recovery method to
cold reset and declaring the device wedged. This ensures that userspace is
notified that a complete device power cycle is required to restore normal
operation.

> diff --git a/drivers/gpu/drm/xe/xe_ras.c b/drivers/gpu/drm/xe/xe_ras.c
> index a31e06b8aa67a..92b4181026cbe 100644
> --- a/drivers/gpu/drm/xe/xe_ras.c
> +++ b/drivers/gpu/drm/xe/xe_ras.c
> @@ -236,6 +236,12 @@ static u8 handle_core_compute_errors(struct 
> xe_ras_error_array *arr)
>       return XE_RAS_RECOVERY_ACTION_RECOVERED;
>  }
>  
> +static void punit_error_handler(struct xe_device *xe)
> +{
> +     xe_device_set_wedged_method(xe, DRM_WEDGE_RECOVERY_COLD_RESET);

[Severity: High]
Does this unprotected write to xe->wedged.method create a data race?

If another thread (e.g., PCI AER or GT reset) concurrently calls
xe_device_declare_wedged(), it could evaluate if (!xe->wedged.method) before
this assignment, and overwrite DRM_WEDGE_RECOVERY_COLD_RESET with the default
DRM_WEDGE_RECOVERY_REBIND | DRM_WEDGE_RECOVERY_BUS_RESET.

Also, since xe_ras_process_errors() processes multiple errors in a loop:

drivers/gpu/drm/xe/xe_ras.c:xe_ras_process_errors() {
    ...
    for (int i = 0; i < response.num_errors && i < XE_RAS_NUM_ERROR_ARR; i++) {
        // error handler called
    ...
}

Will this cause a flood of redundant uevents and wedge method assignments if
multiple PUNIT errors are returned in a single response?

> +     xe_device_declare_wedged(xe);

[Severity: High]
Can this call silently drop the WEDGED uevent if it occurs during driver probe?

If a PUNIT error is detected during early probe via:
xe_device_probe() -> xe_ras_init() -> xe_ras_process_errors() -> 
handle_soc_internal_errors() -> punit_error_handler()

The uevent sent by drm_dev_wedged_event() (called from
xe_device_declare_wedged()) will fail with -EINVAL because the DRM device is
not yet registered in sysfs (kobj->state_in_sysfs is false).

Furthermore, since xe_ras_init() ignores the XE_RAS_RECOVERY_ACTION_DISCONNECT
return value, will the system boot with a wedged GPU while userspace is
completely unaware?

> +}

[ ... ]

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=3

Reply via email to