From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796538193; b=FBsQoq+j07zD8wPIsFJR7j3G9+CwnF0KAEvO+uhPTRtUTUCY+ESMt/TQJQNIs8VOOEWy 5fZM9/pTZ52e8mcEsy9WdoDSIpUZI0xjiWLjC5B+e+asi26q+YcD+oSanRVS+RzUjictT BlMJ0VwXNHdQB7BHraze6DbaqEGIu5xdXm8KqqlIHQKe7htGm5PVAPb5oOFKL1EUikgNT 2o8LrEV9zaFZNpCawT5+LcuIJxOfOQp5S3Dz5/V7phjqL2wC38WVgy8r+E8xv0P+NjAYg Ofy1v3NK54vz5Wz0fGGnfgsMbc0kVdgawNnrmbw2pd2g2u3jnh7BPrXAIuOc+h5tCGg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796538193; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=KyJs+EzGsjdtAHa0XqbzHyikTqq3e2y1mzrmuq7kpe4=; b=KPL3kuVu7/tnFkw1MOdKZLrSyG6Xs08m3533M6Lk0Exna9zwVZA5c45c7lvqJBhtb4L7 fYx8JLPq8vj6i+ZE5QlLoq1yoPw2yU1RNqF+z95Z/vTunQndOH3paq1MqZGUsiG7xNFyr N0unD0uiHvVd48CKqwHWkmI0xWj5g7e9m7M2ismSpJgLEqH4yvjZoAT0xFobVNcVUOFr1 yDiI9oky1lbVfcdSPj9TLLF/A/jXvbnCu8n5q6IrAVexGHDN0jlMctWjAgTTn8LSVk9Ez xOB9+6n8xXQOBKGo/54j5jZZXQNd7KUpkkstwak7FfqpGDJ4zgKer1bvzRtp6NFTkgQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=LkyNECzg; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3124606A31F for ; Sun, 6 Dec 2026 06:23:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=LkyNECzg Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BA581F0093B; Sun, 6 Dec 2026 06:23:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796538193; bh=KyJs+EzGsjdtAHa0XqbzHyikTqq3e2y1mzrmuq7kpe4=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=LkyNECzg455mHc4Tf5P2HTofOMHwtEfxXVj6Zcevi7mTQw4hr7I97VX03zgRdrPJc zZsWihYxei46dzri0ir3ctrO7JQ8LuSnlmHaqRacCtNHqWCgItiOJjg34Y6SFb6Fa+ 1dMRvo6wAF5WT71A4EYMDPOXQimoW3TXwdcwCUuhDiR/ZEpNlXfwCoc1fIr/YSLarX KTVJvQDsNubV20XG1CTU3kAtPB3oBeU9BQU3QxyQJy7eCjZC+nGW08OPBEuYfdozet 5n8cwZ0q2lPK6Dq/93Qjfak+h2XNzZJ82/CjE53ROqpiulIzGVCf2i6+4O0HdeOZSk jwyNfqtHTV3UA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 08/18] media: verisilicon: Reset the Rockchip encoder cores on timeout Reply-To: sashiko-reviews@lists.linux.dev To: "Arun Iyengar" Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org, media-ci@linuxtv.org In-Reply-To: <20261206-hantro-robust-v4-8-b99d33a5ec6d@gmail.com> References: <20261206-hantro-robust-v4-0-b99d33a5ec6d@gmail.com> <20261206-hantro-robust-v4-8-b99d33a5ec6d@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 06 Dec 2026 06:23:12 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] media: verisilicon: rockchip_vpu_enc_hw_reset() races with VEPU IRQ MMIO - [High] media: verisilicon: IOMMU MMIO race during rockchip_vpu_enc_hw_reset() -- commit f26bdf656794e3f590dbb7fe0fa7ce2d6061f6e2 Author: Arun Iyengar media: verisilicon: Reset the Rockchip encoder cores on timeout This commit adds a rockchip_vpu_enc_hw_reset() helper that pulses the optional reset lines for 5 us and calls it from the Rockchip VEPU1 and VEPU2 timeout reset handlers. > diff --git a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c b/drive= rs/media/platform/verisilicon/rockchip_vpu_hw.c > index d54ba36d44495..2ec25d6dac866 100644 > --- a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c > +++ b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c [ ... ] > @@ -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); > } > =20 > +/* > + * 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 re= set > + * lines, if any. > + */ > +static void rockchip_vpu_enc_hw_reset(struct hantro_dev *vpu) > +{ > + int ret; > + > + if (!vpu->resets) > + return; > + > + ret =3D reset_control_assert(vpu->resets); > + if (ret) { > + dev_warn(vpu->dev, "Failed to assert resets: %d\n", ret); > + return; > + } > + > + udelay(5); > + > + ret =3D reset_control_deassert(vpu->resets); > + if (ret) > + dev_err(vpu->dev, "Failed to deassert resets: %d\n", ret); > +} [Severity: High] Can concurrent IOMMU MMIO accesses race with asserting vpu->resets on RK3588? On RK3588, the VEPU121 encoder cores share their AHB/AXI reset lines with the paired Rockchip IOMMU. When hantro_watchdog() runs, the timed-out job still holds the runtime PM reference on vpu->dev (and via the device link on iommu->dev), vpu->dev stays attached to its default DMA domain, and vpu->vpu_mutex is not held. CPU0 (kworker) CPU1 (other V4L2 context) hantro_watchdog() rockchip_vpu2_enc_reset() rockchip_vpu_enc_hw_reset() reset_control_assert(...) VIDIOC_QBUF / VIDIOC_REQBUFS rk_iommu_map() rk_iommu_zap_iova() rk_iommu_zap_lines() <-- MMIO in reset udelay(5) reset_control_deassert(...) rk_iommu_zap_iova() sees pm_runtime_get_if_in_use(iommu->dev) succeed and writes RK_MMU_ZAP_ONE_LINE while the shared reset is asserted; rk_iommu_irq() can also read and write IOMMU registers under the same check. MMIO accesses to a block held in reset can hang the bus or trigger a fatal SError on RK3588. [ ... ] > @@ -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 interrup= t again. */ > vepu_write(vpu, 0, H1_REG_INTERRUPT); > } [Severity: High] Can rockchip_vpu1_vepu_irq() access encoder registers while rockchip_vpu_enc_hw_reset() holds vpu->resets asserted? hantro_watchdog() runs in workqueue context with interrupts enabled and no shared lock, and hantro_irq_done() expects the hard IRQ handler to race with the watchdog around timeout expiration. Writing H1_REG_INTERRUPT_DIS_BIT is a posted MMIO write and does not stop an already-pending interrupt or an IRQ handler already running on another CPU. CPU0 (kworker) CPU1 () hantro_watchdog() rockchip_vpu1_enc_reset() vepu_write(..., DIS_BIT) rockchip_vpu_enc_hw_reset() reset_control_assert(...) rockchip_vpu1_vepu_irq() vepu_read(..., H1_REG_INTERRUPT) <-- MMIO in reset udelay(5) reset_control_deassert(...) The same race applies to rockchip_vpu2_enc_reset() and rockchip_vpu2_vepu_irq(). MMIO accesses while the AHB/AXI reset lines are asserted can hang the bus or trigger a fatal SError on Rockchip SoCs such as RK3588; disabling or synchronizing the encoder IRQ before asserting vpu->resets would avoid this. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261206-hantro-rob= ust-v4-0-b99d33a5ec6d@gmail.com?part=3D8