Skip to content

Commit

Permalink
iommu/vt-d: Use pci_real_dma_dev() for mapping
Browse files Browse the repository at this point in the history
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.com
Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Lu Baolu <baolu.lu@linux.intel.com>
  • Loading branch information
Jon Derrick authored and bjorn-helgaas committed Jan 24, 2020
1 parent 2856ba6 commit 2b0140c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/iommu/intel-iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,8 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf
return NULL;
#endif

pdev = pci_real_dma_dev(pdev);

/* VFs aren't listed in scope tables; we need to look up
* the PF instead to find the IOMMU. */
pf_pdev = pci_physfn(pdev);
Expand Down Expand Up @@ -2428,6 +2430,9 @@ static struct dmar_domain *find_domain(struct device *dev)
dev->archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO))
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 */
info = dev->archdata.iommu;
if (likely(info))
Expand Down

0 comments on commit 2b0140c

Please sign in to comment.