From: sashiko-bot@kernel.org
To: "Arun Iyengar" <aiyengar1990@gmail.com>
Cc: dri-devel@lists.freedesktop.org, media-ci@linuxtv.org
Subject: Re: [PATCH v2 4/4] accel/rocket: Reset the core at unbind
Date: Fri, 04 Dec 2026 07:02:57 +0000 [thread overview]
Message-ID: <sashiko-outbox-249285@kernel.org> (raw)
In-Reply-To: <20261204-rocket-fixes-v2-4-e9f9bb6f1304@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] accel/rocket: leak pending jobs when rocket_job_fini() resets
before teardown
- [Medium] accel/rocket: race with rocket_job_timedout() skips unbind
reset on arm64
--
commit 109a7ae7b99b893c05622e30ed45ea57de24766e
Author: Arun Iyengar <aiyengar1990@gmail.com>
accel/rocket: Reset the core at unbind
This commit resets the NPU core via core->reset.work before calling
drm_sched_fini() in rocket_job_fini(), and adds a core->removing flag so
rocket_job_run() rejects new jobs with -ENODEV during unbind.
> diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
> index 8bc0b80d9190b..2d636f983ced0 100644
> --- a/drivers/accel/rocket/rocket_job.c
> +++ b/drivers/accel/rocket/rocket_job.c
[ ... ]
> @@ -554,6 +558,15 @@ int rocket_job_init(struct rocket_core *core)
>
> void rocket_job_fini(struct rocket_core *core)
> {
> + /*
> + * drm_sched_fini() leaves the job on the NPU. Reset the core on the
> + * timeout queue, serialised with timeouts; that cancels pending jobs.
> + */
> + WRITE_ONCE(core->removing, true);
> + atomic_set(&core->reset.pending, 1);
> + queue_work(core->reset.wq, &core->reset.work);
> + flush_work(&core->reset.work);
[Severity: Medium]
Can a concurrent rocket_job_timedout() overwrite core->reset.pending and
cause the unbind reset to be skipped?
rocket_job_fini() writes core->removing and core->reset.pending with
relaxed operations outside core->reset.wq, while rocket_job_timedout()
runs rocket_reset() on that same ordered workqueue. On arm64,
core->reset.pending = 1 can become visible before core->removing = true:
CPU0 CPU1 CPU2
rocket_job_fini() rocket_job_timedout()
rocket_reset()
WRITE_ONCE(removing, true)
atomic_set(pending, 1)
atomic_set(pending, 0)
drm_sched_start()
rocket_job_run()
READ_ONCE(removing) == 0
rocket_job_hw_submit()
queue_work(reset.work)
flush_work(reset.work)
rocket_reset_work()
rocket_reset()
!atomic_read(pending)
return; <-- skips unbind reset
Because rocket_reset_work() does not set core->reset.pending itself, it
exits early once CPU1 has cleared it. rocket_core_fini() then disables
runtime PM and clears core->iommu_group while CPU2's job is still running,
so a completion IRQ before devres frees the interrupt calls
iommu_detach_group(NULL, NULL).
Setting core->reset.pending inside rocket_reset_work() and skipping
drm_sched_start() when core->removing is set would avoid this race.
> +
> drm_sched_fini(&core->sched);
[Severity: Medium]
Does calling drm_sched_fini() right after flush_work(&core->reset.work)
leak pending struct rocket_job objects?
rocket_reset() calls drm_sched_stop(&core->sched, NULL) and then
drm_sched_start(&core->sched, 0), which marks canceled jobs done on
sched->pending_list and queues sched->work_free_job asynchronously on
sched->submit_wq.
flush_work(&core->reset.work) does not wait for sched->submit_wq, so
drm_sched_fini() immediately cancels work_free_job via
drm_sched_wqueue_stop() before rocket_job_free() can run. Any job popped
by work_run_job in that window and rejected with -ENODEV by
rocket_job_run() stays on pending_list in the same way.
Because rocket_sched_ops has no .cancel_job callback, drm_sched_fini()
logs "Tearing down scheduler while jobs are pending!" and permanently
leaks each pending struct rocket_job along with its GEM BOs and rocket_vm
reference. Implementing .cancel_job in rocket_sched_ops would let
drm_sched_fini() clean up the remaining jobs.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204-rocket-fixes-v2-0-e9f9bb6f1304@gmail.com?part=4
prev parent reply other threads:[~2026-12-04 7:03 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 6:35 [PATCH v2 0/4] accel/rocket: Fix teardown with a job on the NPU Arun Iyengar via B4 Relay
2026-12-04 6:35 ` Arun Iyengar via B4 Relay
2026-12-04 6:35 ` Arun Iyengar
2026-12-04 6:35 ` [PATCH v2 1/4] accel/rocket: Wait for in-flight jobs before releasing the file's BOs Arun Iyengar via B4 Relay
2026-12-04 6:35 ` Arun Iyengar via B4 Relay
2026-12-04 6:35 ` Arun Iyengar
2026-12-04 7:05 ` sashiko-bot
2026-12-04 6:35 ` [PATCH v2 2/4] accel/rocket: Reset the core before detaching its IOMMU Arun Iyengar via B4 Relay
2026-12-04 6:35 ` Arun Iyengar via B4 Relay
2026-12-04 6:35 ` Arun Iyengar
2026-12-04 6:35 ` [PATCH v2 3/4] accel/rocket: Stop the scheduler before releasing the IOMMU group Arun Iyengar via B4 Relay
2026-12-04 6:35 ` Arun Iyengar via B4 Relay
2026-12-04 6:35 ` Arun Iyengar
2026-12-04 7:03 ` sashiko-bot
2026-12-04 6:35 ` [PATCH v2 4/4] accel/rocket: Reset the core at unbind Arun Iyengar via B4 Relay
2026-12-04 6:35 ` Arun Iyengar via B4 Relay
2026-12-04 6:35 ` Arun Iyengar
2026-12-04 7:02 ` 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-249285@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 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.