Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jiaxing Hu" <gahing@gahingwoo.com>
Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v15 04/15] accel/rocket: let the core suspend after a reset
Date: Sun, 01 Nov 2026 08:46:01 +0000	[thread overview]
Message-ID: <sashiko-outbox-192339@kernel.org> (raw)
In-Reply-To: <20261101082307.151957-5-gahing@gahingwoo.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] accel/rocket: asynchronous autosuspend in rocket_reset() skips domain reset
- [Medium] accel/rocket: pm_runtime_put_autosuspend() precedes detach and reset
--

commit a40b84e5c2017a835f035c1e3114023e0444d2a9
Author: Jiaxing Hu <gahing@gahingwoo.com>

accel/rocket: let the core suspend after a reset

This commit replaces pm_runtime_put_noidle() with
pm_runtime_put_autosuspend() in rocket_reset() when dropping the
in-flight job's runtime PM reference so that the NPU core can runtime
suspend and power-cycle its domain after a timeout.

Link: https://lore.kernel.org/all/20260819073530.6087-1-royalnet026@gmail.com/

> diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
> index 5b2abf40b618c..152a9098634b9 100644
> --- a/drivers/accel/rocket/rocket_job.c
> +++ b/drivers/accel/rocket/rocket_job.c
> @@ -467,12 +467,12 @@ rocket_reset(struct rocket_core *core, struct drm_sched_job *bad)
>  
>  	/*
>  	 * No handler is running now, but we might still have stuck jobs. Let's
> -	 * make sure the PM counters stay balanced by manually calling
> -	 * pm_runtime_put_noidle().
> +	 * make sure the PM counters stay balanced by putting the reference the
> +	 * job took, and request idle while doing it so the core can suspend.
>  	 */
>  	scoped_guard(mutex, &core->job_lock) {
>  		if (core->in_flight_job)
> -			pm_runtime_put_noidle(core->dev);
> +			pm_runtime_put_autosuspend(core->dev);

[Severity: High]
As reported by Sashiko on v14 [1], can pm_runtime_put_autosuspend() skip
the required power domain cycle when another job is already queued or
submitted shortly after the reset?

In rocket_core_init(), runtime PM autosuspend is configured with a 50 ms
delay:

    pm_runtime_use_autosuspend(dev);
    ...
    pm_runtime_set_autosuspend_delay(dev, 50);

When rocket_reset() calls pm_runtime_put_autosuspend(core->dev), it marks
the device busy and schedules the autosuspend timer 50 ms in the future,
returning while core->dev is still in RPM_ACTIVE. Immediately after that,
rocket_reset() runs rocket_core_reset(core), clears core->reset.pending,
and restarts the scheduler via drm_sched_start(&core->sched, 0).

If another job is already queued in the scheduler (for example from a
multi-job submission in rocket_ioctl_submit()) or submitted within the
50 ms window, rocket_job_run() will call:

    ret = pm_runtime_resume_and_get(core->dev);

while core->dev is still RPM_ACTIVE, which increments usage_count and
cancels the pending autosuspend without ever suspending the device or
cycling its power domain. On RK3576, won't this leave the NPU bus
interface and IOMMU wedged for subsequent jobs?

[Severity: Medium]
Also in rocket_reset(), is it safe to call
pm_runtime_put_autosuspend(core->dev) before
iommu_detach_group(NULL, core->iommu_group) and rocket_core_reset(core)
have completed?

Unlike the normal completion path in rocket_job_handle_irq(), which
detaches the IOMMU group before dropping the runtime PM reference:

    iommu_detach_group(NULL, iommu_group_get(core->dev));
    dma_fence_signal(core->in_flight_job->done_fence);
    pm_runtime_put_autosuspend(core->dev);
    core->in_flight_job = NULL;

rocket_reset() drops the last runtime PM reference on core->dev before
calling iommu_detach_group() and rocket_core_reset():

    scoped_guard(mutex, &core->job_lock) {
            if (core->in_flight_job)
                    pm_runtime_put_autosuspend(core->dev);

            iommu_detach_group(NULL, core->iommu_group);

            core->in_flight_job = NULL;
    }

    /* Proceed with reset now. */
    rocket_core_reset(core);

If autosuspend_delay_ms is set to 0 or negative via sysfs, or if the reset
worker is preempted past the autosuspend delay, runtime suspend on pm_wq
can run rocket_device_runtime_suspend() and drop supplier references via
__rpm_put_suppliers(core->dev) concurrently with iommu_detach_group() and
rocket_core_reset(core).

Could this turn off core clocks and the power domain before
rocket_core_reset() pulses the synchronous reset lines, and race with
rk_iommu_identity_attach() in drivers/iommu/rockchip-iommu.c:

    iommu->domain = identity_domain;
    ...
    ret = pm_runtime_get_if_in_use(iommu->dev);
    WARN_ON_ONCE(ret < 0);
    if (ret > 0) {
            rk_iommu_disable(iommu);
            pm_runtime_put(iommu->dev);
    }

such that both rk_iommu_identity_attach() and rk_iommu_suspend() skip
rk_iommu_disable(iommu)?

[1] https://lore.kernel.org/r/20260924102135.92217-5-gahing@gahingwoo.com

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261101082307.151957-1-gahing@gahingwoo.com?part=4

  reply	other threads:[~2026-11-01  8:46 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-01  8:22 [PATCH v15 00/15] accel/rocket: RK3576 NPU (RKNN) enablement Jiaxing Hu
2026-11-01  8:22 ` [PATCH v15 01/15] accel/rocket: request the core clocks by name Jiaxing Hu
2026-11-01  8:22 ` [PATCH v15 02/15] accel/rocket: take the completion register writes under job_lock Jiaxing Hu
2026-11-01  8:22 ` [PATCH v15 03/15] accel/rocket: wait for a running IRQ handler before resetting a core Jiaxing Hu
2026-11-01  8:55   ` sashiko-bot
2026-11-01  8:22 ` [PATCH v15 04/15] accel/rocket: let the core suspend after a reset Jiaxing Hu
2026-11-01  8:46   ` sashiko-bot [this message]
2026-11-01  8:22 ` [PATCH v15 05/15] accel/rocket: factor the completion tail out of the IRQ handler Jiaxing Hu
2026-11-01  8:22 ` [PATCH v15 06/15] dt-bindings: npu: rockchip: add rockchip,rk3576-rknn-core Jiaxing Hu
2026-11-01  8:37   ` [PATCH v15 06/15] dt-bindings: npu: rockchip: add rockchip, rk3576-rknn-core sashiko-bot
2026-11-01  8:22 ` [PATCH v15 07/15] dt-bindings: power: rockchip: allow resets in a power domain node Jiaxing Hu
2026-11-01  8:23 ` [PATCH v15 08/15] dt-bindings: iommu: rockchip: describe the RK3576 NPU MMU Jiaxing Hu
2026-11-01  8:23 ` [PATCH v15 09/15] pmdomain: rockchip: add optional per-domain power-on settle delay Jiaxing Hu
2026-11-01  8:47   ` sashiko-bot
2026-11-01  8:23 ` [PATCH v15 10/15] pmdomain: rockchip: cycle an optional power-domain reset on power-on Jiaxing Hu
2026-11-01  8:23 ` [PATCH v15 11/15] accel/rocket: select the per-core clock and reset counts from match data Jiaxing Hu
2026-11-02  1:52   ` Chaoyi Chen
2026-11-01  8:23 ` [PATCH v15 12/15] accel/rocket: add RK3576 NPU (RKNN) support Jiaxing Hu
2026-11-01  8:23 ` [PATCH v15 13/15] arm64: dts: rockchip: add NPU core domain clocks and resets to rk3576 Jiaxing Hu
2026-11-01  8:23 ` [PATCH v15 14/15] arm64: dts: rockchip: add NPU (RKNN) nodes " Jiaxing Hu
2026-11-01  8:23 ` [PATCH v15 15/15] arm64: dts: rockchip: enable the NPU on rk3576-rock-4d Jiaxing Hu

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-192339@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gahing@gahingwoo.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox