dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v11 0/3] Introduce cold reset recovery method
@ 2026-07-20 10:18 Mallesh Koujalagi
  2026-07-20 10:18 ` [PATCH v11 1/3] drm: Add DRM_WEDGE_RECOVERY_COLD_RESET " Mallesh Koujalagi
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Mallesh Koujalagi @ 2026-07-20 10:18 UTC (permalink / raw)
  To: intel-xe, dri-devel, rodrigo.vivi
  Cc: andrealmeid, christian.koenig, airlied, simona.vetter, mripard,
	maarten.lankhorst, tzimmermann, anshuman.gupta, badal.nilawar,
	riana.tauro, karthik.poosa, sk.anirban, raag.jadav,
	Mallesh Koujalagi

Add support for handling errors that require a complete
device power cycle (cold reset) to recover.

Certain error conditions leave the device in a persistent hardware
error state that cannot be cleared through existing recovery mechanisms
such as driver reload or PCIe reset. In these cases, functionality can
only be restored by performing a cold reset.

To support this, the series introduces a new DRM wedging recovery
method, DRM_WEDGE_RECOVERY_COLD_RESET (BIT(4)). When a device is wedged
with this method, the DRM core notifies userspace via a uevent that a cold
reset is required. This allows userspace to take appropriate action to
power-cycle the device.

Example uevent received:
  SUBSYSTEM=drm
  WEDGED=cold-reset
  DEVPATH=/devices/.../drm/card0

v2:
- Add use case: Handling errors from power management unit,
  which requires a complete power cycle to
  recover. (Christian)
- Add several instead of number to avoid update. (Jani)

v3:
- Update any scenario that requires cold-reset. (Riana)
- Update document with generic scenario. (Riana)
- Consistent with terminology. (Raag)
- Remove already covered information.
- Use PUNIT instead of PMU. (Riana)
- Use consistent wordingi.
- Remove log. (Raag)

v4:
- Rename cold reset to power cyclce. (Raag)
- Update doc. (Raag/Riana)
- Change commit message. (Raag)
- Make function static. (Raag)

v5:
- Make it consistent with consumer expectations. (Raag)
- Update commit message.
- Remove unbind.
- Simplify cold-reset script.
- Remove kdoc for static function.
- Remove xe_ prefix for static function.

v6:
- Drop "last resort" wording. (Riana)
- Look up the hotplug slot in DEVPATH instead of scanning
  every PCI slot on the system. (Raag)
- Drop arbitrary sleep values from the example script.
- Expand commit message to explain why SUR_DN is masked. (Raag/Riana)
- Check Slot Implemented bit before reading Slot Capabilities, per
  PCIe spec. (Riana)
- Add debug log.

v7:
- Update recovery script. (Raag)
- Handle surprise link down event properly. (Aravind/Riana)
- Update commit message. (Riana)
- Correct log message.

v8:
- Add rescan instead of reset. (Raag)
- Use find_usp_dev() in punit_error_handler() function.

v9:
- Remove unwanted header. (Sashiko)
- Removed #ifdef CONFIG_PCIEAER. (Riana)
- Used pci_find_ext_capability() instead of usp->aer_cap.
- Clear the PCI_ERR_UNC_SURPDN status bit (W1C) after
  reset complete. (Lukas Wunner)
- Use pci_clear_and_set_config_dword() helper.

v10:
- Rebase.
- Fix column width. (Sashiko)

v11:
- Make udev rules in single line. (Sashiko)

Cc: André Almeida <andrealmeid@igalia.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: David Airlie <airlied@gmail.com>
Cc: Simona Vetter <simona.vetter@ffwll.ch>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Thomas Zimmermann <tzimmermann@suse.de>

Mallesh Koujalagi (3):
  drm: Add DRM_WEDGE_RECOVERY_COLD_RESET recovery method
  drm/doc: Document DRM_WEDGE_RECOVERY_COLD_RESET recovery method
  drm/xe: Handle PUNIT errors by requesting cold-reset recovery

 Documentation/gpu/drm-uapi.rst | 93 ++++++++++++++++++++++++++++++++--
 drivers/gpu/drm/drm_drv.c      |  2 +
 drivers/gpu/drm/xe/xe_ras.c    |  8 ++-
 include/drm/drm_device.h       |  1 +
 4 files changed, 98 insertions(+), 6 deletions(-)

-- 
2.48.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v11 1/3] drm: Add DRM_WEDGE_RECOVERY_COLD_RESET recovery method
  2026-07-20 10:18 [PATCH v11 0/3] Introduce cold reset recovery method Mallesh Koujalagi
@ 2026-07-20 10:18 ` Mallesh Koujalagi
  2026-07-20 10:30   ` sashiko-bot
  2026-07-20 10:18 ` [PATCH v11 2/3] drm/doc: Document " Mallesh Koujalagi
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Mallesh Koujalagi @ 2026-07-20 10:18 UTC (permalink / raw)
  To: intel-xe, dri-devel, rodrigo.vivi
  Cc: andrealmeid, christian.koenig, airlied, simona.vetter, mripard,
	maarten.lankhorst, tzimmermann, anshuman.gupta, badal.nilawar,
	riana.tauro, karthik.poosa, sk.anirban, raag.jadav,
	Mallesh Koujalagi

Introduce DRM_WEDGE_RECOVERY_COLD_RESET (BIT(4)) recovery method to handle
scenarios requiring device power cycle.

This method addresses cases where other recovery mechanisms
(driver reload, PCIe reset, etc.) are insufficient to restore device
functionality. When set, it indicates to userspace that only device power
cycle can recover the device from its current error state.

Signed-off-by: Mallesh Koujalagi <mallesh.koujalagi@intel.com>
Reviewed-by: Raag Jadav <raag.jadav@intel.com>
---
v3:
- Update any scenario that requires cold-reset. (Riana)

v4:
- Rename cold reset to power cycle. (Raag)

v5:
- Make it consistent with consumer expectations. (Raag)

v6:
- Drop "last resort" wording. (Riana)
---
 drivers/gpu/drm/drm_drv.c | 2 ++
 include/drm/drm_device.h  | 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index e51ed959da89..8519e97ef5d3 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -545,6 +545,8 @@ static const char *drm_get_wedge_recovery(unsigned int opt)
 		return "bus-reset";
 	case DRM_WEDGE_RECOVERY_VENDOR:
 		return "vendor-specific";
+	case DRM_WEDGE_RECOVERY_COLD_RESET:
+		return "cold-reset";
 	default:
 		return NULL;
 	}
diff --git a/include/drm/drm_device.h b/include/drm/drm_device.h
index 768a8dae83c5..75f030d027ee 100644
--- a/include/drm/drm_device.h
+++ b/include/drm/drm_device.h
@@ -37,6 +37,7 @@ struct pci_controller;
 #define DRM_WEDGE_RECOVERY_REBIND	BIT(1)	/* unbind + bind driver */
 #define DRM_WEDGE_RECOVERY_BUS_RESET	BIT(2)	/* unbind + reset bus device + bind */
 #define DRM_WEDGE_RECOVERY_VENDOR	BIT(3)	/* vendor specific recovery method */
