All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 00/18] media: verisilicon: Recover the Rockchip VPUs from faults and timeouts
@ 2026-12-06  5:57 ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar,
	Krzysztof Kozlowski, stable

On the RK3588, later jobs time out after a VEPU121 IOVA fault or AV1 error.

1, 7-9, 13: reset a VEPU121 core on a timeout, restore its IOMMU and IRQ
2-4, 6: NULL match in probe, request left queued, stale timestamp, probe
clock unwind (2, 3, 6 found by Sashiko). 5: no reset assert on remove.
10-12, 14: AV1 resets on its IOMMU too, held only in use (Philipp Zabel)
15-18: reset the AV1 decoder after an error; 18 replaces [1], 17 needs it
and ecceb7dba63c (v7.4-rc5). 15 (via media, needs a pmdomain ack) follows
"soc: rockchip: power-domain: export idle request" by Randy Li, Caesar
Wang and Jeffy Chen (not merged). Patches 1 to 14 do not need 15 to 18.

Tested on Orange Pi 5 (RK3588S), v7.3 plus other out-of-tree Hantro
patches. Provoked encoder timeouts and IOVA faults are reset, later jobs
encode; all VPU cores probe, H.264 fluster unchanged, v4l2-compliance -s
passes (JPEG encoder). A job refused after a failed IOMMU restore completes
its request; so does a forced resume failure (3), next decode bit-exact.
60/60 failed jobs return the right timestamp (4), 0/60 without. Forced late
probe failure (6): clock counts unchanged, nothing registered. AV1
unbind/rebind: SError before 5, clean with it; 20/20 with 10-12 and 14,
s2idle 3/3, AV1 fluster and encoder recovery unchanged. 15-18 on KASAN: 216
forced error interrupts, 216 resets, 108/108 decodes between them bit-exact
while a second handle allocates and frees buffers; 344 forced timeouts
reset, in 6 the abort stopped a running core; rebind 3/3, fluster unchanged
(218/242). Forced idle-request, idle-release or IOMMU restore failure: jobs
refused until a rebind, then bit-exact; clock failure in 15: next decode
bit-exact; IOMMU restore failure at probe: bind fails, nothing left.

Claude (Anthropic) wrote the code and commit messages; I reviewed them all.

[1] https://lore.kernel.org/r/20261113-rk3588-av1-reset-order-v1-1-d73f60222ff9@gmail.com

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>

---
Changes in v4:
- Rebased on media next (patches 2, 5 and 9 adjusted)
- New patch 4: copy the buffer metadata before a job can fail
- New patch 6: disable runtime PM before unpreparing the clocks on
  probe failure (Sashiko, v3)
- Patch 9 (was 8): restore the IOMMU at probe too (Sashiko, v3)
- New patches 15 to 18: reset the AV1 decoder after an error
- Patch 2: Reviewed-by from Nicolas; patch 11: Reviewed-by from Rob
- Link to v3: https://patch.msgid.link/20261113-hantro-robust-v3-0-82383c722ad2@gmail.com

Changes in v3:
- New patch 2: check the match data in hantro_probe() (Sashiko, v1)
- New patch 3: complete the request when the VPU can't resume
- Patch 7 (was 5): complete the request of a job refused after a failed
  IOMMU restore (Sashiko); fail the probe if the empty domain can't be
  allocated
- Patches 4 to 7 (were 2 to 5): shorter commit messages and comments
- New patches 8 to 10, 12: the AV1 resets on its IOMMU, released
  reset controls (Philipp Zabel)
- Patch 11 was 6
- Patch 1: Acked-by from Krzysztof
- Link to v2: https://patch.msgid.link/20261112-hantro-robust-v2-0-18561fd48838@gmail.com

Changes in v2:
- Patch 2: never assert the resets on remove or on the probe error path
- New patch 3: re-enable the encoder interrupt after a VEPU1/VEPU2 reset
- Patch 5 (was 4): restore the IOMMU only from the Rockchip encoder
  reset, only with reset lines and a DMA domain; refuse later jobs if
  the attach fails
- Link to v1: https://patch.msgid.link/20261110-hantro-robust-v1-0-6b6269c05bfa@gmail.com

---
Arun Iyengar (18):
      dt-bindings: media: rockchip,rk3568-vepu: Add the reset lines
      media: verisilicon: Check the match data in hantro_probe()
      media: verisilicon: Complete the request when the VPU can't resume
      media: verisilicon: Copy the buffer metadata before a job can fail
      media: verisilicon: Don't hold the VPU in reset after remove
      media: verisilicon: Disable runtime PM before unpreparing the clocks on probe failure
      media: verisilicon: Enable the Rockchip encoder interrupt again after a reset
      media: verisilicon: Reset the Rockchip encoder cores on timeout
      media: verisilicon: Reinitialize the IOMMU after resetting an encoder core
      media: verisilicon: Acquire the reset lines only while using them
      dt-bindings: iommu: verisilicon: Add the reset lines
      iommu/vsi: Deassert the reset lines on probe
      arm64: dts: rockchip: Add the reset lines of the RK3588 VEPU121 cores
      arm64: dts: rockchip: Add the reset lines of the RK3588 AV1 IOMMU
      pmdomain: rockchip: Add rockchip_pmu_idle_reset()
      dt-bindings: media: rockchip-vpu: Add reset-names
      media: verisilicon: Reset the RK3588 AV1 decoder after an error
      arm64: dts: rockchip: Name the RK3588 AV1 decoder resets

 .../bindings/iommu/verisilicon,iommu.yaml          |  10 ++
 .../bindings/media/rockchip,rk3568-vepu.yaml       |  10 ++
 .../devicetree/bindings/media/rockchip-vpu.yaml    |   7 +
 arch/arm64/boot/dts/rockchip/rk3588-base.dtsi      |  14 +-
 drivers/iommu/vsi-iommu.c                          |  16 ++
 drivers/media/platform/verisilicon/hantro.h        |  10 ++
 drivers/media/platform/verisilicon/hantro_drv.c    | 194 ++++++++++++++++-----
 drivers/media/platform/verisilicon/hantro_hw.h     |   6 +-
 .../platform/verisilicon/rockchip_vpu981_regs.h    |   3 +
 .../media/platform/verisilicon/rockchip_vpu_hw.c   | 130 +++++++++++++-
 .../media/platform/verisilicon/stm32mp25_vpu_hw.c  |   4 +
 drivers/media/platform/verisilicon/sunxi_vpu_hw.c  |   4 +
 drivers/pmdomain/rockchip/pm-domains.c             |  52 ++++++
 include/soc/rockchip/pm_domains.h                  |  12 ++
 14 files changed, 429 insertions(+), 43 deletions(-)
---
base-commit: 95c189b26efb07257888ccf9d873a5c366aafbc6
change-id: 20261110-hantro-robust-6a6c84febb06

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


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH v4 00/18] media: verisilicon: Recover the Rockchip VPUs from faults and timeouts
@ 2026-12-06  5:57 ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar,
	Krzysztof Kozlowski, stable

On the RK3588, later jobs time out after a VEPU121 IOVA fault or AV1 error.

1, 7-9, 13: reset a VEPU121 core on a timeout, restore its IOMMU and IRQ
2-4, 6: NULL match in probe, request left queued, stale timestamp, probe
clock unwind (2, 3, 6 found by Sashiko). 5: no reset assert on remove.
10-12, 14: AV1 resets on its IOMMU too, held only in use (Philipp Zabel)
15-18: reset the AV1 decoder after an error; 18 replaces [1], 17 needs it
and ecceb7dba63c (v7.4-rc5). 15 (via media, needs a pmdomain ack) follows
"soc: rockchip: power-domain: export idle request" by Randy Li, Caesar
Wang and Jeffy Chen (not merged). Patches 1 to 14 do not need 15 to 18.

Tested on Orange Pi 5 (RK3588S), v7.3 plus other out-of-tree Hantro
patches. Provoked encoder timeouts and IOVA faults are reset, later jobs
encode; all VPU cores probe, H.264 fluster unchanged, v4l2-compliance -s
passes (JPEG encoder). A job refused after a failed IOMMU restore completes
its request; so does a forced resume failure (3), next decode bit-exact.
60/60 failed jobs return the right timestamp (4), 0/60 without. Forced late
probe failure (6): clock counts unchanged, nothing registered. AV1
unbind/rebind: SError before 5, clean with it; 20/20 with 10-12 and 14,
s2idle 3/3, AV1 fluster and encoder recovery unchanged. 15-18 on KASAN: 216
forced error interrupts, 216 resets, 108/108 decodes between them bit-exact
while a second handle allocates and frees buffers; 344 forced timeouts
reset, in 6 the abort stopped a running core; rebind 3/3, fluster unchanged
(218/242). Forced idle-request, idle-release or IOMMU restore failure: jobs
refused until a rebind, then bit-exact; clock failure in 15: next decode
bit-exact; IOMMU restore failure at probe: bind fails, nothing left.

Claude (Anthropic) wrote the code and commit messages; I reviewed them all.

[1] https://lore.kernel.org/r/20261113-rk3588-av1-reset-order-v1-1-d73f60222ff9@gmail.com

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>

---
Changes in v4:
- Rebased on media next (patches 2, 5 and 9 adjusted)
- New patch 4: copy the buffer metadata before a job can fail
- New patch 6: disable runtime PM before unpreparing the clocks on
  probe failure (Sashiko, v3)
- Patch 9 (was 8): restore the IOMMU at probe too (Sashiko, v3)
- New patches 15 to 18: reset the AV1 decoder after an error
- Patch 2: Reviewed-by from Nicolas; patch 11: Reviewed-by from Rob
- Link to v3: https://patch.msgid.link/20261113-hantro-robust-v3-0-82383c722ad2@gmail.com

Changes in v3:
- New patch 2: check the match data in hantro_probe() (Sashiko, v1)
- New patch 3: complete the request when the VPU can't resume
- Patch 7 (was 5): complete the request of a job refused after a failed
  IOMMU restore (Sashiko); fail the probe if the empty domain can't be
  allocated
- Patches 4 to 7 (were 2 to 5): shorter commit messages and comments
- New patches 8 to 10, 12: the AV1 resets on its IOMMU, released
  reset controls (Philipp Zabel)
- Patch 11 was 6
- Patch 1: Acked-by from Krzysztof
- Link to v2: https://patch.msgid.link/20261112-hantro-robust-v2-0-18561fd48838@gmail.com

Changes in v2:
- Patch 2: never assert the resets on remove or on the probe error path
- New patch 3: re-enable the encoder interrupt after a VEPU1/VEPU2 reset
- Patch 5 (was 4): restore the IOMMU only from the Rockchip encoder
  reset, only with reset lines and a DMA domain; refuse later jobs if
  the attach fails
- Link to v1: https://patch.msgid.link/20261110-hantro-robust-v1-0-6b6269c05bfa@gmail.com

---
Arun Iyengar (18):
      dt-bindings: media: rockchip,rk3568-vepu: Add the reset lines
      media: verisilicon: Check the match data in hantro_probe()
      media: verisilicon: Complete the request when the VPU can't resume
      media: verisilicon: Copy the buffer metadata before a job can fail
      media: verisilicon: Don't hold the VPU in reset after remove
      media: verisilicon: Disable runtime PM before unpreparing the clocks on probe failure
      media: verisilicon: Enable the Rockchip encoder interrupt again after a reset
      media: verisilicon: Reset the Rockchip encoder cores on timeout
      media: verisilicon: Reinitialize the IOMMU after resetting an encoder core
      media: verisilicon: Acquire the reset lines only while using them
      dt-bindings: iommu: verisilicon: Add the reset lines
      iommu/vsi: Deassert the reset lines on probe
      arm64: dts: rockchip: Add the reset lines of the RK3588 VEPU121 cores
      arm64: dts: rockchip: Add the reset lines of the RK3588 AV1 IOMMU
      pmdomain: rockchip: Add rockchip_pmu_idle_reset()
      dt-bindings: media: rockchip-vpu: Add reset-names
      media: verisilicon: Reset the RK3588 AV1 decoder after an error
      arm64: dts: rockchip: Name the RK3588 AV1 decoder resets

 .../bindings/iommu/verisilicon,iommu.yaml          |  10 ++
 .../bindings/media/rockchip,rk3568-vepu.yaml       |  10 ++
 .../devicetree/bindings/media/rockchip-vpu.yaml    |   7 +
 arch/arm64/boot/dts/rockchip/rk3588-base.dtsi      |  14 +-
 drivers/iommu/vsi-iommu.c                          |  16 ++
 drivers/media/platform/verisilicon/hantro.h        |  10 ++
 drivers/media/platform/verisilicon/hantro_drv.c    | 194 ++++++++++++++++-----
 drivers/media/platform/verisilicon/hantro_hw.h     |   6 +-
 .../platform/verisilicon/rockchip_vpu981_regs.h    |   3 +
 .../media/platform/verisilicon/rockchip_vpu_hw.c   | 130 +++++++++++++-
 .../media/platform/verisilicon/stm32mp25_vpu_hw.c  |   4 +
 drivers/media/platform/verisilicon/sunxi_vpu_hw.c  |   4 +
 drivers/pmdomain/rockchip/pm-domains.c             |  52 ++++++
 include/soc/rockchip/pm_domains.h                  |  12 ++
 14 files changed, 429 insertions(+), 43 deletions(-)
---
base-commit: 95c189b26efb07257888ccf9d873a5c366aafbc6
change-id: 20261110-hantro-robust-6a6c84febb06

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



^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH v4 00/18] media: verisilicon: Recover the Rockchip VPUs from faults and timeouts
@ 2026-12-06  5:57 ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar,
	Krzysztof Kozlowski, stable

On the RK3588, later jobs time out after a VEPU121 IOVA fault or AV1 error.

1, 7-9, 13: reset a VEPU121 core on a timeout, restore its IOMMU and IRQ
2-4, 6: NULL match in probe, request left queued, stale timestamp, probe
clock unwind (2, 3, 6 found by Sashiko). 5: no reset assert on remove.
10-12, 14: AV1 resets on its IOMMU too, held only in use (Philipp Zabel)
15-18: reset the AV1 decoder after an error; 18 replaces [1], 17 needs it
and ecceb7dba63c (v7.4-rc5). 15 (via media, needs a pmdomain ack) follows
"soc: rockchip: power-domain: export idle request" by Randy Li, Caesar
Wang and Jeffy Chen (not merged). Patches 1 to 14 do not need 15 to 18.

Tested on Orange Pi 5 (RK3588S), v7.3 plus other out-of-tree Hantro
patches. Provoked encoder timeouts and IOVA faults are reset, later jobs
encode; all VPU cores probe, H.264 fluster unchanged, v4l2-compliance -s
passes (JPEG encoder). A job refused after a failed IOMMU restore completes
its request; so does a forced resume failure (3), next decode bit-exact.
60/60 failed jobs return the right timestamp (4), 0/60 without. Forced late
probe failure (6): clock counts unchanged, nothing registered. AV1
unbind/rebind: SError before 5, clean with it; 20/20 with 10-12 and 14,
s2idle 3/3, AV1 fluster and encoder recovery unchanged. 15-18 on KASAN: 216
forced error interrupts, 216 resets, 108/108 decodes between them bit-exact
while a second handle allocates and frees buffers; 344 forced timeouts
reset, in 6 the abort stopped a running core; rebind 3/3, fluster unchanged
(218/242). Forced idle-request, idle-release or IOMMU restore failure: jobs
refused until a rebind, then bit-exact; clock failure in 15: next decode
bit-exact; IOMMU restore failure at probe: bind fails, nothing left.

Claude (Anthropic) wrote the code and commit messages; I reviewed them all.

[1] https://lore.kernel.org/r/20261113-rk3588-av1-reset-order-v1-1-d73f60222ff9@gmail.com

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>

---
Changes in v4:
- Rebased on media next (patches 2, 5 and 9 adjusted)
- New patch 4: copy the buffer metadata before a job can fail
- New patch 6: disable runtime PM before unpreparing the clocks on
  probe failure (Sashiko, v3)
- Patch 9 (was 8): restore the IOMMU at probe too (Sashiko, v3)
- New patches 15 to 18: reset the AV1 decoder after an error
- Patch 2: Reviewed-by from Nicolas; patch 11: Reviewed-by from Rob
- Link to v3: https://patch.msgid.link/20261113-hantro-robust-v3-0-82383c722ad2@gmail.com

Changes in v3:
- New patch 2: check the match data in hantro_probe() (Sashiko, v1)
- New patch 3: complete the request when the VPU can't resume
- Patch 7 (was 5): complete the request of a job refused after a failed
  IOMMU restore (Sashiko); fail the probe if the empty domain can't be
  allocated
- Patches 4 to 7 (were 2 to 5): shorter commit messages and comments
- New patches 8 to 10, 12: the AV1 resets on its IOMMU, released
  reset controls (Philipp Zabel)
- Patch 11 was 6
- Patch 1: Acked-by from Krzysztof
- Link to v2: https://patch.msgid.link/20261112-hantro-robust-v2-0-18561fd48838@gmail.com

Changes in v2:
- Patch 2: never assert the resets on remove or on the probe error path
- New patch 3: re-enable the encoder interrupt after a VEPU1/VEPU2 reset
- Patch 5 (was 4): restore the IOMMU only from the Rockchip encoder
  reset, only with reset lines and a DMA domain; refuse later jobs if
  the attach fails
- Link to v1: https://patch.msgid.link/20261110-hantro-robust-v1-0-6b6269c05bfa@gmail.com

---
Arun Iyengar (18):
      dt-bindings: media: rockchip,rk3568-vepu: Add the reset lines
      media: verisilicon: Check the match data in hantro_probe()
      media: verisilicon: Complete the request when the VPU can't resume
      media: verisilicon: Copy the buffer metadata before a job can fail
      media: verisilicon: Don't hold the VPU in reset after remove
      media: verisilicon: Disable runtime PM before unpreparing the clocks on probe failure
      media: verisilicon: Enable the Rockchip encoder interrupt again after a reset
      media: verisilicon: Reset the Rockchip encoder cores on timeout
      media: verisilicon: Reinitialize the IOMMU after resetting an encoder core
      media: verisilicon: Acquire the reset lines only while using them
      dt-bindings: iommu: verisilicon: Add the reset lines
      iommu/vsi: Deassert the reset lines on probe
      arm64: dts: rockchip: Add the reset lines of the RK3588 VEPU121 cores
      arm64: dts: rockchip: Add the reset lines of the RK3588 AV1 IOMMU
      pmdomain: rockchip: Add rockchip_pmu_idle_reset()
      dt-bindings: media: rockchip-vpu: Add reset-names
      media: verisilicon: Reset the RK3588 AV1 decoder after an error
      arm64: dts: rockchip: Name the RK3588 AV1 decoder resets

 .../bindings/iommu/verisilicon,iommu.yaml          |  10 ++
 .../bindings/media/rockchip,rk3568-vepu.yaml       |  10 ++
 .../devicetree/bindings/media/rockchip-vpu.yaml    |   7 +
 arch/arm64/boot/dts/rockchip/rk3588-base.dtsi      |  14 +-
 drivers/iommu/vsi-iommu.c                          |  16 ++
 drivers/media/platform/verisilicon/hantro.h        |  10 ++
 drivers/media/platform/verisilicon/hantro_drv.c    | 194 ++++++++++++++++-----
 drivers/media/platform/verisilicon/hantro_hw.h     |   6 +-
 .../platform/verisilicon/rockchip_vpu981_regs.h    |   3 +
 .../media/platform/verisilicon/rockchip_vpu_hw.c   | 130 +++++++++++++-
 .../media/platform/verisilicon/stm32mp25_vpu_hw.c  |   4 +
 drivers/media/platform/verisilicon/sunxi_vpu_hw.c  |   4 +
 drivers/pmdomain/rockchip/pm-domains.c             |  52 ++++++
 include/soc/rockchip/pm_domains.h                  |  12 ++
 14 files changed, 429 insertions(+), 43 deletions(-)
---
base-commit: 95c189b26efb07257888ccf9d873a5c366aafbc6
change-id: 20261110-hantro-robust-6a6c84febb06

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



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

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH v4 01/18] dt-bindings: media: rockchip,rk3568-vepu: Add the reset lines
  2026-12-06  5:57 ` Arun Iyengar via B4 Relay
  (?)
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  -1 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar,
	Krzysztof Kozlowski

The VEPU121 encoder cores of the RK3588 each have their own AXI and AHB
reset lines in the CRU (SRST_A_JPEG_ENCODERx and SRST_H_JPEG_ENCODERx).
They are needed to recover a core that is stuck on the bus, which its
registers can't stop.

Describe them as optional, so that existing device trees stay valid.

Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 .../devicetree/bindings/media/rockchip,rk3568-vepu.yaml        | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/rockchip,rk3568-vepu.yaml b/Documentation/devicetree/bindings/media/rockchip,rk3568-vepu.yaml
index d246f5d38427..e9fda4373f0f 100644
--- a/Documentation/devicetree/bindings/media/rockchip,rk3568-vepu.yaml
+++ b/Documentation/devicetree/bindings/media/rockchip,rk3568-vepu.yaml
@@ -32,6 +32,16 @@ properties:
       - const: aclk
       - const: hclk
 
+  resets:
+    items:
+      - description: AXI reset line
+      - description: AHB reset line
+
+  reset-names:
+    items:
+      - const: axi
+      - const: ahb
+
   power-domains:
     maxItems: 1
 

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 01/18] dt-bindings: media: rockchip,rk3568-vepu: Add the reset lines
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar,
	Krzysztof Kozlowski

From: Arun Iyengar <aiyengar1990@gmail.com>

The VEPU121 encoder cores of the RK3588 each have their own AXI and AHB
reset lines in the CRU (SRST_A_JPEG_ENCODERx and SRST_H_JPEG_ENCODERx).
They are needed to recover a core that is stuck on the bus, which its
registers can't stop.

Describe them as optional, so that existing device trees stay valid.

Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 .../devicetree/bindings/media/rockchip,rk3568-vepu.yaml        | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/rockchip,rk3568-vepu.yaml b/Documentation/devicetree/bindings/media/rockchip,rk3568-vepu.yaml
index d246f5d38427..e9fda4373f0f 100644
--- a/Documentation/devicetree/bindings/media/rockchip,rk3568-vepu.yaml
+++ b/Documentation/devicetree/bindings/media/rockchip,rk3568-vepu.yaml
@@ -32,6 +32,16 @@ properties:
       - const: aclk
       - const: hclk
 
+  resets:
+    items:
+      - description: AXI reset line
+      - description: AHB reset line
+
+  reset-names:
+    items:
+      - const: axi
+      - const: ahb
+
   power-domains:
     maxItems: 1
 

-- 
2.55.0



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 01/18] dt-bindings: media: rockchip,rk3568-vepu: Add the reset lines
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar,
	Krzysztof Kozlowski

From: Arun Iyengar <aiyengar1990@gmail.com>

The VEPU121 encoder cores of the RK3588 each have their own AXI and AHB
reset lines in the CRU (SRST_A_JPEG_ENCODERx and SRST_H_JPEG_ENCODERx).
They are needed to recover a core that is stuck on the bus, which its
registers can't stop.

Describe them as optional, so that existing device trees stay valid.

Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 .../devicetree/bindings/media/rockchip,rk3568-vepu.yaml        | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/rockchip,rk3568-vepu.yaml b/Documentation/devicetree/bindings/media/rockchip,rk3568-vepu.yaml
index d246f5d38427..e9fda4373f0f 100644
--- a/Documentation/devicetree/bindings/media/rockchip,rk3568-vepu.yaml
+++ b/Documentation/devicetree/bindings/media/rockchip,rk3568-vepu.yaml
@@ -32,6 +32,16 @@ properties:
       - const: aclk
       - const: hclk
 
+  resets:
+    items:
+      - description: AXI reset line
+      - description: AHB reset line
+
+  reset-names:
+    items:
+      - const: axi
+      - const: ahb
+
   power-domains:
     maxItems: 1
 

-- 
2.55.0



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

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 02/18] media: verisilicon: Check the match data in hantro_probe()
  2026-12-06  5:57 ` Arun Iyengar via B4 Relay
  (?)
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  -1 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

A device bound through driver_override may have no OF match, and
hantro_probe() then dereferences a NULL match. Use
device_get_match_data() and fail with -ENODEV without match data.

Fixes: 775fec69008d ("media: add Rockchip VPU JPEG encoder driver")
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/hantro_drv.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index 5c962847fdf5..da9813c60cf7 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -17,6 +17,7 @@
 #include <linux/platform_device.h>
 #include <linux/pm.h>
 #include <linux/pm_runtime.h>
+#include <linux/property.h>
 #include <linux/slab.h>
 #include <linux/videodev2.h>
 #include <linux/workqueue.h>
