All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Onur Özkan" <work@onurozkan.dev>, dri-devel@lists.freedesktop.org
Cc: ojeda@kernel.org, gary@garyguo.net
Subject: Re: [PATCH v8 2/3] drm/tyr: add GPU reset infrastructure
Date: Fri, 13 Nov 2026 14:47:34 +0000	[thread overview]
Message-ID: <sashiko-outbox-213013@kernel.org> (raw)
In-Reply-To: <20261113-tyr-reset-impl-v8-2-2ee298ac9808@onurozkan.dev>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/tyr: prepared clocks leaked on error in
  TyrPlatformDriver::probe()
- [Low] drm/tyr: overly restrictive &'reset self lifetime in
  ResetHandle::schedule()
--

commit 2f1b0845121531379549eca9ca27fd1ffc58562f
Author: Onur Özkan <work@onurozkan.dev>

drm/tyr: add GPU reset infrastructure

This commit adds GPU reset infrastructure using a dedicated ordered
workqueue and an SRCU-based hardware access gate, and drains pending
or running reset work on teardown.

Link: https://gitlab.freedesktop.org/panfrost/linux/-/work_items/28

> diff --git a/drivers/gpu/drm/tyr/driver.rs b/drivers/gpu/drm/tyr/driver.rs
> index 5b57bc9a1d3e7..863c8008a132b 100644
> --- a/drivers/gpu/drm/tyr/driver.rs
> +++ b/drivers/gpu/drm/tyr/driver.rs
[ ... ]
> @@ -171,8 +153,11 @@ fn probe<'bound>(
>                  _reg <- unsafe { drm::Registration::new(
>                      pdev.as_ref(),
>                      unreg_dev,
> -                    pin_init!(TyrDrmRegistrationData {
> +                    try_pin_init!(TyrDrmRegistrationData {
>                          pdev,
> +                        // SAFETY: The registration is owned by platform driver data,
> +                        // so reset work is drained before borrowed data expires.
> +                        reset <- reset::ResetHandle::new(pdev, iomem.as_arc_borrow())?,
>                          fw: firmware,
>                          clks <- new_mutex!(Clocks {
>                              core: core_clk,

[Severity: Medium]
Does this leak the prepared and enabled clocks if ResetHandle::new() or
its PinInit initializer fails?

Drop for Clk and OptionalClk only calls clk_put(), while
disable_unprepare() is only called in Clocks::drop():

drivers/gpu/drm/tyr/driver.rs:Clocks::drop() {
    fn drop(&mut self) {
        self.core.disable_unprepare();
        self.stacks.disable_unprepare();
        self.coregroup.disable_unprepare();
    }
}

Because TyrDrmRegistrationData now initializes reset via try_pin_init!
before constructing Clocks, a failure in Queue::build() or HwGate::new()
(as well as earlier error paths after prepare_enable() in probe()) drops
core_clk, stacks_clk, and coregroup_clk without disabling or unpreparing
them, leaving the hardware clocks enabled and triggering a warning in
clk_put().  Wrapping the clocks in Clocks immediately after
prepare_enable() would ensure they are cleaned up on all error paths.

> diff --git a/drivers/gpu/drm/tyr/reset.rs b/drivers/gpu/drm/tyr/reset.rs
> new file mode 100644
> index 0000000000000..640371b3104da
> --- /dev/null
> +++ b/drivers/gpu/drm/tyr/reset.rs
[ ... ]
> +pub(crate) struct ResetHandle<'reset> {
> +    #[pin]
> +    controller: ScopedWork<Controller<'reset>>,
> +    wq: OwnedQueue,
> +}
[ ... ]
> +    /// Schedules a GPU reset on the dedicated workqueue.
> +    ///
> +    /// If a reset is already pending or in progress the call is a no-op.
> +    #[expect(dead_code)]
> +    pub(crate) fn schedule(&'reset self) {
> +        // TODO: Similar to `panthor_device_schedule_reset()` in Panthor, add a
> +        // power management check once Tyr supports it.
> +
> +        if self
> +            .controller
> +            .try_transition(ResetState::Idle, ResetState::Pending)
> +        {
> +            let _ = self.wq.enqueue_scoped(&self.controller);
> +        }
> +    }

[Severity: Low]
Can ResetHandle::schedule() take &self instead of &'reset self?

ScopedWork wraps its payload in Opaque (UnsafeCell), making
ResetHandle<'reset> invariant over 'reset, where 'reset is the device
binding lifetime in TyrDrmRegistrationData<'drm>.  Requiring &'reset self
prevents callers holding a normal short-lived borrow of
TyrDrmRegistrationData or ResetHandle from calling schedule(), and
neither try_transition() nor enqueue_scoped() needs the reference to live
for 'reset.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261113-tyr-reset-impl-v8-0-2ee298ac9808@onurozkan.dev?part=2

  reply	other threads:[~2026-11-13 14:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 14:32 [PATCH v8 0/3] drm/tyr: GPU reset infrastructure Onur Özkan
2026-11-13 14:32 ` [PATCH v8 1/3] drm/tyr: clear stale IRQ state before soft reset Onur Özkan
2026-11-13 14:40   ` sashiko-bot
2026-11-13 14:32 ` [PATCH v8 2/3] drm/tyr: add GPU reset infrastructure Onur Özkan
2026-11-13 14:47   ` sashiko-bot [this message]
2026-11-13 14:32 ` [PATCH v8 3/3] drm/tyr: put iomem behind the hardware gate Onur Özkan

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=sashiko-outbox-213013@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gary@garyguo.net \
    --cc=ojeda@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=work@onurozkan.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.