+#define DRM_WEDGE_RECOVERY_COLD_RESET	BIT(4)	/* remove device + slot power cycle + rescan */
 
 /**
  * struct drm_wedge_task_info - information about the guilty task of a wedge dev
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v11 2/3] drm/doc: Document DRM_WEDGE_RECOVERY_COLD_RESET recovery method
  2026-07-20 10:18 [PATCH v11 0/3] Introduce cold reset recovery method Mallesh Koujalagi
  2026-07-20 10:18 ` [PATCH v11 1/3] drm: Add DRM_WEDGE_RECOVERY_COLD_RESET " Mallesh Koujalagi
@ 2026-07-20 10:18 ` Mallesh Koujalagi
  2026-07-20 10:18 ` [PATCH v11 3/3] drm/xe: Handle PUNIT errors by requesting cold-reset recovery Mallesh Koujalagi
       [not found] ` <amHzsHmNSH84SZ92@black.igk.intel.com>
  3 siblings, 0 replies; 8+ messages in thread
From: Mallesh Koujalagi @ 2026-07-20 10:18 UTC (permalink / raw)
  To: intel-xe, dri-devel, rodrigo.vivi
  Cc: andrealmeid, christian.koenig, airlied, simona.vetter, mripard,
	maarten.lankhorst, tzimmermann, anshuman.gupta, badal.nilawar,
	riana.tauro, karthik.poosa, sk.anirban, raag.jadav,
	Mallesh Koujalagi

When ``WEDGED=cold-reset`` is sent, it indicates that the device has
encountered an error condition that cannot be resolved through other
recovery methods such as driver rebind or bus reset, and requires a
complete device power cycle to restore functionality.

Signed-off-by: Mallesh Koujalagi <mallesh.koujalagi@intel.com>
Reviewed-by: Raag Jadav <raag.jadav@intel.com>
---
v2:
- Add several instead of number to avoid update. (Jani)

v3:
- Update document with generic scenario. (Riana)
- Consistent with terminology. (Raag)
- Remove already covered information.

v4:
- Update doc. (Raag/Riana)
- Change commit message.

v5:
- Update commit message. (Raag)
- Remove unbind.
- Simplify cold-reset script.

v6:
- Look up the hotplug slot in DEVPATH instead of scanning
  every PCI slot on the system. (Raag)
- Drop arbitrary sleep values from the example script.

v7:
- Update recovery script. (Raag)

v8:
- Add rescan instead of reset. (Raag)

v10:
- Fix column width. (Sashiko)

v11:
- Make udev rules in single line. (Sashiko)
---
 Documentation/gpu/drm-uapi.rst | 93 ++++++++++++++++++++++++++++++++--
 1 file changed, 88 insertions(+), 5 deletions(-)

diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm-uapi.rst
index 93df92c4ac8c..52255247a6db 100644
--- a/Documentation/gpu/drm-uapi.rst
+++ b/Documentation/gpu/drm-uapi.rst
@@ -424,7 +424,7 @@ needed.
 Recovery
 --------
 
-Current implementation defines four recovery methods, out of which, drivers
+Current implementation defines several recovery methods, out of which, drivers
 can use any one, multiple or none. Method(s) of choice will be sent in the
 uevent environment as ``WEDGED=<method1>[,..,<methodN>]`` in order of less to
 more side-effects. See the section `Vendor Specific Recovery`_
@@ -434,15 +434,16 @@ method is unknown, ``WEDGED=unknown`` will be sent instead.
 Userspace consumers can parse this event and attempt recovery as per the
 following expectations.
 
-    =============== ========================================
+    =============== =========================================
     Recovery method Consumer expectations
-    =============== ========================================
+    =============== =========================================
     none            optional telemetry collection
     rebind          unbind + bind driver
     bus-reset       unbind + bus reset/re-enumeration + bind
     vendor-specific vendor specific recovery method
+    cold-reset      remove device + slot power cycle + rescan
     unknown         consumer policy
-    =============== ========================================
+    =============== =========================================
 
 No Recovery
 -----------
@@ -453,6 +454,17 @@ debug purpose in order to root cause the hang. This is useful because the first
 hang is usually the most critical one which can result in consequential hangs
 or complete wedging.
 
+Cold Reset Recovery
+-------------------
+
+When ``WEDGED=cold-reset`` is sent, it indicates that the device has
+encountered an error condition that cannot be resolved through other
+recovery methods such as driver rebind or bus reset, and requires a complete
+device power cycle to restore functionality.
+
+This method is used by devices that are plugged directly into the PCIe slot
+which supports removing the power.
+
 Vendor Specific Recovery
 ------------------------
 
@@ -516,7 +528,7 @@ Example - rebind
 
 Udev rule::
 
-    SUBSYSTEM=="drm", ENV{WEDGED}=="rebind", DEVPATH=="*/drm/card[0-9]",
+    SUBSYSTEM=="drm", ENV{WEDGED}=="rebind", DEVPATH=="*/drm/card[0-9]", \
     RUN+="/path/to/rebind.sh $env{DEVPATH}"
 
 Recovery script::
@@ -530,6 +542,77 @@ Recovery script::
     echo -n $DEVICE > $DRIVER/unbind
     echo -n $DEVICE > $DRIVER/bind
 