@@ -1099,7 +1100,6 @@ static struct v4l2_m2m_dev *hantro_get_v4l2_m2m_dev(struct hantro_dev *vpu)
 
 static int hantro_probe(struct platform_device *pdev)
 {
-	const struct of_device_id *match;
 	struct hantro_dev *vpu;
 	int i, ret;
 
@@ -1112,8 +1112,9 @@ static int hantro_probe(struct platform_device *pdev)
 	mutex_init(&vpu->vpu_mutex);
 	spin_lock_init(&vpu->irqlock);
 
-	match = of_match_node(of_hantro_match, pdev->dev.of_node);
-	vpu->variant = match->data;
+	vpu->variant = device_get_match_data(&pdev->dev);
+	if (!vpu->variant)
+		return -ENODEV;
 
 	ret = hantro_disable_multicore(vpu);
 	if (ret)

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 02/18] media: verisilicon: Check the match data in hantro_probe()
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

A device bound through driver_override may have no OF match, and
hantro_probe() then dereferences a NULL match. Use
device_get_match_data() and fail with -ENODEV without match data.

Fixes: 775fec69008d ("media: add Rockchip VPU JPEG encoder driver")
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/hantro_drv.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index 5c962847fdf5..da9813c60cf7 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -17,6 +17,7 @@
 #include <linux/platform_device.h>
 #include <linux/pm.h>
 #include <linux/pm_runtime.h>
+#include <linux/property.h>
 #include <linux/slab.h>
 #include <linux/videodev2.h>
 #include <linux/workqueue.h>
@@ -1099,7 +1100,6 @@ static struct v4l2_m2m_dev *hantro_get_v4l2_m2m_dev(struct hantro_dev *vpu)
 
 static int hantro_probe(struct platform_device *pdev)
 {
-	const struct of_device_id *match;
 	struct hantro_dev *vpu;
 	int i, ret;
 
@@ -1112,8 +1112,9 @@ static int hantro_probe(struct platform_device *pdev)
 	mutex_init(&vpu->vpu_mutex);
 	spin_lock_init(&vpu->irqlock);
 
-	match = of_match_node(of_hantro_match, pdev->dev.of_node);
-	vpu->variant = match->data;
+	vpu->variant = device_get_match_data(&pdev->dev);
+	if (!vpu->variant)
+		return -ENODEV;
 
 	ret = hantro_disable_multicore(vpu);
 	if (ret)

-- 
2.55.0



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 02/18] media: verisilicon: Check the match data in hantro_probe()
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

A device bound through driver_override may have no OF match, and
hantro_probe() then dereferences a NULL match. Use
device_get_match_data() and fail with -ENODEV without match data.

Fixes: 775fec69008d ("media: add Rockchip VPU JPEG encoder driver")
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/hantro_drv.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index 5c962847fdf5..da9813c60cf7 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -17,6 +17,7 @@
 #include <linux/platform_device.h>
 #include <linux/pm.h>
 #include <linux/pm_runtime.h>
+#include <linux/property.h>
 #include <linux/slab.h>
 #include <linux/videodev2.h>
 #include <linux/workqueue.h>
@@ -1099,7 +1100,6 @@ static struct v4l2_m2m_dev *hantro_get_v4l2_m2m_dev(struct hantro_dev *vpu)
 
 static int hantro_probe(struct platform_device *pdev)
 {
-	const struct of_device_id *match;
 	struct hantro_dev *vpu;
 	int i, ret;
 
@@ -1112,8 +1112,9 @@ static int hantro_probe(struct platform_device *pdev)
 	mutex_init(&vpu->vpu_mutex);
 	spin_lock_init(&vpu->irqlock);
 
-	match = of_match_node(of_hantro_match, pdev->dev.of_node);
-	vpu->variant = match->data;
+	vpu->variant = device_get_match_data(&pdev->dev);
+	if (!vpu->variant)
+		return -ENODEV;
 
 	ret = hantro_disable_multicore(vpu);
 	if (ret)

-- 
2.55.0



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

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 03/18] media: verisilicon: Complete the request when the VPU can't resume
  2026-12-06  5:57 ` Arun Iyengar via B4 Relay
  (?)
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  -1 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

If pm_runtime_resume_and_get() fails, device_run() returns the buffers
without completing the controls of the request, and the request stays
queued forever. Complete them on that path.

Fixes: 7d47b45dc590 ("media: rockchip/vpu: Support the Request API")
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/hantro_drv.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index da9813c60cf7..fa867168b947 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -203,16 +203,20 @@ static void device_run(void *priv)
 	dst = hantro_get_dst_buf(ctx);
 
 	ret = pm_runtime_resume_and_get(vpu->dev);
-	if (ret < 0) {
-		hantro_job_finish_no_pm(ctx, VB2_BUF_STATE_ERROR);
-		return;
-	}
+	if (ret < 0)
+		goto err_cancel_job;
 
 	v4l2_m2m_buf_copy_metadata(src, dst);
 
 	ret = ctx->codec_ops->run(ctx);
 	if (ret)
 		hantro_job_finish(ctx, VB2_BUF_STATE_ERROR);
+
+	return;
+
+err_cancel_job:
+	v4l2_ctrl_request_complete(src->vb2_buf.req_obj.req, &ctx->ctrl_handler);
+	hantro_job_finish_no_pm(ctx, VB2_BUF_STATE_ERROR);
 }
 
 static const struct v4l2_m2m_ops vpu_m2m_ops = {

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 03/18] media: verisilicon: Complete the request when the VPU can't resume
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

If pm_runtime_resume_and_get() fails, device_run() returns the buffers
without completing the controls of the request, and the request stays
queued forever. Complete them on that path.

Fixes: 7d47b45dc590 ("media: rockchip/vpu: Support the Request API")
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/hantro_drv.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index da9813c60cf7..fa867168b947 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -203,16 +203,20 @@ static void device_run(void *priv)
 	dst = hantro_get_dst_buf(ctx);
 
 	ret = pm_runtime_resume_and_get(vpu->dev);
-	if (ret < 0) {
-		hantro_job_finish_no_pm(ctx, VB2_BUF_STATE_ERROR);
-		return;
-	}
+	if (ret < 0)
+		goto err_cancel_job;
 
 	v4l2_m2m_buf_copy_metadata(src, dst);
 
 	ret = ctx->codec_ops->run(ctx);
 	if (ret)
 		hantro_job_finish(ctx, VB2_BUF_STATE_ERROR);
+
+	return;
+
+err_cancel_job:
+	v4l2_ctrl_request_complete(src->vb2_buf.req_obj.req, &ctx->ctrl_handler);
+	hantro_job_finish_no_pm(ctx, VB2_BUF_STATE_ERROR);
 }
 
 static const struct v4l2_m2m_ops vpu_m2m_ops = {

-- 
2.55.0



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 03/18] media: verisilicon: Complete the request when the VPU can't resume
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

If pm_runtime_resume_and_get() fails, device_run() returns the buffers
without completing the controls of the request, and the request stays
queued forever. Complete them on that path.

Fixes: 7d47b45dc590 ("media: rockchip/vpu: Support the Request API")
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/hantro_drv.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index da9813c60cf7..fa867168b947 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -203,16 +203,20 @@ static void device_run(void *priv)
 	dst = hantro_get_dst_buf(ctx);
 
 	ret = pm_runtime_resume_and_get(vpu->dev);
-	if (ret < 0) {
-		hantro_job_finish_no_pm(ctx, VB2_BUF_STATE_ERROR);
-		return;
-	}
+	if (ret < 0)
+		goto err_cancel_job;
 
 	v4l2_m2m_buf_copy_metadata(src, dst);
 
 	ret = ctx->codec_ops->run(ctx);
 	if (ret)
 		hantro_job_finish(ctx, VB2_BUF_STATE_ERROR);
+
+	return;
+
+err_cancel_job:
+	v4l2_ctrl_request_complete(src->vb2_buf.req_obj.req, &ctx->ctrl_handler);
+	hantro_job_finish_no_pm(ctx, VB2_BUF_STATE_ERROR);
 }
 
 static const struct v4l2_m2m_ops vpu_m2m_ops = {

-- 
2.55.0



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

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 04/18] media: verisilicon: Copy the buffer metadata before a job can fail
  2026-12-06  5:57 ` Arun Iyengar via B4 Relay
  (?)
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  -1 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

device_run() copies the OUTPUT buffer metadata to the CAPTURE buffer
only after pm_runtime_resume_and_get(). If that fails, the CAPTURE
buffer is returned with the error flag and a stale timestamp, so
userspace that matches buffers by timestamp drops the wrong frame.

Copy the metadata first.

Fixes: 6c2eb77bf566 ("media: hantro: Move copy_metadata() before doing a decode operation")
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/hantro_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index fa867168b947..40ff60dd098a 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -202,12 +202,12 @@ static void device_run(void *priv)
 	src = hantro_get_src_buf(ctx);
 	dst = hantro_get_dst_buf(ctx);
 
+	v4l2_m2m_buf_copy_metadata(src, dst);
+
 	ret = pm_runtime_resume_and_get(vpu->dev);
 	if (ret < 0)
 		goto err_cancel_job;
 
-	v4l2_m2m_buf_copy_metadata(src, dst);
-
 	ret = ctx->codec_ops->run(ctx);
 	if (ret)
 		hantro_job_finish(ctx, VB2_BUF_STATE_ERROR);

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 04/18] media: verisilicon: Copy the buffer metadata before a job can fail
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

device_run() copies the OUTPUT buffer metadata to the CAPTURE buffer
only after pm_runtime_resume_and_get(). If that fails, the CAPTURE
buffer is returned with the error flag and a stale timestamp, so
userspace that matches buffers by timestamp drops the wrong frame.

Copy the metadata first.

Fixes: 6c2eb77bf566 ("media: hantro: Move copy_metadata() before doing a decode operation")
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/hantro_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index fa867168b947..40ff60dd098a 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -202,12 +202,12 @@ static void device_run(void *priv)
 	src = hantro_get_src_buf(ctx);
 	dst = hantro_get_dst_buf(ctx);
 
+	v4l2_m2m_buf_copy_metadata(src, dst);
+
 	ret = pm_runtime_resume_and_get(vpu->dev);
 	if (ret < 0)
 		goto err_cancel_job;
 
-	v4l2_m2m_buf_copy_metadata(src, dst);
-
 	ret = ctx->codec_ops->run(ctx);
 	if (ret)
 		hantro_job_finish(ctx, VB2_BUF_STATE_ERROR);

-- 
2.55.0



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 04/18] media: verisilicon: Copy the buffer metadata before a job can fail
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

device_run() copies the OUTPUT buffer metadata to the CAPTURE buffer
only after pm_runtime_resume_and_get(). If that fails, the CAPTURE
buffer is returned with the error flag and a stale timestamp, so
userspace that matches buffers by timestamp drops the wrong frame.

Copy the metadata first.

Fixes: 6c2eb77bf566 ("media: hantro: Move copy_metadata() before doing a decode operation")
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/hantro_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index fa867168b947..40ff60dd098a 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -202,12 +202,12 @@ static void device_run(void *priv)
 	src = hantro_get_src_buf(ctx);
 	dst = hantro_get_dst_buf(ctx);
 
+	v4l2_m2m_buf_copy_metadata(src, dst);
+
 	ret = pm_runtime_resume_and_get(vpu->dev);
 	if (ret < 0)
 		goto err_cancel_job;
 
-	v4l2_m2m_buf_copy_metadata(src, dst);
-
 	ret = ctx->codec_ops->run(ctx);
 	if (ret)
 		hantro_job_finish(ctx, VB2_BUF_STATE_ERROR);

-- 
2.55.0



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

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 05/18] media: verisilicon: Don't hold the VPU in reset after remove
  2026-12-06  5:57 ` Arun Iyengar via B4 Relay
  (?)
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  -1 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar, stable

On the RK3588 the AV1 decoder resets include its bus interface resets,
which also reset its IOMMU. On unbind, hantro_remove() asserts them while
the IOMMU is runtime active; when it autosuspends, vsi_iommu_suspend()
writes its registers in reset and the SError panics the system. Hit when
reloading the module.

A runtime suspended VPU has its resets deasserted and its clocks off.
Leave it so on remove and on probe failure instead of asserting the
resets.

Fixes: ea71631b7129 ("media: hantro: add support for reset lines")
Cc: stable@vger.kernel.org
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/hantro_drv.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index 40ff60dd098a..a5d0c09a3534 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -1224,7 +1224,7 @@ static int hantro_probe(struct platform_device *pdev)
 	ret = clk_bulk_prepare(vpu->variant->num_clocks, vpu->clocks);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to prepare clocks\n");
-		goto err_pm_disable_assert_reset;
+		goto err_pm_disable;
 	}
 
 	ret = v4l2_device_register(&pdev->dev, &vpu->v4l2_dev);
@@ -1278,11 +1278,6 @@ static int hantro_probe(struct platform_device *pdev)
 	v4l2_device_unregister(&vpu->v4l2_dev);
 err_clk_unprepare:
 	clk_bulk_unprepare(vpu->variant->num_clocks, vpu->clocks);
-err_pm_disable_assert_reset:
-	pm_runtime_dont_use_autosuspend(vpu->dev);
-	pm_runtime_disable(vpu->dev);
-	reset_control_assert(vpu->resets);
-	return ret;
 err_pm_disable:
 	pm_runtime_dont_use_autosuspend(vpu->dev);
 	pm_runtime_disable(vpu->dev);
@@ -1318,7 +1313,6 @@ static void hantro_remove(struct platform_device *pdev)
 	}
 	v4l2_device_unregister(&vpu->v4l2_dev);
 	clk_bulk_unprepare(vpu->variant->num_clocks, vpu->clocks);
-	reset_control_assert(vpu->resets);
 }
 
 static int hantro_runtime_resume(struct device *dev)

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 05/18] media: verisilicon: Don't hold the VPU in reset after remove
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar, stable

From: Arun Iyengar <aiyengar1990@gmail.com>

On the RK3588 the AV1 decoder resets include its bus interface resets,
which also reset its IOMMU. On unbind, hantro_remove() asserts them while
the IOMMU is runtime active; when it autosuspends, vsi_iommu_suspend()
writes its registers in reset and the SError panics the system. Hit when
reloading the module.

A runtime suspended VPU has its resets deasserted and its clocks off.
Leave it so on remove and on probe failure instead of asserting the
resets.

Fixes: ea71631b7129 ("media: hantro: add support for reset lines")
Cc: stable@vger.kernel.org
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/hantro_drv.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index 40ff60dd098a..a5d0c09a3534 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -1224,7 +1224,7 @@ static int hantro_probe(struct platform_device *pdev)
 	ret = clk_bulk_prepare(vpu->variant->num_clocks, vpu->clocks);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to prepare clocks\n");
-		goto err_pm_disable_assert_reset;
+		goto err_pm_disable;
 	}
 
 	ret = v4l2_device_register(&pdev->dev, &vpu->v4l2_dev);
@@ -1278,11 +1278,6 @@ static int hantro_probe(struct platform_device *pdev)
 	v4l2_device_unregister(&vpu->v4l2_dev);
 err_clk_unprepare:
 	clk_bulk_unprepare(vpu->variant->num_clocks, vpu->clocks);
-err_pm_disable_assert_reset:
-	pm_runtime_dont_use_autosuspend(vpu->dev);
-	pm_runtime_disable(vpu->dev);
-	reset_control_assert(vpu->resets);
-	return ret;
 err_pm_disable:
 	pm_runtime_dont_use_autosuspend(vpu->dev);
 	pm_runtime_disable(vpu->dev);
@@ -1318,7 +1313,6 @@ static void hantro_remove(struct platform_device *pdev)
 	}
 	v4l2_device_unregister(&vpu->v4l2_dev);
 	clk_bulk_unprepare(vpu->variant->num_clocks, vpu->clocks);
-	reset_control_assert(vpu->resets);
 }
 
 static int hantro_runtime_resume(struct device *dev)

-- 
2.55.0



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 05/18] media: verisilicon: Don't hold the VPU in reset after remove
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar, stable

From: Arun Iyengar <aiyengar1990@gmail.com>

On the RK3588 the AV1 decoder resets include its bus interface resets,
which also reset its IOMMU. On unbind, hantro_remove() asserts them while
the IOMMU is runtime active; when it autosuspends, vsi_iommu_suspend()
writes its registers in reset and the SError panics the system. Hit when
reloading the module.

A runtime suspended VPU has its resets deasserted and its clocks off.
Leave it so on remove and on probe failure instead of asserting the
resets.

Fixes: ea71631b7129 ("media: hantro: add support for reset lines")
Cc: stable@vger.kernel.org
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/hantro_drv.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index 40ff60dd098a..a5d0c09a3534 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -1224,7 +1224,7 @@ static int hantro_probe(struct platform_device *pdev)
 	ret = clk_bulk_prepare(vpu->variant->num_clocks, vpu->clocks);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to prepare clocks\n");
-		goto err_pm_disable_assert_reset;
+		goto err_pm_disable;
 	}
 
 	ret = v4l2_device_register(&pdev->dev, &vpu->v4l2_dev);
@@ -1278,11 +1278,6 @@ static int hantro_probe(struct platform_device *pdev)
 	v4l2_device_unregister(&vpu->v4l2_dev);
 err_clk_unprepare:
 	clk_bulk_unprepare(vpu->variant->num_clocks, vpu->clocks);
-err_pm_disable_assert_reset:
-	pm_runtime_dont_use_autosuspend(vpu->dev);
-	pm_runtime_disable(vpu->dev);
-	reset_control_assert(vpu->resets);
-	return ret;
 err_pm_disable:
 	pm_runtime_dont_use_autosuspend(vpu->dev);
 	pm_runtime_disable(vpu->dev);
@@ -1318,7 +1313,6 @@ static void hantro_remove(struct platform_device *pdev)
 	}
 	v4l2_device_unregister(&vpu->v4l2_dev);
 	clk_bulk_unprepare(vpu->variant->num_clocks, vpu->clocks);
-	reset_control_assert(vpu->resets);
 }
 
 static int hantro_runtime_resume(struct device *dev)

-- 
2.55.0



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

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 06/18] media: verisilicon: Disable runtime PM before unpreparing the clocks on probe failure
  2026-12-06  5:57 ` Arun Iyengar via B4 Relay
  (?)
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  -1 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

The probe error path unprepares the clocks before it disables runtime
PM, so a VPU resumed through its video nodes before a late failure
keeps its clocks enabled, or suspends after they are unprepared.
Prepare the clocks before enabling runtime PM, and unwind like
hantro_remove(): suspend first, then unprepare.

Fixes: 775fec69008d ("media: add Rockchip VPU JPEG encoder driver")
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/hantro_drv.c | 53 ++++++++++++++-----------
 1 file changed, 30 insertions(+), 23 deletions(-)

diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index a5d0c09a3534..957ed7a59197 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -1102,6 +1102,25 @@ static struct v4l2_m2m_dev *hantro_get_v4l2_m2m_dev(struct hantro_dev *vpu)
 	return v4l2_m2m_init(&vpu_m2m_ops);
 }
 
+static int hantro_runtime_suspend(struct device *dev)
+{
+	struct hantro_dev *vpu = dev_get_drvdata(dev);
+
+	clk_bulk_disable(vpu->variant->num_clocks, vpu->clocks);
+	return 0;
+}
+
+static void hantro_disable_runtime_pm(struct hantro_dev *vpu)
+{
+	pm_runtime_dont_use_autosuspend(vpu->dev);
+	pm_runtime_disable(vpu->dev);
+	/* Runtime PM forbidden through sysfs: the device is still active. */
+	if (IS_ENABLED(CONFIG_PM) && !pm_runtime_status_suspended(vpu->dev)) {
+		hantro_runtime_suspend(vpu->dev);
+		pm_runtime_set_suspended(vpu->dev);
+	}
+}
+
 static int hantro_probe(struct platform_device *pdev)
 {
 	struct hantro_dev *vpu;
@@ -1211,6 +1230,12 @@ static int hantro_probe(struct platform_device *pdev)
 		}
 	}
 
+	ret = clk_bulk_prepare(vpu->variant->num_clocks, vpu->clocks);
+	if (ret) {
+		dev_err(&pdev->dev, "Failed to prepare clocks\n");
+		return ret;
+	}
+
 	pm_runtime_set_autosuspend_delay(vpu->dev, 100);
 	pm_runtime_use_autosuspend(vpu->dev);
 	pm_runtime_enable(vpu->dev);
@@ -1221,16 +1246,10 @@ static int hantro_probe(struct platform_device *pdev)
 		goto err_pm_disable;
 	}
 
-	ret = clk_bulk_prepare(vpu->variant->num_clocks, vpu->clocks);
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to prepare clocks\n");
-		goto err_pm_disable;
-	}
-
 	ret = v4l2_device_register(&pdev->dev, &vpu->v4l2_dev);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to register v4l2 device\n");
-		goto err_clk_unprepare;
+		goto err_pm_disable;
 	}
 	platform_set_drvdata(pdev, vpu);
 
@@ -1275,23 +1294,17 @@ static int hantro_probe(struct platform_device *pdev)
 	media_device_cleanup(&vpu->mdev);
 	v4l2_m2m_put(vpu->m2m_dev);
 err_v4l2_unreg:
+	hantro_disable_runtime_pm(vpu);
 	v4l2_device_unregister(&vpu->v4l2_dev);
-err_clk_unprepare:
 	clk_bulk_unprepare(vpu->variant->num_clocks, vpu->clocks);
+	return ret;
 err_pm_disable:
 	pm_runtime_dont_use_autosuspend(vpu->dev);
 	pm_runtime_disable(vpu->dev);
+	clk_bulk_unprepare(vpu->variant->num_clocks, vpu->clocks);
 	return ret;
 }
 
-static int hantro_runtime_suspend(struct device *dev)
-{
-	struct hantro_dev *vpu = dev_get_drvdata(dev);
-
-	clk_bulk_disable(vpu->variant->num_clocks, vpu->clocks);
-	return 0;
-}
-
 static void hantro_remove(struct platform_device *pdev)
 {
 	struct hantro_dev *vpu = platform_get_drvdata(pdev);
@@ -1304,13 +1317,7 @@ static void hantro_remove(struct platform_device *pdev)
 	media_device_cleanup(&vpu->mdev);
 	v4l2_m2m_put(vpu->m2m_dev);
 	/* Suspend first: v4l2_device_unregister() clears the driver data. */
-	pm_runtime_dont_use_autosuspend(vpu->dev);
-	pm_runtime_disable(vpu->dev);
-	/* Runtime PM forbidden through sysfs: the device is still active. */
-	if (IS_ENABLED(CONFIG_PM) && !pm_runtime_status_suspended(vpu->dev)) {
-		hantro_runtime_suspend(vpu->dev);
-		pm_runtime_set_suspended(vpu->dev);
-	}
+	hantro_disable_runtime_pm(vpu);
 	v4l2_device_unregister(&vpu->v4l2_dev);
 	clk_bulk_unprepare(vpu->variant->num_clocks, vpu->clocks);
 }

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 06/18] media: verisilicon: Disable runtime PM before unpreparing the clocks on probe failure
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

The probe error path unprepares the clocks before it disables runtime
PM, so a VPU resumed through its video nodes before a late failure
keeps its clocks enabled, or suspends after they are unprepared.
Prepare the clocks before enabling runtime PM, and unwind like
hantro_remove(): suspend first, then unprepare.

Fixes: 775fec69008d ("media: add Rockchip VPU JPEG encoder driver")
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/hantro_drv.c | 53 ++++++++++++++-----------
 1 file changed, 30 insertions(+), 23 deletions(-)

diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index a5d0c09a3534..957ed7a59197 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -1102,6 +1102,25 @@ static struct v4l2_m2m_dev *hantro_get_v4l2_m2m_dev(struct hantro_dev *vpu)
 	return v4l2_m2m_init(&vpu_m2m_ops);
 }
 
+static int hantro_runtime_suspend(struct device *dev)
+{
+	struct hantro_dev *vpu = dev_get_drvdata(dev);
+
+	clk_bulk_disable(vpu->variant->num_clocks, vpu->clocks);
+	return 0;
+}
+
+static void hantro_disable_runtime_pm(struct hantro_dev *vpu)
+{
+	pm_runtime_dont_use_autosuspend(vpu->dev);
+	pm_runtime_disable(vpu->dev);
+	/* Runtime PM forbidden through sysfs: the device is still active. */
+	if (IS_ENABLED(CONFIG_PM) && !pm_runtime_status_suspended(vpu->dev)) {
+		hantro_runtime_suspend(vpu->dev);
+		pm_runtime_set_suspended(vpu->dev);
+	}
+}
+
 static int hantro_probe(struct platform_device *pdev)
 {
 	struct hantro_dev *vpu;
@@ -1211,6 +1230,12 @@ static int hantro_probe(struct platform_device *pdev)
 		}
 	}
 
+	ret = clk_bulk_prepare(vpu->variant->num_clocks, vpu->clocks);
+	if (ret) {
+		dev_err(&pdev->dev, "Failed to prepare clocks\n");
+		return ret;
+	}
+
 	pm_runtime_set_autosuspend_delay(vpu->dev, 100);
 	pm_runtime_use_autosuspend(vpu->dev);
 	pm_runtime_enable(vpu->dev);
