From: Arun Iyengar via B4 Relay <devnull+aiyengar1990.gmail.com@kernel.org>
To: Tomeu Vizoso <tomeu@tomeuvizoso.net>, Oded Gabbay <ogabbay@kernel.org>
Cc: "Heiko Stuebner" <heiko@sntech.de>,
"Jeff Hugo" <jeff.hugo@oss.qualcomm.com>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Christian König" <christian.koenig@amd.com>,
"Philipp Stanner" <phasta@kernel.org>,
"Danilo Krummrich" <dakr@kernel.org>,
"Matthew Brost" <matthew.brost@intel.com>,
"Igor Paunovic" <royalnet026@gmail.com>,
"Midgy BALON" <midgy971@gmail.com>,
"Jiaxing Hu" <gahing@gahingwoo.com>,
dri-devel@lists.freedesktop.org,
linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org,
stable@vger.kernel.org, "Arun Iyengar" <aiyengar1990@gmail.com>
Subject: [PATCH v3 5/7] accel/rocket: Reset the core at unbind
Date: Sat, 05 Dec 2026 06:51:09 +0000 [thread overview]
Message-ID: <20261205-rocket-fixes-v3-5-e5032fa408a3@gmail.com> (raw)
In-Reply-To: <20261205-rocket-fixes-v3-0-e5032fa408a3@gmail.com>
From: Arun Iyengar <aiyengar1990@gmail.com>
drm_sched_fini() leaves the job on the NPU running. If it completes
before devres frees the interrupt, rocket_job_handle_irq() detaches
a NULL IOMMU group. If it hangs, its fence never signals and a file
close waiting for it blocks forever.
Reset the core before stopping the scheduler, as on a timeout, and
do not start jobs after that. Timeouts from then on leave the core to
that reset, so none restarts the scheduler during drm_sched_fini().
Fixes: 0810d5ad88a1 ("accel/rocket: Add job submission IOCTL")
Cc: stable@vger.kernel.org
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
drivers/accel/rocket/rocket_core.h | 2 ++
drivers/accel/rocket/rocket_job.c | 17 +++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/drivers/accel/rocket/rocket_core.h b/drivers/accel/rocket/rocket_core.h
index 0b7e82ae7ef2..6bbdba221e9e 100644
--- a/drivers/accel/rocket/rocket_core.h
+++ b/drivers/accel/rocket/rocket_core.h
@@ -64,6 +64,8 @@ struct rocket_core {
atomic_t pending;
} reset;
+ bool removing;
+
struct drm_gpu_scheduler sched;
u64 fence_context;
u64 emit_seqno;
diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
index d83306eaeb86..b44101800f85 100644
--- a/drivers/accel/rocket/rocket_job.c
+++ b/drivers/accel/rocket/rocket_job.c
@@ -330,6 +330,9 @@ static struct dma_fence *rocket_job_run(struct drm_sched_job *sched_job)
if (unlikely(job->base.s_fence->finished.error))
return NULL;
+ if (READ_ONCE(core->removing))
+ return ERR_PTR(-ENODEV);
+
/*
* Nothing to execute: can happen if the job has finished while
* we were resetting the NPU.
@@ -453,6 +456,10 @@ static enum drm_gpu_sched_stat rocket_job_timedout(struct drm_sched_job *sched_j
struct rocket_device *rdev = job->rdev;
struct rocket_core *core = sched_to_core(rdev, sched_job->sched);
+ /* The reset work queued by rocket_job_fini() resets the core */
+ if (READ_ONCE(core->removing))
+ return DRM_GPU_SCHED_STAT_NO_HANG;
+
dev_err(core->dev, "NPU job timed out");
atomic_set(&core->reset.pending, 1);
@@ -466,6 +473,7 @@ static void rocket_reset_work(struct work_struct *work)
struct rocket_core *core;
core = container_of(work, struct rocket_core, reset.work);
+ atomic_set(&core->reset.pending, 1);
rocket_reset(core, NULL);
}
@@ -514,6 +522,7 @@ int rocket_job_init(struct rocket_core *core)
int ret;
INIT_WORK(&core->reset.work, rocket_reset_work);
+ core->removing = false;
spin_lock_init(&core->fence_lock);
mutex_init(&core->job_lock);
@@ -553,6 +562,14 @@ 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, after any running timeout; that cancels pending jobs.
+ */
+ WRITE_ONCE(core->removing, true);
+ queue_work(core->reset.wq, &core->reset.work);
+ flush_work(&core->reset.work);
+
drm_sched_fini(&core->sched);
cancel_work_sync(&core->reset.work);
--
2.55.0
WARNING: multiple messages have this Message-ID (diff)
From: Arun Iyengar <aiyengar1990@gmail.com>
To: Tomeu Vizoso <tomeu@tomeuvizoso.net>, Oded Gabbay <ogabbay@kernel.org>
Cc: "Heiko Stuebner" <heiko@sntech.de>,
"Jeff Hugo" <jeff.hugo@oss.qualcomm.com>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Christian König" <christian.koenig@amd.com>,
"Philipp Stanner" <phasta@kernel.org>,
"Danilo Krummrich" <dakr@kernel.org>,
"Matthew Brost" <matthew.brost@intel.com>,
"Igor Paunovic" <royalnet026@gmail.com>,
"Midgy BALON" <midgy971@gmail.com>,
"Jiaxing Hu" <gahing@gahingwoo.com>,
dri-devel@lists.freedesktop.org,
linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org,
stable@vger.kernel.org, "Arun Iyengar" <aiyengar1990@gmail.com>
Subject: [PATCH v3 5/7] accel/rocket: Reset the core at unbind
Date: Sat, 05 Dec 2026 06:51:09 +0000 [thread overview]
Message-ID: <20261205-rocket-fixes-v3-5-e5032fa408a3@gmail.com> (raw)
In-Reply-To: <20261205-rocket-fixes-v3-0-e5032fa408a3@gmail.com>
drm_sched_fini() leaves the job on the NPU running. If it completes
before devres frees the interrupt, rocket_job_handle_irq() detaches
a NULL IOMMU group. If it hangs, its fence never signals and a file
close waiting for it blocks forever.
Reset the core before stopping the scheduler, as on a timeout, and
do not start jobs after that. Timeouts from then on leave the core to
that reset, so none restarts the scheduler during drm_sched_fini().
Fixes: 0810d5ad88a1 ("accel/rocket: Add job submission IOCTL")
Cc: stable@vger.kernel.org
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
drivers/accel/rocket/rocket_core.h | 2 ++
drivers/accel/rocket/rocket_job.c | 17 +++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/drivers/accel/rocket/rocket_core.h b/drivers/accel/rocket/rocket_core.h
index 0b7e82ae7ef2..6bbdba221e9e 100644
--- a/drivers/accel/rocket/rocket_core.h
+++ b/drivers/accel/rocket/rocket_core.h
@@ -64,6 +64,8 @@ struct rocket_core {
atomic_t pending;
} reset;
+ bool removing;
+
struct drm_gpu_scheduler sched;
u64 fence_context;
u64 emit_seqno;
diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
index d83306eaeb86..b44101800f85 100644
--- a/drivers/accel/rocket/rocket_job.c
+++ b/drivers/accel/rocket/rocket_job.c
@@ -330,6 +330,9 @@ static struct dma_fence *rocket_job_run(struct drm_sched_job *sched_job)
if (unlikely(job->base.s_fence->finished.error))
return NULL;
+ if (READ_ONCE(core->removing))
+ return ERR_PTR(-ENODEV);
+
/*
* Nothing to execute: can happen if the job has finished while
* we were resetting the NPU.
@@ -453,6 +456,10 @@ static enum drm_gpu_sched_stat rocket_job_timedout(struct drm_sched_job *sched_j
struct rocket_device *rdev = job->rdev;
struct rocket_core *core = sched_to_core(rdev, sched_job->sched);
+ /* The reset work queued by rocket_job_fini() resets the core */
+ if (READ_ONCE(core->removing))
+ return DRM_GPU_SCHED_STAT_NO_HANG;
+
dev_err(core->dev, "NPU job timed out");
atomic_set(&core->reset.pending, 1);
@@ -466,6 +473,7 @@ static void rocket_reset_work(struct work_struct *work)
struct rocket_core *core;
core = container_of(work, struct rocket_core, reset.work);
+ atomic_set(&core->reset.pending, 1);
rocket_reset(core, NULL);
}
@@ -514,6 +522,7 @@ int rocket_job_init(struct rocket_core *core)
int ret;
INIT_WORK(&core->reset.work, rocket_reset_work);
+ core->removing = false;
spin_lock_init(&core->fence_lock);
mutex_init(&core->job_lock);
@@ -553,6 +562,14 @@ 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, after any running timeout; that cancels pending jobs.
+ */
+ WRITE_ONCE(core->removing, true);
+ queue_work(core->reset.wq, &core->reset.work);
+ flush_work(&core->reset.work);
+
drm_sched_fini(&core->sched);
cancel_work_sync(&core->reset.work);
--
2.55.0
WARNING: multiple messages have this Message-ID (diff)
From: Arun Iyengar via B4 Relay <devnull+aiyengar1990.gmail.com@kernel.org>
To: Tomeu Vizoso <tomeu@tomeuvizoso.net>, Oded Gabbay <ogabbay@kernel.org>
Cc: "Heiko Stuebner" <heiko@sntech.de>,
"Jeff Hugo" <jeff.hugo@oss.qualcomm.com>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Christian König" <christian.koenig@amd.com>,
"Philipp Stanner" <phasta@kernel.org>,
"Danilo Krummrich" <dakr@kernel.org>,
"Matthew Brost" <matthew.brost@intel.com>,
"Igor Paunovic" <royalnet026@gmail.com>,
"Midgy BALON" <midgy971@gmail.com>,
"Jiaxing Hu" <gahing@gahingwoo.com>,
dri-devel@lists.freedesktop.org,
linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org,
stable@vger.kernel.org, "Arun Iyengar" <aiyengar1990@gmail.com>
Subject: [PATCH v3 5/7] accel/rocket: Reset the core at unbind
Date: Sat, 05 Dec 2026 06:51:09 +0000 [thread overview]
Message-ID: <20261205-rocket-fixes-v3-5-e5032fa408a3@gmail.com> (raw)
In-Reply-To: <20261205-rocket-fixes-v3-0-e5032fa408a3@gmail.com>
From: Arun Iyengar <aiyengar1990@gmail.com>
drm_sched_fini() leaves the job on the NPU running. If it completes
before devres frees the interrupt, rocket_job_handle_irq() detaches
a NULL IOMMU group. If it hangs, its fence never signals and a file
close waiting for it blocks forever.
Reset the core before stopping the scheduler, as on a timeout, and
do not start jobs after that. Timeouts from then on leave the core to
that reset, so none restarts the scheduler during drm_sched_fini().
Fixes: 0810d5ad88a1 ("accel/rocket: Add job submission IOCTL")
Cc: stable@vger.kernel.org
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
drivers/accel/rocket/rocket_core.h | 2 ++
drivers/accel/rocket/rocket_job.c | 17 +++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/drivers/accel/rocket/rocket_core.h b/drivers/accel/rocket/rocket_core.h
index 0b7e82ae7ef2..6bbdba221e9e 100644
--- a/drivers/accel/rocket/rocket_core.h
+++ b/drivers/accel/rocket/rocket_core.h
@@ -64,6 +64,8 @@ struct rocket_core {
atomic_t pending;
} reset;
+ bool removing;
+
struct drm_gpu_scheduler sched;
u64 fence_context;
u64 emit_seqno;
diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
index d83306eaeb86..b44101800f85 100644
--- a/drivers/accel/rocket/rocket_job.c
+++ b/drivers/accel/rocket/rocket_job.c
@@ -330,6 +330,9 @@ static struct dma_fence *rocket_job_run(struct drm_sched_job *sched_job)
if (unlikely(job->base.s_fence->finished.error))
return NULL;
+ if (READ_ONCE(core->removing))
+ return ERR_PTR(-ENODEV);
+
/*
* Nothing to execute: can happen if the job has finished while
* we were resetting the NPU.
@@ -453,6 +456,10 @@ static enum drm_gpu_sched_stat rocket_job_timedout(struct drm_sched_job *sched_j
struct rocket_device *rdev = job->rdev;
struct rocket_core *core = sched_to_core(rdev, sched_job->sched);
+ /* The reset work queued by rocket_job_fini() resets the core */
+ if (READ_ONCE(core->removing))
+ return DRM_GPU_SCHED_STAT_NO_HANG;
+
dev_err(core->dev, "NPU job timed out");
atomic_set(&core->reset.pending, 1);
@@ -466,6 +473,7 @@ static void rocket_reset_work(struct work_struct *work)
struct rocket_core *core;
core = container_of(work, struct rocket_core, reset.work);
+ atomic_set(&core->reset.pending, 1);
rocket_reset(core, NULL);
}
@@ -514,6 +522,7 @@ int rocket_job_init(struct rocket_core *core)
int ret;
INIT_WORK(&core->reset.work, rocket_reset_work);
+ core->removing = false;
spin_lock_init(&core->fence_lock);
mutex_init(&core->job_lock);
@@ -553,6 +562,14 @@ 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, after any running timeout; that cancels pending jobs.
+ */
+ WRITE_ONCE(core->removing, true);
+ queue_work(core->reset.wq, &core->reset.work);
+ flush_work(&core->reset.work);
+
drm_sched_fini(&core->sched);
cancel_work_sync(&core->reset.work);
--
2.55.0
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
next prev parent reply other threads:[~2026-12-05 6:51 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 6:51 [PATCH v3 0/7] accel/rocket: Fix teardown with a job on the NPU Arun Iyengar via B4 Relay
2026-12-05 6:51 ` Arun Iyengar via B4 Relay
2026-12-05 6:51 ` Arun Iyengar
2026-12-05 6:51 ` [PATCH v3 1/7] accel/rocket: Wait for in-flight jobs before releasing the file's BOs Arun Iyengar via B4 Relay
2026-12-05 6:51 ` Arun Iyengar via B4 Relay
2026-12-05 6:51 ` Arun Iyengar
2026-12-05 6:51 ` [PATCH v3 2/7] accel/rocket: Reset the core before detaching its IOMMU Arun Iyengar via B4 Relay
2026-12-05 6:51 ` Arun Iyengar via B4 Relay
2026-12-05 6:51 ` Arun Iyengar
2026-12-05 6:51 ` [PATCH v3 3/7] accel/rocket: Stop the scheduler before releasing the IOMMU group Arun Iyengar via B4 Relay
2026-12-05 6:51 ` Arun Iyengar via B4 Relay
2026-12-05 6:51 ` Arun Iyengar
2026-12-05 6:51 ` [PATCH v3 4/7] accel/rocket: Serialise core probe and removal Arun Iyengar via B4 Relay
2026-12-05 6:51 ` Arun Iyengar via B4 Relay
2026-12-05 6:51 ` Arun Iyengar
2026-12-05 7:16 ` sashiko-bot
2026-12-05 6:51 ` Arun Iyengar via B4 Relay [this message]
2026-12-05 6:51 ` [PATCH v3 5/7] accel/rocket: Reset the core at unbind Arun Iyengar via B4 Relay
2026-12-05 6:51 ` Arun Iyengar
2026-12-05 6:51 ` [PATCH v3 6/7] accel/rocket: Free the jobs left at scheduler teardown Arun Iyengar via B4 Relay
2026-12-05 6:51 ` Arun Iyengar via B4 Relay
2026-12-05 6:51 ` Arun Iyengar
2026-12-05 6:51 ` [PATCH v3 7/7] accel/rocket: Move open files off a core at unbind Arun Iyengar via B4 Relay
2026-12-05 6:51 ` Arun Iyengar via B4 Relay
2026-12-05 6:51 ` Arun Iyengar
2026-12-05 7:31 ` sashiko-bot
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=20261205-rocket-fixes-v3-5-e5032fa408a3@gmail.com \
--to=devnull+aiyengar1990.gmail.com@kernel.org \
--cc=aiyengar1990@gmail.com \
--cc=christian.koenig@amd.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gahing@gahingwoo.com \
--cc=heiko@sntech.de \
--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=linux-rockchip@lists.infradead.org \
--cc=matthew.brost@intel.com \
--cc=midgy971@gmail.com \
--cc=ogabbay@kernel.org \
--cc=phasta@kernel.org \
--cc=royalnet026@gmail.com \
--cc=stable@vger.kernel.org \
--cc=sumit.semwal@linaro.org \
--cc=tomeu@tomeuvizoso.net \
/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.