From: Christoph Hellwig <hch@lst.de>
To: Jon Derrick <jonathan.derrick@intel.com>
Cc: linux-pci@vger.kernel.org, iommu@lists.linux-foundation.org,
Bjorn Helgaas <helgaas@kernel.org>,
Keith Busch <kbusch@kernel.org>,
David Woodhouse <dwmw2@infradead.org>,
Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v3 4/5] PCI: vmd: Stop overriding dma_map_ops
Date: Tue, 14 Jan 2020 09:54:25 +0100 [thread overview]
Message-ID: <20200114085425.GD32024@lst.de> (raw)
In-Reply-To: <1578676873-6206-5-git-send-email-jonathan.derrick@intel.com>
On Fri, Jan 10, 2020 at 10:21:12AM -0700, Jon Derrick wrote:
> Devices on the VMD domain use the VMD endpoint's requester ID and have
> been relying on the VMD endpoint's DMA operations. The problem with this
> was that VMD domain devices would use the VMD endpoint's attributes when
> doing DMA and IOMMU mapping. We can be smarter about this by only using
> the VMD endpoint when mapping and providing the correct child device's
> attributes during DMA operations.
>
> This patch modifies Intel-IOMMU to check for a 'Direct DMA Alias' and
> refer to it for mapping.
>
> Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
> ---
> drivers/iommu/intel-iommu.c | 18 +++--
> drivers/pci/controller/Kconfig | 1 -
> drivers/pci/controller/vmd.c | 150 -----------------------------------------
> 3 files changed, 13 insertions(+), 156 deletions(-)
>
> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
> index 716347e2..7ca807a 100644
> --- a/drivers/iommu/intel-iommu.c
> +++ b/drivers/iommu/intel-iommu.c
> @@ -804,14 +804,14 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf
>
> if (dev_is_pci(dev)) {
> struct pci_dev *pf_pdev;
> + struct pci_dev *dma_alias;
>
> pdev = to_pci_dev(dev);
>
> -#ifdef CONFIG_X86
> - /* VMD child devices currently cannot be handled individually */
> - if (is_vmd(pdev->bus))
> - return NULL;
> -#endif
Don't we need this sanity check to prevent assingning vmd subdevices?
> + /* DMA aliased devices use the DMA alias's IOMMU */
> + dma_alias = pci_direct_dma_alias(pdev);
> + if (dma_alias)
> + pdev = dma_alias;
>
> /* VFs aren't listed in scope tables; we need to look up
> * the PF instead to find the IOMMU. */
> @@ -2521,6 +2521,14 @@ struct dmar_domain *find_domain(struct device *dev)
> dev->archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO))
> return NULL;
>
> + if (dev_is_pci(dev)) {
> + struct pci_dev *pdev = to_pci_dev(dev);
> + struct pci_dev *dma_alias = pci_direct_dma_alias(pdev);
> +
> + if (dma_alias)
> + dev = &dma_alias->dev;
Instead of all these duplicate calls, shouldn't pci_direct_dma_alias be
replaced with a pci_real_dma_dev helper that either returns the
dma parent if it exiѕts, or the actual device?
Also I think this patch should be split - one for intel-iommu that
just adds the real device checks, and then one that wires up vmd to
the new mechanism and then removes all the cruft.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Jon Derrick <jonathan.derrick@intel.com>
Cc: iommu@lists.linux-foundation.org, linux-pci@vger.kernel.org,
Bjorn Helgaas <helgaas@kernel.org>,
Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
Keith Busch <kbusch@kernel.org>, Joerg Roedel <joro@8bytes.org>,
Christoph Hellwig <hch@lst.de>,
David Woodhouse <dwmw2@infradead.org>,
Lu Baolu <baolu.lu@linux.intel.com>
Subject: Re: [PATCH v3 4/5] PCI: vmd: Stop overriding dma_map_ops
Date: Tue, 14 Jan 2020 09:54:25 +0100 [thread overview]
Message-ID: <20200114085425.GD32024@lst.de> (raw)
In-Reply-To: <1578676873-6206-5-git-send-email-jonathan.derrick@intel.com>
On Fri, Jan 10, 2020 at 10:21:12AM -0700, Jon Derrick wrote:
> Devices on the VMD domain use the VMD endpoint's requester ID and have
> been relying on the VMD endpoint's DMA operations. The problem with this
> was that VMD domain devices would use the VMD endpoint's attributes when
> doing DMA and IOMMU mapping. We can be smarter about this by only using
> the VMD endpoint when mapping and providing the correct child device's
> attributes during DMA operations.
>
> This patch modifies Intel-IOMMU to check for a 'Direct DMA Alias' and
> refer to it for mapping.
>
> Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
> ---
> drivers/iommu/intel-iommu.c | 18 +++--
> drivers/pci/controller/Kconfig | 1 -
> drivers/pci/controller/vmd.c | 150 -----------------------------------------
> 3 files changed, 13 insertions(+), 156 deletions(-)
>
> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
> index 716347e2..7ca807a 100644
> --- a/drivers/iommu/intel-iommu.c
> +++ b/drivers/iommu/intel-iommu.c
> @@ -804,14 +804,14 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf
>
> if (dev_is_pci(dev)) {
> struct pci_dev *pf_pdev;
> + struct pci_dev *dma_alias;
>
> pdev = to_pci_dev(dev);
>
> -#ifdef CONFIG_X86
> - /* VMD child devices currently cannot be handled individually */
> - if (is_vmd(pdev->bus))
> - return NULL;
> -#endif
Don't we need this sanity check to prevent assingning vmd subdevices?
> + /* DMA aliased devices use the DMA alias's IOMMU */
> + dma_alias = pci_direct_dma_alias(pdev);
> + if (dma_alias)
> + pdev = dma_alias;
>
> /* VFs aren't listed in scope tables; we need to look up
> * the PF instead to find the IOMMU. */
> @@ -2521,6 +2521,14 @@ struct dmar_domain *find_domain(struct device *dev)
> dev->archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO))
> return NULL;
>
> + if (dev_is_pci(dev)) {
> + struct pci_dev *pdev = to_pci_dev(dev);
> + struct pci_dev *dma_alias = pci_direct_dma_alias(pdev);
> +
> + if (dma_alias)
> + dev = &dma_alias->dev;
Instead of all these duplicate calls, shouldn't pci_direct_dma_alias be
replaced with a pci_real_dma_dev helper that either returns the
dma parent if it exiѕts, or the actual device?
Also I think this patch should be split - one for intel-iommu that
just adds the real device checks, and then one that wires up vmd to
the new mechanism and then removes all the cruft.
next prev parent reply other threads:[~2020-01-14 8:54 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-10 17:21 [PATCH v3 0/5] Clean up VMD DMA Map Ops Jon Derrick
2020-01-10 17:21 ` Jon Derrick
2020-01-10 17:21 ` [PATCH v3 1/5] x86/pci: Add a to_pci_sysdata helper Jon Derrick
2020-01-10 17:21 ` Jon Derrick
2020-01-13 14:40 ` Bjorn Helgaas
2020-01-13 14:40 ` Bjorn Helgaas
2020-01-14 8:49 ` Christoph Hellwig
2020-01-14 8:49 ` Christoph Hellwig
2020-01-10 17:21 ` [PATCH v3 2/5] x86/PCI: Expose VMD's PCI Device in pci_sysdata Jon Derrick
2020-01-10 17:21 ` Jon Derrick
2020-01-14 8:50 ` Christoph Hellwig
2020-01-14 8:50 ` Christoph Hellwig
2020-01-10 17:21 ` [PATCH v3 3/5] PCI: Introduce pci_direct_dma_alias() Jon Derrick
2020-01-10 17:21 ` Jon Derrick
2020-01-14 8:51 ` Christoph Hellwig
2020-01-14 8:51 ` Christoph Hellwig
2020-01-10 17:21 ` [PATCH v3 4/5] PCI: vmd: Stop overriding dma_map_ops Jon Derrick
2020-01-10 17:21 ` Jon Derrick
2020-01-14 8:54 ` Christoph Hellwig [this message]
2020-01-14 8:54 ` Christoph Hellwig
2020-01-17 18:17 ` Derrick, Jonathan
2020-01-17 18:17 ` Derrick, Jonathan
2020-01-10 17:21 ` [PATCH v3 5/5] x86/pci: Remove X86_DEV_DMA_OPS Jon Derrick
2020-01-10 17:21 ` Jon Derrick
2020-01-13 12:08 ` [PATCH v3 0/5] Clean up VMD DMA Map Ops Lorenzo Pieralisi
2020-01-13 12:08 ` Lorenzo Pieralisi
2020-01-13 17:13 ` Derrick, Jonathan
2020-01-13 17:13 ` Derrick, Jonathan
2020-01-13 18:01 ` Bjorn Helgaas
2020-01-13 18:01 ` Bjorn Helgaas
2020-01-13 18:17 ` Lorenzo Pieralisi
2020-01-13 18:17 ` Lorenzo Pieralisi
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=20200114085425.GD32024@lst.de \
--to=hch@lst.de \
--cc=dwmw2@infradead.org \
--cc=helgaas@kernel.org \
--cc=iommu@lists.linux-foundation.org \
--cc=jonathan.derrick@intel.com \
--cc=kbusch@kernel.org \
--cc=linux-pci@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.