@@ -1221,16 +1246,10 @@ static int hantro_probe(struct platform_device *pdev)
 		goto err_pm_disable;
 	}
 
-	ret = clk_bulk_prepare(vpu->variant->num_clocks, vpu->clocks);
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to prepare clocks\n");
-		goto err_pm_disable;
-	}
-
 	ret = v4l2_device_register(&pdev->dev, &vpu->v4l2_dev);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to register v4l2 device\n");
-		goto err_clk_unprepare;
+		goto err_pm_disable;
 	}
 	platform_set_drvdata(pdev, vpu);
 
@@ -1275,23 +1294,17 @@ static int hantro_probe(struct platform_device *pdev)
 	media_device_cleanup(&vpu->mdev);
 	v4l2_m2m_put(vpu->m2m_dev);
 err_v4l2_unreg:
+	hantro_disable_runtime_pm(vpu);
 	v4l2_device_unregister(&vpu->v4l2_dev);
-err_clk_unprepare:
 	clk_bulk_unprepare(vpu->variant->num_clocks, vpu->clocks);
+	return ret;
 err_pm_disable:
 	pm_runtime_dont_use_autosuspend(vpu->dev);
 	pm_runtime_disable(vpu->dev);
+	clk_bulk_unprepare(vpu->variant->num_clocks, vpu->clocks);
 	return ret;
 }
 
-static int hantro_runtime_suspend(struct device *dev)
-{
-	struct hantro_dev *vpu = dev_get_drvdata(dev);
-
-	clk_bulk_disable(vpu->variant->num_clocks, vpu->clocks);
-	return 0;
-}
-
 static void hantro_remove(struct platform_device *pdev)
 {
 	struct hantro_dev *vpu = platform_get_drvdata(pdev);
@@ -1304,13 +1317,7 @@ static void hantro_remove(struct platform_device *pdev)
 	media_device_cleanup(&vpu->mdev);
 	v4l2_m2m_put(vpu->m2m_dev);
 	/* Suspend first: v4l2_device_unregister() clears the driver data. */
-	pm_runtime_dont_use_autosuspend(vpu->dev);
-	pm_runtime_disable(vpu->dev);
-	/* Runtime PM forbidden through sysfs: the device is still active. */
-	if (IS_ENABLED(CONFIG_PM) && !pm_runtime_status_suspended(vpu->dev)) {
-		hantro_runtime_suspend(vpu->dev);
-		pm_runtime_set_suspended(vpu->dev);
-	}
+	hantro_disable_runtime_pm(vpu);
 	v4l2_device_unregister(&vpu->v4l2_dev);
 	clk_bulk_unprepare(vpu->variant->num_clocks, vpu->clocks);
 }

-- 
2.55.0



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 06/18] media: verisilicon: Disable runtime PM before unpreparing the clocks on probe failure
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

The probe error path unprepares the clocks before it disables runtime
PM, so a VPU resumed through its video nodes before a late failure
keeps its clocks enabled, or suspends after they are unprepared.
Prepare the clocks before enabling runtime PM, and unwind like
hantro_remove(): suspend first, then unprepare.

Fixes: 775fec69008d ("media: add Rockchip VPU JPEG encoder driver")
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/hantro_drv.c | 53 ++++++++++++++-----------
 1 file changed, 30 insertions(+), 23 deletions(-)

diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index a5d0c09a3534..957ed7a59197 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -1102,6 +1102,25 @@ static struct v4l2_m2m_dev *hantro_get_v4l2_m2m_dev(struct hantro_dev *vpu)
 	return v4l2_m2m_init(&vpu_m2m_ops);
 }
 
+static int hantro_runtime_suspend(struct device *dev)
+{
+	struct hantro_dev *vpu = dev_get_drvdata(dev);
+
+	clk_bulk_disable(vpu->variant->num_clocks, vpu->clocks);
+	return 0;
+}
+
+static void hantro_disable_runtime_pm(struct hantro_dev *vpu)
+{
+	pm_runtime_dont_use_autosuspend(vpu->dev);
+	pm_runtime_disable(vpu->dev);
+	/* Runtime PM forbidden through sysfs: the device is still active. */
+	if (IS_ENABLED(CONFIG_PM) && !pm_runtime_status_suspended(vpu->dev)) {
+		hantro_runtime_suspend(vpu->dev);
+		pm_runtime_set_suspended(vpu->dev);
+	}
+}
+
 static int hantro_probe(struct platform_device *pdev)
 {
 	struct hantro_dev *vpu;
@@ -1211,6 +1230,12 @@ static int hantro_probe(struct platform_device *pdev)
 		}
 	}
 
+	ret = clk_bulk_prepare(vpu->variant->num_clocks, vpu->clocks);
+	if (ret) {
+		dev_err(&pdev->dev, "Failed to prepare clocks\n");
+		return ret;
+	}
+
 	pm_runtime_set_autosuspend_delay(vpu->dev, 100);
 	pm_runtime_use_autosuspend(vpu->dev);
 	pm_runtime_enable(vpu->dev);
@@ -1221,16 +1246,10 @@ static int hantro_probe(struct platform_device *pdev)
 		goto err_pm_disable;
 	}
 
-	ret = clk_bulk_prepare(vpu->variant->num_clocks, vpu->clocks);
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to prepare clocks\n");
-		goto err_pm_disable;
-	}
-
 	ret = v4l2_device_register(&pdev->dev, &vpu->v4l2_dev);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to register v4l2 device\n");
-		goto err_clk_unprepare;
+		goto err_pm_disable;
 	}
 	platform_set_drvdata(pdev, vpu);
 
@@ -1275,23 +1294,17 @@ static int hantro_probe(struct platform_device *pdev)
 	media_device_cleanup(&vpu->mdev);
 	v4l2_m2m_put(vpu->m2m_dev);
 err_v4l2_unreg:
+	hantro_disable_runtime_pm(vpu);
 	v4l2_device_unregister(&vpu->v4l2_dev);
-err_clk_unprepare:
 	clk_bulk_unprepare(vpu->variant->num_clocks, vpu->clocks);
+	return ret;
 err_pm_disable:
 	pm_runtime_dont_use_autosuspend(vpu->dev);
 	pm_runtime_disable(vpu->dev);
+	clk_bulk_unprepare(vpu->variant->num_clocks, vpu->clocks);
 	return ret;
 }
 
-static int hantro_runtime_suspend(struct device *dev)
-{
-	struct hantro_dev *vpu = dev_get_drvdata(dev);
-
-	clk_bulk_disable(vpu->variant->num_clocks, vpu->clocks);
-	return 0;
-}
-
 static void hantro_remove(struct platform_device *pdev)
 {
 	struct hantro_dev *vpu = platform_get_drvdata(pdev);
@@ -1304,13 +1317,7 @@ static void hantro_remove(struct platform_device *pdev)
 	media_device_cleanup(&vpu->mdev);
 	v4l2_m2m_put(vpu->m2m_dev);
 	/* Suspend first: v4l2_device_unregister() clears the driver data. */
-	pm_runtime_dont_use_autosuspend(vpu->dev);
-	pm_runtime_disable(vpu->dev);
-	/* Runtime PM forbidden through sysfs: the device is still active. */
-	if (IS_ENABLED(CONFIG_PM) && !pm_runtime_status_suspended(vpu->dev)) {
-		hantro_runtime_suspend(vpu->dev);
-		pm_runtime_set_suspended(vpu->dev);
-	}
+	hantro_disable_runtime_pm(vpu);
 	v4l2_device_unregister(&vpu->v4l2_dev);
 	clk_bulk_unprepare(vpu->variant->num_clocks, vpu->clocks);
 }

-- 
2.55.0



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

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 07/18] media: verisilicon: Enable the Rockchip encoder interrupt again after a reset
  2026-12-06  5:57 ` Arun Iyengar via B4 Relay
  (?)
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  -1 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar, stable

The reset operations of the Rockchip VEPU1 and VEPU2 encoders disable
the encoder interrupt before stopping the encoder. Nothing enables it
again: the encoder run functions don't write the interrupt register,
only the interrupt handler does. Every later job on the encoder then
times out as well.

Clear the interrupt register at the end of the reset, as the interrupt
handler does after each frame.

Fixes: 775fec69008d ("media: add Rockchip VPU JPEG encoder driver")
Cc: stable@vger.kernel.org
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/rockchip_vpu_hw.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
index 614d54e3a8ef..d54ba36d4449 100644
--- a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
+++ b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
@@ -476,6 +476,8 @@ static void rockchip_vpu1_enc_reset(struct hantro_ctx *ctx)
 	vepu_write(vpu, H1_REG_INTERRUPT_DIS_BIT, H1_REG_INTERRUPT);
 	vepu_write(vpu, 0, H1_REG_ENC_CTRL);
 	vepu_write(vpu, 0, H1_REG_AXI_CTRL);
+	/* Only the interrupt handler writes this register: enable the interrupt again. */
+	vepu_write(vpu, 0, H1_REG_INTERRUPT);
 }
 
 static void rockchip_vpu2_dec_reset(struct hantro_ctx *ctx)
@@ -494,6 +496,8 @@ static void rockchip_vpu2_enc_reset(struct hantro_ctx *ctx)
 	vepu_write(vpu, VEPU_REG_INTERRUPT_DIS_BIT, VEPU_REG_INTERRUPT);
 	vepu_write(vpu, 0, VEPU_REG_ENCODE_START);
 	vepu_write(vpu, 0, VEPU_REG_AXI_CTRL);
+	/* Only the interrupt handler writes this register: enable the interrupt again. */
+	vepu_write(vpu, 0, VEPU_REG_INTERRUPT);
 }
 
 /*

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 07/18] media: verisilicon: Enable the Rockchip encoder interrupt again after a reset
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar, stable

From: Arun Iyengar <aiyengar1990@gmail.com>

The reset operations of the Rockchip VEPU1 and VEPU2 encoders disable
the encoder interrupt before stopping the encoder. Nothing enables it
again: the encoder run functions don't write the interrupt register,
only the interrupt handler does. Every later job on the encoder then
times out as well.

Clear the interrupt register at the end of the reset, as the interrupt
handler does after each frame.

Fixes: 775fec69008d ("media: add Rockchip VPU JPEG encoder driver")
Cc: stable@vger.kernel.org
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/rockchip_vpu_hw.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
index 614d54e3a8ef..d54ba36d4449 100644
--- a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
+++ b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
@@ -476,6 +476,8 @@ static void rockchip_vpu1_enc_reset(struct hantro_ctx *ctx)
 	vepu_write(vpu, H1_REG_INTERRUPT_DIS_BIT, H1_REG_INTERRUPT);
 	vepu_write(vpu, 0, H1_REG_ENC_CTRL);
 	vepu_write(vpu, 0, H1_REG_AXI_CTRL);
+	/* Only the interrupt handler writes this register: enable the interrupt again. */
+	vepu_write(vpu, 0, H1_REG_INTERRUPT);
 }
 
 static void rockchip_vpu2_dec_reset(struct hantro_ctx *ctx)
@@ -494,6 +496,8 @@ static void rockchip_vpu2_enc_reset(struct hantro_ctx *ctx)
 	vepu_write(vpu, VEPU_REG_INTERRUPT_DIS_BIT, VEPU_REG_INTERRUPT);
 	vepu_write(vpu, 0, VEPU_REG_ENCODE_START);
 	vepu_write(vpu, 0, VEPU_REG_AXI_CTRL);
+	/* Only the interrupt handler writes this register: enable the interrupt again. */
+	vepu_write(vpu, 0, VEPU_REG_INTERRUPT);
 }
 
 /*

-- 
2.55.0



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 07/18] media: verisilicon: Enable the Rockchip encoder interrupt again after a reset
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar, stable

From: Arun Iyengar <aiyengar1990@gmail.com>

The reset operations of the Rockchip VEPU1 and VEPU2 encoders disable
the encoder interrupt before stopping the encoder. Nothing enables it
again: the encoder run functions don't write the interrupt register,
only the interrupt handler does. Every later job on the encoder then
times out as well.

Clear the interrupt register at the end of the reset, as the interrupt
handler does after each frame.

Fixes: 775fec69008d ("media: add Rockchip VPU JPEG encoder driver")
Cc: stable@vger.kernel.org
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/rockchip_vpu_hw.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
index 614d54e3a8ef..d54ba36d4449 100644
--- a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
+++ b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
@@ -476,6 +476,8 @@ static void rockchip_vpu1_enc_reset(struct hantro_ctx *ctx)
 	vepu_write(vpu, H1_REG_INTERRUPT_DIS_BIT, H1_REG_INTERRUPT);
 	vepu_write(vpu, 0, H1_REG_ENC_CTRL);
 	vepu_write(vpu, 0, H1_REG_AXI_CTRL);
+	/* Only the interrupt handler writes this register: enable the interrupt again. */
+	vepu_write(vpu, 0, H1_REG_INTERRUPT);
 }
 
 static void rockchip_vpu2_dec_reset(struct hantro_ctx *ctx)
@@ -494,6 +496,8 @@ static void rockchip_vpu2_enc_reset(struct hantro_ctx *ctx)
 	vepu_write(vpu, VEPU_REG_INTERRUPT_DIS_BIT, VEPU_REG_INTERRUPT);
 	vepu_write(vpu, 0, VEPU_REG_ENCODE_START);
 	vepu_write(vpu, 0, VEPU_REG_AXI_CTRL);
+	/* Only the interrupt handler writes this register: enable the interrupt again. */
+	vepu_write(vpu, 0, VEPU_REG_INTERRUPT);
 }
 
 /*

-- 
2.55.0



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

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 08/18] media: verisilicon: Reset the Rockchip encoder cores on timeout
  2026-12-06  5:57 ` Arun Iyengar via B4 Relay
  (?)
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  -1 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

On a job timeout, the Rockchip VEPU1 and VEPU2 reset operations mask the
interrupt and clear the encode enable and AXI control registers. On
RK3588, when a VEPU121 core reads an IOVA that isn't mapped, the IOMMU
reports a page fault and the core never becomes idle again: its AXI
transactions stay outstanding, the IOMMU can't be stalled anymore
("Enable stall request timed out", then "Disable paging request timed
out" on runtime suspend), and every later job times out as well.

Pulse the optional reset lines in the encoder reset operations, after
stopping the core through its registers, as the Rockchip BSP MPP driver
does. The job that timed out still holds the clocks. Nothing changes
for device trees without the resets.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 .../media/platform/verisilicon/rockchip_vpu_hw.c   | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
index d54ba36d4449..2ec25d6dac86 100644
--- a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
+++ b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
@@ -7,6 +7,7 @@
  */
 
 #include <linux/clk.h>
+#include <linux/delay.h>
 
 #include "hantro.h"
 #include "hantro_av1.h"
@@ -469,6 +470,31 @@ static void rk3066_vpu_dec_reset(struct hantro_ctx *ctx)
 	vdpu_write(vpu, G1_REG_CONFIG_DEC_CLK_GATE_E, G1_REG_CONFIG);
 }
 
+/*
+ * A core stuck on the bus, e.g. after an IOMMU fault, can't be stopped
+ * through its registers and keeps the IOMMU from stalling. Pulse its reset
+ * lines, if any.
+ */
+static void rockchip_vpu_enc_hw_reset(struct hantro_dev *vpu)
+{
+	int ret;
+
+	if (!vpu->resets)
+		return;
+
+	ret = reset_control_assert(vpu->resets);
+	if (ret) {
+		dev_warn(vpu->dev, "Failed to assert resets: %d\n", ret);
+		return;
+	}
+
+	udelay(5);
+
+	ret = reset_control_deassert(vpu->resets);
+	if (ret)
+		dev_err(vpu->dev, "Failed to deassert resets: %d\n", ret);
+}
+
 static void rockchip_vpu1_enc_reset(struct hantro_ctx *ctx)
 {
 	struct hantro_dev *vpu = ctx->dev;
@@ -476,6 +502,7 @@ static void rockchip_vpu1_enc_reset(struct hantro_ctx *ctx)
 	vepu_write(vpu, H1_REG_INTERRUPT_DIS_BIT, H1_REG_INTERRUPT);
 	vepu_write(vpu, 0, H1_REG_ENC_CTRL);
 	vepu_write(vpu, 0, H1_REG_AXI_CTRL);
+	rockchip_vpu_enc_hw_reset(vpu);
 	/* Only the interrupt handler writes this register: enable the interrupt again. */
 	vepu_write(vpu, 0, H1_REG_INTERRUPT);
 }
@@ -496,6 +523,7 @@ static void rockchip_vpu2_enc_reset(struct hantro_ctx *ctx)
 	vepu_write(vpu, VEPU_REG_INTERRUPT_DIS_BIT, VEPU_REG_INTERRUPT);
 	vepu_write(vpu, 0, VEPU_REG_ENCODE_START);
 	vepu_write(vpu, 0, VEPU_REG_AXI_CTRL);
+	rockchip_vpu_enc_hw_reset(vpu);
 	/* Only the interrupt handler writes this register: enable the interrupt again. */
 	vepu_write(vpu, 0, VEPU_REG_INTERRUPT);
 }

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 08/18] media: verisilicon: Reset the Rockchip encoder cores on timeout
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

On a job timeout, the Rockchip VEPU1 and VEPU2 reset operations mask the
interrupt and clear the encode enable and AXI control registers. On
RK3588, when a VEPU121 core reads an IOVA that isn't mapped, the IOMMU
reports a page fault and the core never becomes idle again: its AXI
transactions stay outstanding, the IOMMU can't be stalled anymore
("Enable stall request timed out", then "Disable paging request timed
out" on runtime suspend), and every later job times out as well.

Pulse the optional reset lines in the encoder reset operations, after
stopping the core through its registers, as the Rockchip BSP MPP driver
does. The job that timed out still holds the clocks. Nothing changes
for device trees without the resets.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 .../media/platform/verisilicon/rockchip_vpu_hw.c   | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
index d54ba36d4449..2ec25d6dac86 100644
--- a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
+++ b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
@@ -7,6 +7,7 @@
  */
 
 #include <linux/clk.h>
+#include <linux/delay.h>
 
 #include "hantro.h"
 #include "hantro_av1.h"
@@ -469,6 +470,31 @@ static void rk3066_vpu_dec_reset(struct hantro_ctx *ctx)
 	vdpu_write(vpu, G1_REG_CONFIG_DEC_CLK_GATE_E, G1_REG_CONFIG);
 }
 
+/*
+ * A core stuck on the bus, e.g. after an IOMMU fault, can't be stopped
+ * through its registers and keeps the IOMMU from stalling. Pulse its reset
+ * lines, if any.
+ */
+static void rockchip_vpu_enc_hw_reset(struct hantro_dev *vpu)
+{
+	int ret;
+
+	if (!vpu->resets)
+		return;
+
+	ret = reset_control_assert(vpu->resets);
+	if (ret) {
+		dev_warn(vpu->dev, "Failed to assert resets: %d\n", ret);
+		return;
+	}
+
+	udelay(5);
+
+	ret = reset_control_deassert(vpu->resets);
+	if (ret)
+		dev_err(vpu->dev, "Failed to deassert resets: %d\n", ret);
+}
+
 static void rockchip_vpu1_enc_reset(struct hantro_ctx *ctx)
 {
 	struct hantro_dev *vpu = ctx->dev;
@@ -476,6 +502,7 @@ static void rockchip_vpu1_enc_reset(struct hantro_ctx *ctx)
 	vepu_write(vpu, H1_REG_INTERRUPT_DIS_BIT, H1_REG_INTERRUPT);
 	vepu_write(vpu, 0, H1_REG_ENC_CTRL);
 	vepu_write(vpu, 0, H1_REG_AXI_CTRL);
+	rockchip_vpu_enc_hw_reset(vpu);
 	/* Only the interrupt handler writes this register: enable the interrupt again. */
 	vepu_write(vpu, 0, H1_REG_INTERRUPT);
 }
@@ -496,6 +523,7 @@ static void rockchip_vpu2_enc_reset(struct hantro_ctx *ctx)
 	vepu_write(vpu, VEPU_REG_INTERRUPT_DIS_BIT, VEPU_REG_INTERRUPT);
 	vepu_write(vpu, 0, VEPU_REG_ENCODE_START);
 	vepu_write(vpu, 0, VEPU_REG_AXI_CTRL);
+	rockchip_vpu_enc_hw_reset(vpu);
 	/* Only the interrupt handler writes this register: enable the interrupt again. */
 	vepu_write(vpu, 0, VEPU_REG_INTERRUPT);
 }

-- 
2.55.0



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 08/18] media: verisilicon: Reset the Rockchip encoder cores on timeout
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

On a job timeout, the Rockchip VEPU1 and VEPU2 reset operations mask the
interrupt and clear the encode enable and AXI control registers. On
RK3588, when a VEPU121 core reads an IOVA that isn't mapped, the IOMMU
reports a page fault and the core never becomes idle again: its AXI
transactions stay outstanding, the IOMMU can't be stalled anymore
("Enable stall request timed out", then "Disable paging request timed
out" on runtime suspend), and every later job times out as well.

Pulse the optional reset lines in the encoder reset operations, after
stopping the core through its registers, as the Rockchip BSP MPP driver
does. The job that timed out still holds the clocks. Nothing changes
for device trees without the resets.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 .../media/platform/verisilicon/rockchip_vpu_hw.c   | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
index d54ba36d4449..2ec25d6dac86 100644
--- a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
+++ b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
@@ -7,6 +7,7 @@
  */
 
 #include <linux/clk.h>
+#include <linux/delay.h>
 
 #include "hantro.h"
 #include "hantro_av1.h"
@@ -469,6 +470,31 @@ static void rk3066_vpu_dec_reset(struct hantro_ctx *ctx)
 	vdpu_write(vpu, G1_REG_CONFIG_DEC_CLK_GATE_E, G1_REG_CONFIG);
 }
 
+/*
+ * A core stuck on the bus, e.g. after an IOMMU fault, can't be stopped
+ * through its registers and keeps the IOMMU from stalling. Pulse its reset
+ * lines, if any.
+ */
+static void rockchip_vpu_enc_hw_reset(struct hantro_dev *vpu)
+{
+	int ret;
+
+	if (!vpu->resets)
+		return;
+
+	ret = reset_control_assert(vpu->resets);
+	if (ret) {
+		dev_warn(vpu->dev, "Failed to assert resets: %d\n", ret);
+		return;
+	}
+
+	udelay(5);
+
+	ret = reset_control_deassert(vpu->resets);
+	if (ret)
+		dev_err(vpu->dev, "Failed to deassert resets: %d\n", ret);
+}
+
 static void rockchip_vpu1_enc_reset(struct hantro_ctx *ctx)
 {
 	struct hantro_dev *vpu = ctx->dev;
@@ -476,6 +502,7 @@ static void rockchip_vpu1_enc_reset(struct hantro_ctx *ctx)
 	vepu_write(vpu, H1_REG_INTERRUPT_DIS_BIT, H1_REG_INTERRUPT);
 	vepu_write(vpu, 0, H1_REG_ENC_CTRL);
 	vepu_write(vpu, 0, H1_REG_AXI_CTRL);
+	rockchip_vpu_enc_hw_reset(vpu);
 	/* Only the interrupt handler writes this register: enable the interrupt again. */
 	vepu_write(vpu, 0, H1_REG_INTERRUPT);
 }
@@ -496,6 +523,7 @@ static void rockchip_vpu2_enc_reset(struct hantro_ctx *ctx)
 	vepu_write(vpu, VEPU_REG_INTERRUPT_DIS_BIT, VEPU_REG_INTERRUPT);
 	vepu_write(vpu, 0, VEPU_REG_ENCODE_START);
 	vepu_write(vpu, 0, VEPU_REG_AXI_CTRL);
+	rockchip_vpu_enc_hw_reset(vpu);
 	/* Only the interrupt handler writes this register: enable the interrupt again. */
 	vepu_write(vpu, 0, VEPU_REG_INTERRUPT);
 }

