Re: [PATCH v3 0/3] implement GPU reset API
From: Onur Özkan
Date: Wed Jul 08 2026 - 07:53:34 EST
On Wed, 08 Jul 2026 14:43:15 +0300
Onur Özkan <work@xxxxxxxxxxxxx> wrote:
> Add support for scheduling GPU resets on a dedicated workqueue. Track
> the reset state to avoid queueing another reset while one is already
> pending or in progress.
>
> Use an SRCU based gate to block new hardware access once a reset is
> scheduled and wait for current users before starting it. Run the
> pre_reset() and post_reset() hooks around the reset sequence so driver
> components can prepare for a reset and restore their state afterwards.
>
> Model the reset stages with a typestate pattern where each operation
> consumes the current state and returns the next one. This keeps the
> pre_reset(), GPU reset and post_reset() calls in order and prevents
> a stage from being called twice accidentally.
>
> Stop new reset requests during teardown and drain any queued or running
> reset work before releasing the device resources.
>
> Also move the existing synchronous reset sequence into the reset module
> and use it for both the initial reset and scheduled resets.
>
> This implementation is WIP and will be followed with more work later. It
> should be safe to land this series as there's no hardware using this API
> yet.
>
> Based on 'commit 53441a9cae3c ("drm/tyr: program CSF global interface")'
> from tyr-for-upstream with the following patch series on the ML:
> - rust: workqueue: add cancel_sync support [1]
> - rust: add SRCU abstraction [2]
> - rust: workqueue: add ScopedQueue for lifetime bound items [3]
> - Creation of workqueues in Rust [4]
>
> TODOs:
> - On post_reset() failure, we don't do anything for now. We should
> unplug the GPU (that's what Panthor does) but we don't have the
> infrastructure for that yet [5].
> - In schedule(), similar to panthor_device_schedule_reset(), we should
> have a PM check but similar to the note above, we don't have the
> infrastructure for that yet.
>
> Changes since v2:
> - Replaced Work::disable_sync with Work::cancel_sync.
> - Used type state pattern for reset stages.
> - Using ScopedQueue with device lifetime instead of a static workqueue.
> - Removed SRCU patch from this series.
>
> Changes since v1:
> - Removed OrderedQueue and using Alice's workqueue implementation [1] instead.
> - Added Resettable trait with pre_reset and post_reset hooks to be implemented by
> reset-managed hardwares.
> - Added SRCU abstraction and used it to synchronize the reset work and hardware access.
>
Seems like I messed up the indentation. Sorry about that.
– Onur
> v1: https://lore.kernel.org/rust-for-linux/20260313091646.16938-1-work@xxxxxxxxxxxxx
> v2: https://lore.kernel.org/rust-for-linux/20260416171728.205141-1-work@xxxxxxxxxxxxx
>
> Link: https://lore.kernel.org/all/20260617131731.145337-1-work@xxxxxxxxxxxxx [1]
> Link: https://lore.kernel.org/all/20260613065348.96750-1-work@xxxxxxxxxxxxx [2]
> Link: https://lore.kernel.org/all/20260617144645.253444-1-work@xxxxxxxxxxxxx [3]
> Link: https://lore.kernel.org/all/20260312-create-workqueue-v4-0-ea39c351c38f@xxxxxxxxxx [4]
> Link: https://gitlab.freedesktop.org/panfrost/linux/-/work_items/29#note_3391826 [5]
> Link: https://gitlab.freedesktop.org/panfrost/linux/-/issues/28
>
> Onur Özkan (3):
> rust: workqueue: impl Send and Sync for OwnedQueue
> drm/tyr: clear stale IRQ state before soft reset
> drm/tyr: add GPU reset infrastructure
>
> drivers/gpu/drm/tyr/driver.rs | 39 ++--
> drivers/gpu/drm/tyr/reset.rs | 323 +++++++++++++++++++++++++++
> drivers/gpu/drm/tyr/reset/hw_gate.rs | 298 ++++++++++++++++++++++++
> drivers/gpu/drm/tyr/tyr.rs | 1 +
> rust/kernel/workqueue/mod.rs | 8 +
> 5 files changed, 644 insertions(+), 25 deletions(-)
> create mode 100644 drivers/gpu/drm/tyr/reset.rs
> create mode 100644 drivers/gpu/drm/tyr/reset/hw_gate.rs
>
> --
> 2.51.2
>