+Example - cold-reset
+--------------------
+
+Udev rule::
+
+    SUBSYSTEM=="drm", ENV{WEDGED}=="cold-reset", DEVPATH=="*/drm/card[0-9]", \
+    RUN+="/path/to/cold-reset.sh $env{DEVPATH}"
+
+Recovery script::
+
+    #!/bin/sh
+    die() { echo "ERROR: $*" >&2; exit 1; }
+
+    [ -n "$1" ] || die "Usage: $0 <device-path>"
+
+    PCI_DEVS=/sys/bus/pci/devices
+    PCI_SLOTS=/sys/bus/pci/slots
+
+    syspath=$(readlink -f "/sys/$1/device" 2>/dev/null || readlink -f "/sys/$1" 2>/dev/null)
+    [ -n "$syspath" ] || die "cannot resolve sysfs path for: $1"
+
+    dev=$(basename "$syspath")
+    [ -e "$PCI_DEVS/$dev" ] || die "not a PCI device: $dev"
+    echo "device : $dev"
+
+    slot=""
+    walk=$(dirname "$(readlink -f "$PCI_DEVS/$dev")")
+
+    while true; do
+        ancestor=$(basename "$walk")
+        case "$ancestor" in pci*) break ;; esac  # reached the virtual bus root
+
+        ancestor_nofn=${ancestor%.*}  # strip function: 0000:03:01.0 -> 0000:03:01
+
+        for f in "$PCI_SLOTS"/*/address; do
+            [ -f "$f" ] || continue
+            addr=$(cat "$f")
+            case "$ancestor_nofn" in
+                *"$addr") slot=$(basename "$(dirname "$f")"); break ;;
+            esac
+        done
+
+        if [ -n "$slot" ] && [ -e "$PCI_SLOTS/$slot/power" ]; then
+            echo "slot   : $slot (port $ancestor)"
+            break
+        fi
+        slot=""
+        walk=$(dirname "$walk")
+    done
+
+    [ -n "$slot" ] || die "no hotplug slot with power control found in PCIe topology"
+
+    # Cold reset: remove the device, cut slot power, restore power, rescan.
+    echo "Removing $dev..."
+    [ -e "$PCI_DEVS/$dev" ] && echo 1 > "$PCI_DEVS/$dev/remove"
+
+    echo "Powering off slot $slot..."
+    echo 0 > "$PCI_SLOTS/$slot/power"
+
+    echo "Powering on slot $slot..."
+    echo 1 > "$PCI_SLOTS/$slot/power"
+
+    echo "Rescanning PCI bus..."
+    echo 1 > /sys/bus/pci/rescan
+
+    if [ -e "$PCI_DEVS/$dev" ]; then
+        echo "Done: $dev is back online."
+    else
+        echo "WARNING: $dev did not re-appear after rescan."
+    fi
+
 Customization
 -------------
 
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v11 3/3] drm/xe: Handle PUNIT errors by requesting cold-reset recovery
  2026-07-20 10:18 [PATCH v11 0/3] Introduce cold reset recovery method Mallesh Koujalagi
  2026-07-20 10:18 ` [PATCH v11 1/3] drm: Add DRM_WEDGE_RECOVERY_COLD_RESET " Mallesh Koujalagi
  2026-07-20 10:18 ` [PATCH v11 2/3] drm/doc: Document " Mallesh Koujalagi
@ 2026-07-20 10:18 ` Mallesh Koujalagi
  2026-07-20 10:48   ` sashiko-bot
       [not found] ` <amHzsHmNSH84SZ92@black.igk.intel.com>
  3 siblings, 1 reply; 8+ messages in thread
From: Mallesh Koujalagi @ 2026-07-20 10:18 UTC (permalink / raw)
  To: intel-xe, dri-devel, rodrigo.vivi
  Cc: andrealmeid, christian.koenig, airlied, simona.vetter, mripard,
	maarten.lankhorst, tzimmermann, anshuman.gupta, badal.nilawar,
	riana.tauro, karthik.poosa, sk.anirban, raag.jadav,
	Mallesh Koujalagi

When PUNIT (power management unit) errors are detected that persist across
warm resets, mark the device as wedged with DRM_WEDGE_RECOVERY_COLD_RESET
and notify userspace that a complete device power cycle is required to
restore normal operation.

Signed-off-by: Mallesh Koujalagi <mallesh.koujalagi@intel.com>
Reviewed-by: Raag Jadav <raag.jadav@intel.com>
---
v3:
- Use PUNIT instead of PMU. (Riana)
- Use consistent wording.
- Remove log. (Raag)

v4:
- Make function static. (Raag)

v5:
- Remove kdoc for static function. (Raag)
- Remove xe_ prefix for static function.

v9:
- Remove unwanted header. (Sashiko)
---
 drivers/gpu/drm/xe/xe_ras.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_ras.c b/drivers/gpu/drm/xe/xe_ras.c
index a31e06b8aa67..92b4181026cb 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);
+	xe_device_declare_wedged(xe);
+}
+
 static u8 handle_soc_internal_errors(struct xe_device *xe, struct xe_ras_error_array *arr)
 {
 	struct xe_ras_soc_error *info = (void *)arr->details;
@@ -267,7 +273,7 @@ static u8 handle_soc_internal_errors(struct xe_device *xe, struct xe_ras_error_a
 			xe_err(xe, "[RAS]: PUNIT %s detected: 0x%x\n",
 			       sev_to_str(counter->common.severity),
 			       ieh_error->global_error_status);
-			/* TODO: Add PUNIT error handling */
+			punit_error_handler(xe);
 			return XE_RAS_RECOVERY_ACTION_DISCONNECT;
 		}
 	}
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v11 1/3] drm: Add DRM_WEDGE_RECOVERY_COLD_RESET recovery method
  2026-07-20 10:18 ` [PATCH v11 1/3] drm: Add DRM_WEDGE_RECOVERY_COLD_RESET " Mallesh Koujalagi
@ 2026-07-20 10:30   ` sashiko-bot
  0 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-07-20 10:30 UTC (permalink / raw)
  To: Mallesh Koujalagi; +Cc: dri-devel

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [Low] The newly introduced `cold-reset` uAPI string is missing from the official device wedging documentation.