-- 
2.55.0



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

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 09/18] media: verisilicon: Reinitialize the IOMMU after resetting an encoder core
  2026-12-06  5:57 ` Arun Iyengar via B4 Relay
  (?)
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  -1 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

A Rockchip encoder core that faulted on an unmapped IOVA leaves its
IOMMU with the fault pending, and the reset pulse of the previous patch
can reset the IOMMU behind its driver. The IOMMU is only reprogrammed
on runtime resume, which doesn't happen between back-to-back jobs.

Do like rkvdec: allocate an empty paging domain at probe and, after the
reset pulse, attach and detach it. The IOMMU driver reprograms the
IOMMU on each domain change, and the default domain keeps its mappings.

Only do this for a device with reset lines whose domain is a DMA
domain. If the attach fails, the IOMMU may be left without translation
(rockchip-iommu falls back to its identity domain), so refuse all
further jobs. Also attach and detach it at probe, so that a rebind
repairs the IOMMU after such a failure.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/hantro.h        |  5 ++
 drivers/media/platform/verisilicon/hantro_drv.c    | 69 ++++++++++++++++++++++
 drivers/media/platform/verisilicon/hantro_hw.h     |  1 +
 .../media/platform/verisilicon/rockchip_vpu_hw.c   |  6 +-
 4 files changed, 80 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/verisilicon/hantro.h b/drivers/media/platform/verisilicon/hantro.h
index 1efa032506e1..5a9acc8c82a8 100644
--- a/drivers/media/platform/verisilicon/hantro.h
+++ b/drivers/media/platform/verisilicon/hantro.h
@@ -188,6 +188,9 @@ hantro_vdev_to_func(struct video_device *vdev)
  *			shared with interrupt handlers.
  * @variant:		Hardware variant-specific parameters.
  * @watchdog_work:	Delayed work for hardware timeout handling.
+ * @empty_domain:	Empty IOMMU domain, used to reinitialize the IOMMU after
+ *			a reset of the core. NULL if not needed.
+ * @iommu_lost:		The IOMMU couldn't be reinitialized, no job can run.
  */
 struct hantro_dev {
 	struct v4l2_device v4l2_dev;
@@ -207,6 +210,8 @@ struct hantro_dev {
 	spinlock_t irqlock;
 	const struct hantro_variant *variant;
 	struct delayed_work watchdog_work;
+	struct iommu_domain *empty_domain;
+	bool iommu_lost;
 };
 
 /**
diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index 957ed7a59197..e268858269ff 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -11,6 +11,7 @@
  */
 
 #include <linux/clk.h>
+#include <linux/iommu.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
@@ -113,6 +114,31 @@ void hantro_irq_done(struct hantro_dev *vpu,
 	}
 }
 
+/*
+ * Pulsing the reset lines of a core can reset its IOMMU behind the IOMMU
+ * driver. Attaching and detaching the empty domain makes the driver reprogram
+ * it; the default domain keeps its mappings. A failed attach may leave the
+ * IOMMU without translation, so no further job may run.
+ */
+int hantro_iommu_restore(struct hantro_dev *vpu)
+{
+	int ret;
+
+	if (!vpu->empty_domain)
+		return 0;
+
+	ret = iommu_attach_device(vpu->empty_domain, vpu->dev);
+	if (ret) {
+		dev_err(vpu->dev, "Failed to reinitialize the IOMMU (%d), refusing further jobs\n",
+			ret);
+		vpu->iommu_lost = true;
+		return ret;
+	}
+
+	iommu_detach_device(vpu->empty_domain, vpu->dev);
+	return 0;
+}
+
 void hantro_watchdog(struct work_struct *work)
 {
 	struct hantro_dev *vpu;
@@ -204,6 +230,9 @@ static void device_run(void *priv)
 
 	v4l2_m2m_buf_copy_metadata(src, dst);
 
+	if (unlikely(vpu->iommu_lost))
+		goto err_cancel_job;
+
 	ret = pm_runtime_resume_and_get(vpu->dev);
 	if (ret < 0)
 		goto err_cancel_job;
@@ -1121,6 +1150,42 @@ static void hantro_disable_runtime_pm(struct hantro_dev *vpu)
 	}
 }
 
+static void hantro_free_empty_domain(void *data)
+{
+	iommu_domain_free(data);
+}
+
+static int hantro_alloc_empty_domain(struct hantro_dev *vpu)
+{
+	struct iommu_domain *domain;
+	int ret;
+
+	/*
+	 * Only needed if the core can be reset, and only possible with a DMA
+	 * domain to return to.
+	 */
+	if (!vpu->resets)
+		return 0;
+
+	domain = iommu_get_domain_for_dev(vpu->dev);
+	if (!domain || !iommu_is_dma_domain(domain))
+		return 0;
+
+	domain = iommu_paging_domain_alloc(vpu->dev);
+	if (IS_ERR(domain))
+		return PTR_ERR(domain);
+
+	vpu->empty_domain = domain;
+
+	ret = devm_add_action_or_reset(vpu->dev, hantro_free_empty_domain,
+				       domain);
+	if (ret)
+		return ret;
+
+	/* A failed restore before a rebind can have left the IOMMU in bypass. */
+	return hantro_iommu_restore(vpu);
+}
+
 static int hantro_probe(struct platform_device *pdev)
 {
 	struct hantro_dev *vpu;
@@ -1172,6 +1237,10 @@ static int hantro_probe(struct platform_device *pdev)
 	if (IS_ERR(vpu->resets))
 		return PTR_ERR(vpu->resets);
 
+	ret = hantro_alloc_empty_domain(vpu);
+	if (ret)
+		return ret;
+
 	vpu->reg_base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(vpu->reg_base))
 		return PTR_ERR(vpu->reg_base);
diff --git a/drivers/media/platform/verisilicon/hantro_hw.h b/drivers/media/platform/verisilicon/hantro_hw.h
index 2d12e605cb55..d3c36948208d 100644
--- a/drivers/media/platform/verisilicon/hantro_hw.h
+++ b/drivers/media/platform/verisilicon/hantro_hw.h
@@ -431,6 +431,7 @@ extern const struct hantro_postproc_ops rockchip_vpu981_postproc_ops;
 extern const u32 hantro_vp8_dec_mc_filter[8][6];
 
 void hantro_watchdog(struct work_struct *work);
+int hantro_iommu_restore(struct hantro_dev *vpu);
 void hantro_irq_done(struct hantro_dev *vpu,
 		     enum vb2_buffer_state result);
 void hantro_start_prepare_run(struct hantro_ctx *ctx);
diff --git a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
index 2ec25d6dac86..02fcd74e5ee0 100644
--- a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
+++ b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
@@ -491,8 +491,12 @@ static void rockchip_vpu_enc_hw_reset(struct hantro_dev *vpu)
 	udelay(5);
 
 	ret = reset_control_deassert(vpu->resets);
-	if (ret)
+	if (ret) {
 		dev_err(vpu->dev, "Failed to deassert resets: %d\n", ret);
+		return;
+	}
+
+	hantro_iommu_restore(vpu);
 }
 
 static void rockchip_vpu1_enc_reset(struct hantro_ctx *ctx)

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 09/18] media: verisilicon: Reinitialize the IOMMU after resetting an encoder core
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

A Rockchip encoder core that faulted on an unmapped IOVA leaves its
IOMMU with the fault pending, and the reset pulse of the previous patch
can reset the IOMMU behind its driver. The IOMMU is only reprogrammed
on runtime resume, which doesn't happen between back-to-back jobs.

Do like rkvdec: allocate an empty paging domain at probe and, after the
reset pulse, attach and detach it. The IOMMU driver reprograms the
IOMMU on each domain change, and the default domain keeps its mappings.

Only do this for a device with reset lines whose domain is a DMA
domain. If the attach fails, the IOMMU may be left without translation
(rockchip-iommu falls back to its identity domain), so refuse all
further jobs. Also attach and detach it at probe, so that a rebind
repairs the IOMMU after such a failure.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/hantro.h        |  5 ++
 drivers/media/platform/verisilicon/hantro_drv.c    | 69 ++++++++++++++++++++++
 drivers/media/platform/verisilicon/hantro_hw.h     |  1 +
 .../media/platform/verisilicon/rockchip_vpu_hw.c   |  6 +-
 4 files changed, 80 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/verisilicon/hantro.h b/drivers/media/platform/verisilicon/hantro.h
index 1efa032506e1..5a9acc8c82a8 100644
--- a/drivers/media/platform/verisilicon/hantro.h
+++ b/drivers/media/platform/verisilicon/hantro.h
@@ -188,6 +188,9 @@ hantro_vdev_to_func(struct video_device *vdev)
  *			shared with interrupt handlers.
  * @variant:		Hardware variant-specific parameters.
  * @watchdog_work:	Delayed work for hardware timeout handling.
+ * @empty_domain:	Empty IOMMU domain, used to reinitialize the IOMMU after
+ *			a reset of the core. NULL if not needed.
+ * @iommu_lost:		The IOMMU couldn't be reinitialized, no job can run.
  */
 struct hantro_dev {
 	struct v4l2_device v4l2_dev;
@@ -207,6 +210,8 @@ struct hantro_dev {
 	spinlock_t irqlock;
 	const struct hantro_variant *variant;
 	struct delayed_work watchdog_work;
+	struct iommu_domain *empty_domain;
+	bool iommu_lost;
 };
 
 /**
diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index 957ed7a59197..e268858269ff 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -11,6 +11,7 @@
  */
 
 #include <linux/clk.h>
+#include <linux/iommu.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
@@ -113,6 +114,31 @@ void hantro_irq_done(struct hantro_dev *vpu,
 	}
 }
 
+/*
+ * Pulsing the reset lines of a core can reset its IOMMU behind the IOMMU
+ * driver. Attaching and detaching the empty domain makes the driver reprogram
+ * it; the default domain keeps its mappings. A failed attach may leave the
+ * IOMMU without translation, so no further job may run.
+ */
+int hantro_iommu_restore(struct hantro_dev *vpu)
+{
+	int ret;
+
+	if (!vpu->empty_domain)
+		return 0;
+
+	ret = iommu_attach_device(vpu->empty_domain, vpu->dev);
+	if (ret) {
+		dev_err(vpu->dev, "Failed to reinitialize the IOMMU (%d), refusing further jobs\n",
+			ret);
+		vpu->iommu_lost = true;
+		return ret;
+	}
+
+	iommu_detach_device(vpu->empty_domain, vpu->dev);
+	return 0;
+}
+
 void hantro_watchdog(struct work_struct *work)
 {
 	struct hantro_dev *vpu;
@@ -204,6 +230,9 @@ static void device_run(void *priv)
 
 	v4l2_m2m_buf_copy_metadata(src, dst);
 
+	if (unlikely(vpu->iommu_lost))
+		goto err_cancel_job;
+
 	ret = pm_runtime_resume_and_get(vpu->dev);
 	if (ret < 0)
 		goto err_cancel_job;
@@ -1121,6 +1150,42 @@ static void hantro_disable_runtime_pm(struct hantro_dev *vpu)
 	}
 }
 
+static void hantro_free_empty_domain(void *data)
+{
+	iommu_domain_free(data);
+}
+
+static int hantro_alloc_empty_domain(struct hantro_dev *vpu)
+{
+	struct iommu_domain *domain;
+	int ret;
+
+	/*
+	 * Only needed if the core can be reset, and only possible with a DMA
+	 * domain to return to.
+	 */
+	if (!vpu->resets)
+		return 0;
+
+	domain = iommu_get_domain_for_dev(vpu->dev);
+	if (!domain || !iommu_is_dma_domain(domain))
+		return 0;
+
+	domain = iommu_paging_domain_alloc(vpu->dev);
+	if (IS_ERR(domain))
+		return PTR_ERR(domain);
+
+	vpu->empty_domain = domain;
+
+	ret = devm_add_action_or_reset(vpu->dev, hantro_free_empty_domain,
+				       domain);
+	if (ret)
+		return ret;
+
+	/* A failed restore before a rebind can have left the IOMMU in bypass. */
+	return hantro_iommu_restore(vpu);
+}
+
 static int hantro_probe(struct platform_device *pdev)
 {
 	struct hantro_dev *vpu;
@@ -1172,6 +1237,10 @@ static int hantro_probe(struct platform_device *pdev)
 	if (IS_ERR(vpu->resets))
 		return PTR_ERR(vpu->resets);
 
+	ret = hantro_alloc_empty_domain(vpu);
+	if (ret)
+		return ret;
+
 	vpu->reg_base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(vpu->reg_base))
 		return PTR_ERR(vpu->reg_base);
diff --git a/drivers/media/platform/verisilicon/hantro_hw.h b/drivers/media/platform/verisilicon/hantro_hw.h
index 2d12e605cb55..d3c36948208d 100644
--- a/drivers/media/platform/verisilicon/hantro_hw.h
+++ b/drivers/media/platform/verisilicon/hantro_hw.h
@@ -431,6 +431,7 @@ extern const struct hantro_postproc_ops rockchip_vpu981_postproc_ops;
 extern const u32 hantro_vp8_dec_mc_filter[8][6];
 
 void hantro_watchdog(struct work_struct *work);
+int hantro_iommu_restore(struct hantro_dev *vpu);
 void hantro_irq_done(struct hantro_dev *vpu,
 		     enum vb2_buffer_state result);
 void hantro_start_prepare_run(struct hantro_ctx *ctx);
diff --git a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
index 2ec25d6dac86..02fcd74e5ee0 100644
--- a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
+++ b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
@@ -491,8 +491,12 @@ static void rockchip_vpu_enc_hw_reset(struct hantro_dev *vpu)
 	udelay(5);
 
 	ret = reset_control_deassert(vpu->resets);
-	if (ret)
+	if (ret) {
 		dev_err(vpu->dev, "Failed to deassert resets: %d\n", ret);
+		return;
+	}
+
+	hantro_iommu_restore(vpu);
 }
 
 static void rockchip_vpu1_enc_reset(struct hantro_ctx *ctx)

-- 
2.55.0



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 09/18] media: verisilicon: Reinitialize the IOMMU after resetting an encoder core
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

A Rockchip encoder core that faulted on an unmapped IOVA leaves its
IOMMU with the fault pending, and the reset pulse of the previous patch
can reset the IOMMU behind its driver. The IOMMU is only reprogrammed
on runtime resume, which doesn't happen between back-to-back jobs.

Do like rkvdec: allocate an empty paging domain at probe and, after the
reset pulse, attach and detach it. The IOMMU driver reprograms the
IOMMU on each domain change, and the default domain keeps its mappings.

Only do this for a device with reset lines whose domain is a DMA
domain. If the attach fails, the IOMMU may be left without translation
(rockchip-iommu falls back to its identity domain), so refuse all
further jobs. Also attach and detach it at probe, so that a rebind
repairs the IOMMU after such a failure.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/hantro.h        |  5 ++
 drivers/media/platform/verisilicon/hantro_drv.c    | 69 ++++++++++++++++++++++
 drivers/media/platform/verisilicon/hantro_hw.h     |  1 +
 .../media/platform/verisilicon/rockchip_vpu_hw.c   |  6 +-
 4 files changed, 80 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/verisilicon/hantro.h b/drivers/media/platform/verisilicon/hantro.h
index 1efa032506e1..5a9acc8c82a8 100644
--- a/drivers/media/platform/verisilicon/hantro.h
+++ b/drivers/media/platform/verisilicon/hantro.h
@@ -188,6 +188,9 @@ hantro_vdev_to_func(struct video_device *vdev)
  *			shared with interrupt handlers.
  * @variant:		Hardware variant-specific parameters.
  * @watchdog_work:	Delayed work for hardware timeout handling.
+ * @empty_domain:	Empty IOMMU domain, used to reinitialize the IOMMU after
+ *			a reset of the core. NULL if not needed.
+ * @iommu_lost:		The IOMMU couldn't be reinitialized, no job can run.
  */
 struct hantro_dev {
 	struct v4l2_device v4l2_dev;
@@ -207,6 +210,8 @@ struct hantro_dev {
 	spinlock_t irqlock;
 	const struct hantro_variant *variant;
 	struct delayed_work watchdog_work;
+	struct iommu_domain *empty_domain;
+	bool iommu_lost;
 };
 
 /**
diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index 957ed7a59197..e268858269ff 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -11,6 +11,7 @@
  */
 
 #include <linux/clk.h>
+#include <linux/iommu.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
@@ -113,6 +114,31 @@ void hantro_irq_done(struct hantro_dev *vpu,
 	}
 }
 
+/*
+ * Pulsing the reset lines of a core can reset its IOMMU behind the IOMMU
+ * driver. Attaching and detaching the empty domain makes the driver reprogram
+ * it; the default domain keeps its mappings. A failed attach may leave the
+ * IOMMU without translation, so no further job may run.
+ */
+int hantro_iommu_restore(struct hantro_dev *vpu)
+{
+	int ret;
+
+	if (!vpu->empty_domain)
+		return 0;
+
+	ret = iommu_attach_device(vpu->empty_domain, vpu->dev);
+	if (ret) {
+		dev_err(vpu->dev, "Failed to reinitialize the IOMMU (%d), refusing further jobs\n",
+			ret);
+		vpu->iommu_lost = true;
+		return ret;
+	}
+
+	iommu_detach_device(vpu->empty_domain, vpu->dev);
+	return 0;
+}
+
 void hantro_watchdog(struct work_struct *work)
 {
 	struct hantro_dev *vpu;
@@ -204,6 +230,9 @@ static void device_run(void *priv)
 
 	v4l2_m2m_buf_copy_metadata(src, dst);
 
+	if (unlikely(vpu->iommu_lost))
+		goto err_cancel_job;
+
 	ret = pm_runtime_resume_and_get(vpu->dev);
 	if (ret < 0)
 		goto err_cancel_job;
@@ -1121,6 +1150,42 @@ static void hantro_disable_runtime_pm(struct hantro_dev *vpu)
 	}
 }
 
+static void hantro_free_empty_domain(void *data)
+{
+	iommu_domain_free(data);
+}
+
+static int hantro_alloc_empty_domain(struct hantro_dev *vpu)
+{
+	struct iommu_domain *domain;
+	int ret;
+
+	/*
+	 * Only needed if the core can be reset, and only possible with a DMA
+	 * domain to return to.
+	 */
+	if (!vpu->resets)
+		return 0;
+
+	domain = iommu_get_domain_for_dev(vpu->dev);
+	if (!domain || !iommu_is_dma_domain(domain))
+		return 0;
+
+	domain = iommu_paging_domain_alloc(vpu->dev);
+	if (IS_ERR(domain))
+		return PTR_ERR(domain);
+
+	vpu->empty_domain = domain;
+
+	ret = devm_add_action_or_reset(vpu->dev, hantro_free_empty_domain,
+				       domain);
+	if (ret)
+		return ret;
+
+	/* A failed restore before a rebind can have left the IOMMU in bypass. */
+	return hantro_iommu_restore(vpu);
+}
+
 static int hantro_probe(struct platform_device *pdev)
 {
 	struct hantro_dev *vpu;
@@ -1172,6 +1237,10 @@ static int hantro_probe(struct platform_device *pdev)
 	if (IS_ERR(vpu->resets))
 		return PTR_ERR(vpu->resets);
 
+	ret = hantro_alloc_empty_domain(vpu);
+	if (ret)
+		return ret;
+
 	vpu->reg_base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(vpu->reg_base))
 		return PTR_ERR(vpu->reg_base);
diff --git a/drivers/media/platform/verisilicon/hantro_hw.h b/drivers/media/platform/verisilicon/hantro_hw.h
index 2d12e605cb55..d3c36948208d 100644
--- a/drivers/media/platform/verisilicon/hantro_hw.h
+++ b/drivers/media/platform/verisilicon/hantro_hw.h
@@ -431,6 +431,7 @@ extern const struct hantro_postproc_ops rockchip_vpu981_postproc_ops;
 extern const u32 hantro_vp8_dec_mc_filter[8][6];
 
 void hantro_watchdog(struct work_struct *work);
+int hantro_iommu_restore(struct hantro_dev *vpu);
 void hantro_irq_done(struct hantro_dev *vpu,
 		     enum vb2_buffer_state result);
 void hantro_start_prepare_run(struct hantro_ctx *ctx);
diff --git a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
index 2ec25d6dac86..02fcd74e5ee0 100644
--- a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
+++ b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
@@ -491,8 +491,12 @@ static void rockchip_vpu_enc_hw_reset(struct hantro_dev *vpu)
 	udelay(5);
 
 	ret = reset_control_deassert(vpu->resets);
-	if (ret)
+	if (ret) {
 		dev_err(vpu->dev, "Failed to deassert resets: %d\n", ret);
+		return;
+	}
+
+	hantro_iommu_restore(vpu);
 }
 
 static void rockchip_vpu1_enc_reset(struct hantro_ctx *ctx)

-- 
2.55.0



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

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 10/18] media: verisilicon: Acquire the reset lines only while using them
  2026-12-06  5:57 ` Arun Iyengar via B4 Relay
  (?)
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  -1 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

The RK3588 AV1 IOMMU has no reset lines of its own: it shares the four
AV1 resets with the decoder. Get them as released exclusive controls and
acquire them only around their use, so that the IOMMU driver can
deassert them too.

Suggested-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/hantro_drv.c       | 10 ++++++++--
 drivers/media/platform/verisilicon/rockchip_vpu_hw.c  | 12 ++++++++++--
 drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c |  4 ++++
 drivers/media/platform/verisilicon/sunxi_vpu_hw.c     |  4 ++++
 4 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index e268858269ff..26b273cd339d 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -1233,7 +1233,9 @@ static int hantro_probe(struct platform_device *pdev)
 			return PTR_ERR(vpu->clocks[0].clk);
 	}
 
-	vpu->resets = devm_reset_control_array_get_optional_exclusive(&pdev->dev);
+	/* Released: the IOMMU of a core can share its reset lines. */
+	vpu->resets = devm_reset_control_array_get(&pdev->dev,
+						   RESET_CONTROL_OPTIONAL_EXCLUSIVE_RELEASED);
 	if (IS_ERR(vpu->resets))
 		return PTR_ERR(vpu->resets);
 
@@ -1309,7 +1311,11 @@ static int hantro_probe(struct platform_device *pdev)
 	pm_runtime_use_autosuspend(vpu->dev);
 	pm_runtime_enable(vpu->dev);
 
-	ret = reset_control_deassert(vpu->resets);
+	ret = reset_control_acquire(vpu->resets);
+	if (!ret) {
+		ret = reset_control_deassert(vpu->resets);
+		reset_control_release(vpu->resets);
+	}
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to deassert resets\n");
 		goto err_pm_disable;
diff --git a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
index 02fcd74e5ee0..f04d3cc0c1a8 100644
--- a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
+++ b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
@@ -482,10 +482,16 @@ static void rockchip_vpu_enc_hw_reset(struct hantro_dev *vpu)
 	if (!vpu->resets)
 		return;
 
+	ret = reset_control_acquire(vpu->resets);
+	if (ret) {
+		dev_warn(vpu->dev, "Failed to acquire resets: %d\n", ret);
+		return;
+	}
+
 	ret = reset_control_assert(vpu->resets);
 	if (ret) {
 		dev_warn(vpu->dev, "Failed to assert resets: %d\n", ret);
-		return;
+		goto release;
 	}
 
 	udelay(5);
@@ -493,10 +499,12 @@ static void rockchip_vpu_enc_hw_reset(struct hantro_dev *vpu)
 	ret = reset_control_deassert(vpu->resets);
 	if (ret) {
 		dev_err(vpu->dev, "Failed to deassert resets: %d\n", ret);
-		return;
+		goto release;
 	}
 
 	hantro_iommu_restore(vpu);
+release:
+	reset_control_release(vpu->resets);
 }
 
 static void rockchip_vpu1_enc_reset(struct hantro_ctx *ctx)
diff --git a/drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c b/drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c
index 833821120b20..a16c43bdeb24 100644
--- a/drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c
+++ b/drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c
@@ -115,7 +115,11 @@ static void stm32mp25_venc_reset(struct hantro_ctx *ctx)
 {
 	struct hantro_dev *vpu = ctx->dev;
 
+	if (reset_control_acquire(vpu->resets))
+		return;
+
 	reset_control_reset(vpu->resets);
+	reset_control_release(vpu->resets);
 }
 
 /*
diff --git a/drivers/media/platform/verisilicon/sunxi_vpu_hw.c b/drivers/media/platform/verisilicon/sunxi_vpu_hw.c
index 02ce8b064a8f..f15ead62dc96 100644
--- a/drivers/media/platform/verisilicon/sunxi_vpu_hw.c
+++ b/drivers/media/platform/verisilicon/sunxi_vpu_hw.c
@@ -91,7 +91,11 @@ static void sunxi_vpu_reset(struct hantro_ctx *ctx)
 {
 	struct hantro_dev *vpu = ctx->dev;
 
+	if (reset_control_acquire(vpu->resets))
+		return;
+
 	reset_control_reset(vpu->resets);
+	reset_control_release(vpu->resets);
 }
 
 static const struct hantro_codec_ops sunxi_vpu_codec_ops[] = {

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 10/18] media: verisilicon: Acquire the reset lines only while using them
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

The RK3588 AV1 IOMMU has no reset lines of its own: it shares the four
AV1 resets with the decoder. Get them as released exclusive controls and
acquire them only around their use, so that the IOMMU driver can
deassert them too.

Suggested-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/hantro_drv.c       | 10 ++++++++--
 drivers/media/platform/verisilicon/rockchip_vpu_hw.c  | 12 ++++++++++--
 drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c |  4 ++++
 drivers/media/platform/verisilicon/sunxi_vpu_hw.c     |  4 ++++
 4 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index e268858269ff..26b273cd339d 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -1233,7 +1233,9 @@ static int hantro_probe(struct platform_device *pdev)
 			return PTR_ERR(vpu->clocks[0].clk);
 	}
 
-	vpu->resets = devm_reset_control_array_get_optional_exclusive(&pdev->dev);
+	/* Released: the IOMMU of a core can share its reset lines. */
+	vpu->resets = devm_reset_control_array_get(&pdev->dev,
+						   RESET_CONTROL_OPTIONAL_EXCLUSIVE_RELEASED);
 	if (IS_ERR(vpu->resets))
 		return PTR_ERR(vpu->resets);
 
@@ -1309,7 +1311,11 @@ static int hantro_probe(struct platform_device *pdev)
 	pm_runtime_use_autosuspend(vpu->dev);
 	pm_runtime_enable(vpu->dev);
 
-	ret = reset_control_deassert(vpu->resets);
+	ret = reset_control_acquire(vpu->resets);
+	if (!ret) {
+		ret = reset_control_deassert(vpu->resets);
+		reset_control_release(vpu->resets);
+	}
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to deassert resets\n");
 		goto err_pm_disable;
diff --git a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
index 02fcd74e5ee0..f04d3cc0c1a8 100644
--- a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
+++ b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
@@ -482,10 +482,16 @@ static void rockchip_vpu_enc_hw_reset(struct hantro_dev *vpu)
 	if (!vpu->resets)
 		return;
 
+	ret = reset_control_acquire(vpu->resets);
+	if (ret) {
+		dev_warn(vpu->dev, "Failed to acquire resets: %d\n", ret);
+		return;
+	}
+
 	ret = reset_control_assert(vpu->resets);
 	if (ret) {
 		dev_warn(vpu->dev, "Failed to assert resets: %d\n", ret);
-		return;
+		goto release;
 	}
 
 	udelay(5);
@@ -493,10 +499,12 @@ static void rockchip_vpu_enc_hw_reset(struct hantro_dev *vpu)
 	ret = reset_control_deassert(vpu->resets);
 	if (ret) {
 		dev_err(vpu->dev, "Failed to deassert resets: %d\n", ret);
-		return;
+		goto release;
 	}
 
 	hantro_iommu_restore(vpu);
+release:
+	reset_control_release(vpu->resets);
 }
 
 static void rockchip_vpu1_enc_reset(struct hantro_ctx *ctx)
diff --git a/drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c b/drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c
index 833821120b20..a16c43bdeb24 100644
--- a/drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c
+++ b/drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c
@@ -115,7 +115,11 @@ static void stm32mp25_venc_reset(struct hantro_ctx *ctx)
 {
 	struct hantro_dev *vpu = ctx->dev;
 
+	if (reset_control_acquire(vpu->resets))
+		return;
+
 	reset_control_reset(vpu->resets);
+	reset_control_release(vpu->resets);
 }
 
 /*
diff --git a/drivers/media/platform/verisilicon/sunxi_vpu_hw.c b/drivers/media/platform/verisilicon/sunxi_vpu_hw.c
index 02ce8b064a8f..f15ead62dc96 100644
--- a/drivers/media/platform/verisilicon/sunxi_vpu_hw.c
+++ b/drivers/media/platform/verisilicon/sunxi_vpu_hw.c
@@ -91,7 +91,11 @@ static void sunxi_vpu_reset(struct hantro_ctx *ctx)
 {
 	struct hantro_dev *vpu = ctx->dev;
 
+	if (reset_control_acquire(vpu->resets))
+		return;
+
 	reset_control_reset(vpu->resets);
+	reset_control_release(vpu->resets);
 }
 
 static const struct hantro_codec_ops sunxi_vpu_codec_ops[] = {

-- 
2.55.0



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 10/18] media: verisilicon: Acquire the reset lines only while using them
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

The RK3588 AV1 IOMMU has no reset lines of its own: it shares the four
AV1 resets with the decoder. Get them as released exclusive controls and
acquire them only around their use, so that the IOMMU driver can
deassert them too.

Suggested-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/hantro_drv.c       | 10 ++++++++--
 drivers/media/platform/verisilicon/rockchip_vpu_hw.c  | 12 ++++++++++--
 drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c |  4 ++++
 drivers/media/platform/verisilicon/sunxi_vpu_hw.c     |  4 ++++
 4 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index e268858269ff..26b273cd339d 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -1233,7 +1233,9 @@ static int hantro_probe(struct platform_device *pdev)
 			return PTR_ERR(vpu->clocks[0].clk);
 	}
 
-	vpu->resets = devm_reset_control_array_get_optional_exclusive(&pdev->dev);
+	/* Released: the IOMMU of a core can share its reset lines. */
+	vpu->resets = devm_reset_control_array_get(&pdev->dev,
+						   RESET_CONTROL_OPTIONAL_EXCLUSIVE_RELEASED);
 	if (IS_ERR(vpu->resets))
 		return PTR_ERR(vpu->resets);
 
@@ -1309,7 +1311,11 @@ static int hantro_probe(struct platform_device *pdev)
 	pm_runtime_use_autosuspend(vpu->dev);
 	pm_runtime_enable(vpu->dev);
 
-	ret = reset_control_deassert(vpu->resets);
+	ret = reset_control_acquire(vpu->resets);
+	if (!ret) {
+		ret = reset_control_deassert(vpu->resets);
+		reset_control_release(vpu->resets);
+	}
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to deassert resets\n");
 		goto err_pm_disable;
diff --git a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
index 02fcd74e5ee0..f04d3cc0c1a8 100644
--- a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
+++ b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
@@ -482,10 +482,16 @@ static void rockchip_vpu_enc_hw_reset(struct hantro_dev *vpu)
 	if (!vpu->resets)
 		return;
 
+	ret = reset_control_acquire(vpu->resets);
+	if (ret) {
+		dev_warn(vpu->dev, "Failed to acquire resets: %d\n", ret);
+		return;
+	}
+
 	ret = reset_control_assert(vpu->resets);
 	if (ret) {
 		dev_warn(vpu->dev, "Failed to assert resets: %d\n", ret);
-		return;
+		goto release;
 	}
 
 	udelay(5);
@@ -493,10 +499,12 @@ static void rockchip_vpu_enc_hw_reset(struct hantro_dev *vpu)
 	ret = reset_control_deassert(vpu->resets);
 	if (ret) {
 		dev_err(vpu->dev, "Failed to deassert resets: %d\n", ret);
-		return;
+		goto release;
 	}
 
 	hantro_iommu_restore(vpu);
+release:
+	reset_control_release(vpu->resets);
 }
 
 static void rockchip_vpu1_enc_reset(struct hantro_ctx *ctx)
diff --git a/drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c b/drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c
index 833821120b20..a16c43bdeb24 100644
--- a/drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c
+++ b/drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c
@@ -115,7 +115,11 @@ static void stm32mp25_venc_reset(struct hantro_ctx *ctx)
 {
 	struct hantro_dev *vpu = ctx->dev;
 
+	if (reset_control_acquire(vpu->resets))
+		return;
+
 	reset_control_reset(vpu->resets);
+	reset_control_release(vpu->resets);
 }
 
 /*
diff --git a/drivers/media/platform/verisilicon/sunxi_vpu_hw.c b/drivers/media/platform/verisilicon/sunxi_vpu_hw.c
index 02ce8b064a8f..f15ead62dc96 100644
--- a/drivers/media/platform/verisilicon/sunxi_vpu_hw.c
+++ b/drivers/media/platform/verisilicon/sunxi_vpu_hw.c
@@ -91,7 +91,11 @@ static void sunxi_vpu_reset(struct hantro_ctx *ctx)
 {
 	struct hantro_dev *vpu = ctx->dev;
 
+	if (reset_control_acquire(vpu->resets))
+		return;
+
 	reset_control_reset(vpu->resets);
+	reset_control_release(vpu->resets);
 }
 
 static const struct hantro_codec_ops sunxi_vpu_codec_ops[] = {

-- 
2.55.0



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

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 11/18] dt-bindings: iommu: verisilicon: Add the reset lines
  2026-12-06  5:57 ` Arun Iyengar via B4 Relay
  (?)
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  -1 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

The RK3588 AV1 IOMMU is part of the AV1 block and has no reset lines
of its own: the four AV1 resets also cover it. Its registers can't be
accessed while they are asserted. Describe them.

Suggested-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 Documentation/devicetree/bindings/iommu/verisilicon,iommu.yaml | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/Documentation/devicetree/bindings/iommu/verisilicon,iommu.yaml b/Documentation/devicetree/bindings/iommu/verisilicon,iommu.yaml
index d3ce9e603b61..70df03102015 100644
--- a/Documentation/devicetree/bindings/iommu/verisilicon,iommu.yaml
+++ b/Documentation/devicetree/bindings/iommu/verisilicon,iommu.yaml
@@ -41,6 +41,13 @@ properties:
   power-domains:
     maxItems: 1
 
+  resets:
+    items:
+      - description: AXI reset line
+      - description: AXI bus interface unit reset line
+      - description: APB reset line
+      - description: APB bus interface unit reset line
+
 required:
   - compatible
   - reg
@@ -55,6 +62,7 @@ examples:
   - |
     #include <dt-bindings/clock/rockchip,rk3588-cru.h>
     #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/reset/rockchip,rk3588-cru.h>
 
     bus {
       #address-cells = <2>;
@@ -67,5 +75,7 @@ examples:
         clocks = <&cru ACLK_AV1>, <&cru PCLK_AV1>;
         clock-names = "core", "iface";
         #iommu-cells = <0>;
+        resets = <&cru SRST_A_AV1>, <&cru SRST_A_AV1_BIU>,
+                 <&cru SRST_P_AV1>, <&cru SRST_P_AV1_BIU>;
       };
     };

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 11/18] dt-bindings: iommu: verisilicon: Add the reset lines
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

The RK3588 AV1 IOMMU is part of the AV1 block and has no reset lines
of its own: the four AV1 resets also cover it. Its registers can't be
accessed while they are asserted. Describe them.

Suggested-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 Documentation/devicetree/bindings/iommu/verisilicon,iommu.yaml | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/Documentation/devicetree/bindings/iommu/verisilicon,iommu.yaml b/Documentation/devicetree/bindings/iommu/verisilicon,iommu.yaml
index d3ce9e603b61..70df03102015 100644
--- a/Documentation/devicetree/bindings/iommu/verisilicon,iommu.yaml
+++ b/Documentation/devicetree/bindings/iommu/verisilicon,iommu.yaml
@@ -41,6 +41,13 @@ properties:
   power-domains:
     maxItems: 1
 
+  resets:
+    items:
+      - description: AXI reset line
+      - description: AXI bus interface unit reset line
+      - description: APB reset line
+      - description: APB bus interface unit reset line
+
 required:
   - compatible
   - reg
@@ -55,6 +62,7 @@ examples:
   - |
     #include <dt-bindings/clock/rockchip,rk3588-cru.h>
     #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/reset/rockchip,rk3588-cru.h>
 
     bus {
       #address-cells = <2>;
@@ -67,5 +75,7 @@ examples:
         clocks = <&cru ACLK_AV1>, <&cru PCLK_AV1>;
         clock-names = "core", "iface";
         #iommu-cells = <0>;
+        resets = <&cru SRST_A_AV1>, <&cru SRST_A_AV1_BIU>,
+                 <&cru SRST_P_AV1>, <&cru SRST_P_AV1_BIU>;
       };
     };

-- 
2.55.0



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 11/18] dt-bindings: iommu: verisilicon: Add the reset lines
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

The RK3588 AV1 IOMMU is part of the AV1 block and has no reset lines
of its own: the four AV1 resets also cover it. Its registers can't be
accessed while they are asserted. Describe them.

Suggested-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 Documentation/devicetree/bindings/iommu/verisilicon,iommu.yaml | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/Documentation/devicetree/bindings/iommu/verisilicon,iommu.yaml b/Documentation/devicetree/bindings/iommu/verisilicon,iommu.yaml
index d3ce9e603b61..70df03102015 100644
--- a/Documentation/devicetree/bindings/iommu/verisilicon,iommu.yaml
+++ b/Documentation/devicetree/bindings/iommu/verisilicon,iommu.yaml
@@ -41,6 +41,13 @@ properties:
   power-domains:
     maxItems: 1
 
+  resets:
+    items:
+      - description: AXI reset line
+      - description: AXI bus interface unit reset line
+      - description: APB reset line
+      - description: APB bus interface unit reset line
+
 required:
   - compatible
   - reg
@@ -55,6 +62,7 @@ examples:
   - |
     #include <dt-bindings/clock/rockchip,rk3588-cru.h>
     #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/reset/rockchip,rk3588-cru.h>
 
     bus {
       #address-cells = <2>;
@@ -67,5 +75,7 @@ examples:
         clocks = <&cru ACLK_AV1>, <&cru PCLK_AV1>;
         clock-names = "core", "iface";
         #iommu-cells = <0>;
+        resets = <&cru SRST_A_AV1>, <&cru SRST_A_AV1_BIU>,
+                 <&cru SRST_P_AV1>, <&cru SRST_P_AV1_BIU>;
       };
     };

-- 
2.55.0



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

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 12/18] iommu/vsi: Deassert the reset lines on probe
  2026-12-06  5:57 ` Arun Iyengar via B4 Relay
  (?)
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  -1 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

The RK3588 AV1 IOMMU shares its reset lines with the decoder, and its
registers can't be accessed while they are asserted. It writes them on
attach, before the decoder's probe deasserts the resets.

Deassert the resets on probe. They are released exclusive controls,
acquired only for that, so the decoder can still use them.

Suggested-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/iommu/vsi-iommu.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/iommu/vsi-iommu.c b/drivers/iommu/vsi-iommu.c
index 5dac20b143a5..a3ec2fe5ecd5 100644
--- a/drivers/iommu/vsi-iommu.c
+++ b/drivers/iommu/vsi-iommu.c
@@ -33,6 +33,7 @@
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/reset.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 
@@ -669,6 +670,7 @@ MODULE_DEVICE_TABLE(of, vsi_iommu_dt_ids);
 static int vsi_iommu_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
+	struct reset_control *resets;
 	struct vsi_iommu *iommu;
 	int err;
 
@@ -688,6 +690,20 @@ static int vsi_iommu_probe(struct platform_device *pdev)
 	if  (iommu->num_clocks < 0)
 		return iommu->num_clocks;
 
+	/* Shared with the decoder. */
+	resets = devm_reset_control_array_get(dev, RESET_CONTROL_OPTIONAL_EXCLUSIVE_RELEASED);
+	if (IS_ERR(resets))
+		return PTR_ERR(resets);
+
+	err = reset_control_acquire(resets);
+	if (err)
+		return err;
+
+	err = reset_control_deassert(resets);
+	reset_control_release(resets);
+	if (err)
+		return err;
+
 	err = clk_bulk_prepare(iommu->num_clocks, iommu->clocks);
 	if (err)
 		return err;

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 12/18] iommu/vsi: Deassert the reset lines on probe
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

The RK3588 AV1 IOMMU shares its reset lines with the decoder, and its
registers can't be accessed while they are asserted. It writes them on
attach, before the decoder's probe deasserts the resets.

Deassert the resets on probe. They are released exclusive controls,
acquired only for that, so the decoder can still use them.

Suggested-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/iommu/vsi-iommu.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/iommu/vsi-iommu.c b/drivers/iommu/vsi-iommu.c
index 5dac20b143a5..a3ec2fe5ecd5 100644
--- a/drivers/iommu/vsi-iommu.c
+++ b/drivers/iommu/vsi-iommu.c
@@ -33,6 +33,7 @@
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/reset.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 
@@ -669,6 +670,7 @@ MODULE_DEVICE_TABLE(of, vsi_iommu_dt_ids);
 static int vsi_iommu_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
+	struct reset_control *resets;
 	struct vsi_iommu *iommu;
 	int err;
 
@@ -688,6 +690,20 @@ static int vsi_iommu_probe(struct platform_device *pdev)
 	if  (iommu->num_clocks < 0)
 		return iommu->num_clocks;
 
+	/* Shared with the decoder. */
+	resets = devm_reset_control_array_get(dev, RESET_CONTROL_OPTIONAL_EXCLUSIVE_RELEASED);
+	if (IS_ERR(resets))
+		return PTR_ERR(resets);
+
+	err = reset_control_acquire(resets);
+	if (err)
+		return err;
+
+	err = reset_control_deassert(resets);
+	reset_control_release(resets);
+	if (err)
+		return err;
+
 	err = clk_bulk_prepare(iommu->num_clocks, iommu->clocks);
 	if (err)
 		return err;

-- 
2.55.0



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 12/18] iommu/vsi: Deassert the reset lines on probe
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

The RK3588 AV1 IOMMU shares its reset lines with the decoder, and its
registers can't be accessed while they are asserted. It writes them on
attach, before the decoder's probe deasserts the resets.

Deassert the resets on probe. They are released exclusive controls,
acquired only for that, so the decoder can still use them.

Suggested-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/iommu/vsi-iommu.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/iommu/vsi-iommu.c b/drivers/iommu/vsi-iommu.c
index 5dac20b143a5..a3ec2fe5ecd5 100644
--- a/drivers/iommu/vsi-iommu.c
+++ b/drivers/iommu/vsi-iommu.c
@@ -33,6 +33,7 @@
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/reset.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 
@@ -669,6 +670,7 @@ MODULE_DEVICE_TABLE(of, vsi_iommu_dt_ids);
 static int vsi_iommu_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
+	struct reset_control *resets;
 	struct vsi_iommu *iommu;
 	int err;
 
@@ -688,6 +690,20 @@ static int vsi_iommu_probe(struct platform_device *pdev)
 	if  (iommu->num_clocks < 0)
 		return iommu->num_clocks;
 
+	/* Shared with the decoder. */
+	resets = devm_reset_control_array_get(dev, RESET_CONTROL_OPTIONAL_EXCLUSIVE_RELEASED);
+	if (IS_ERR(resets))
+		return PTR_ERR(resets);
+
+	err = reset_control_acquire(resets);
+	if (err)
+		return err;
+
+	err = reset_control_deassert(resets);
+	reset_control_release(resets);
+	if (err)
+		return err;
+
 	err = clk_bulk_prepare(iommu->num_clocks, iommu->clocks);
 	if (err)
 		return err;

-- 
2.55.0



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

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 13/18] arm64: dts: rockchip: Add the reset lines of the RK3588 VEPU121 cores
  2026-12-06  5:57 ` Arun Iyengar via B4 Relay
  (?)
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  -1 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

Describe the AXI and AHB reset lines of the four VEPU121 JPEG encoder
cores, so that the driver can reset a core that is stuck after a fault
of its IOMMU.

The IOMMU of each core sits in the same register block and is clocked
by the same clocks, so these resets likely cover its bus interface as
well. This relies on the driver not leaving the VPU in reset after
remove ("media: verisilicon: Don't hold the VPU in reset after remove").

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 arch/arm64/boot/dts/rockchip/rk3588-base.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi b/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
index aa69fd3793fd..227465d446a2 100644
--- a/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
@@ -1325,6 +1325,8 @@ vepu121_0: video-codec@fdba0000 {
 		clock-names = "aclk", "hclk";
 		iommus = <&vepu121_0_mmu>;
 		power-domains = <&power RK3588_PD_VDPU>;
+		resets = <&cru SRST_A_JPEG_ENCODER0>, <&cru SRST_H_JPEG_ENCODER0>;
+		reset-names = "axi", "ahb";
 	};
 
 	vepu121_0_mmu: iommu@fdba0800 {
@@ -1345,6 +1347,8 @@ vepu121_1: video-codec@fdba4000 {
 		clock-names = "aclk", "hclk";
 		iommus = <&vepu121_1_mmu>;
 		power-domains = <&power RK3588_PD_VDPU>;
+		resets = <&cru SRST_A_JPEG_ENCODER1>, <&cru SRST_H_JPEG_ENCODER1>;
+		reset-names = "axi", "ahb";
 	};
 
 	vepu121_1_mmu: iommu@fdba4800 {
@@ -1365,6 +1369,8 @@ vepu121_2: video-codec@fdba8000 {
 		clock-names = "aclk", "hclk";
 		iommus = <&vepu121_2_mmu>;
 		power-domains = <&power RK3588_PD_VDPU>;
+		resets = <&cru SRST_A_JPEG_ENCODER2>, <&cru SRST_H_JPEG_ENCODER2>;
+		reset-names = "axi", "ahb";
 	};
 
 	vepu121_2_mmu: iommu@fdba8800 {
@@ -1385,6 +1391,8 @@ vepu121_3: video-codec@fdbac000 {
 		clock-names = "aclk", "hclk";
 		iommus = <&vepu121_3_mmu>;
 		power-domains = <&power RK3588_PD_VDPU>;
+		resets = <&cru SRST_A_JPEG_ENCODER3>, <&cru SRST_H_JPEG_ENCODER3>;
+		reset-names = "axi", "ahb";
 	};
 
 	vepu121_3_mmu: iommu@fdbac800 {

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 13/18] arm64: dts: rockchip: Add the reset lines of the RK3588 VEPU121 cores
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

Describe the AXI and AHB reset lines of the four VEPU121 JPEG encoder
cores, so that the driver can reset a core that is stuck after a fault
of its IOMMU.

The IOMMU of each core sits in the same register block and is clocked
by the same clocks, so these resets likely cover its bus interface as
well. This relies on the driver not leaving the VPU in reset after
remove ("media: verisilicon: Don't hold the VPU in reset after remove").

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 arch/arm64/boot/dts/rockchip/rk3588-base.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi b/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
index aa69fd3793fd..227465d446a2 100644
--- a/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
@@ -1325,6 +1325,8 @@ vepu121_0: video-codec@fdba0000 {
 		clock-names = "aclk", "hclk";
 		iommus = <&vepu121_0_mmu>;
 		power-domains = <&power RK3588_PD_VDPU>;
+		resets = <&cru SRST_A_JPEG_ENCODER0>, <&cru SRST_H_JPEG_ENCODER0>;
+		reset-names = "axi", "ahb";
 	};
 
 	vepu121_0_mmu: iommu@fdba0800 {
@@ -1345,6 +1347,8 @@ vepu121_1: video-codec@fdba4000 {
 		clock-names = "aclk", "hclk";
 		iommus = <&vepu121_1_mmu>;
 		power-domains = <&power RK3588_PD_VDPU>;
+		resets = <&cru SRST_A_JPEG_ENCODER1>, <&cru SRST_H_JPEG_ENCODER1>;
+		reset-names = "axi", "ahb";
 	};
 
 	vepu121_1_mmu: iommu@fdba4800 {
@@ -1365,6 +1369,8 @@ vepu121_2: video-codec@fdba8000 {
 		clock-names = "aclk", "hclk";
 		iommus = <&vepu121_2_mmu>;
 		power-domains = <&power RK3588_PD_VDPU>;
+		resets = <&cru SRST_A_JPEG_ENCODER2>, <&cru SRST_H_JPEG_ENCODER2>;
+		reset-names = "axi", "ahb";
 	};
 
 	vepu121_2_mmu: iommu@fdba8800 {
@@ -1385,6 +1391,8 @@ vepu121_3: video-codec@fdbac000 {
 		clock-names = "aclk", "hclk";
 		iommus = <&vepu121_3_mmu>;
 		power-domains = <&power RK3588_PD_VDPU>;
+		resets = <&cru SRST_A_JPEG_ENCODER3>, <&cru SRST_H_JPEG_ENCODER3>;
+		reset-names = "axi", "ahb";
 	};
 
 	vepu121_3_mmu: iommu@fdbac800 {

-- 
2.55.0



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 13/18] arm64: dts: rockchip: Add the reset lines of the RK3588 VEPU121 cores
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

Describe the AXI and AHB reset lines of the four VEPU121 JPEG encoder
cores, so that the driver can reset a core that is stuck after a fault
of its IOMMU.

The IOMMU of each core sits in the same register block and is clocked
by the same clocks, so these resets likely cover its bus interface as
well. This relies on the driver not leaving the VPU in reset after
remove ("media: verisilicon: Don't hold the VPU in reset after remove").

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 arch/arm64/boot/dts/rockchip/rk3588-base.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi b/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
index aa69fd3793fd..227465d446a2 100644
--- a/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
@@ -1325,6 +1325,8 @@ vepu121_0: video-codec@fdba0000 {
 		clock-names = "aclk", "hclk";
 		iommus = <&vepu121_0_mmu>;
 		power-domains = <&power RK3588_PD_VDPU>;
+		resets = <&cru SRST_A_JPEG_ENCODER0>, <&cru SRST_H_JPEG_ENCODER0>;
+		reset-names = "axi", "ahb";
 	};
 
 	vepu121_0_mmu: iommu@fdba0800 {
@@ -1345,6 +1347,8 @@ vepu121_1: video-codec@fdba4000 {
 		clock-names = "aclk", "hclk";
 		iommus = <&vepu121_1_mmu>;
 		power-domains = <&power RK3588_PD_VDPU>;
+		resets = <&cru SRST_A_JPEG_ENCODER1>, <&cru SRST_H_JPEG_ENCODER1>;
+		reset-names = "axi", "ahb";
 	};
 
 	vepu121_1_mmu: iommu@fdba4800 {
@@ -1365,6 +1369,8 @@ vepu121_2: video-codec@fdba8000 {
 		clock-names = "aclk", "hclk";
 		iommus = <&vepu121_2_mmu>;
 		power-domains = <&power RK3588_PD_VDPU>;
+		resets = <&cru SRST_A_JPEG_ENCODER2>, <&cru SRST_H_JPEG_ENCODER2>;
+		reset-names = "axi", "ahb";
 	};
 
 	vepu121_2_mmu: iommu@fdba8800 {
@@ -1385,6 +1391,8 @@ vepu121_3: video-codec@fdbac000 {
 		clock-names = "aclk", "hclk";
 		iommus = <&vepu121_3_mmu>;
 		power-domains = <&power RK3588_PD_VDPU>;
+		resets = <&cru SRST_A_JPEG_ENCODER3>, <&cru SRST_H_JPEG_ENCODER3>;
+		reset-names = "axi", "ahb";
 	};
 
 	vepu121_3_mmu: iommu@fdbac800 {

-- 
2.55.0



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

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 14/18] arm64: dts: rockchip: Add the reset lines of the RK3588 AV1 IOMMU
  2026-12-06  5:57 ` Arun Iyengar via B4 Relay
  (?)
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  -1 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

