Merge branch 'for-linus' of git://one.firstfloor.org/home/andi/git/linux-2.6
[pandora-kernel.git] / arch / x86_64 / pci / mmconfig.c
index 2d48a79..7732f42 100644 (file)
@@ -9,7 +9,6 @@
 #include <linux/init.h>
 #include <linux/acpi.h>
 #include <linux/bitmap.h>
-#include <linux/dmi.h>
 #include <asm/e820.h>
 
 #include "pci.h"
@@ -157,41 +156,49 @@ static __init void unreachable_devices(void)
                        addr = pci_dev_base(0, k, PCI_DEVFN(i, 0));
                        if (addr == NULL|| readl(addr) != val1) {
                                set_bit(i + 32*k, fallback_slots);
-                               printk(KERN_NOTICE
-                               "PCI: No mmconfig possible on device %x:%x\n",
-                                       k, i);
+                               printk(KERN_NOTICE "PCI: No mmconfig possible"
+                                      " on device %02x:%02x\n", k, i);
                        }
                }
        }
 }
 
-static int disable_mcfg(struct dmi_system_id *d)
+static __init void pci_mmcfg_insert_resources(void)
 {
-       printk("PCI: %s detected. Disabling MCFG.\n", d->ident);
-       pci_probe &= ~PCI_PROBE_MMCONF;
-       return 0;
-}
+#define PCI_MMCFG_RESOURCE_NAME_LEN 19
+       int i;
+       struct resource *res;
+       char *names;
+       unsigned num_buses;
 
-static struct dmi_system_id __initdata dmi_bad_mcfg[] = {
-       /* Has broken MCFG table that makes the system hang when used */
-        {
-         .callback = disable_mcfg,
-         .ident = "Intel D3C5105 SDV",
-         .matches = {
-                     DMI_MATCH(DMI_BIOS_VENDOR, "Intel"),
-                     DMI_MATCH(DMI_BOARD_NAME, "D26928"),
-                     },
-         },
-         {}
-};
+       res = kcalloc(PCI_MMCFG_RESOURCE_NAME_LEN + sizeof(*res),
+                       pci_mmcfg_config_num, GFP_KERNEL);
+
+       if (!res) {
+               printk(KERN_ERR "PCI: Unable to allocate MMCONFIG resources\n");
+               return;
+       }
 
-void __init pci_mmcfg_init(void)
+       names = (void *)&res[pci_mmcfg_config_num];
+       for (i = 0; i < pci_mmcfg_config_num; i++, res++) {
+               num_buses = pci_mmcfg_config[i].end_bus_number -
+                   pci_mmcfg_config[i].start_bus_number + 1;
+               res->name = names;
+               snprintf(names, PCI_MMCFG_RESOURCE_NAME_LEN, "PCI MMCONFIG %u",
+                       pci_mmcfg_config[i].pci_segment_group_number);
+               res->start = pci_mmcfg_config[i].base_address;
+               res->end = res->start + (num_buses << 20) - 1;
+               res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+               insert_resource(&iomem_resource, res);
+               names += PCI_MMCFG_RESOURCE_NAME_LEN;
+       }
+}
+
+void __init pci_mmcfg_init(int type)
 {
        int i;
 
-       dmi_check_system(dmi_bad_mcfg);
-
-       if ((pci_probe & (PCI_PROBE_MMCONF|PCI_PROBE_MMCONF_FORCE)) == 0)
+       if ((pci_probe & PCI_PROBE_MMCONF) == 0)
                return;
 
        acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg);
@@ -200,7 +207,17 @@ void __init pci_mmcfg_init(void)
            (pci_mmcfg_config[0].base_address == 0))
                return;
 
-       /* RED-PEN i386 doesn't do _nocache right now */
+       /* Only do this check when type 1 works. If it doesn't work
+           assume we run on a Mac and always use MCFG */
+       if (type == 1 && !e820_all_mapped(pci_mmcfg_config[0].base_address,
+                       pci_mmcfg_config[0].base_address + MMCONFIG_APER_MIN,
+                       E820_RESERVED)) {
+               printk(KERN_ERR "PCI: BIOS Bug: MCFG area at %x is not E820-reserved\n",
+                               pci_mmcfg_config[0].base_address);
+               printk(KERN_ERR "PCI: Not using MMCONFIG.\n");
+               return;
+       }
+
        pci_mmcfg_virt = kmalloc(sizeof(*pci_mmcfg_virt) * pci_mmcfg_config_num, GFP_KERNEL);
        if (pci_mmcfg_virt == NULL) {
                printk("PCI: Can not allocate memory for mmconfig structures\n");
@@ -219,6 +236,7 @@ void __init pci_mmcfg_init(void)
        }
 
        unreachable_devices();
+       pci_mmcfg_insert_resources();
 
        raw_pci_ops = &pci_mmcfg;
        pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF;