[PATCH v3 06/12] media: verisilicon: Reset the Rockchip encoder cores on timeout

From: Arun Iyengar via B4 Relay

Date: Fri Nov 13 2026 - 13:42:11 EST


From: Arun Iyengar <aiyengar1990@xxxxxxxxx>

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@xxxxxxxxx>
---
.../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 ce3dbea70a8d..1467ae2bed1a 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_jpeg.h"
@@ -468,6 +469,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;
@@ -475,6 +501,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);
}
@@ -495,6 +522,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