The AV1 IOMMU shares the four AV1 resets with the decoder. Describe
them, so that its driver deasserts them before using its registers.

This needs the decoder to get them as released controls ("media:
verisilicon: Acquire the reset lines only while using them").

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 arch/arm64/boot/dts/rockchip/rk3588-base.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi b/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
index 227465d446a2..96898fefe840 100644
--- a/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
@@ -1491,6 +1491,8 @@ av1d_mmu: iommu@fdca0000 {
 		clock-names = "core", "iface";
 		#iommu-cells = <0>;
 		power-domains = <&power RK3588_PD_AV1>;
+		resets = <&cru SRST_A_AV1>, <&cru SRST_A_AV1_BIU>,
+			 <&cru SRST_P_AV1>, <&cru SRST_P_AV1_BIU>;
 	};
 
 	vicap: video-capture@fdce0000 {

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 14/18] arm64: dts: rockchip: Add the reset lines of the RK3588 AV1 IOMMU
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

The AV1 IOMMU shares the four AV1 resets with the decoder. Describe
them, so that its driver deasserts them before using its registers.

This needs the decoder to get them as released controls ("media:
verisilicon: Acquire the reset lines only while using them").

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 arch/arm64/boot/dts/rockchip/rk3588-base.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi b/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
index 227465d446a2..96898fefe840 100644
--- a/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
@@ -1491,6 +1491,8 @@ av1d_mmu: iommu@fdca0000 {
 		clock-names = "core", "iface";
 		#iommu-cells = <0>;
 		power-domains = <&power RK3588_PD_AV1>;
+		resets = <&cru SRST_A_AV1>, <&cru SRST_A_AV1_BIU>,
+			 <&cru SRST_P_AV1>, <&cru SRST_P_AV1_BIU>;
 	};
 
 	vicap: video-capture@fdce0000 {

-- 
2.55.0



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 14/18] arm64: dts: rockchip: Add the reset lines of the RK3588 AV1 IOMMU
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

The AV1 IOMMU shares the four AV1 resets with the decoder. Describe
them, so that its driver deasserts them before using its registers.

This needs the decoder to get them as released controls ("media:
verisilicon: Acquire the reset lines only while using them").

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 arch/arm64/boot/dts/rockchip/rk3588-base.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi b/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
index 227465d446a2..96898fefe840 100644
--- a/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
@@ -1491,6 +1491,8 @@ av1d_mmu: iommu@fdca0000 {
 		clock-names = "core", "iface";
 		#iommu-cells = <0>;
 		power-domains = <&power RK3588_PD_AV1>;
+		resets = <&cru SRST_A_AV1>, <&cru SRST_A_AV1_BIU>,
+			 <&cru SRST_P_AV1>, <&cru SRST_P_AV1_BIU>;
 	};
 
 	vicap: video-capture@fdce0000 {

-- 
2.55.0



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

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 15/18] pmdomain: rockchip: Add rockchip_pmu_idle_reset()
  2026-12-06  5:57 ` Arun Iyengar via B4 Relay
  (?)
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  -1 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

Randy Li, Caesar Wang and Jeffy Chen posted "soc: rockchip: power-domain:
export idle request" for this in 2017 and 2019; it was not merged.

A device reset during a bus transfer can hang the bus of its domain.
Let drivers reset a device with the bus stopped, as the vendor kernel
does: idle request, reset callback and idle release under the PMU mutex.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/pmdomain/rockchip/pm-domains.c | 52 ++++++++++++++++++++++++++++++++++
 include/soc/rockchip/pm_domains.h      | 12 ++++++++
 2 files changed, 64 insertions(+)

diff --git a/drivers/pmdomain/rockchip/pm-domains.c b/drivers/pmdomain/rockchip/pm-domains.c
index db3879846db6..5dc1c4c6e211 100644
--- a/drivers/pmdomain/rockchip/pm-domains.c
+++ b/drivers/pmdomain/rockchip/pm-domains.c
@@ -743,6 +743,58 @@ static int rockchip_pd_power_off(struct generic_pm_domain *domain)
 	return ret;
 }
 
+/**
+ * rockchip_pmu_idle_reset() - Reset a device with the bus of its domain stopped
+ * @dev: device with a single power domain, which must be on
+ * @reset: resets the device; must not access the domain
+ * @data: argument of @reset
+ *
+ * A reset during a bus transfer can hang the bus. The caller must keep the
+ * other devices of the domain off the bus during the call. @reset runs with
+ * the PMU mutex held and must not change the state of a power domain.
+ *
+ * Return: 0, the error of @reset or of enabling the domain clocks, -EINVAL if
+ * @dev does not have exactly one Rockchip power domain, -EIO if the domain is
+ * off, or -ETIMEDOUT if the bus did not stop or restart; its state is then
+ * unknown.
+ */
+int rockchip_pmu_idle_reset(struct device *dev, int (*reset)(void *data),
+			    void *data)
+{
+	struct rockchip_pm_domain *pd;
+	struct generic_pm_domain *genpd;
+	int ret, ret2;
+
+	if (!dev->pm_domain)
+		return -EINVAL;
+
+	genpd = pd_to_genpd(dev->pm_domain);
+	if (genpd->power_on != rockchip_pd_power_on)
+		return -EINVAL;
+
+	pd = to_rockchip_pd(genpd);
+	guard(mutex)(&pd->pmu->mutex);
+
+	if (!rockchip_pmu_domain_is_on(pd))
+		return -EIO;
+
+	ret = clk_bulk_enable(pd->num_clks, pd->clks);
+	if (ret)
+		return ret;
+
+	rockchip_pmu_ungate_clk(pd, true);
+	ret = rockchip_pmu_set_idle_request(pd, true);
+	if (!ret)
+		ret = reset(data);
+	ret2 = rockchip_pmu_set_idle_request(pd, false);
+	rockchip_pmu_ungate_clk(pd, false);
+
+	clk_bulk_disable(pd->num_clks, pd->clks);
+
+	return ret2 ?: ret;
+}
+EXPORT_SYMBOL_GPL(rockchip_pmu_idle_reset);
+
 static int rockchip_pd_attach_dev(struct generic_pm_domain *genpd,
 				  struct device *dev)
 {
diff --git a/include/soc/rockchip/pm_domains.h b/include/soc/rockchip/pm_domains.h
index 7dbd941fc937..e1f488140b12 100644
--- a/include/soc/rockchip/pm_domains.h
+++ b/include/soc/rockchip/pm_domains.h
@@ -6,10 +6,16 @@
 #ifndef __SOC_ROCKCHIP_PM_DOMAINS_H__
 #define __SOC_ROCKCHIP_PM_DOMAINS_H__
 
+#include <linux/errno.h>
+
+struct device;
+
 #ifdef CONFIG_ROCKCHIP_PM_DOMAINS
 
 int rockchip_pmu_block(void);
 void rockchip_pmu_unblock(void);
+int rockchip_pmu_idle_reset(struct device *dev, int (*reset)(void *data),
+			    void *data);
 
 #else /* CONFIG_ROCKCHIP_PM_DOMAINS */
 
@@ -20,6 +26,12 @@ static inline int rockchip_pmu_block(void)
 
 static inline void rockchip_pmu_unblock(void) { }
 
+static inline int rockchip_pmu_idle_reset(struct device *dev,
+					  int (*reset)(void *data), void *data)
+{
+	return -EOPNOTSUPP;
+}
+
 #endif /* CONFIG_ROCKCHIP_PM_DOMAINS */
 
 #endif /* __SOC_ROCKCHIP_PM_DOMAINS_H__ */

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 15/18] pmdomain: rockchip: Add rockchip_pmu_idle_reset()
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

Randy Li, Caesar Wang and Jeffy Chen posted "soc: rockchip: power-domain:
export idle request" for this in 2017 and 2019; it was not merged.

A device reset during a bus transfer can hang the bus of its domain.
Let drivers reset a device with the bus stopped, as the vendor kernel
does: idle request, reset callback and idle release under the PMU mutex.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/pmdomain/rockchip/pm-domains.c | 52 ++++++++++++++++++++++++++++++++++
 include/soc/rockchip/pm_domains.h      | 12 ++++++++
 2 files changed, 64 insertions(+)

diff --git a/drivers/pmdomain/rockchip/pm-domains.c b/drivers/pmdomain/rockchip/pm-domains.c
index db3879846db6..5dc1c4c6e211 100644
--- a/drivers/pmdomain/rockchip/pm-domains.c
+++ b/drivers/pmdomain/rockchip/pm-domains.c
@@ -743,6 +743,58 @@ static int rockchip_pd_power_off(struct generic_pm_domain *domain)
 	return ret;
 }
 
+/**
+ * rockchip_pmu_idle_reset() - Reset a device with the bus of its domain stopped
+ * @dev: device with a single power domain, which must be on
+ * @reset: resets the device; must not access the domain
+ * @data: argument of @reset
+ *
+ * A reset during a bus transfer can hang the bus. The caller must keep the
+ * other devices of the domain off the bus during the call. @reset runs with
+ * the PMU mutex held and must not change the state of a power domain.
+ *
+ * Return: 0, the error of @reset or of enabling the domain clocks, -EINVAL if
+ * @dev does not have exactly one Rockchip power domain, -EIO if the domain is
+ * off, or -ETIMEDOUT if the bus did not stop or restart; its state is then
+ * unknown.
+ */
+int rockchip_pmu_idle_reset(struct device *dev, int (*reset)(void *data),
+			    void *data)
+{
+	struct rockchip_pm_domain *pd;
+	struct generic_pm_domain *genpd;
+	int ret, ret2;
+
+	if (!dev->pm_domain)
+		return -EINVAL;
+
+	genpd = pd_to_genpd(dev->pm_domain);
+	if (genpd->power_on != rockchip_pd_power_on)
+		return -EINVAL;
+
+	pd = to_rockchip_pd(genpd);
+	guard(mutex)(&pd->pmu->mutex);
+
+	if (!rockchip_pmu_domain_is_on(pd))
+		return -EIO;
+
+	ret = clk_bulk_enable(pd->num_clks, pd->clks);
+	if (ret)
+		return ret;
+
+	rockchip_pmu_ungate_clk(pd, true);
+	ret = rockchip_pmu_set_idle_request(pd, true);
+	if (!ret)
+		ret = reset(data);
+	ret2 = rockchip_pmu_set_idle_request(pd, false);
+	rockchip_pmu_ungate_clk(pd, false);
+
+	clk_bulk_disable(pd->num_clks, pd->clks);
+
+	return ret2 ?: ret;
+}
+EXPORT_SYMBOL_GPL(rockchip_pmu_idle_reset);
+
 static int rockchip_pd_attach_dev(struct generic_pm_domain *genpd,
 				  struct device *dev)
 {
diff --git a/include/soc/rockchip/pm_domains.h b/include/soc/rockchip/pm_domains.h
index 7dbd941fc937..e1f488140b12 100644
--- a/include/soc/rockchip/pm_domains.h
+++ b/include/soc/rockchip/pm_domains.h
@@ -6,10 +6,16 @@
 #ifndef __SOC_ROCKCHIP_PM_DOMAINS_H__
 #define __SOC_ROCKCHIP_PM_DOMAINS_H__
 
+#include <linux/errno.h>
+
+struct device;
+
 #ifdef CONFIG_ROCKCHIP_PM_DOMAINS
 
 int rockchip_pmu_block(void);
 void rockchip_pmu_unblock(void);
+int rockchip_pmu_idle_reset(struct device *dev, int (*reset)(void *data),
+			    void *data);
 
 #else /* CONFIG_ROCKCHIP_PM_DOMAINS */
 
@@ -20,6 +26,12 @@ static inline int rockchip_pmu_block(void)
 
 static inline void rockchip_pmu_unblock(void) { }
 
+static inline int rockchip_pmu_idle_reset(struct device *dev,
+					  int (*reset)(void *data), void *data)
+{
+	return -EOPNOTSUPP;
+}
+
 #endif /* CONFIG_ROCKCHIP_PM_DOMAINS */
 
 #endif /* __SOC_ROCKCHIP_PM_DOMAINS_H__ */

-- 
2.55.0



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 15/18] pmdomain: rockchip: Add rockchip_pmu_idle_reset()
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

Randy Li, Caesar Wang and Jeffy Chen posted "soc: rockchip: power-domain:
export idle request" for this in 2017 and 2019; it was not merged.

A device reset during a bus transfer can hang the bus of its domain.
Let drivers reset a device with the bus stopped, as the vendor kernel
does: idle request, reset callback and idle release under the PMU mutex.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/pmdomain/rockchip/pm-domains.c | 52 ++++++++++++++++++++++++++++++++++
 include/soc/rockchip/pm_domains.h      | 12 ++++++++
 2 files changed, 64 insertions(+)

diff --git a/drivers/pmdomain/rockchip/pm-domains.c b/drivers/pmdomain/rockchip/pm-domains.c
index db3879846db6..5dc1c4c6e211 100644
--- a/drivers/pmdomain/rockchip/pm-domains.c
+++ b/drivers/pmdomain/rockchip/pm-domains.c
@@ -743,6 +743,58 @@ static int rockchip_pd_power_off(struct generic_pm_domain *domain)
 	return ret;
 }
 
+/**
+ * rockchip_pmu_idle_reset() - Reset a device with the bus of its domain stopped
+ * @dev: device with a single power domain, which must be on
+ * @reset: resets the device; must not access the domain
+ * @data: argument of @reset
+ *
+ * A reset during a bus transfer can hang the bus. The caller must keep the
+ * other devices of the domain off the bus during the call. @reset runs with
+ * the PMU mutex held and must not change the state of a power domain.
+ *
+ * Return: 0, the error of @reset or of enabling the domain clocks, -EINVAL if
+ * @dev does not have exactly one Rockchip power domain, -EIO if the domain is
+ * off, or -ETIMEDOUT if the bus did not stop or restart; its state is then
+ * unknown.
+ */
+int rockchip_pmu_idle_reset(struct device *dev, int (*reset)(void *data),
+			    void *data)
+{
+	struct rockchip_pm_domain *pd;
+	struct generic_pm_domain *genpd;
+	int ret, ret2;
+
+	if (!dev->pm_domain)
+		return -EINVAL;
+
+	genpd = pd_to_genpd(dev->pm_domain);
+	if (genpd->power_on != rockchip_pd_power_on)
+		return -EINVAL;
+
+	pd = to_rockchip_pd(genpd);
+	guard(mutex)(&pd->pmu->mutex);
+
+	if (!rockchip_pmu_domain_is_on(pd))
+		return -EIO;
+
+	ret = clk_bulk_enable(pd->num_clks, pd->clks);
+	if (ret)
+		return ret;
+
+	rockchip_pmu_ungate_clk(pd, true);
+	ret = rockchip_pmu_set_idle_request(pd, true);
+	if (!ret)
+		ret = reset(data);
+	ret2 = rockchip_pmu_set_idle_request(pd, false);
+	rockchip_pmu_ungate_clk(pd, false);
+
+	clk_bulk_disable(pd->num_clks, pd->clks);
+
+	return ret2 ?: ret;
+}
+EXPORT_SYMBOL_GPL(rockchip_pmu_idle_reset);
+
 static int rockchip_pd_attach_dev(struct generic_pm_domain *genpd,
 				  struct device *dev)
 {
diff --git a/include/soc/rockchip/pm_domains.h b/include/soc/rockchip/pm_domains.h
index 7dbd941fc937..e1f488140b12 100644
--- a/include/soc/rockchip/pm_domains.h
+++ b/include/soc/rockchip/pm_domains.h
@@ -6,10 +6,16 @@
 #ifndef __SOC_ROCKCHIP_PM_DOMAINS_H__
 #define __SOC_ROCKCHIP_PM_DOMAINS_H__
 
+#include <linux/errno.h>
+
+struct device;
+
 #ifdef CONFIG_ROCKCHIP_PM_DOMAINS
 
 int rockchip_pmu_block(void);
 void rockchip_pmu_unblock(void);
+int rockchip_pmu_idle_reset(struct device *dev, int (*reset)(void *data),
+			    void *data);
 
 #else /* CONFIG_ROCKCHIP_PM_DOMAINS */
 
@@ -20,6 +26,12 @@ static inline int rockchip_pmu_block(void)
 
 static inline void rockchip_pmu_unblock(void) { }
 
+static inline int rockchip_pmu_idle_reset(struct device *dev,
+					  int (*reset)(void *data), void *data)
+{
+	return -EOPNOTSUPP;
+}
+
 #endif /* CONFIG_ROCKCHIP_PM_DOMAINS */
 
 #endif /* __SOC_ROCKCHIP_PM_DOMAINS_H__ */

-- 
2.55.0



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

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 16/18] dt-bindings: media: rockchip-vpu: Add reset-names
  2026-12-06  5:57 ` Arun Iyengar via B4 Relay
  (?)
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  -1 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

The AV1 decoder driver resets only the AXI and APB lines of the core,
not their bus interfaces. Name the lines so it can pick them.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 Documentation/devicetree/bindings/media/rockchip-vpu.yaml | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/rockchip-vpu.yaml b/Documentation/devicetree/bindings/media/rockchip-vpu.yaml
index 8c2501634080..533ee3eb20d2 100644
--- a/Documentation/devicetree/bindings/media/rockchip-vpu.yaml
+++ b/Documentation/devicetree/bindings/media/rockchip-vpu.yaml
@@ -79,6 +79,13 @@ properties:
       - description: APB reset line
       - description: APB bus interface unit reset line
 
+  reset-names:
+    items:
+      - const: axi
+      - const: axi-biu
+      - const: apb
+      - const: apb-biu
+
 required:
   - compatible
   - reg

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 16/18] dt-bindings: media: rockchip-vpu: Add reset-names
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

The AV1 decoder driver resets only the AXI and APB lines of the core,
not their bus interfaces. Name the lines so it can pick them.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 Documentation/devicetree/bindings/media/rockchip-vpu.yaml | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/rockchip-vpu.yaml b/Documentation/devicetree/bindings/media/rockchip-vpu.yaml
index 8c2501634080..533ee3eb20d2 100644
--- a/Documentation/devicetree/bindings/media/rockchip-vpu.yaml
+++ b/Documentation/devicetree/bindings/media/rockchip-vpu.yaml
@@ -79,6 +79,13 @@ properties:
       - description: APB reset line
       - description: APB bus interface unit reset line
 
+  reset-names:
+    items:
+      - const: axi
+      - const: axi-biu
+      - const: apb
+      - const: apb-biu
+
 required:
   - compatible
   - reg

-- 
2.55.0



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 16/18] dt-bindings: media: rockchip-vpu: Add reset-names
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

The AV1 decoder driver resets only the AXI and APB lines of the core,
not their bus interfaces. Name the lines so it can pick them.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 Documentation/devicetree/bindings/media/rockchip-vpu.yaml | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/rockchip-vpu.yaml b/Documentation/devicetree/bindings/media/rockchip-vpu.yaml
index 8c2501634080..533ee3eb20d2 100644
--- a/Documentation/devicetree/bindings/media/rockchip-vpu.yaml
+++ b/Documentation/devicetree/bindings/media/rockchip-vpu.yaml
@@ -79,6 +79,13 @@ properties:
       - description: APB reset line
       - description: APB bus interface unit reset line
 
+  reset-names:
+    items:
+      - const: axi
+      - const: axi-biu
+      - const: apb
+      - const: apb-biu
+
 required:
   - compatible
   - reg

-- 
2.55.0



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

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 17/18] media: verisilicon: Reset the RK3588 AV1 decoder after an error
  2026-12-06  5:57 ` Arun Iyengar via B4 Relay
  (?)
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  -1 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

Nothing resets the AV1 core after an error interrupt, and the frames
after it time out: 50 watchdog timeouts in one AV1 test run.

Reset the core from the watchdog work as the vendor driver does: its AXI
and APB lines only, with the bus of its power domain stopped and its
interrupt masked. A reset of all four lines without the bus stop left
the domain unable to go idle, and an SError followed.

Stop a core still running after a timeout with its abort first, as
hantro_g2_reset() does: a reset during its bus transfers corrupted
memory. If it does not stop, refuse further jobs.

Attach the empty IOMMU domain for the reset, so that unmaps of other
contexts do not write the IOMMU of the stopped bus; the vendor driver
blocks them with a lock. With two decoders, a reset failed to idle the
domain, and a write from an unmap then raised an SError. If the bus
does not stop or restart, keep the empty domain and refuse further
jobs.

Fixes: 003afda97c65 ("media: verisilicon: Enable AV1 decoder on rk3588")
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/hantro.h        |  7 +-
 drivers/media/platform/verisilicon/hantro_drv.c    | 51 ++++++++++---
 drivers/media/platform/verisilicon/hantro_hw.h     |  5 +-
 .../platform/verisilicon/rockchip_vpu981_regs.h    |  3 +
 .../media/platform/verisilicon/rockchip_vpu_hw.c   | 86 +++++++++++++++++++++-
 5 files changed, 140 insertions(+), 12 deletions(-)

diff --git a/drivers/media/platform/verisilicon/hantro.h b/drivers/media/platform/verisilicon/hantro.h
index 5a9acc8c82a8..2d021c98f085 100644
--- a/drivers/media/platform/verisilicon/hantro.h
+++ b/drivers/media/platform/verisilicon/hantro.h
@@ -180,6 +180,7 @@ hantro_vdev_to_func(struct video_device *vdev)
  *			dev_ macros.
  * @clocks:		Array of clock handles.
  * @resets:		Array of reset handles.
+ * @core_resets:	AXI and APB resets of the core, without the bus interfaces.
  * @reg_base:		Mapped address of VPU registers.
  * @enc_base:		Mapped address of VPU encoder register for convenience.
  * @dec_base:		Mapped address of VPU decoder register for convenience.
@@ -190,7 +191,9 @@ hantro_vdev_to_func(struct video_device *vdev)
  * @watchdog_work:	Delayed work for hardware timeout handling.
  * @empty_domain:	Empty IOMMU domain, used to reinitialize the IOMMU after
  *			a reset of the core. NULL if not needed.
- * @iommu_lost:		The IOMMU couldn't be reinitialized, no job can run.
+ * @iommu_lost:		The IOMMU couldn't be reinitialized, or the bus of the
+ *			core hangs: no job can run.
+ * @error_reset:	The watchdog was queued by hantro_irq_reset().
  */
 struct hantro_dev {
 	struct v4l2_device v4l2_dev;
@@ -202,6 +205,7 @@ struct hantro_dev {
 	struct device *dev;
 	struct clk_bulk_data *clocks;
 	struct reset_control *resets;
+	struct reset_control_bulk_data core_resets[2];
 	void __iomem *reg_base;
 	void __iomem *enc_base;
 	void __iomem *dec_base;
@@ -212,6 +216,7 @@ struct hantro_dev {
 	struct delayed_work watchdog_work;
 	struct iommu_domain *empty_domain;
 	bool iommu_lost;
+	bool error_reset;
 };
 
 /**
diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index 26b273cd339d..bb611b414e75 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -117,10 +117,12 @@ void hantro_irq_done(struct hantro_dev *vpu,
 /*
  * Pulsing the reset lines of a core can reset its IOMMU behind the IOMMU
  * driver. Attaching and detaching the empty domain makes the driver reprogram
- * it; the default domain keeps its mappings. A failed attach may leave the
- * IOMMU without translation, so no further job may run.
+ * it; the default domain keeps its mappings. While the empty domain is
+ * attached, maps and unmaps of the default domain leave the IOMMU alone. A
+ * failed attach may leave the IOMMU without translation, so no further job may
+ * run.
  */
-int hantro_iommu_restore(struct hantro_dev *vpu)
+int hantro_iommu_park(struct hantro_dev *vpu)
 {
 	int ret;
 
@@ -132,29 +134,55 @@ int hantro_iommu_restore(struct hantro_dev *vpu)
 		dev_err(vpu->dev, "Failed to reinitialize the IOMMU (%d), refusing further jobs\n",
 			ret);
 		vpu->iommu_lost = true;
-		return ret;
 	}
 
-	iommu_detach_device(vpu->empty_domain, vpu->dev);
-	return 0;
+	return ret;
+}
+
+void hantro_iommu_unpark(struct hantro_dev *vpu)
+{
+	if (vpu->empty_domain)
+		iommu_detach_device(vpu->empty_domain, vpu->dev);
+}
+
+int hantro_iommu_restore(struct hantro_dev *vpu)
+{
+	int ret = hantro_iommu_park(vpu);
+
+	if (!ret)
+		hantro_iommu_unpark(vpu);
+	return ret;
 }
 
 void hantro_watchdog(struct work_struct *work)
 {
 	struct hantro_dev *vpu;
 	struct hantro_ctx *ctx;
+	bool error_reset;
 
 	vpu = container_of(to_delayed_work(work),
 			   struct hantro_dev, watchdog_work);
+	error_reset = vpu->error_reset;
+	vpu->error_reset = false;
 	ctx = v4l2_m2m_get_curr_priv(vpu->m2m_dev);
 	if (ctx) {
-		vpu_err("frame processing timed out!\n");
+		if (!error_reset)
+			vpu_err("frame processing timed out!\n");
 		if (ctx->codec_ops->reset)
 			ctx->codec_ops->reset(ctx);
 		hantro_job_finish(ctx, VB2_BUF_STATE_ERROR);
 	}
 }
 
+/* For a failed job whose core needs a reset: the watchdog work resets it and ends the job. */
+void hantro_irq_reset(struct hantro_dev *vpu)
+{
+	if (cancel_delayed_work(&vpu->watchdog_work)) {
+		vpu->error_reset = true;
+		schedule_delayed_work(&vpu->watchdog_work, 0);
+	}
+}
+
 void hantro_start_prepare_run(struct hantro_ctx *ctx)
 {
 	struct vb2_v4l2_buffer *src_buf;
@@ -1152,7 +1180,12 @@ static void hantro_disable_runtime_pm(struct hantro_dev *vpu)
 
 static void hantro_free_empty_domain(void *data)
 {
-	iommu_domain_free(data);
+	struct hantro_dev *vpu = data;
+
+	/* Still attached after a failed reset */
+	if (iommu_get_domain_for_dev(vpu->dev) == vpu->empty_domain)
+		hantro_iommu_unpark(vpu);
+	iommu_domain_free(vpu->empty_domain);
 }
 
 static int hantro_alloc_empty_domain(struct hantro_dev *vpu)
@@ -1178,7 +1211,7 @@ static int hantro_alloc_empty_domain(struct hantro_dev *vpu)
 	vpu->empty_domain = domain;
 
 	ret = devm_add_action_or_reset(vpu->dev, hantro_free_empty_domain,
-				       domain);
+				       vpu);
 	if (ret)
 		return ret;
 
diff --git a/drivers/media/platform/verisilicon/hantro_hw.h b/drivers/media/platform/verisilicon/hantro_hw.h
index d3c36948208d..b63893a17df0 100644
--- a/drivers/media/platform/verisilicon/hantro_hw.h
+++ b/drivers/media/platform/verisilicon/hantro_hw.h
@@ -382,7 +382,7 @@ struct hantro_postproc_ops {
  *		should be programmed and started. Returns zero if OK, a
  *		negative value in error cases.
  * @done:	Read back processing results and additional data from hardware.
- * @reset:	Reset the hardware in case of a timeout.
+ * @reset:	Reset the hardware in case of a timeout or hantro_irq_reset().
  */
 struct hantro_codec_ops {
 	int (*init)(struct hantro_ctx *ctx);
@@ -431,12 +431,15 @@ extern const struct hantro_postproc_ops rockchip_vpu981_postproc_ops;
 extern const u32 hantro_vp8_dec_mc_filter[8][6];
 
 void hantro_watchdog(struct work_struct *work);
+int hantro_iommu_park(struct hantro_dev *vpu);
+void hantro_iommu_unpark(struct hantro_dev *vpu);
 int hantro_iommu_restore(struct hantro_dev *vpu);
 void hantro_irq_done(struct hantro_dev *vpu,
 		     enum vb2_buffer_state result);
 void hantro_start_prepare_run(struct hantro_ctx *ctx);
 void hantro_end_prepare_run(struct hantro_ctx *ctx);
 void hantro_abort_prepare_run(struct hantro_ctx *ctx);
+void hantro_irq_reset(struct hantro_dev *vpu);
 
 irqreturn_t hantro_g1_irq(int irq, void *dev_id);
 void hantro_g1_reset(struct hantro_ctx *ctx);
diff --git a/drivers/media/platform/verisilicon/rockchip_vpu981_regs.h b/drivers/media/platform/verisilicon/rockchip_vpu981_regs.h
index e4008da64f19..b88df093b5e2 100644
--- a/drivers/media/platform/verisilicon/rockchip_vpu981_regs.h
+++ b/drivers/media/platform/verisilicon/rockchip_vpu981_regs.h
@@ -21,6 +21,9 @@
 
 #define AV1_REG_INTERRUPT		AV1_SWREG(1)
 #define AV1_REG_INTERRUPT_DEC_RDY_INT	BIT(12)
+#define AV1_REG_INTERRUPT_DEC_ABORT_E	BIT(5)
+#define AV1_REG_INTERRUPT_DEC_IRQ_DIS	BIT(4)
+#define AV1_REG_INTERRUPT_DEC_E		BIT(0)
 
 #define AV1_REG_CONFIG			AV1_SWREG(2)
 #define AV1_REG_CONFIG_DEC_CLK_GATE_E	BIT(10)
diff --git a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
index f04d3cc0c1a8..6bb85ccbf460 100644
--- a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
+++ b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
@@ -8,6 +8,9 @@
 
 #include <linux/clk.h>
 #include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/iopoll.h>
+#include <soc/rockchip/pm_domains.h>
 
 #include "hantro.h"
 #include "hantro_av1.h"
@@ -435,11 +438,23 @@ static irqreturn_t rk3588_vpu981_irq(int irq, void *dev_id)
 	vdpu_write(vpu, 0, AV1_REG_INTERRUPT);
 	vdpu_write(vpu, AV1_REG_CONFIG_DEC_CLK_GATE_E, AV1_REG_CONFIG);
 
-	hantro_irq_done(vpu, state);
+	if (state == VB2_BUF_STATE_DONE)
+		hantro_irq_done(vpu, state);
+	else
+		hantro_irq_reset(vpu);
 
 	return IRQ_HANDLED;
 }
 
+static int rk3588_vpu981_hw_init(struct hantro_dev *vpu)
+{
+	vpu->core_resets[0].id = "axi";
+	vpu->core_resets[1].id = "apb";
+
+	return devm_reset_control_bulk_get_optional_exclusive_released(vpu->dev,
+			ARRAY_SIZE(vpu->core_resets), vpu->core_resets);
+}
+
 static int rk3036_vpu_hw_init(struct hantro_dev *vpu)
 {
 	/* Bump ACLK to max. possible freq. to improve performance. */
@@ -540,6 +555,73 @@ static void rockchip_vpu2_enc_reset(struct hantro_ctx *ctx)
 	vepu_write(vpu, 0, VEPU_REG_INTERRUPT);
 }
 
+static int rockchip_vpu981_core_reset(void *data)
+{
+	struct hantro_dev *vpu = data;
+	int n = ARRAY_SIZE(vpu->core_resets);
+	int ret;
+
+	ret = reset_control_bulk_assert(n, vpu->core_resets);
+	udelay(5);
+	return reset_control_bulk_deassert(n, vpu->core_resets) ?: ret;
+}
+
+static void rockchip_vpu981_av1_dec_reset(struct hantro_ctx *ctx)
+{
+	struct hantro_dev *vpu = ctx->dev;
+	struct reset_control_bulk_data *rst = vpu->core_resets;
+	int n = ARRAY_SIZE(vpu->core_resets);
+	int irq, ret;
+	u32 status;
+
+	if (!rst[0].rstc)
+		return;
+
+	irq = platform_get_irq(vpu->pdev, 0);
+	if (irq < 0)
+		return;
+
+	ret = reset_control_bulk_acquire(n, rst);
+	if (ret) {
+		dev_err(vpu->dev, "Failed to acquire the core resets: %d\n", ret);
+		return;
+	}
+
+	/* After a timeout, keep the handler off the core and the next job. */
+	disable_irq(irq);
+
+	status = vdpu_read(vpu, AV1_REG_INTERRUPT);
+	if (status & AV1_REG_INTERRUPT_DEC_E) {
+		vdpu_write(vpu, status | AV1_REG_INTERRUPT_DEC_ABORT_E |
+			   AV1_REG_INTERRUPT_DEC_IRQ_DIS, AV1_REG_INTERRUPT);
+		if (readl_poll_timeout(vpu->dec_base + AV1_REG_INTERRUPT, status,
+				       !(status & AV1_REG_INTERRUPT_DEC_E), 100, 100000)) {
+			dev_err(vpu->dev, "The core does not stop, refusing further jobs\n");
+			hantro_iommu_park(vpu);
+			vpu->iommu_lost = true;
+			goto release;
+		}
+	}
+
+	if (hantro_iommu_park(vpu))
+		goto out;
+
+	ret = rockchip_pmu_idle_reset(vpu->dev, rockchip_vpu981_core_reset, vpu);
+	if (ret) {
+		dev_err(vpu->dev, "Failed to reset the core: %d\n", ret);
+		/* Bus state unknown: keep the IOMMU and the handler off it. */
+		if (ret == -ETIMEDOUT) {
+			vpu->iommu_lost = true;
+			goto release;
+		}
+	}
+	hantro_iommu_unpark(vpu);
+out:
+	enable_irq(irq);
+release:
+	reset_control_bulk_release(n, rst);
+}
+
 /*
  * Supported codec ops.
  */
@@ -656,6 +738,7 @@ static const struct hantro_codec_ops rk3588_vpu981_codec_ops[] = {
 		.init = hantro_av1_init,
 		.exit = hantro_av1_exit,
 		.done = hantro_av1_update_prob,
+		.reset = rockchip_vpu981_av1_dec_reset,
 	},
 };
 /*
@@ -856,6 +939,7 @@ const struct hantro_variant rk3588_vpu981_variant = {
 	.postproc_ops = &rockchip_vpu981_postproc_ops,
 	.codec = HANTRO_AV1_DECODER,
 	.codec_ops = rk3588_vpu981_codec_ops,
+	.init = rk3588_vpu981_hw_init,
 	.irqs = rk3588_vpu981_irqs,
 	.num_irqs = ARRAY_SIZE(rk3588_vpu981_irqs),
 	.clk_names = rk3588_vpu981_vpu_clk_names,

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 17/18] media: verisilicon: Reset the RK3588 AV1 decoder after an error
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

Nothing resets the AV1 core after an error interrupt, and the frames
after it time out: 50 watchdog timeouts in one AV1 test run.

Reset the core from the watchdog work as the vendor driver does: its AXI
and APB lines only, with the bus of its power domain stopped and its
interrupt masked. A reset of all four lines without the bus stop left
the domain unable to go idle, and an SError followed.

Stop a core still running after a timeout with its abort first, as
hantro_g2_reset() does: a reset during its bus transfers corrupted
memory. If it does not stop, refuse further jobs.

Attach the empty IOMMU domain for the reset, so that unmaps of other
contexts do not write the IOMMU of the stopped bus; the vendor driver
blocks them with a lock. With two decoders, a reset failed to idle the
domain, and a write from an unmap then raised an SError. If the bus
does not stop or restart, keep the empty domain and refuse further
jobs.

Fixes: 003afda97c65 ("media: verisilicon: Enable AV1 decoder on rk3588")
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/hantro.h        |  7 +-
 drivers/media/platform/verisilicon/hantro_drv.c    | 51 ++++++++++---
 drivers/media/platform/verisilicon/hantro_hw.h     |  5 +-
 .../platform/verisilicon/rockchip_vpu981_regs.h    |  3 +
 .../media/platform/verisilicon/rockchip_vpu_hw.c   | 86 +++++++++++++++++++++-
 5 files changed, 140 insertions(+), 12 deletions(-)

diff --git a/drivers/media/platform/verisilicon/hantro.h b/drivers/media/platform/verisilicon/hantro.h
index 5a9acc8c82a8..2d021c98f085 100644
--- a/drivers/media/platform/verisilicon/hantro.h
+++ b/drivers/media/platform/verisilicon/hantro.h
@@ -180,6 +180,7 @@ hantro_vdev_to_func(struct video_device *vdev)
  *			dev_ macros.
  * @clocks:		Array of clock handles.
  * @resets:		Array of reset handles.
+ * @core_resets:	AXI and APB resets of the core, without the bus interfaces.
  * @reg_base:		Mapped address of VPU registers.
  * @enc_base:		Mapped address of VPU encoder register for convenience.
  * @dec_base:		Mapped address of VPU decoder register for convenience.
@@ -190,7 +191,9 @@ hantro_vdev_to_func(struct video_device *vdev)
  * @watchdog_work:	Delayed work for hardware timeout handling.
  * @empty_domain:	Empty IOMMU domain, used to reinitialize the IOMMU after
  *			a reset of the core. NULL if not needed.
- * @iommu_lost:		The IOMMU couldn't be reinitialized, no job can run.
+ * @iommu_lost:		The IOMMU couldn't be reinitialized, or the bus of the
+ *			core hangs: no job can run.
+ * @error_reset:	The watchdog was queued by hantro_irq_reset().
  */
 struct hantro_dev {
 	struct v4l2_device v4l2_dev;
@@ -202,6 +205,7 @@ struct hantro_dev {
 	struct device *dev;
 	struct clk_bulk_data *clocks;
 	struct reset_control *resets;
+	struct reset_control_bulk_data core_resets[2];
 	void __iomem *reg_base;
 	void __iomem *enc_base;
 	void __iomem *dec_base;
@@ -212,6 +216,7 @@ struct hantro_dev {
 	struct delayed_work watchdog_work;
 	struct iommu_domain *empty_domain;
 	bool iommu_lost;
+	bool error_reset;
 };
 
 /**
diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index 26b273cd339d..bb611b414e75 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -117,10 +117,12 @@ void hantro_irq_done(struct hantro_dev *vpu,
 /*
  * Pulsing the reset lines of a core can reset its IOMMU behind the IOMMU
  * driver. Attaching and detaching the empty domain makes the driver reprogram
- * it; the default domain keeps its mappings. A failed attach may leave the
- * IOMMU without translation, so no further job may run.
+ * it; the default domain keeps its mappings. While the empty domain is
+ * attached, maps and unmaps of the default domain leave the IOMMU alone. A
+ * failed attach may leave the IOMMU without translation, so no further job may
+ * run.
  */
-int hantro_iommu_restore(struct hantro_dev *vpu)
+int hantro_iommu_park(struct hantro_dev *vpu)
 {
 	int ret;
 
@@ -132,29 +134,55 @@ int hantro_iommu_restore(struct hantro_dev *vpu)
 		dev_err(vpu->dev, "Failed to reinitialize the IOMMU (%d), refusing further jobs\n",
 			ret);
 		vpu->iommu_lost = true;
-		return ret;
 	}
 
-	iommu_detach_device(vpu->empty_domain, vpu->dev);
-	return 0;
+	return ret;
+}
+
+void hantro_iommu_unpark(struct hantro_dev *vpu)
+{
+	if (vpu->empty_domain)
+		iommu_detach_device(vpu->empty_domain, vpu->dev);
+}
+
+int hantro_iommu_restore(struct hantro_dev *vpu)
+{
+	int ret = hantro_iommu_park(vpu);
+
+	if (!ret)
+		hantro_iommu_unpark(vpu);
+	return ret;
 }
 
 void hantro_watchdog(struct work_struct *work)
 {
 	struct hantro_dev *vpu;
 	struct hantro_ctx *ctx;
+	bool error_reset;
 
 	vpu = container_of(to_delayed_work(work),
 			   struct hantro_dev, watchdog_work);
+	error_reset = vpu->error_reset;
+	vpu->error_reset = false;
 	ctx = v4l2_m2m_get_curr_priv(vpu->m2m_dev);
 	if (ctx) {
-		vpu_err("frame processing timed out!\n");
+		if (!error_reset)
+			vpu_err("frame processing timed out!\n");
 		if (ctx->codec_ops->reset)
 			ctx->codec_ops->reset(ctx);
 		hantro_job_finish(ctx, VB2_BUF_STATE_ERROR);
 	}
 }
 
+/* For a failed job whose core needs a reset: the watchdog work resets it and ends the job. */
+void hantro_irq_reset(struct hantro_dev *vpu)
+{
+	if (cancel_delayed_work(&vpu->watchdog_work)) {
+		vpu->error_reset = true;
+		schedule_delayed_work(&vpu->watchdog_work, 0);
+	}
+}
+
 void hantro_start_prepare_run(struct hantro_ctx *ctx)
 {
 	struct vb2_v4l2_buffer *src_buf;
@@ -1152,7 +1180,12 @@ static void hantro_disable_runtime_pm(struct hantro_dev *vpu)
 
 static void hantro_free_empty_domain(void *data)
 {
-	iommu_domain_free(data);
+	struct hantro_dev *vpu = data;
+
+	/* Still attached after a failed reset */
+	if (iommu_get_domain_for_dev(vpu->dev) == vpu->empty_domain)
+		hantro_iommu_unpark(vpu);
+	iommu_domain_free(vpu->empty_domain);
 }
 
 static int hantro_alloc_empty_domain(struct hantro_dev *vpu)
@@ -1178,7 +1211,7 @@ static int hantro_alloc_empty_domain(struct hantro_dev *vpu)
 	vpu->empty_domain = domain;
 
 	ret = devm_add_action_or_reset(vpu->dev, hantro_free_empty_domain,
-				       domain);
+				       vpu);
 	if (ret)
 		return ret;
 
diff --git a/drivers/media/platform/verisilicon/hantro_hw.h b/drivers/media/platform/verisilicon/hantro_hw.h
index d3c36948208d..b63893a17df0 100644
--- a/drivers/media/platform/verisilicon/hantro_hw.h
+++ b/drivers/media/platform/verisilicon/hantro_hw.h
@@ -382,7 +382,7 @@ struct hantro_postproc_ops {
  *		should be programmed and started. Returns zero if OK, a
  *		negative value in error cases.
  * @done:	Read back processing results and additional data from hardware.
- * @reset:	Reset the hardware in case of a timeout.
+ * @reset:	Reset the hardware in case of a timeout or hantro_irq_reset().
  */
 struct hantro_codec_ops {
 	int (*init)(struct hantro_ctx *ctx);
@@ -431,12 +431,15 @@ extern const struct hantro_postproc_ops rockchip_vpu981_postproc_ops;
 extern const u32 hantro_vp8_dec_mc_filter[8][6];
 
 void hantro_watchdog(struct work_struct *work);
+int hantro_iommu_park(struct hantro_dev *vpu);
+void hantro_iommu_unpark(struct hantro_dev *vpu);
 int hantro_iommu_restore(struct hantro_dev *vpu);
 void hantro_irq_done(struct hantro_dev *vpu,
 		     enum vb2_buffer_state result);
 void hantro_start_prepare_run(struct hantro_ctx *ctx);
 void hantro_end_prepare_run(struct hantro_ctx *ctx);
 void hantro_abort_prepare_run(struct hantro_ctx *ctx);
+void hantro_irq_reset(struct hantro_dev *vpu);
 
 irqreturn_t hantro_g1_irq(int irq, void *dev_id);
 void hantro_g1_reset(struct hantro_ctx *ctx);
diff --git a/drivers/media/platform/verisilicon/rockchip_vpu981_regs.h b/drivers/media/platform/verisilicon/rockchip_vpu981_regs.h
index e4008da64f19..b88df093b5e2 100644
--- a/drivers/media/platform/verisilicon/rockchip_vpu981_regs.h
+++ b/drivers/media/platform/verisilicon/rockchip_vpu981_regs.h
@@ -21,6 +21,9 @@
 
 #define AV1_REG_INTERRUPT		AV1_SWREG(1)
 #define AV1_REG_INTERRUPT_DEC_RDY_INT	BIT(12)
+#define AV1_REG_INTERRUPT_DEC_ABORT_E	BIT(5)
+#define AV1_REG_INTERRUPT_DEC_IRQ_DIS	BIT(4)
+#define AV1_REG_INTERRUPT_DEC_E		BIT(0)
 
 #define AV1_REG_CONFIG			AV1_SWREG(2)
 #define AV1_REG_CONFIG_DEC_CLK_GATE_E	BIT(10)
diff --git a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
index f04d3cc0c1a8..6bb85ccbf460 100644
--- a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
+++ b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
@@ -8,6 +8,9 @@
 
 #include <linux/clk.h>
 #include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/iopoll.h>
+#include <soc/rockchip/pm_domains.h>
 
 #include "hantro.h"
 #include "hantro_av1.h"
@@ -435,11 +438,23 @@ static irqreturn_t rk3588_vpu981_irq(int irq, void *dev_id)
 	vdpu_write(vpu, 0, AV1_REG_INTERRUPT);
 	vdpu_write(vpu, AV1_REG_CONFIG_DEC_CLK_GATE_E, AV1_REG_CONFIG);
 
-	hantro_irq_done(vpu, state);
+	if (state == VB2_BUF_STATE_DONE)
+		hantro_irq_done(vpu, state);
+	else
+		hantro_irq_reset(vpu);
 
 	return IRQ_HANDLED;
 }
 
+static int rk3588_vpu981_hw_init(struct hantro_dev *vpu)
+{
+	vpu->core_resets[0].id = "axi";
+	vpu->core_resets[1].id = "apb";
+
+	return devm_reset_control_bulk_get_optional_exclusive_released(vpu->dev,
+			ARRAY_SIZE(vpu->core_resets), vpu->core_resets);
+}
+
 static int rk3036_vpu_hw_init(struct hantro_dev *vpu)
 {
 	/* Bump ACLK to max. possible freq. to improve performance. */
@@ -540,6 +555,73 @@ static void rockchip_vpu2_enc_reset(struct hantro_ctx *ctx)
 	vepu_write(vpu, 0, VEPU_REG_INTERRUPT);
 }
 
+static int rockchip_vpu981_core_reset(void *data)
+{
+	struct hantro_dev *vpu = data;
+	int n = ARRAY_SIZE(vpu->core_resets);
+	int ret;
+
+	ret = reset_control_bulk_assert(n, vpu->core_resets);
+	udelay(5);
+	return reset_control_bulk_deassert(n, vpu->core_resets) ?: ret;
+}
+
+static void rockchip_vpu981_av1_dec_reset(struct hantro_ctx *ctx)
+{
+	struct hantro_dev *vpu = ctx->dev;
+	struct reset_control_bulk_data *rst = vpu->core_resets;
+	int n = ARRAY_SIZE(vpu->core_resets);
+	int irq, ret;
+	u32 status;
+
+	if (!rst[0].rstc)
+		return;
+
+	irq = platform_get_irq(vpu->pdev, 0);
+	if (irq < 0)
+		return;
+
+	ret = reset_control_bulk_acquire(n, rst);
+	if (ret) {
+		dev_err(vpu->dev, "Failed to acquire the core resets: %d\n", ret);
+		return;
+	}
+
+	/* After a timeout, keep the handler off the core and the next job. */
+	disable_irq(irq);
+
+	status = vdpu_read(vpu, AV1_REG_INTERRUPT);
+	if (status & AV1_REG_INTERRUPT_DEC_E) {
+		vdpu_write(vpu, status | AV1_REG_INTERRUPT_DEC_ABORT_E |
+			   AV1_REG_INTERRUPT_DEC_IRQ_DIS, AV1_REG_INTERRUPT);
+		if (readl_poll_timeout(vpu->dec_base + AV1_REG_INTERRUPT, status,
+				       !(status & AV1_REG_INTERRUPT_DEC_E), 100, 100000)) {
+			dev_err(vpu->dev, "The core does not stop, refusing further jobs\n");
+			hantro_iommu_park(vpu);
+			vpu->iommu_lost = true;
+			goto release;
+		}
+	}
+
+	if (hantro_iommu_park(vpu))
+		goto out;
+
+	ret = rockchip_pmu_idle_reset(vpu->dev, rockchip_vpu981_core_reset, vpu);
+	if (ret) {
+		dev_err(vpu->dev, "Failed to reset the core: %d\n", ret);
+		/* Bus state unknown: keep the IOMMU and the handler off it. */
+		if (ret == -ETIMEDOUT) {
+			vpu->iommu_lost = true;
+			goto release;
+		}
+	}
+	hantro_iommu_unpark(vpu);
+out:
+	enable_irq(irq);
+release:
+	reset_control_bulk_release(n, rst);
+}
+
 /*
  * Supported codec ops.
  */
@@ -656,6 +738,7 @@ static const struct hantro_codec_ops rk3588_vpu981_codec_ops[] = {
 		.init = hantro_av1_init,
 		.exit = hantro_av1_exit,
 		.done = hantro_av1_update_prob,
+		.reset = rockchip_vpu981_av1_dec_reset,
 	},
 };
 /*
@@ -856,6 +939,7 @@ const struct hantro_variant rk3588_vpu981_variant = {
 	.postproc_ops = &rockchip_vpu981_postproc_ops,
 	.codec = HANTRO_AV1_DECODER,
 	.codec_ops = rk3588_vpu981_codec_ops,
+	.init = rk3588_vpu981_hw_init,
 	.irqs = rk3588_vpu981_irqs,
 	.num_irqs = ARRAY_SIZE(rk3588_vpu981_irqs),
 	.clk_names = rk3588_vpu981_vpu_clk_names,

-- 
2.55.0



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 17/18] media: verisilicon: Reset the RK3588 AV1 decoder after an error
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

Nothing resets the AV1 core after an error interrupt, and the frames
after it time out: 50 watchdog timeouts in one AV1 test run.

Reset the core from the watchdog work as the vendor driver does: its AXI
and APB lines only, with the bus of its power domain stopped and its
interrupt masked. A reset of all four lines without the bus stop left
the domain unable to go idle, and an SError followed.

Stop a core still running after a timeout with its abort first, as
hantro_g2_reset() does: a reset during its bus transfers corrupted
memory. If it does not stop, refuse further jobs.

Attach the empty IOMMU domain for the reset, so that unmaps of other
contexts do not write the IOMMU of the stopped bus; the vendor driver
blocks them with a lock. With two decoders, a reset failed to idle the
domain, and a write from an unmap then raised an SError. If the bus
does not stop or restart, keep the empty domain and refuse further
jobs.

Fixes: 003afda97c65 ("media: verisilicon: Enable AV1 decoder on rk3588")
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/verisilicon/hantro.h        |  7 +-
 drivers/media/platform/verisilicon/hantro_drv.c    | 51 ++++++++++---
 drivers/media/platform/verisilicon/hantro_hw.h     |  5 +-
 .../platform/verisilicon/rockchip_vpu981_regs.h    |  3 +
 .../media/platform/verisilicon/rockchip_vpu_hw.c   | 86 +++++++++++++++++++++-
 5 files changed, 140 insertions(+), 12 deletions(-)

diff --git a/drivers/media/platform/verisilicon/hantro.h b/drivers/media/platform/verisilicon/hantro.h
index 5a9acc8c82a8..2d021c98f085 100644
--- a/drivers/media/platform/verisilicon/hantro.h
+++ b/drivers/media/platform/verisilicon/hantro.h
@@ -180,6 +180,7 @@ hantro_vdev_to_func(struct video_device *vdev)
  *			dev_ macros.
  * @clocks:		Array of clock handles.
  * @resets:		Array of reset handles.
+ * @core_resets:	AXI and APB resets of the core, without the bus interfaces.
  * @reg_base:		Mapped address of VPU registers.
  * @enc_base:		Mapped address of VPU encoder register for convenience.
  * @dec_base:		Mapped address of VPU decoder register for convenience.
@@ -190,7 +191,9 @@ hantro_vdev_to_func(struct video_device *vdev)
  * @watchdog_work:	Delayed work for hardware timeout handling.
  * @empty_domain:	Empty IOMMU domain, used to reinitialize the IOMMU after
  *			a reset of the core. NULL if not needed.
- * @iommu_lost:		The IOMMU couldn't be reinitialized, no job can run.
+ * @iommu_lost:		The IOMMU couldn't be reinitialized, or the bus of the
+ *			core hangs: no job can run.
+ * @error_reset:	The watchdog was queued by hantro_irq_reset().
  */
 struct hantro_dev {
 	struct v4l2_device v4l2_dev;
@@ -202,6 +205,7 @@ struct hantro_dev {
 	struct device *dev;
 	struct clk_bulk_data *clocks;
 	struct reset_control *resets;
+	struct reset_control_bulk_data core_resets[2];
 	void __iomem *reg_base;
 	void __iomem *enc_base;
 	void __iomem *dec_base;
@@ -212,6 +216,7 @@ struct hantro_dev {
 	struct delayed_work watchdog_work;
 	struct iommu_domain *empty_domain;
 	bool iommu_lost;
+	bool error_reset;
 };
 
 /**
diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index 26b273cd339d..bb611b414e75 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -117,10 +117,12 @@ void hantro_irq_done(struct hantro_dev *vpu,
 /*
  * Pulsing the reset lines of a core can reset its IOMMU behind the IOMMU
  * driver. Attaching and detaching the empty domain makes the driver reprogram
- * it; the default domain keeps its mappings. A failed attach may leave the
- * IOMMU without translation, so no further job may run.
+ * it; the default domain keeps its mappings. While the empty domain is
+ * attached, maps and unmaps of the default domain leave the IOMMU alone. A
+ * failed attach may leave the IOMMU without translation, so no further job may
+ * run.
  */
-int hantro_iommu_restore(struct hantro_dev *vpu)
+int hantro_iommu_park(struct hantro_dev *vpu)
 {
 	int ret;
 
@@ -132,29 +134,55 @@ int hantro_iommu_restore(struct hantro_dev *vpu)
 		dev_err(vpu->dev, "Failed to reinitialize the IOMMU (%d), refusing further jobs\n",
 			ret);
 		vpu->iommu_lost = true;
-		return ret;
 	}
 
-	iommu_detach_device(vpu->empty_domain, vpu->dev);
-	return 0;
+	return ret;
+}
+
+void hantro_iommu_unpark(struct hantro_dev *vpu)
+{
+	if (vpu->empty_domain)
+		iommu_detach_device(vpu->empty_domain, vpu->dev);
+}
+
+int hantro_iommu_restore(struct hantro_dev *vpu)
+{
+	int ret = hantro_iommu_park(vpu);
+
+	if (!ret)
+		hantro_iommu_unpark(vpu);
+	return ret;
 }
 
 void hantro_watchdog(struct work_struct *work)
 {
 	struct hantro_dev *vpu;
 	struct hantro_ctx *ctx;
+	bool error_reset;
 
 	vpu = container_of(to_delayed_work(work),
 			   struct hantro_dev, watchdog_work);
+	error_reset = vpu->error_reset;
+	vpu->error_reset = false;
 	ctx = v4l2_m2m_get_curr_priv(vpu->m2m_dev);
 	if (ctx) {
-		vpu_err("frame processing timed out!\n");
+		if (!error_reset)
+			vpu_err("frame processing timed out!\n");
 		if (ctx->codec_ops->reset)
 			ctx->codec_ops->reset(ctx);
 		hantro_job_finish(ctx, VB2_BUF_STATE_ERROR);
 	}
 }
 
+/* For a failed job whose core needs a reset: the watchdog work resets it and ends the job. */
+void hantro_irq_reset(struct hantro_dev *vpu)
+{
+	if (cancel_delayed_work(&vpu->watchdog_work)) {
+		vpu->error_reset = true;
+		schedule_delayed_work(&vpu->watchdog_work, 0);
+	}
+}
+
 void hantro_start_prepare_run(struct hantro_ctx *ctx)
 {
 	struct vb2_v4l2_buffer *src_buf;
@@ -1152,7 +1180,12 @@ static void hantro_disable_runtime_pm(struct hantro_dev *vpu)
 
 static void hantro_free_empty_domain(void *data)
 {
-	iommu_domain_free(data);
+	struct hantro_dev *vpu = data;
+
+	/* Still attached after a failed reset */
+	if (iommu_get_domain_for_dev(vpu->dev) == vpu->empty_domain)
+		hantro_iommu_unpark(vpu);
+	iommu_domain_free(vpu->empty_domain);
 }
 
 static int hantro_alloc_empty_domain(struct hantro_dev *vpu)
@@ -1178,7 +1211,7 @@ static int hantro_alloc_empty_domain(struct hantro_dev *vpu)
 	vpu->empty_domain = domain;
 
 	ret = devm_add_action_or_reset(vpu->dev, hantro_free_empty_domain,
-				       domain);
+				       vpu);
 	if (ret)
 		return ret;
 
diff --git a/drivers/media/platform/verisilicon/hantro_hw.h b/drivers/media/platform/verisilicon/hantro_hw.h
index d3c36948208d..b63893a17df0 100644
--- a/drivers/media/platform/verisilicon/hantro_hw.h
+++ b/drivers/media/platform/verisilicon/hantro_hw.h
@@ -382,7 +382,7 @@ struct hantro_postproc_ops {
  *		should be programmed and started. Returns zero if OK, a
  *		negative value in error cases.
  * @done:	Read back processing results and additional data from hardware.
- * @reset:	Reset the hardware in case of a timeout.
+ * @reset:	Reset the hardware in case of a timeout or hantro_irq_reset().
  */
 struct hantro_codec_ops {
 	int (*init)(struct hantro_ctx *ctx);
@@ -431,12 +431,15 @@ extern const struct hantro_postproc_ops rockchip_vpu981_postproc_ops;
 extern const u32 hantro_vp8_dec_mc_filter[8][6];
 
 void hantro_watchdog(struct work_struct *work);
+int hantro_iommu_park(struct hantro_dev *vpu);
+void hantro_iommu_unpark(struct hantro_dev *vpu);
 int hantro_iommu_restore(struct hantro_dev *vpu);
 void hantro_irq_done(struct hantro_dev *vpu,
 		     enum vb2_buffer_state result);
 void hantro_start_prepare_run(struct hantro_ctx *ctx);
 void hantro_end_prepare_run(struct hantro_ctx *ctx);
 void hantro_abort_prepare_run(struct hantro_ctx *ctx);
+void hantro_irq_reset(struct hantro_dev *vpu);
 
 irqreturn_t hantro_g1_irq(int irq, void *dev_id);
 void hantro_g1_reset(struct hantro_ctx *ctx);
diff --git a/drivers/media/platform/verisilicon/rockchip_vpu981_regs.h b/drivers/media/platform/verisilicon/rockchip_vpu981_regs.h
index e4008da64f19..b88df093b5e2 100644
--- a/drivers/media/platform/verisilicon/rockchip_vpu981_regs.h
+++ b/drivers/media/platform/verisilicon/rockchip_vpu981_regs.h
@@ -21,6 +21,9 @@
 
 #define AV1_REG_INTERRUPT		AV1_SWREG(1)
 #define AV1_REG_INTERRUPT_DEC_RDY_INT	BIT(12)
+#define AV1_REG_INTERRUPT_DEC_ABORT_E	BIT(5)
+#define AV1_REG_INTERRUPT_DEC_IRQ_DIS	BIT(4)
+#define AV1_REG_INTERRUPT_DEC_E		BIT(0)
 
 #define AV1_REG_CONFIG			AV1_SWREG(2)
 #define AV1_REG_CONFIG_DEC_CLK_GATE_E	BIT(10)
diff --git a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
index f04d3cc0c1a8..6bb85ccbf460 100644
--- a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
+++ b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
@@ -8,6 +8,9 @@
 
 #include <linux/clk.h>
 #include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/iopoll.h>
+#include <soc/rockchip/pm_domains.h>
 
 #include "hantro.h"
 #include "hantro_av1.h"
@@ -435,11 +438,23 @@ static irqreturn_t rk3588_vpu981_irq(int irq, void *dev_id)
 	vdpu_write(vpu, 0, AV1_REG_INTERRUPT);
 	vdpu_write(vpu, AV1_REG_CONFIG_DEC_CLK_GATE_E, AV1_REG_CONFIG);
 
-	hantro_irq_done(vpu, state);
+	if (state == VB2_BUF_STATE_DONE)
+		hantro_irq_done(vpu, state);
+	else
+		hantro_irq_reset(vpu);
 
 	return IRQ_HANDLED;
 }
 
+static int rk3588_vpu981_hw_init(struct hantro_dev *vpu)
+{
+	vpu->core_resets[0].id = "axi";
+	vpu->core_resets[1].id = "apb";
+
+	return devm_reset_control_bulk_get_optional_exclusive_released(vpu->dev,
+			ARRAY_SIZE(vpu->core_resets), vpu->core_resets);
+}
+
 static int rk3036_vpu_hw_init(struct hantro_dev *vpu)
 {
 	/* Bump ACLK to max. possible freq. to improve performance. */
@@ -540,6 +555,73 @@ static void rockchip_vpu2_enc_reset(struct hantro_ctx *ctx)
 	vepu_write(vpu, 0, VEPU_REG_INTERRUPT);
 }
 
+static int rockchip_vpu981_core_reset(void *data)
+{
+	struct hantro_dev *vpu = data;
+	int n = ARRAY_SIZE(vpu->core_resets);
+	int ret;
+
+	ret = reset_control_bulk_assert(n, vpu->core_resets);
+	udelay(5);
+	return reset_control_bulk_deassert(n, vpu->core_resets) ?: ret;
+}
+
+static void rockchip_vpu981_av1_dec_reset(struct hantro_ctx *ctx)
+{
+	struct hantro_dev *vpu = ctx->dev;
+	struct reset_control_bulk_data *rst = vpu->core_resets;
+	int n = ARRAY_SIZE(vpu->core_resets);
+	int irq, ret;
+	u32 status;
+
+	if (!rst[0].rstc)
+		return;
+
+	irq = platform_get_irq(vpu->pdev, 0);
+	if (irq < 0)
+		return;
+
+	ret = reset_control_bulk_acquire(n, rst);
+	if (ret) {
+		dev_err(vpu->dev, "Failed to acquire the core resets: %d\n", ret);
+		return;
+	}
+
+	/* After a timeout, keep the handler off the core and the next job. */
+	disable_irq(irq);
+
+	status = vdpu_read(vpu, AV1_REG_INTERRUPT);
+	if (status & AV1_REG_INTERRUPT_DEC_E) {
+		vdpu_write(vpu, status | AV1_REG_INTERRUPT_DEC_ABORT_E |
+			   AV1_REG_INTERRUPT_DEC_IRQ_DIS, AV1_REG_INTERRUPT);
+		if (readl_poll_timeout(vpu->dec_base + AV1_REG_INTERRUPT, status,
+				       !(status & AV1_REG_INTERRUPT_DEC_E), 100, 100000)) {
+			dev_err(vpu->dev, "The core does not stop, refusing further jobs\n");
+			hantro_iommu_park(vpu);
+			vpu->iommu_lost = true;
+			goto release;
+		}
+	}
+
+	if (hantro_iommu_park(vpu))
+		goto out;
+
+	ret = rockchip_pmu_idle_reset(vpu->dev, rockchip_vpu981_core_reset, vpu);
+	if (ret) {
+		dev_err(vpu->dev, "Failed to reset the core: %d\n", ret);
+		/* Bus state unknown: keep the IOMMU and the handler off it. */
+		if (ret == -ETIMEDOUT) {
+			vpu->iommu_lost = true;
+			goto release;
+		}
+	}
+	hantro_iommu_unpark(vpu);
+out:
+	enable_irq(irq);
+release:
+	reset_control_bulk_release(n, rst);
+}
+
 /*
  * Supported codec ops.
  */
@@ -656,6 +738,7 @@ static const struct hantro_codec_ops rk3588_vpu981_codec_ops[] = {
 		.init = hantro_av1_init,
 		.exit = hantro_av1_exit,
 		.done = hantro_av1_update_prob,
+		.reset = rockchip_vpu981_av1_dec_reset,
 	},
 };
 /*
@@ -856,6 +939,7 @@ const struct hantro_variant rk3588_vpu981_variant = {
 	.postproc_ops = &rockchip_vpu981_postproc_ops,
 	.codec = HANTRO_AV1_DECODER,
 	.codec_ops = rk3588_vpu981_codec_ops,
+	.init = rk3588_vpu981_hw_init,
 	.irqs = rk3588_vpu981_irqs,
 	.num_irqs = ARRAY_SIZE(rk3588_vpu981_irqs),
 	.clk_names = rk3588_vpu981_vpu_clk_names,

-- 
2.55.0



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

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 18/18] arm64: dts: rockchip: Name the RK3588 AV1 decoder resets
  2026-12-06  5:57 ` Arun Iyengar via B4 Relay
  (?)
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  -1 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

