On Wed, 08 Jul 2026 14:43:15 +0300
Onur Özkan <[email protected]> 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/[email protected]
> v2: 
> https://lore.kernel.org/rust-for-linux/[email protected]
> 
> Link: https://lore.kernel.org/all/[email protected] 
> [1]
> Link: https://lore.kernel.org/all/[email protected] 
> [2]
> Link: https://lore.kernel.org/all/[email protected] 
> [3]
> Link: 
> https://lore.kernel.org/all/[email protected]
>  [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
> 

Reply via email to