From: Baolu Lu <baolu.lu@linux.intel.com>
To: Jason Gunthorpe <jgg@nvidia.com>, Robin Murphy <robin.murphy@arm.com>
Cc: baolu.lu@linux.intel.com, joro@8bytes.org, will@kernel.org,
hch@lst.de, iommu@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/8] iommu: Decouple iommu_present() from bus ops
Date: Sat, 28 Jan 2023 16:49:11 +0800 [thread overview]
Message-ID: <df59477f-3751-7314-40ab-9519dbfe0fe2@linux.intel.com> (raw)
In-Reply-To: <Y9PxKLyQg/+ZrK6a@nvidia.com>
On 2023/1/27 23:43, Jason Gunthorpe wrote:
> On Fri, Jan 27, 2023 at 03:19:55PM +0000, Robin Murphy wrote:
>
>> The current implementation of device_iommu_mapped() just dates back to when
>> dev->iommu_group was the only per-device thing we had, so in principle I
>> don't have any conceptual objection to redefining it in terms of "device has
>> ops" rather than "device has a group", but as things stand you'd still have
>> to do something about PPC first (I know Jason had been pushing on that, but
>> I've not kept track of where it got to).
> PPC hasn't moved at all, AFAICT. In a few more months I'm going to
> suggest we delete the special VFIO support due to it being broken,
> distros already having turned it off and nobody caring enough to fix
> it..
>
> What does device_iommu_mapped() even really mean?
>
> Looking at usages..
>
> These are fixing SOC HW bugs/issues - the desire seems to be "is the SOC's
> IOMMU enabled"
>
> drivers/char/agp/intel-gtt.c: device_iommu_mapped(&intel_private.pcidev->dev));
> drivers/dma/sh/rcar-dmac.c: if (device_iommu_mapped(&pdev->dev))
> drivers/gpu/drm/i915/i915_utils.c: if (device_iommu_mapped(i915->drm.dev))
> ?
> drivers/usb/dwc3/dwc3-xilinx.c: if (of_dma_is_coherent(dev->of_node) || device_iommu_mapped(dev)) {
> drivers/usb/host/xhci.c: if (!(xhci->quirks & XHCI_ZERO_64B_REGS) || !device_iommu_mapped(dev))
> drivers/crypto/qat/qat_common/adf_sriov.c: if (!device_iommu_mapped(&pdev->dev))
> ?
>
> These seem to be trying to decide if iommu_domain's can be used (and
> they can't be on power):
>
> drivers/gpu/drm/msm/msm_drv.c: if (device_iommu_mapped(mdp_dev))
> drivers/gpu/drm/msm/msm_drv.c: device_iommu_mapped(dev->dev) ||
> drivers/gpu/drm/msm/msm_drv.c: device_iommu_mapped(dev->dev->parent);
> drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c: if (device_iommu_mapped(dev)) {
> drivers/gpu/drm/rockchip/rockchip_drm_drv.c: if (!device_iommu_mapped(dev))
> drivers/gpu/drm/tegra/uapi.c: if (device_iommu_mapped(client->base.dev) && client->ops->can_use_memory_ctx) {
> drivers/gpu/host1x/context.c: if (!fwspec || !device_iommu_mapped(&ctx->dev)) {
> drivers/infiniband/hw/usnic/usnic_ib_main.c: if (!device_iommu_mapped(&pdev->dev)) {
>
> Yikes, trying to map DMA addresses programmed into devices back to CPU addresses:
>
> drivers/misc/habanalabs/common/debugfs.c: if (!user_address || device_iommu_mapped(&hdev->pdev->dev)) {
> drivers/misc/habanalabs/gaudi2/gaudi2.c: if (!device_iommu_mapped(&hdev->pdev->dev))
>
> And then sequencing the call to iommu_probe_device() which doesn't
> apply to power:
>
> drivers/acpi/scan.c: if (!err && dev->bus && !device_iommu_mapped(dev))
> drivers/iommu/of_iommu.c: if (!err && dev->bus && !device_iommu_mapped(dev))
>
> Leaving these:
>
> arch/powerpc/kernel/eeh.c: if (device_iommu_mapped(dev)) {
>
> This is only used to support eeh_iommu_group_to_pe which is only
> caleld by vfio_iommu_spapr_tce.c. Since power vfio doesn't work right
> now this is uncallable, and when power is fixed this will work
> properly.
>
> arch/powerpc/kernel/iommu.c: if (device_iommu_mapped(dev)) {
> arch/powerpc/kernel/iommu.c: if (!device_iommu_mapped(dev)) {
>
> These should both be replaced with some kind of 'device has iommu group', since
> it is really driving ppc unique group logic.
>
> So, I'd say Baolu's approach is the right thing, just replace the
> above two in ppc with something else.
Thank you both. I will follow up a series later.
Best regards,
baolu
next prev parent reply other threads:[~2023-01-28 8:49 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-19 19:18 [PATCH 0/8] iommu: The early demise of bus ops Robin Murphy
2023-01-19 19:18 ` [PATCH 1/8] iommu: Decouple iommu_present() from " Robin Murphy
2023-01-26 13:13 ` Baolu Lu
2023-01-26 14:21 ` Robin Murphy
2023-01-26 14:41 ` Jason Gunthorpe
2023-01-27 13:50 ` Baolu Lu
2023-01-27 13:59 ` Jason Gunthorpe
2023-01-27 15:19 ` Robin Murphy
2023-01-27 15:43 ` Jason Gunthorpe
2023-01-28 8:49 ` Baolu Lu [this message]
2023-01-30 13:49 ` Robin Murphy
2023-01-30 13:53 ` Jason Gunthorpe
2023-01-30 14:22 ` Oded Gabbay
2023-01-19 19:18 ` [PATCH 2/8] iommu: Validate that devices match domains Robin Murphy
2023-01-19 19:18 ` [PATCH 3/8] iommu: Factor out a "first device in group" helper Robin Murphy
2023-01-19 19:23 ` Jason Gunthorpe
2023-01-19 19:36 ` Robin Murphy
2023-01-19 19:18 ` [PATCH 4/8] iommu: Switch __iommu_domain_alloc() to device ops Robin Murphy
2023-01-19 19:26 ` Jason Gunthorpe
2023-01-19 20:12 ` Robin Murphy
2023-01-19 19:18 ` [PATCH 5/8] iommu/arm-smmu: Don't register fwnode for legacy binding Robin Murphy
2023-01-19 19:18 ` [PATCH 6/8] iommu: Retire bus ops Robin Murphy
2023-01-20 0:27 ` Baolu Lu
2023-01-20 12:31 ` Robin Murphy
2023-01-26 12:37 ` Baolu Lu
2023-01-20 10:23 ` Greg Kroah-Hartman
2023-01-19 19:18 ` [PATCH 7/8] iommu: Clean up open-coded ownership checks Robin Murphy
2023-01-19 19:31 ` Jason Gunthorpe
2023-01-19 20:52 ` Robin Murphy
2023-01-19 19:18 ` [PATCH 8/8] iommu: Pass device through ops->domain_alloc Robin Murphy
2023-01-19 19:34 ` [PATCH 0/8] iommu: The early demise of bus ops Jason Gunthorpe
2023-01-20 12:33 ` Joerg Roedel
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=df59477f-3751-7314-40ab-9519dbfe0fe2@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=hch@lst.de \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.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