The AV1 decoder driver picks its core resets by name. Add the names and
list the resets in the binding order: AXI, AXI BIU, APB, APB BIU.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 arch/arm64/boot/dts/rockchip/rk3588-base.dtsi | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi b/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
index 96898fefe840..ffaab952d0ee 100644
--- a/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
@@ -1479,7 +1479,9 @@ av1d: video-codec@fdc70000 {
 		clocks = <&cru ACLK_AV1>, <&cru PCLK_AV1>;
 		clock-names = "aclk", "hclk";
 		power-domains = <&power RK3588_PD_AV1>;
-		resets = <&cru SRST_A_AV1>, <&cru SRST_P_AV1>, <&cru SRST_A_AV1_BIU>, <&cru SRST_P_AV1_BIU>;
+		resets = <&cru SRST_A_AV1>, <&cru SRST_A_AV1_BIU>,
+			 <&cru SRST_P_AV1>, <&cru SRST_P_AV1_BIU>;
+		reset-names = "axi", "axi-biu", "apb", "apb-biu";
 		iommus = <&av1d_mmu>;
 	};
 

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 18/18] arm64: dts: rockchip: Name the RK3588 AV1 decoder resets
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

The AV1 decoder driver picks its core resets by name. Add the names and
list the resets in the binding order: AXI, AXI BIU, APB, APB BIU.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 arch/arm64/boot/dts/rockchip/rk3588-base.dtsi | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi b/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
index 96898fefe840..ffaab952d0ee 100644
--- a/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
@@ -1479,7 +1479,9 @@ av1d: video-codec@fdc70000 {
 		clocks = <&cru ACLK_AV1>, <&cru PCLK_AV1>;
 		clock-names = "aclk", "hclk";
 		power-domains = <&power RK3588_PD_AV1>;
-		resets = <&cru SRST_A_AV1>, <&cru SRST_P_AV1>, <&cru SRST_A_AV1_BIU>, <&cru SRST_P_AV1_BIU>;
+		resets = <&cru SRST_A_AV1>, <&cru SRST_A_AV1_BIU>,
+			 <&cru SRST_P_AV1>, <&cru SRST_P_AV1_BIU>;
+		reset-names = "axi", "axi-biu", "apb", "apb-biu";
 		iommus = <&av1d_mmu>;
 	};
 

