|
@@ -19,9 +19,7 @@
|
|
|
|
|
|
/* Verify the first 16 busses. We assume that systems with more busses
|
|
|
get MCFG right. */
|
|
|
-#define MAX_CHECK_BUS 16
|
|
|
-
|
|
|
-static DECLARE_BITMAP(fallback_slots, 32*MAX_CHECK_BUS);
|
|
|
+#define PCI_MMCFG_MAX_CHECK_BUS 16
|
|
|
|
|
|
/* Static virtual mapping of the MMCONFIG aperture */
|
|
|
struct mmcfg_virt {
|
|
@@ -63,8 +61,8 @@ static char __iomem *get_virt(unsigned int seg, unsigned bus)
|
|
|
static char __iomem *pci_dev_base(unsigned int seg, unsigned int bus, unsigned int devfn)
|
|
|
{
|
|
|
char __iomem *addr;
|
|
|
- if (seg == 0 && bus < MAX_CHECK_BUS &&
|
|
|
- test_bit(32*bus + PCI_SLOT(devfn), fallback_slots))
|
|
|
+ if (seg == 0 && bus < PCI_MMCFG_MAX_CHECK_BUS &&
|
|
|
+ test_bit(32*bus + PCI_SLOT(devfn), pci_mmcfg_fallback_slots))
|
|
|
return NULL;
|
|
|
addr = get_virt(seg, bus);
|
|
|
if (!addr)
|
|
@@ -135,63 +133,16 @@ static struct pci_raw_ops pci_mmcfg = {
|
|
|
.write = pci_mmcfg_write,
|
|
|
};
|
|
|
|
|
|
-/* K8 systems have some devices (typically in the builtin northbridge)
|
|
|
- that are only accessible using type1
|
|
|
- Normally this can be expressed in the MCFG by not listing them
|
|
|
- and assigning suitable _SEGs, but this isn't implemented in some BIOS.
|
|
|
- Instead try to discover all devices on bus 0 that are unreachable using MM
|
|
|
- and fallback for them. */
|
|
|
-static __init void unreachable_devices(void)
|
|
|
-{
|
|
|
- int i, k;
|
|
|
- /* Use the max bus number from ACPI here? */
|
|
|
- for (k = 0; k < MAX_CHECK_BUS; k++) {
|
|
|
- for (i = 0; i < 32; i++) {
|
|
|
- u32 val1;
|
|
|
- char __iomem *addr;
|
|
|
-
|
|
|
- pci_conf1_read(0, k, PCI_DEVFN(i,0), 0, 4, &val1);
|
|
|
- if (val1 == 0xffffffff)
|
|
|
- continue;
|
|
|
- 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 %02x:%02x\n", k, i);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-void __init pci_mmcfg_init(int type)
|
|
|
+int __init pci_mmcfg_arch_init(void)
|
|
|
{
|
|
|
int i;
|
|
|
-
|
|
|
- if ((pci_probe & PCI_PROBE_MMCONF) == 0)
|
|
|
- return;
|
|
|
-
|
|
|
- acpi_table_parse(ACPI_SIG_MCFG, acpi_parse_mcfg);
|
|
|
- if ((pci_mmcfg_config_num == 0) ||
|
|
|
- (pci_mmcfg_config == NULL) ||
|
|
|
- (pci_mmcfg_config[0].address == 0))
|
|
|
- return;
|
|
|
-
|
|
|
- /* 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].address,
|
|
|
- pci_mmcfg_config[0].address + MMCONFIG_APER_MIN,
|
|
|
- E820_RESERVED)) {
|
|
|
- printk(KERN_ERR "PCI: BIOS Bug: MCFG area at %lx is not E820-reserved\n",
|
|
|
- (unsigned long)pci_mmcfg_config[0].address);
|
|
|
- printk(KERN_ERR "PCI: Not using MMCONFIG.\n");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- pci_mmcfg_virt = kmalloc(sizeof(*pci_mmcfg_virt) * pci_mmcfg_config_num, GFP_KERNEL);
|
|
|
+ pci_mmcfg_virt = kmalloc(sizeof(*pci_mmcfg_virt) *
|
|
|
+ pci_mmcfg_config_num, GFP_KERNEL);
|
|
|
if (pci_mmcfg_virt == NULL) {
|
|
|
printk(KERN_ERR "PCI: Can not allocate memory for mmconfig structures\n");
|
|
|
- return;
|
|
|
+ return 0;
|
|
|
}
|
|
|
+
|
|
|
for (i = 0; i < pci_mmcfg_config_num; ++i) {
|
|
|
pci_mmcfg_virt[i].cfg = &pci_mmcfg_config[i];
|
|
|
pci_mmcfg_virt[i].virt = ioremap_nocache(pci_mmcfg_config[i].address,
|
|
@@ -200,14 +151,11 @@ void __init pci_mmcfg_init(int type)
|
|
|
printk(KERN_ERR "PCI: Cannot map mmconfig aperture for "
|
|
|
"segment %d\n",
|
|
|
pci_mmcfg_config[i].pci_segment);
|
|
|
- return;
|
|
|
+ return 0;
|
|
|
}
|
|
|
- printk(KERN_INFO "PCI: Using MMCONFIG at %lx\n",
|
|
|
- (unsigned long)pci_mmcfg_config[i].address);
|
|
|
+ printk(KERN_INFO "PCI: Using MMCONFIG at %Lx\n",
|
|
|
+ pci_mmcfg_config[i].address);
|
|
|
}
|
|
|
-
|
|
|
- unreachable_devices();
|
|
|
-
|
|
|
raw_pci_ops = &pci_mmcfg;
|
|
|
- pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF;
|
|
|
+ return 1;
|
|
|
}
|