Commit 31fe9435 authored by Alex Williamson's avatar Alex Williamson Committed by Joerg Roedel

iommu/amd: Fix ACS path checking

SR-IOV can create buses without a bridge.  There may be other cases
where this happens as well.  In these cases skip to the parent bus
and continue testing devices there.
Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
Signed-off-by: default avatarJoerg Roedel <joerg.roedel@amd.com>
parent a4ff1fc2
...@@ -296,8 +296,13 @@ static int iommu_init_device(struct device *dev) ...@@ -296,8 +296,13 @@ static int iommu_init_device(struct device *dev)
} else } else
dma_pdev = pci_dev_get(pdev); dma_pdev = pci_dev_get(pdev);
/* Account for quirked devices */
swap_pci_ref(&dma_pdev, pci_get_dma_source(dma_pdev)); swap_pci_ref(&dma_pdev, pci_get_dma_source(dma_pdev));
/*
* If it's a multifunction device that does not support our
* required ACS flags, add to the same group as function 0.
*/
if (dma_pdev->multifunction && if (dma_pdev->multifunction &&
!pci_acs_enabled(dma_pdev, REQ_ACS_FLAGS)) !pci_acs_enabled(dma_pdev, REQ_ACS_FLAGS))
swap_pci_ref(&dma_pdev, swap_pci_ref(&dma_pdev,
...@@ -305,14 +310,28 @@ static int iommu_init_device(struct device *dev) ...@@ -305,14 +310,28 @@ static int iommu_init_device(struct device *dev)
PCI_DEVFN(PCI_SLOT(dma_pdev->devfn), PCI_DEVFN(PCI_SLOT(dma_pdev->devfn),
0))); 0)));
/*
* Devices on the root bus go through the iommu. If that's not us,
* find the next upstream device and test ACS up to the root bus.
* Finding the next device may require skipping virtual buses.
*/
while (!pci_is_root_bus(dma_pdev->bus)) { while (!pci_is_root_bus(dma_pdev->bus)) {
if (pci_acs_path_enabled(dma_pdev->bus->self, struct pci_bus *bus = dma_pdev->bus;
NULL, REQ_ACS_FLAGS))
while (!bus->self) {
if (!pci_is_root_bus(bus))
bus = bus->parent;
else
goto root_bus;
}
if (pci_acs_path_enabled(bus->self, NULL, REQ_ACS_FLAGS))
break; break;
swap_pci_ref(&dma_pdev, pci_dev_get(dma_pdev->bus->self)); swap_pci_ref(&dma_pdev, pci_dev_get(bus->self));
} }
root_bus:
group = iommu_group_get(&dma_pdev->dev); group = iommu_group_get(&dma_pdev->dev);
pci_dev_put(dma_pdev); pci_dev_put(dma_pdev);
if (!group) { if (!group) {
......
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