x86, Calgary IOMMU quirk: Find nearest matching Calgary while walking up the PCI...
[linux-2.6.git] / arch / x86 / kernel / pci-calgary_64.c
index 849a099..c563e4c 100644 (file)
@@ -316,13 +316,15 @@ static inline struct iommu_table *find_iommu_table(struct device *dev)
 
        pdev = to_pci_dev(dev);
 
+       /* search up the device tree for an iommu */
        pbus = pdev->bus;
-
-       /* is the device behind a bridge? Look for the root bus */
-       while (pbus->parent)
+       do {
+               tbl = pci_iommu(pbus);
+               if (tbl && tbl->it_busno == pbus->number)
+                       break;
+               tbl = NULL;
                pbus = pbus->parent;
-
-       tbl = pci_iommu(pbus);
+       } while (pbus);
 
        BUG_ON(tbl && (tbl->it_busno != pbus->number));