From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
To: aiyengar1990@gmail.com,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Heiko Stuebner <heiko@sntech.de>,
"Joerg Roedel (AMD)" <joro@8bytes.org>,
Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
Philipp Zabel <p.zabel@pengutronix.de>
Cc: linux-rockchip@lists.infradead.org, linux-media@vger.kernel.org,
devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, iommu@lists.linux.dev,
Hans Verkuil <hverkuil@kernel.org>,
Alex Bee <knaerzche@gmail.com>
Subject: Re: [PATCH v5 2/4] iommu/rockchip: Add rockchip_iommu_restore()
Date: Thu, 26 Nov 2026 15:20:24 -0500 [thread overview]
Message-ID: <23748f44fb9f43f88af97c65200cc75ed5d1ee6e.camel@collabora.com> (raw)
In-Reply-To: <20261126-iep2-v5-2-3deac0976f10@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3342 bytes --]
Le jeudi 26 novembre 2026 à 19:51 +0000, Arun Iyengar via B4 Relay a écrit :
> From: Arun Iyengar <aiyengar1990@gmail.com>
>
> Some masters reset their IOMMU along with themselves. The RK3588 IEP2
> does: after its soft reset, paging is off and its DMA is untranslated.
>
> Add a helper to reprogram the IOMMU of such a master, so that its
> driver need not attach and detach an empty domain to do it. rkvdec
> does the same with rkvdec_iommu_restore().
>
> Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
We are trying to get rid of hacks in many Rockchip m2m media drivers. rkvdec
have that hack upstream, and now I have rga2 and iep2 driver submission wanting
to use the same hack. So I asked Arun to give it a try and find a solution. So
see this as a v1.
Nicolas
> ---
> drivers/iommu/rockchip-iommu.c | 36 +++++++++++++++++++++++++++++++++++
> include/soc/rockchip/rockchip_iommu.h | 17 +++++++++++++++++
> 2 files changed, 53 insertions(+)
>
> diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
> index 21af2f621c76..81cad102929e 100644
> --- a/drivers/iommu/rockchip-iommu.c
> +++ b/drivers/iommu/rockchip-iommu.c
> @@ -27,6 +27,8 @@
> #include <linux/spinlock.h>
> #include <linux/string_choices.h>
>
> +#include <soc/rockchip/rockchip_iommu.h>
> +
> #include "iommu-pages.h"
>
> /** MMU register offsets */
> @@ -1349,6 +1351,40 @@ static int __maybe_unused rk_iommu_resume(struct device *dev)
> return rk_iommu_enable(iommu);
> }
>
> +/**
> + * rockchip_iommu_restore() - Reprogram the IOMMU of a master after its reset
> + * @dev: master device, runtime active, with no DMA in flight
> + *
> + * Some masters reset their IOMMU with themselves, which turns paging off.
> + *
> + * Context: may sleep.
> + *
> + * Return: 0 on success or a negative error code.
> + */
> +int rockchip_iommu_restore(struct device *dev)
> +{
> + struct rk_iommu *iommu;
> + int ret;
> +
> + if (!device_iommu_mapped(dev) ||
> + dev->iommu->iommu_dev->ops != &rk_iommu_ops)
> + return 0;
> +
> + iommu = rk_iommu_from_dev(dev);
> + if (!iommu || iommu->domain == &rk_identity_domain)
> + return 0;
> +
> + ret = pm_runtime_get_if_in_use(iommu->dev);
> + if (ret <= 0)
> + return ret;
> +
> + ret = rk_iommu_enable(iommu);
> + pm_runtime_put(iommu->dev);
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(rockchip_iommu_restore);
> +
> static const struct dev_pm_ops rk_iommu_pm_ops = {
> SET_RUNTIME_PM_OPS(rk_iommu_suspend, rk_iommu_resume, NULL)
> SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
> diff --git a/include/soc/rockchip/rockchip_iommu.h b/include/soc/rockchip/rockchip_iommu.h
> new file mode 100644
> index 000000000000..79fdd898a0fc
> --- /dev/null
> +++ b/include/soc/rockchip/rockchip_iommu.h
> @@ -0,0 +1,17 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +
> +#ifndef __SOC_ROCKCHIP_IOMMU_H__
> +#define __SOC_ROCKCHIP_IOMMU_H__
> +
> +struct device;
> +
> +#ifdef CONFIG_ROCKCHIP_IOMMU
> +int rockchip_iommu_restore(struct device *dev);
> +#else
> +static inline int rockchip_iommu_restore(struct device *dev)
> +{
> + return 0;
> +}
> +#endif
> +
> +#endif /* __SOC_ROCKCHIP_IOMMU_H__ */
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2026-11-26 20:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 19:51 [PATCH v5 0/4] media: rockchip: Add the IEP2 deinterlacer of RK3568/RK3588 Arun Iyengar via B4 Relay
2026-11-26 19:51 ` [PATCH v5 1/4] media: dt-bindings: Add Rockchip IEP2 deinterlacer Arun Iyengar via B4 Relay
2026-11-26 19:51 ` [PATCH v5 2/4] iommu/rockchip: Add rockchip_iommu_restore() Arun Iyengar via B4 Relay
2026-11-26 20:20 ` Nicolas Dufresne [this message]
2026-11-26 20:34 ` Nicolas Dufresne
2026-11-26 19:51 ` [PATCH v5 3/4] media: rockchip: Add IEP2 deinterlacer driver Arun Iyengar via B4 Relay
2026-11-26 19:51 ` [PATCH v5 4/4] arm64: dts: rockchip: Add IEP2 deinterlacer to RK3588 Arun Iyengar via B4 Relay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=23748f44fb9f43f88af97c65200cc75ed5d1ee6e.camel@collabora.com \
--to=nicolas.dufresne@collabora.com \
--cc=aiyengar1990@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=heiko@sntech.de \
--cc=hverkuil@kernel.org \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=knaerzche@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=mchehab@kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=robh@kernel.org \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®