Merge branch 'upstream-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/linvil...
[pandora-kernel.git] / arch / x86_64 / kernel / pci-gart.c
index 0c3f052..2480d3f 100644 (file)
@@ -65,9 +65,7 @@ static u32 gart_unmapped_entry;
 
 #define for_all_nb(dev) \
        dev = NULL;     \
-       while ((dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x1103, dev))!=NULL)\
-            if (dev->bus->number == 0 &&                                    \
-                   (PCI_SLOT(dev->devfn) >= 24) && (PCI_SLOT(dev->devfn) <= 31))
+       while ((dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x1103, dev))!=NULL)
 
 static struct pci_dev *northbridges[MAX_NB];
 static u32 northbridge_flush_word[MAX_NB];
@@ -114,10 +112,6 @@ static unsigned long alloc_iommu(int size)
 static void free_iommu(unsigned long offset, int size)
 { 
        unsigned long flags;
-       if (size == 1) { 
-               clear_bit(offset, iommu_gart_bitmap); 
-               return;
-       }
        spin_lock_irqsave(&iommu_bitmap_lock, flags);
        __clear_bit_string(iommu_gart_bitmap, offset, size);
        spin_unlock_irqrestore(&iommu_bitmap_lock, flags);
@@ -148,9 +142,12 @@ static void flush_gart(struct device *dev)
                        if (!northbridges[i])
                                continue;
                        /* Make sure the hardware actually executed the flush. */
-                       do { 
+                       for (;;) { 
                                pci_read_config_dword(northbridges[i], 0x9c, &w);
-                       } while (w & 1);
+                               if (!(w & 1))
+                                       break;
+                               cpu_relax();
+                       }
                } 
                if (!flushed) 
                        printk("nothing to flush?\n");
@@ -642,6 +639,14 @@ static int __init pci_iommu_init(void)
                return -1;
        }
 
+       i = 0;
+       for_all_nb(dev)
+               i++;
+       if (i > MAX_NB) {
+               printk(KERN_ERR "PCI-GART: Too many northbridges (%ld). Disabled\n", i);
+               return -1;
+       }
+
        printk(KERN_INFO "PCI-DMA: using GART IOMMU.\n");
        aper_size = info.aper_size * 1024 * 1024;       
        iommu_size = check_iommu_size(info.aper_base, aper_size);