From: Nicolas Dufresne <nicolas@ndufresne.ca>
To: ZhaoJinming <zhaojinming@uniontech.com>,
Tomeu Vizoso <tomeu@tomeuvizoso.net>,
Oded Gabbay <ogabbay@kernel.org>
Cc: "Sumit Semwal" <sumit.semwal@linaro.org>,
"Christian König" <christian.koenig@amd.com>,
"Jeff Hugo" <jeff.hugo@oss.qualcomm.com>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org,
stable@vger.kernel.org
Subject: Re: [PATCH v6 1/2] accel/rocket: Fix error path handling in rocket_job_run()
Date: Wed, 10 Jun 2026 13:55:09 -0400 [thread overview]
Message-ID: <0e3b9cdb9d8bd692290dfabafb32d7faa5bd50f8.camel@ndufresne.ca> (raw)
In-Reply-To: <20260610071045.3414828-1-zhaojinming@uniontech.com>
[-- Attachment #1: Type: text/plain, Size: 2524 bytes --]
Hi,
Le mercredi 10 juin 2026 à 15:10 +0800, ZhaoJinming a écrit :
> In rocket_job_run(), after taking an extra fence reference for
> job->done_fence via dma_fence_get(), the error paths have three bugs:
>
> - The dma_fence reference held by job->done_fence is never released,
> causing a reference leak.
> - pm_runtime_get_sync() increments the usage counter even on failure,
> but the error path does not decrement it, leaking the runtime PM
> reference and preventing the NPU from suspending.
> - A valid but unsignaled fence is returned to the DRM scheduler,
> which triggers WARN("Fence ... released with pending signals!")
> when the scheduler drops its reference.
>
> Fix by replacing pm_runtime_get_sync() with pm_runtime_resume_and_get()
> which auto-balances the usage counter on failure, releasing both fence
> references on error, and returning ERR_PTR(ret) instead of the
> unsignaled fence.
>
> Cc: stable@vger.kernel.org
> Fixes: 0810d5ad88a1 ("accel/rocket: Add job submission IOCTL")
> Signed-off-by: ZhaoJinming <zhaojinming@uniontech.com>
> ---
This is a lot of versions within the same day. You should slow down a little so
a human can provide a review, and also document the differences in this section,
after the ---, or using a cover letter.
Nicolas
> drivers/accel/rocket/rocket_job.c | 19 ++++++++++++++-----
> 1 file changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/accel/rocket/rocket_job.c
> b/drivers/accel/rocket/rocket_job.c
> index ac51bff39833..e8a073e22ac2 100644
> --- a/drivers/accel/rocket/rocket_job.c
> +++ b/drivers/accel/rocket/rocket_job.c
> @@ -310,13 +310,22 @@ static struct dma_fence *rocket_job_run(struct
> drm_sched_job *sched_job)
> dma_fence_put(job->done_fence);
> job->done_fence = dma_fence_get(fence);
>
> - ret = pm_runtime_get_sync(core->dev);
> - if (ret < 0)
> - return fence;
> + ret = pm_runtime_resume_and_get(core->dev);
> + if (ret < 0) {
> + dma_fence_put(job->done_fence);
> + job->done_fence = NULL;
> + dma_fence_put(fence);
> + return ERR_PTR(ret);
> + }
>
> ret = iommu_attach_group(job->domain->domain, core->iommu_group);
> - if (ret < 0)
> - return fence;
> + if (ret < 0) {
> + pm_runtime_put(core->dev);
> + dma_fence_put(job->done_fence);
> + job->done_fence = NULL;
> + dma_fence_put(fence);
> + return ERR_PTR(ret);
> + }
>
> scoped_guard(mutex, &core->job_lock) {
> core->in_flight_job = job;
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2026-06-10 17:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260610061915.1CA281F00893@smtp.kernel.org>
2026-06-10 7:10 ` ZhaoJinming
2026-06-10 7:10 ` [PATCH v6 2/2] accel/rocket: Fix iommu_group leak and unsafe IRQ register access ZhaoJinming
2026-10-17 5:30 ` Sidong Yang
2026-06-10 17:55 ` Nicolas Dufresne [this message]
2026-06-12 9:03 ` [PATCH v6 1/2] accel/rocket: Fix error path handling in rocket_job_run() 赵金明
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=0e3b9cdb9d8bd692290dfabafb32d7faa5bd50f8.camel@ndufresne.ca \
--to=nicolas@ndufresne.ca \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jeff.hugo@oss.qualcomm.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=ogabbay@kernel.org \
--cc=stable@vger.kernel.org \
--cc=sumit.semwal@linaro.org \
--cc=tomeu@tomeuvizoso.net \
--cc=zhaojinming@uniontech.com \
/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
all inboxes | Powered by JetHome®