dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Arun Iyengar" <aiyengar1990@gmail.com>
Cc: dri-devel@lists.freedesktop.org, media-ci@linuxtv.org
Subject: Re: [PATCH 2/2] accel/rocket: Reset the core before detaching its IOMMU
Date: Tue, 01 Dec 2026 07:32:58 +0000	[thread overview]
Message-ID: <sashiko-outbox-242777@kernel.org> (raw)
In-Reply-To: <20261201-rocket-fixes-v1-2-986c3e5ceb44@gmail.com>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] accel/rocket: use-after-free and NULL pointer dereference
  in rocket_core_fini() [1]
--

commit 3c0ae1c947c1bfa587406e1f23468f81ff1b2fca
Author: Arun Iyengar <aiyengar1990@gmail.com>

accel/rocket: Reset the core before detaching its IOMMU

This commit moves the rocket_core_reset() call in rocket_reset() ahead of
iommu_detach_group() so that a hung NPU job does not block the IOMMU from
entering stall mode during detach.

Link: https://lore.kernel.org/r/20260613070116.438906-5-midgy971@gmail.com [1]

> diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
> index 32926afb0144c..8bc0b80d9190b 100644
> --- a/drivers/accel/rocket/rocket_job.c
> +++ b/drivers/accel/rocket/rocket_job.c
> @@ -427,15 +427,17 @@ rocket_reset(struct rocket_core *core, struct drm_sched_job *bad)
>  	 */
>  	scoped_guard(mutex, &core->job_lock) {
>  		put_job_ref = core->in_flight_job;
> -
> -		iommu_detach_group(NULL, core->iommu_group);
> -
>  		core->in_flight_job = NULL;
>  	}
>  
> -	/* Proceed with reset now. */
> +	/*
> +	 * Reset before detaching: the IOMMU cannot stall while a hung job
> +	 * keeps the bus busy, and then the detach fails.
> +	 */
>  	rocket_core_reset(core);
>  
> +	iommu_detach_group(NULL, core->iommu_group);
> +
>  	if (put_job_ref)
>  		pm_runtime_put_autosuspend(core->dev);

[Severity: Critical]
This problem wasn't introduced by this patch, but can rocket_reset() hit a
NULL pointer dereference in iommu_detach_group() and operate on disabled
runtime PM during teardown [1]?

In rocket_core_fini(), runtime PM is disabled and core->iommu_group is
released and cleared before rocket_job_fini() stops the scheduler:

drivers/accel/rocket/rocket_core.c:rocket_core_fini() {
	pm_runtime_dont_use_autosuspend(core->dev);
	pm_runtime_disable(core->dev);
	iommu_group_put(core->iommu_group);
	core->iommu_group = NULL;
	rocket_job_fini(core);
}

If an in-flight job times out before or during rocket_job_fini(),
rocket_reset() passes a NULL core->iommu_group to iommu_detach_group() and
calls pm_runtime_put_autosuspend() after runtime PM has been disabled.
Calling rocket_job_fini() first in rocket_core_fini() would avoid this.

[1] https://sashiko.dev/#/bug/linux-ef3ef432-292a-4ee1-addd-1b0440571e2d

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-rocket-fixes-v1-0-986c3e5ceb44@gmail.com?part=2

      reply	other threads:[~2026-12-01  7:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  7:28 [PATCH 0/2] accel/rocket: Fix file close and reset with a job on the NPU Arun Iyengar via B4 Relay
2026-12-01  7:28 ` [PATCH 1/2] accel/rocket: Wait for in-flight jobs before releasing the file's BOs Arun Iyengar via B4 Relay
2026-12-01  7:37   ` sashiko-bot
2026-12-01  7:28 ` [PATCH 2/2] accel/rocket: Reset the core before detaching its IOMMU Arun Iyengar via B4 Relay
2026-12-01  7:32   ` sashiko-bot [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=sashiko-outbox-242777@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=aiyengar1990@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=media-ci@linuxtv.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