Pre-existing issues:
- [High] The `event_string` buffer used for the uevent is too small to hold multiple wedge recovery methods, leading to silent truncation and malformed uevent strings being sent to userspace.
--

--- Patch [1]: [PATCH v11 1/3] drm: Add DRM_WEDGE_RECOVERY_COLD_RESET recovery method ---
commit 187c2c07431486fea095780d51c31e9abe6dc614
Author: Mallesh Koujalagi <mallesh.koujalagi@intel.com>

drm: Add DRM_WEDGE_RECOVERY_COLD_RESET recovery method

Introduce DRM_WEDGE_RECOVERY_COLD_RESET (BIT(4)) recovery method to handle
scenarios requiring device power cycle.

> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 1ff0bf7cba6aa..94abe7a811a52 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -537,6 +537,8 @@ static const char *drm_get_wedge_recovery(unsigned int opt)
>  		return "bus-reset";
>  	case DRM_WEDGE_RECOVERY_VENDOR:
>  		return "vendor-specific";
> +	case DRM_WEDGE_RECOVERY_COLD_RESET:
> +		return "cold-reset";

[Severity: High]
This is a pre-existing issue, but is the WEDGE_STR_LEN buffer large enough
to hold all combinations now that a new recovery method is added?

In drivers/gpu/drm/drm_drv.c:drm_dev_wedged_event():

#define WEDGE_STR_LEN 32
...
	len = scnprintf(event_string, sizeof(event_string), "%s", "WEDGED=");
...
		len += scnprintf(event_string + len, sizeof(event_string) - len,
				 "%s,", recovery);
...
	if (recovery)
		/* Get rid of trailing comma */
		event_string[len - 1] = '\0';

If a device enters an unrecoverable state with multiple flags set
(like DRM_WEDGE_RECOVERY_REBIND | DRM_WEDGE_RECOVERY_BUS_RESET |
DRM_WEDGE_RECOVERY_COLD_RESET), the string representation exceeds the 32 byte
limit of event_string.

Because scnprintf caps the write, the trailing comma removal logic will
inadvertently overwrite the last valid character, leading to a malformed
uevent string being sent to userspace (e.g., WEDGED=rebind,bus-reset,cold-r).
Could this prevent userspace parsers from recognizing the method?

>  	default:
>  		return NULL;
>  	}
> diff --git a/include/drm/drm_device.h b/include/drm/drm_device.h
> index 768a8dae83c52..75f030d027ee4 100644
> --- a/include/drm/drm_device.h
> +++ b/include/drm/drm_device.h
> @@ -37,6 +37,7 @@ struct pci_controller;
>  #define DRM_WEDGE_RECOVERY_REBIND	BIT(1)	/* unbind + bind driver */
>  #define DRM_WEDGE_RECOVERY_BUS_RESET	BIT(2)	/* unbind + reset bus device + bind */
>  #define DRM_WEDGE_RECOVERY_VENDOR	BIT(3)	/* vendor specific recovery method */
> +#define DRM_WEDGE_RECOVERY_COLD_RESET	BIT(4)	/* remove device + slot power cycle + rescan */

