Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Medium] The cold-reset recovery script fails to find the hotplug slot for 
standard single-endpoint PCIe GPUs because it starts its search at the parent 
bridge, skipping the device itself.
--

--- Patch [2]: [PATCH v12 2/4] drm/doc: Document DRM_WEDGE_RECOVERY_COLD_RESET 
recovery method ---
commit 40a35f3de596a4e78fa7c7c9f9433ec0c0f1b456
Author: Mallesh Koujalagi <[email protected]>
drm/doc: Document DRM_WEDGE_RECOVERY_COLD_RESET recovery method

This commit adds documentation for the new "cold-reset" wedge recovery
method. It updates the expectations table and provides an example udev
rule and recovery script to perform a cold reset by removing the device,
toggling slot power, and rescanning the PCI bus.

> diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm-uapi.rst
> index 93df92c4ac8cf..52255247a6db9 100644
> --- a/Documentation/gpu/drm-uapi.rst
> +++ b/Documentation/gpu/drm-uapi.rst
[ ... ]
> @@ -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")")

[Severity: Medium]
Will this fail to find the hotplug slot for standard single-endpoint PCIe GPUs?

By initializing walk with dirname here, the script appears to start its search
at the parent bridge, skipping the device itself. Since the device's own
address typically matches the hotplug slot address, this skips checking the
device's slot and will result in no hotplug slot being found for single
endpoint devices.

> +
> +    while true; do
> +        ancestor=$(basename "$walk")
> +        case "$ancestor" in pci*) break ;; esac  # reached the virtual bus 
> root

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

Reply via email to