Commit 2b0140c6 authored by Jon Derrick's avatar Jon Derrick Committed by Bjorn Helgaas

iommu/vt-d: Use pci_real_dma_dev() for mapping

The PCI device may have a DMA requester on another bus, such as VMD
subdevices needing to use the VMD endpoint.  This case requires the real
DMA device for the IOMMU mapping, so use pci_real_dma_dev() to find that
device.

Link: https://lore.kernel.org/r/1579613871-301529-5-git-send-email-jonathan.derrick@intel.comSigned-off-by: default avatarJon Derrick <jonathan.derrick@intel.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Acked-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
parent 2856ba60
...@@ -782,6 +782,8 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf ...@@ -782,6 +782,8 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf
return NULL; return NULL;
#endif #endif
pdev = pci_real_dma_dev(pdev);
/* VFs aren't listed in scope tables; we need to look up /* VFs aren't listed in scope tables; we need to look up
* the PF instead to find the IOMMU. */ * the PF instead to find the IOMMU. */
pf_pdev = pci_physfn(pdev); pf_pdev = pci_physfn(pdev);
...@@ -2428,6 +2430,9 @@ static struct dmar_domain *find_domain(struct device *dev) ...@@ -2428,6 +2430,9 @@ static struct dmar_domain *find_domain(struct device *dev)
dev->archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO)) dev->archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO))
return NULL; return NULL;
if (dev_is_pci(dev))
dev = &pci_real_dma_dev(to_pci_dev(dev))->dev;
/* No lock here, assumes no domain exit in normal case */ /* No lock here, assumes no domain exit in normal case */
info = dev->archdata.iommu; info = dev->archdata.iommu;
if (likely(info)) if (likely(info))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment