All of lore.kernel.org
 help / color / mirror / Atom feed
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 v4 0/7] accel/rocket: Fix teardown with a job on the NPU
Date: Sun, 06 Dec 2026 07:17:11 +0000	[thread overview]
Message-ID: <20261206-rocket-fixes-v4-0-75a6279bce98@gmail.com> (raw)

Fixes for teardown with a job on the NPU: at file close, in the
timeout reset and at core unbind.

1: wait for the file's jobs before its BOs are released.
2: reset the core before detaching its IOMMU (same change as Midgy
   Balon's RK3568 RFC, linked in the patch).
3: stop the scheduler before releasing the IOMMU group.
4: serialise core probe, removal and open (the slot part overlaps
   Igor Paunovic's pending patch, linked in the patch).
5: reset the core at unbind, which also cancels the job on the NPU.
6: free the jobs left at scheduler teardown.
7: move open files off a core at unbind, and back onto it at bind.

Tested on an Orange Pi 5 (RK3588), 7.3, KASAN, unbinding the second of
the three cores. Before: SIGKILL during inference timed out 12 times in
10 kills, faulting jobs gave IOMMU stall timeouts, an unbind during a
timeout oopsed in iommu_detach_group(), close hung on a hung job, and an
unbind with queued jobs hit a use-after-free. After: none of these in 70
kills, 10 faulting jobs and 3-5 runs of each unbind case; on v4 also an
open during a core's probe, SIGKILL of the unbinding task and close of a
killed file after the last unbind (all three reproduced on v3, the last
a use-after-free oops). No KASAN or lockdep report; inference unchanged
after rebinds. The NULL detach from the interrupt handler in patch 5
follows from the code; I could not trigger it.

Developed with Claude (Anthropic), which wrote the code and the commit
messages. I reviewed every change.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
Changes in v4:
- Patch 4: hold the lock across open, so a file never gets a core whose
  probe is still running; READ_ONCE()/WRITE_ONCE() on the core's .dev
  (Sashiko).
- Patch 7: close waits until the file's jobs are freed, as killed jobs
  are freed later and use the core (Sashiko).
- Patch 7: only entities on the unbound core are rebuilt; the others,
  and all at bind, get the new core list. No wait for other files' jobs,
  and a signal to the unbinding task no longer kills them (Sashiko).
- Link to v3: https://patch.msgid.link/20261205-rocket-fixes-v3-0-e5032fa408a3@gmail.com

Changes in v3:
- Patch 1: wait for the last job that reached the NPU, set in
  rocket_job_run(), not the last one pushed: close no longer waits for
  killed jobs or their fences (Sashiko).
- New patch 4: serialise core probe and removal, take a free slot.
- Patch 5: timeouts during unbind leave the core to the unbind reset and
  do not restart the scheduler (Sashiko).
- Patch 5: the reset work sets reset.pending itself, so a concurrent
  timeout cannot skip the unbind reset (Sashiko).
- New patch 6: .cancel_job, so drm_sched_fini() frees the jobs left
  pending (Sashiko).
- New patch 7: move open files off a core at unbind (was "Not fixed"),
  and back at bind.
- Link to v2: https://patch.msgid.link/20261204-rocket-fixes-v2-0-e9f9bb6f1304@gmail.com

Changes in v2:
- New patch 3: stop the scheduler before releasing the IOMMU group
  (Sashiko).
- New patch 4: reset the core at unbind.
- Patch 1: drop a comment that repeated the commit message.
- Patch 2 unchanged.
- Link to v1: https://patch.msgid.link/20261201-rocket-fixes-v1-0-986c3e5ceb44@gmail.com

---
Arun Iyengar (7):
      accel/rocket: Wait for in-flight jobs before releasing the file's BOs
      accel/rocket: Reset the core before detaching its IOMMU
      accel/rocket: Stop the scheduler before releasing the IOMMU group
      accel/rocket: Serialise core probe and removal
      accel/rocket: Reset the core at unbind
      accel/rocket: Free the jobs left at scheduler teardown
      accel/rocket: Move open files off a core at unbind

 drivers/accel/rocket/rocket_core.c   |   4 +-
 drivers/accel/rocket/rocket_core.h   |   2 +
 drivers/accel/rocket/rocket_device.c |   7 +-
 drivers/accel/rocket/rocket_device.h |   2 +
 drivers/accel/rocket/rocket_drv.c    |  79 ++++++++++++---
 drivers/accel/rocket/rocket_drv.h    |  10 ++
 drivers/accel/rocket/rocket_job.c    | 189 +++++++++++++++++++++++++++++++----
 drivers/accel/rocket/rocket_job.h    |   3 +
 8 files changed, 256 insertions(+), 40 deletions(-)
---
base-commit: 502ea48d0d8fa5dd0c31dc449efb3d82deef8efe
change-id: 20261130-rocket-fixes-e1438ca23bee

Best regards,
--  
Arun Iyengar <aiyengar1990@gmail.com>


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 v4 0/7] accel/rocket: Fix teardown with a job on the NPU
Date: Sun, 06 Dec 2026 07:17:11 +0000	[thread overview]
Message-ID: <20261206-rocket-fixes-v4-0-75a6279bce98@gmail.com> (raw)

Fixes for teardown with a job on the NPU: at file close, in the
timeout reset and at core unbind.

1: wait for the file's jobs before its BOs are released.
2: reset the core before detaching its IOMMU (same change as Midgy
   Balon's RK3568 RFC, linked in the patch).
3: stop the scheduler before releasing the IOMMU group.
4: serialise core probe, removal and open (the slot part overlaps
   Igor Paunovic's pending patch, linked in the patch).
5: reset the core at unbind, which also cancels the job on the NPU.
6: free the jobs left at scheduler teardown.
7: move open files off a core at unbind, and back onto it at bind.

Tested on an Orange Pi 5 (RK3588), 7.3, KASAN, unbinding the second of
the three cores. Before: SIGKILL during inference timed out 12 times in
10 kills, faulting jobs gave IOMMU stall timeouts, an unbind during a
timeout oopsed in iommu_detach_group(), close hung on a hung job, and an
unbind with queued jobs hit a use-after-free. After: none of these in 70
kills, 10 faulting jobs and 3-5 runs of each unbind case; on v4 also an
open during a core's probe, SIGKILL of the unbinding task and close of a
killed file after the last unbind (all three reproduced on v3, the last
a use-after-free oops). No KASAN or lockdep report; inference unchanged
after rebinds. The NULL detach from the interrupt handler in patch 5
follows from the code; I could not trigger it.

Developed with Claude (Anthropic), which wrote the code and the commit
messages. I reviewed every change.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
Changes in v4:
- Patch 4: hold the lock across open, so a file never gets a core whose
  probe is still running; READ_ONCE()/WRITE_ONCE() on the core's .dev
  (Sashiko).
- Patch 7: close waits until the file's jobs are freed, as killed jobs
  are freed later and use the core (Sashiko).
- Patch 7: only entities on the unbound core are rebuilt; the others,
  and all at bind, get the new core list. No wait for other files' jobs,
  and a signal to the unbinding task no longer kills them (Sashiko).
- Link to v3: https://patch.msgid.link/20261205-rocket-fixes-v3-0-e5032fa408a3@gmail.com

Changes in v3:
- Patch 1: wait for the last job that reached the NPU, set in
  rocket_job_run(), not the last one pushed: close no longer waits for
  killed jobs or their fences (Sashiko).
- New patch 4: serialise core probe and removal, take a free slot.
- Patch 5: timeouts during unbind leave the core to the unbind reset and
  do not restart the scheduler (Sashiko).
- Patch 5: the reset work sets reset.pending itself, so a concurrent
  timeout cannot skip the unbind reset (Sashiko).
- New patch 6: .cancel_job, so drm_sched_fini() frees the jobs left
  pending (Sashiko).
- New patch 7: move open files off a core at unbind (was "Not fixed"),
  and back at bind.
- Link to v2: https://patch.msgid.link/20261204-rocket-fixes-v2-0-e9f9bb6f1304@gmail.com

Changes in v2:
- New patch 3: stop the scheduler before releasing the IOMMU group
  (Sashiko).
- New patch 4: reset the core at unbind.
- Patch 1: drop a comment that repeated the commit message.
- Patch 2 unchanged.
- Link to v1: https://patch.msgid.link/20261201-rocket-fixes-v1-0-986c3e5ceb44@gmail.com

---
Arun Iyengar (7):
      accel/rocket: Wait for in-flight jobs before releasing the file's BOs
      accel/rocket: Reset the core before detaching its IOMMU
      accel/rocket: Stop the scheduler before releasing the IOMMU group
      accel/rocket: Serialise core probe and removal
      accel/rocket: Reset the core at unbind
      accel/rocket: Free the jobs left at scheduler teardown
      accel/rocket: Move open files off a core at unbind

 drivers/accel/rocket/rocket_core.c   |   4 +-
 drivers/accel/rocket/rocket_core.h   |   2 +
 drivers/accel/rocket/rocket_device.c |   7 +-
 drivers/accel/rocket/rocket_device.h |   2 +
 drivers/accel/rocket/rocket_drv.c    |  79 ++++++++++++---
 drivers/accel/rocket/rocket_drv.h    |  10 ++
 drivers/accel/rocket/rocket_job.c    | 189 +++++++++++++++++++++++++++++++----
 drivers/accel/rocket/rocket_job.h    |   3 +
 8 files changed, 256 insertions(+), 40 deletions(-)
---
base-commit: 502ea48d0d8fa5dd0c31dc449efb3d82deef8efe
change-id: 20261130-rocket-fixes-e1438ca23bee

Best regards,
--  
Arun Iyengar <aiyengar1990@gmail.com>



_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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 v4 0/7] accel/rocket: Fix teardown with a job on the NPU
Date: Sun, 06 Dec 2026 07:17:11 +0000	[thread overview]
Message-ID: <20261206-rocket-fixes-v4-0-75a6279bce98@gmail.com> (raw)

Fixes for teardown with a job on the NPU: at file close, in the
timeout reset and at core unbind.

1: wait for the file's jobs before its BOs are released.
2: reset the core before detaching its IOMMU (same change as Midgy
   Balon's RK3568 RFC, linked in the patch).
3: stop the scheduler before releasing the IOMMU group.
4: serialise core probe, removal and open (the slot part overlaps
   Igor Paunovic's pending patch, linked in the patch).
5: reset the core at unbind, which also cancels the job on the NPU.
6: free the jobs left at scheduler teardown.
7: move open files off a core at unbind, and back onto it at bind.

Tested on an Orange Pi 5 (RK3588), 7.3, KASAN, unbinding the second of
the three cores. Before: SIGKILL during inference timed out 12 times in
10 kills, faulting jobs gave IOMMU stall timeouts, an unbind during a
timeout oopsed in iommu_detach_group(), close hung on a hung job, and an
unbind with queued jobs hit a use-after-free. After: none of these in 70
kills, 10 faulting jobs and 3-5 runs of each unbind case; on v4 also an
open during a core's probe, SIGKILL of the unbinding task and close of a
killed file after the last unbind (all three reproduced on v3, the last
a use-after-free oops). No KASAN or lockdep report; inference unchanged
after rebinds. The NULL detach from the interrupt handler in patch 5
follows from the code; I could not trigger it.

Developed with Claude (Anthropic), which wrote the code and the commit
messages. I reviewed every change.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
Changes in v4:
- Patch 4: hold the lock across open, so a file never gets a core whose
  probe is still running; READ_ONCE()/WRITE_ONCE() on the core's .dev
  (Sashiko).
- Patch 7: close waits until the file's jobs are freed, as killed jobs
  are freed later and use the core (Sashiko).
- Patch 7: only entities on the unbound core are rebuilt; the others,
  and all at bind, get the new core list. No wait for other files' jobs,
  and a signal to the unbinding task no longer kills them (Sashiko).
- Link to v3: https://patch.msgid.link/20261205-rocket-fixes-v3-0-e5032fa408a3@gmail.com

Changes in v3:
- Patch 1: wait for the last job that reached the NPU, set in
  rocket_job_run(), not the last one pushed: close no longer waits for
  killed jobs or their fences (Sashiko).
- New patch 4: serialise core probe and removal, take a free slot.
- Patch 5: timeouts during unbind leave the core to the unbind reset and
  do not restart the scheduler (Sashiko).
- Patch 5: the reset work sets reset.pending itself, so a concurrent
  timeout cannot skip the unbind reset (Sashiko).
- New patch 6: .cancel_job, so drm_sched_fini() frees the jobs left
  pending (Sashiko).
- New patch 7: move open files off a core at unbind (was "Not fixed"),
  and back at bind.
- Link to v2: https://patch.msgid.link/20261204-rocket-fixes-v2-0-e9f9bb6f1304@gmail.com

Changes in v2:
- New patch 3: stop the scheduler before releasing the IOMMU group
  (Sashiko).
- New patch 4: reset the core at unbind.
- Patch 1: drop a comment that repeated the commit message.
- Patch 2 unchanged.
- Link to v1: https://patch.msgid.link/20261201-rocket-fixes-v1-0-986c3e5ceb44@gmail.com

---
Arun Iyengar (7):
      accel/rocket: Wait for in-flight jobs before releasing the file's BOs
      accel/rocket: Reset the core before detaching its IOMMU
      accel/rocket: Stop the scheduler before releasing the IOMMU group
      accel/rocket: Serialise core probe and removal
      accel/rocket: Reset the core at unbind
      accel/rocket: Free the jobs left at scheduler teardown
      accel/rocket: Move open files off a core at unbind

 drivers/accel/rocket/rocket_core.c   |   4 +-
 drivers/accel/rocket/rocket_core.h   |   2 +
 drivers/accel/rocket/rocket_device.c |   7 +-
 drivers/accel/rocket/rocket_device.h |   2 +
 drivers/accel/rocket/rocket_drv.c    |  79 ++++++++++++---
 drivers/accel/rocket/rocket_drv.h    |  10 ++
 drivers/accel/rocket/rocket_job.c    | 189 +++++++++++++++++++++++++++++++----
 drivers/accel/rocket/rocket_job.h    |   3 +
 8 files changed, 256 insertions(+), 40 deletions(-)
---
base-commit: 502ea48d0d8fa5dd0c31dc449efb3d82deef8efe
change-id: 20261130-rocket-fixes-e1438ca23bee

Best regards,
--  
Arun Iyengar <aiyengar1990@gmail.com>



             reply	other threads:[~2026-12-06  7:17 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-06  7:17 Arun Iyengar [this message]
2026-12-06  7:17 ` [PATCH v4 0/7] accel/rocket: Fix teardown with a job on the NPU Arun Iyengar via B4 Relay
2026-12-06  7:17 ` Arun Iyengar via B4 Relay
2026-12-06  7:17 ` [PATCH v4 1/7] accel/rocket: Wait for in-flight jobs before releasing the file's BOs Arun Iyengar
2026-12-06  7:17   ` Arun Iyengar via B4 Relay
2026-12-06  7:17   ` Arun Iyengar via B4 Relay
2026-12-06  7:17 ` [PATCH v4 2/7] accel/rocket: Reset the core before detaching its IOMMU Arun Iyengar
2026-12-06  7:17   ` Arun Iyengar via B4 Relay
2026-12-06  7:17   ` Arun Iyengar via B4 Relay
2026-12-06  7:17 ` [PATCH v4 3/7] accel/rocket: Stop the scheduler before releasing the IOMMU group Arun Iyengar
2026-12-06  7:17   ` Arun Iyengar via B4 Relay
2026-12-06  7:17   ` Arun Iyengar via B4 Relay
2026-12-06  7:17 ` [PATCH v4 4/7] accel/rocket: Serialise core probe and removal Arun Iyengar
2026-12-06  7:17   ` Arun Iyengar via B4 Relay
2026-12-06  7:17   ` Arun Iyengar via B4 Relay
2026-12-06  7:42   ` sashiko-bot
2026-12-06  7:17 ` [PATCH v4 5/7] accel/rocket: Reset the core at unbind Arun Iyengar
2026-12-06  7:17   ` Arun Iyengar via B4 Relay
2026-12-06  7:17   ` Arun Iyengar via B4 Relay
2026-12-06  7:41   ` sashiko-bot
2026-12-06  7:17 ` [PATCH v4 6/7] accel/rocket: Free the jobs left at scheduler teardown Arun Iyengar
2026-12-06  7:17   ` Arun Iyengar via B4 Relay
2026-12-06  7:17   ` Arun Iyengar via B4 Relay
2026-12-06  7:17 ` [PATCH v4 7/7] accel/rocket: Move open files off a core at unbind Arun Iyengar
2026-12-06  7:17   ` Arun Iyengar via B4 Relay
2026-12-06  7:17   ` Arun Iyengar via B4 Relay

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=20261206-rocket-fixes-v4-0-75a6279bce98@gmail.com \
    --to=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.