[Severity: Low]
Should this newly introduced cold-reset method also be added to the uAPI
documentation?

The device wedging documentation in Documentation/gpu/drm-uapi.rst lists
consumer expectations for other methods (none, rebind, bus-reset,
vendor-specific, unknown), but cold-reset is currently missing.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260720101815.526813-5-mallesh.koujalagi@intel.com?part=1

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v11 3/3] drm/xe: Handle PUNIT errors by requesting cold-reset recovery
  2026-07-20 10:18 ` [PATCH v11 3/3] drm/xe: Handle PUNIT errors by requesting cold-reset recovery Mallesh Koujalagi
@ 2026-07-20 10:48   ` sashiko-bot
  2026-07-21 17:37     ` Rodrigo Vivi
  0 siblings, 1 reply; 8+ messages in thread
From: sashiko-bot @ 2026-07-20 10:48 UTC (permalink / raw)
  To: Mallesh Koujalagi; +Cc: dri-devel

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Calling `xe_device_declare_wedged()` during early driver probe fails to notify userspace because the DRM device is not yet registered in sysfs.
--

--- Patch [3]: [PATCH v11 3/3] drm/xe: Handle PUNIT errors by requesting cold-reset recovery ---
commit e4801339581daca0be0db10f90d94f25e72cfa52
Author: Mallesh Koujalagi <mallesh.koujalagi@intel.com>

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

When PUNIT (power management unit) errors are detected that persist across
warm resets, mark the device as wedged with DRM_WEDGE_RECOVERY_COLD_RESET
and notify userspace 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);
> +	xe_device_declare_wedged(xe);
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

[Severity: High]
Does calling xe_device_declare_wedged() here fail to notify userspace when
triggered during early driver probe?

If a PUNIT error is present at driver load, the call chain is:

xe_device_probe()
  xe_ras_init()
    xe_ras_process_errors()
      handle_soc_internal_errors()
        punit_error_handler()
          xe_device_declare_wedged()
            drm_dev_wedged_event()

Since drm_dev_register() has not yet been called at this stage of the probe
path, the sysfs directory for the DRM device does not exist, and the KOBJ_ADD
event has not been emitted.

Consequently, userspace (e.g., udev) will likely drop or ignore the KOBJ_CHANGE
uevent emitted by drm_dev_wedged_event().

Will this cause the device to finish probe successfully but leave userspace
unaware of the wedged state, breaking the automated cold reset recovery
mechanism?

> +}
> +
>  static u8 handle_soc_internal_errors(struct xe_device *xe, struct xe_ras_error_array *arr)
>  {
>  	struct xe_ras_soc_error *info = (void *)arr->details;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260720101815.526813-5-mallesh.koujalagi@intel.com?part=3

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v11 3/3] drm/xe: Handle PUNIT errors by requesting cold-reset recovery
  2026-07-20 10:48   ` sashiko-bot
