From: Robin Murphy <robin.murphy@arm.com>
To: Jason Gunthorpe <jgg@nvidia.com>, Andy Gross <agross@kernel.org>,
Alim Akhtar <alim.akhtar@samsung.com>,
Bjorn Andersson <andersson@kernel.org>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Gerald Schaefer <gerald.schaefer@linux.ibm.com>,
Heiko Stuebner <heiko@sntech.de>,
iommu@lists.linux.dev, Jernej Skrabec <jernej.skrabec@gmail.com>,
Jonathan Hunter <jonathanh@nvidia.com>,
Joerg Roedel <joro@8bytes.org>,
Konrad Dybcio <konrad.dybcio@linaro.org>,
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
linux-arm-kernel@lists.infradead.org,
linux-arm-msm@vger.kernel.org,
linux-mediatek@lists.infradead.org,
linux-rockchip@lists.infradead.org, linux-s390@vger.kernel.org,
linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev,
linux-tegra@vger.kernel.org,
Marek Szyprowski <m.szyprowski@samsung.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
Matthew Rosato <mjrosato@linux.ibm.com>,
Orson Zhai <orsonzhai@gmail.com>, Rob Clark <robdclark@gmail.com>,
Samuel Holland <samuel@sholland.org>,
Niklas Schnelle <schnelle@linux.ibm.com>,
Thierry Reding <thierry.reding@gmail.com>,
Krishna Reddy <vdumpa@nvidia.com>, Chen-Yu Tsai <wens@csie.org>,
Will Deacon <will@kernel.org>, Yong Wu <yong.wu@mediatek.com>,
Chunyan Zhang <zhang.lyra@gmail.com>
Cc: Lu Baolu <baolu.lu@linux.intel.com>,
Kevin Tian <kevin.tian@intel.com>,
Nicolin Chen <nicolinc@nvidia.com>,
Steven Price <steven.price@arm.com>
Subject: Re: [PATCH 04/20] iommu/fsl_pamu: Replace set_platform_dma_ops() with IOMMU_DOMAIN_PLATFORM
Date: Wed, 3 May 2023 11:57:59 +0100 [thread overview]
Message-ID: <32aa1228-3eb9-340a-41e7-88fdd7c0a5ac@arm.com> (raw)
In-Reply-To: <4-v1-21cc72fcfb22+a7a-iommu_all_defdom_jgg@nvidia.com>
On 2023-05-01 19:02, Jason Gunthorpe wrote:
> It is not clear what this is actually doing, most likely this is IDENTITY
> behavior, but I think there is a chance it is BLOCKING given how the PAMU
> stuff is oddly used.
Logically it has to be identity, since there are no DMA ops interacting
with this driver (it's not the TCE IOMMU of
arch/powerpc/kernel/iommu.c), so any device using a kernel driver rather
than VFIO must be using dma-direct and thus require an identity mapping.
At this point I finally got sufficiently fed up of this driver always
being the mystery weirdo and tracked down an old QorIQ reference manual,
and now I have about half an hours' worth of understanding of how the
PAMU actually works.
Based on that, what setup_liodns() is doing is indeed setting up
identity for everything initially. It also becomes apparent that it's
never supported giving a PCI device back to its regular driver after
using vfio-pci, since an attach/detach cycle will then leave the PPAACE
invalid and thus DMA blocked. Oh well, that's been broken for 10 years;
nobody cares. Call it an identity domain and move on.
Thanks,
Robin.
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
> drivers/iommu/fsl_pamu_domain.c | 29 ++++++++++++++++++++++++++---
> 1 file changed, 26 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domain.c
> index bce37229709965..4c65f1adfe7511 100644
> --- a/drivers/iommu/fsl_pamu_domain.c
> +++ b/drivers/iommu/fsl_pamu_domain.c
> @@ -283,15 +283,28 @@ static int fsl_pamu_attach_device(struct iommu_domain *domain,
> return ret;
> }
>
> -static void fsl_pamu_set_platform_dma(struct device *dev)
> +/*
> + * FIXME: This seems to turn off the iommu HW but it is not obvious what state
> + * it leaves the HW in. This is probably really a BLOCKING or IDENTITY domain.
> + * For now this ensures that the old detach_dev behavior functions about the
> + * same as it always did, and we turn off the IOMMU whenever the UNMANAGED
> + * domain is detached.
> + */
> +static int fsl_pamu_platform_attach(struct iommu_domain *platform_domain,
> + struct device *dev)
> {
> struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
> - struct fsl_dma_domain *dma_domain = to_fsl_dma_domain(domain);
> + struct fsl_dma_domain *dma_domain;
> const u32 *prop;
> int len;
> struct pci_dev *pdev = NULL;
> struct pci_controller *pci_ctl;
>
> + if (domain == platform_domain || !domain)
> + return 0;
> +
> + dma_domain = to_fsl_dma_domain(domain);
> +
> /*
> * Use LIODN of the PCI controller while detaching a
> * PCI device.
> @@ -312,8 +325,18 @@ static void fsl_pamu_set_platform_dma(struct device *dev)
> detach_device(dev, dma_domain);
> else
> pr_debug("missing fsl,liodn property at %pOF\n", dev->of_node);
> + return 0;
> }
>
> +static struct iommu_domain_ops fsl_pamu_platform_ops = {
> + .attach_dev = fsl_pamu_platform_attach,
> +};
> +
> +static struct iommu_domain fsl_pamu_platform_domain = {
> + .type = IOMMU_DOMAIN_PLATFORM,
> + .ops = &fsl_pamu_platform_ops,
> +};
> +
> /* Set the domain stash attribute */
> int fsl_pamu_configure_l1_stash(struct iommu_domain *domain, u32 cpu)
> {
> @@ -448,11 +471,11 @@ static struct iommu_device *fsl_pamu_probe_device(struct device *dev)
> }
>
> static const struct iommu_ops fsl_pamu_ops = {
> + .default_domain = &fsl_pamu_platform_domain,
> .capable = fsl_pamu_capable,
> .domain_alloc = fsl_pamu_domain_alloc,
> .probe_device = fsl_pamu_probe_device,
> .device_group = fsl_pamu_device_group,
> - .set_platform_dma_ops = fsl_pamu_set_platform_dma,
> .default_domain_ops = &(const struct iommu_domain_ops) {
> .attach_dev = fsl_pamu_attach_device,
> .iova_to_phys = fsl_pamu_iova_to_phys,
next prev parent reply other threads:[~2023-05-03 10:58 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-01 18:02 [PATCH 00/20] iommu: Make default_domain's mandatory Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 01/20] iommu: Add IOMMU_DOMAIN_PLATFORM Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 02/20] iommu/terga-gart: Replace set_platform_dma_ops() with IOMMU_DOMAIN_PLATFORM Jason Gunthorpe
2023-05-03 9:17 ` Robin Murphy
2023-05-03 11:01 ` Jason Gunthorpe
2023-05-03 12:01 ` Robin Murphy
2023-05-03 13:45 ` Jason Gunthorpe
2023-05-03 14:43 ` Thierry Reding
2023-05-03 17:20 ` Jason Gunthorpe
2023-05-12 2:55 ` Dmitry Osipenko
2023-05-12 16:49 ` Jason Gunthorpe
2023-05-12 18:12 ` Robin Murphy
2023-05-12 20:52 ` Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 03/20] iommu/s390: " Jason Gunthorpe
2023-05-02 17:57 ` Niklas Schnelle
2023-05-01 18:02 ` [PATCH 04/20] iommu/fsl_pamu: " Jason Gunthorpe
2023-05-03 10:57 ` Robin Murphy [this message]
2023-05-03 12:54 ` Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 05/20] iommu: Allow an IDENTITY domain as the default_domain in ARM32 Jason Gunthorpe
2023-05-03 13:50 ` Robin Murphy
2023-05-03 14:23 ` Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 06/20] iommu/exynos: Implement an IDENTITY domain Jason Gunthorpe
2023-05-03 15:31 ` Robin Murphy
2023-05-04 14:19 ` Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 07/20] iommu/tegra-smmu: " Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 08/20] iommu/tegra-smmu: Support DMA domains in tegra Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 09/20] iommu/omap: Implement an IDENTITY domain Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 10/20] iommu/msm: " Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 11/20] iommu/mtk_iommu_v1: " Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 12/20] iommu: Remove ops->set_platform_dma_ops() Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 13/20] iommu/qcom_iommu: Add an IOMMU_IDENTITIY_DOMAIN Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 14/20] iommu/ipmmu: " Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 15/20] iommu/mtk_iommu: " Jason Gunthorpe
2023-05-01 18:03 ` [PATCH 16/20] iommu/sun50i: " Jason Gunthorpe
2023-05-03 15:54 ` Robin Murphy
2023-05-03 16:49 ` Jason Gunthorpe
2023-05-01 18:03 ` [PATCH 17/20] iommu: Require a default_domain for all iommu drivers Jason Gunthorpe
2023-05-01 18:03 ` [PATCH 18/20] iommu: Add ops->domain_alloc_paging() Jason Gunthorpe
2023-05-03 17:17 ` Robin Murphy
2023-05-03 19:35 ` Jason Gunthorpe
2023-05-04 12:35 ` Niklas Schnelle
2023-05-04 13:14 ` Jason Gunthorpe
2023-05-01 18:03 ` [PATCH 19/20] iommu: Convert simple drivers with DOMAIN_DMA to domain_alloc_paging() Jason Gunthorpe
2023-05-01 18:03 ` [PATCH 20/20] iommu: Convert remaining simple drivers " Jason Gunthorpe
2023-05-02 14:52 ` Niklas Schnelle
2023-05-02 15:25 ` Jason Gunthorpe
2023-05-02 18:02 ` Niklas Schnelle
2023-05-01 21:34 ` [PATCH 00/20] iommu: Make default_domain's mandatory Heiko Stübner
2023-05-01 22:40 ` Jason Gunthorpe
2023-05-01 22:10 ` Heiko Stübner
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=32aa1228-3eb9-340a-41e7-88fdd7c0a5ac@arm.com \
--to=robin.murphy@arm.com \
--cc=agross@kernel.org \
--cc=alim.akhtar@samsung.com \
--cc=andersson@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=baolu.lu@linux.intel.com \
--cc=gerald.schaefer@linux.ibm.com \
--cc=heiko@sntech.de \
--cc=iommu@lists.linux.dev \
--cc=jernej.skrabec@gmail.com \
--cc=jgg@nvidia.com \
--cc=jonathanh@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=konrad.dybcio@linaro.org \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=linux-tegra@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=matthias.bgg@gmail.com \
--cc=mjrosato@linux.ibm.com \
--cc=nicolinc@nvidia.com \
--cc=orsonzhai@gmail.com \
--cc=robdclark@gmail.com \
--cc=samuel@sholland.org \
--cc=schnelle@linux.ibm.com \
--cc=steven.price@arm.com \
--cc=thierry.reding@gmail.com \
--cc=vdumpa@nvidia.com \
--cc=wens@csie.org \
--cc=will@kernel.org \
--cc=yong.wu@mediatek.com \
--cc=zhang.lyra@gmail.com \
/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