-- 
2.55.0



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v4 18/18] arm64: dts: rockchip: Name the RK3588 AV1 decoder resets
@ 2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  0 siblings, 0 replies; 58+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-06  5:57 UTC (permalink / raw)
  To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiko Stuebner, Nicolas Frattaroli,
	Andrzej Pietrasiewicz, Ezequiel Garcia, Hans Verkuil,
	Boris Brezillon, Jernej Skrabec, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Ulf Hansson
  Cc: linux-media, iommu, linux-rockchip, devicetree, linux-arm-kernel,
	linux-pm, linux-kernel, Sergei Khomenkov,
	Tharit Tangkijwanichakul, Sascha Hauer, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

The AV1 decoder driver picks its core resets by name. Add the names and
list the resets in the binding order: AXI, AXI BIU, APB, APB BIU.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 arch/arm64/boot/dts/rockchip/rk3588-base.dtsi | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi b/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
index 96898fefe840..ffaab952d0ee 100644
--- a/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
@@ -1479,7 +1479,9 @@ av1d: video-codec@fdc70000 {
 		clocks = <&cru ACLK_AV1>, <&cru PCLK_AV1>;
 		clock-names = "aclk", "hclk";
 		power-domains = <&power RK3588_PD_AV1>;
-		resets = <&cru SRST_A_AV1>, <&cru SRST_P_AV1>, <&cru SRST_A_AV1_BIU>, <&cru SRST_P_AV1_BIU>;
+		resets = <&cru SRST_A_AV1>, <&cru SRST_A_AV1_BIU>,
+			 <&cru SRST_P_AV1>, <&cru SRST_P_AV1_BIU>;
+		reset-names = "axi", "axi-biu", "apb", "apb-biu";
 		iommus = <&av1d_mmu>;
 	};
 

-- 
2.55.0



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

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* Re: [PATCH v4 06/18] media: verisilicon: Disable runtime PM before unpreparing the clocks on probe failure
  2026-12-06  5:57   ` Arun Iyengar via B4 Relay
  (?)
  (?)
@ 2026-12-06  6:11   ` sashiko-bot
  -1 siblings, 0 replies; 58+ messages in thread
From: sashiko-bot @ 2026-12-06  6:11 UTC (permalink / raw)
  To: Arun Iyengar; +Cc: devicetree, robh, conor+dt, media-ci

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] media: verisilicon: Fixes trailer cites 775fec69008d instead of
  556ab0b2741d
--

commit 56349933e88ca17d9f433ca9184631783de8230d
Author: Arun Iyengar <aiyengar1990@gmail.com>

> media: verisilicon: Disable runtime PM before unpreparing the clocks on probe failure
>
> The probe error path unprepares the clocks before it disables runtime
> PM, so a VPU resumed through its video nodes before a late failure
> keeps its clocks enabled, or suspends after they are unprepared.
> Prepare the clocks before enabling runtime PM, and unwind like
> hantro_remove(): suspend first, then unprepare.
>
> Fixes: 775fec69008d ("media: add Rockchip VPU JPEG encoder driver")
> Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>

[Severity: Low]
Should the Fixes tag point to 556ab0b2741d ("media: hantro: release runtime
resources when device_run fails") instead?

In 775fec69008d ("media: add Rockchip VPU JPEG encoder driver"), clocks were
enabled and disabled directly per job rather than by runtime PM callbacks.
That later commit moved clk_bulk_enable() and clk_bulk_disable() into
hantro_runtime_resume() and hantro_runtime_suspend(), introducing this bug.

The companion fix in 8f9ab25ffef6 ("media: verisilicon: suspend the device
before unregistering it on remove") cites the same commit.  Citing the
initial driver commit can misdirect stable backports to kernels where clocks
are not managed by runtime PM.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261206-hantro-robust-v4-0-b99d33a5ec6d@gmail.com?part=6

^ permalink raw reply	[flat|nested] 58+ messages in thread

end of thread, other threads:[~2026-12-06  6:11 UTC | newest]

Thread overview: 58+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-06  5:57 [PATCH v4 00/18] media: verisilicon: Recover the Rockchip VPUs from faults and timeouts Arun Iyengar
2026-12-06  5:57 ` Arun Iyengar via B4 Relay
2026-12-06  5:57 ` Arun Iyengar via B4 Relay
2026-12-06  5:57 ` [PATCH v4 01/18] dt-bindings: media: rockchip,rk3568-vepu: Add the reset lines Arun Iyengar
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57 ` [PATCH v4 02/18] media: verisilicon: Check the match data in hantro_probe() Arun Iyengar
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57 ` [PATCH v4 03/18] media: verisilicon: Complete the request when the VPU can't resume Arun Iyengar
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57 ` [PATCH v4 04/18] media: verisilicon: Copy the buffer metadata before a job can fail Arun Iyengar
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57 ` [PATCH v4 05/18] media: verisilicon: Don't hold the VPU in reset after remove Arun Iyengar
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57 ` [PATCH v4 06/18] media: verisilicon: Disable runtime PM before unpreparing the clocks on probe failure Arun Iyengar
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  6:11   ` sashiko-bot
2026-12-06  5:57 ` [PATCH v4 07/18] media: verisilicon: Enable the Rockchip encoder interrupt again after a reset Arun Iyengar
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57 ` [PATCH v4 08/18] media: verisilicon: Reset the Rockchip encoder cores on timeout Arun Iyengar
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57 ` [PATCH v4 09/18] media: verisilicon: Reinitialize the IOMMU after resetting an encoder core Arun Iyengar
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57 ` [PATCH v4 10/18] media: verisilicon: Acquire the reset lines only while using them Arun Iyengar
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57 ` [PATCH v4 11/18] dt-bindings: iommu: verisilicon: Add the reset lines Arun Iyengar
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57 ` [PATCH v4 12/18] iommu/vsi: Deassert the reset lines on probe Arun Iyengar
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57 ` [PATCH v4 13/18] arm64: dts: rockchip: Add the reset lines of the RK3588 VEPU121 cores Arun Iyengar
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57 ` [PATCH v4 14/18] arm64: dts: rockchip: Add the reset lines of the RK3588 AV1 IOMMU Arun Iyengar
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57 ` [PATCH v4 15/18] pmdomain: rockchip: Add rockchip_pmu_idle_reset() Arun Iyengar
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57 ` [PATCH v4 16/18] dt-bindings: media: rockchip-vpu: Add reset-names Arun Iyengar
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57 ` [PATCH v4 17/18] media: verisilicon: Reset the RK3588 AV1 decoder after an error Arun Iyengar
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57 ` [PATCH v4 18/18] arm64: dts: rockchip: Name the RK3588 AV1 decoder resets Arun Iyengar
2026-12-06  5:57   ` Arun Iyengar via B4 Relay
2026-12-06  5:57   ` Arun Iyengar via B4 Relay

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.