@ 2026-07-21 17:37     ` Rodrigo Vivi
  0 siblings, 0 replies; 8+ messages in thread
From: Rodrigo Vivi @ 2026-07-21 17:37 UTC (permalink / raw)
  To: sashiko-reviews; +Cc: Mallesh Koujalagi, dri-devel

On Mon, Jul 20, 2026 at 10:48:15AM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] Calling `xe_device_declare_wedged()` during early driver probe fails to notify userspace because the DRM device is not yet registered in sysfs.
> --
> 
> --- Patch [3]: [PATCH v11 3/3] drm/xe: Handle PUNIT errors by requesting cold-reset recovery ---
> commit e4801339581daca0be0db10f90d94f25e72cfa52
> Author: Mallesh Koujalagi <mallesh.koujalagi@intel.com>
> 
> drm/xe: Handle PUNIT errors by requesting cold-reset recovery
> 
> When PUNIT (power management unit) errors are detected that persist across
> warm resets, mark the device as wedged with DRM_WEDGE_RECOVERY_COLD_RESET
> and notify userspace 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);
> > +	xe_device_declare_wedged(xe);
>         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> [Severity: High]
> Does calling xe_device_declare_wedged() here fail to notify userspace when
> triggered during early driver probe?
> 
> If a PUNIT error is present at driver load, the call chain is:
> 
> xe_device_probe()
>   xe_ras_init()
>     xe_ras_process_errors()
>       handle_soc_internal_errors()
>         punit_error_handler()
>           xe_device_declare_wedged()
>             drm_dev_wedged_event()
> 
> Since drm_dev_register() has not yet been called at this stage of the probe
> path, the sysfs directory for the DRM device does not exist, and the KOBJ_ADD
> event has not been emitted.
> 
> Consequently, userspace (e.g., udev) will likely drop or ignore the KOBJ_CHANGE
> uevent emitted by drm_dev_wedged_event().
> 
> Will this cause the device to finish probe successfully but leave userspace
> unaware of the wedged state, breaking the automated cold reset recovery
> mechanism?

Mallesh, could you please add a fault-inject test to this flow here and
ensure that we are indeed getting the notification we are willing to get?

It looks that right now we are really never getting the uevent that we
are willing to get.

Thanks,
Rodrigo.

> 
> > +}
> > +
> >  static u8 handle_soc_internal_errors(struct xe_device *xe, struct xe_ras_error_array *arr)
> >  {
> >  	struct xe_ras_soc_error *info = (void *)arr->details;
> 
> -- 
> Sashiko AI review · https://sashiko.dev/#/patchset/20260720101815.526813-5-mallesh.koujalagi@intel.com?part=3

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v11 0/3] Introduce cold reset recovery method
       [not found] ` <amHzsHmNSH84SZ92@black.igk.intel.com>
@ 2026-07-23 14:03   ` Rodrigo Vivi
  0 siblings, 0 replies; 8+ messages in thread
From: Rodrigo Vivi @ 2026-07-23 14:03 UTC (permalink / raw)
  To: Raag Jadav
  Cc: Mallesh Koujalagi, intel-xe, dri-devel, andrealmeid,
	christian.koenig, airlied, simona.vetter, mripard,
	maarten.lankhorst, tzimmermann, anshuman.gupta, badal.nilawar,
	riana.tauro, karthik.poosa, sk.anirban

On Thu, Jul 23, 2026 at 12:57:52PM +0200, Raag Jadav wrote:
> On Mon, Jul 20, 2026 at 03:48:16PM +0530, Mallesh Koujalagi wrote:
> > Add support for handling errors that require a complete
> > device power cycle (cold reset) to recover.
> > 
> > Certain error conditions leave the device in a persistent hardware
> > error state that cannot be cleared through existing recovery mechanisms
> > such as driver reload or PCIe reset. In these cases, functionality can
> > only be restored by performing a cold reset.
> > 
> > To support this, the series introduces a new DRM wedging recovery
> > method, DRM_WEDGE_RECOVERY_COLD_RESET (BIT(4)). When a device is wedged
> > with this method, the DRM core notifies userspace via a uevent that a cold
> > reset is required. This allows userspace to take appropriate action to
> > power-cycle the device.
> 
> This one looks like to good to go.

I don't think so. Sashiko had identified that this path of cold reset
won't be actually reached in the probe. I asked the introduction
of a fault-inject test case so we can ensure that we do hit this case.

> 
> Chris? André? Can you please help review so we can merge it?

That aside, after we ensure the path is hit, we want to keep this
cold reset one.
So, the ack is already welcomed and needed.

Thanks,
Rodrigo.

> 
> Raag

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-07-23 14:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-20 10:18 [PATCH v11 0/3] Introduce cold reset recovery method Mallesh Koujalagi
2026-07-20 10:18 ` [PATCH v11 1/3] drm: Add DRM_WEDGE_RECOVERY_COLD_RESET " Mallesh Koujalagi
2026-07-20 10:30   ` sashiko-bot
2026-07-20 10:18 ` [PATCH v11 2/3] drm/doc: Document " Mallesh Koujalagi
2026-07-20 10:18 ` [PATCH v11 3/3] drm/xe: Handle PUNIT errors by requesting cold-reset recovery Mallesh Koujalagi
2026-07-20 10:48   ` sashiko-bot
2026-07-21 17:37     ` Rodrigo Vivi
     [not found] ` <amHzsHmNSH84SZ92@black.igk.intel.com>
2026-07-23 14:03   ` [PATCH v11 0/3] Introduce cold reset recovery method Rodrigo Vivi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox