The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Onur Özkan" <work@onurozkan.dev>
To: "Onur Özkan" <work@onurozkan.dev>
Cc: linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
	dri-devel@lists.freedesktop.org, dakr@kernel.org,
	aliceryhl@google.com, daniel.almeida@collabora.com,
	airlied@gmail.com, simona@ffwll.ch, ojeda@kernel.org,
	boqun@kernel.org, gary@garyguo.net, bjorn3_gh@protonmail.com,
	lossin@kernel.org, a.hindborg@kernel.org, tmgross@umich.edu
Subject: Re: [PATCH v3 0/3] implement GPU reset API
Date: Wed,  8 Jul 2026 14:47:53 +0300	[thread overview]
Message-ID: <20260708114756.963735-1-work@onurozkan.dev> (raw)
In-Reply-To: <20260708114358.957305-1-work@onurozkan.dev>

On Wed, 08 Jul 2026 14:43:15 +0300
Onur Özkan <work@onurozkan.dev> 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@onurozkan.dev
> v2: https://lore.kernel.org/rust-for-linux/20260416171728.205141-1-work@onurozkan.dev
> 
> Link: https://lore.kernel.org/all/20260617131731.145337-1-work@onurozkan.dev [1]
> Link: https://lore.kernel.org/all/20260613065348.96750-1-work@onurozkan.dev [2]
> Link: https://lore.kernel.org/all/20260617144645.253444-1-work@onurozkan.dev [3]
> Link: https://lore.kernel.org/all/20260312-create-workqueue-v4-0-ea39c351c38f@google.com [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
> 

      parent reply	other threads:[~2026-07-08 11:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-08 11:43 [PATCH v3 0/3] implement GPU reset API Onur Özkan
2026-07-08 11:43 ` [PATCH v3 1/3] rust: workqueue: impl Send and Sync for OwnedQueue Onur Özkan
2026-07-08 11:43 ` [PATCH v3 2/3] drm/tyr: clear stale IRQ state before soft reset Onur Özkan
2026-07-08 11:43 ` [PATCH v3 3/3] drm/tyr: add GPU reset infrastructure Onur Özkan
2026-07-08 11:47 ` Onur Özkan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260708114756.963735-1-work@onurozkan.dev \
    --to=work@onurozkan.dev \
    --cc=a.hindborg@kernel.org \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tmgross@umich.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox