diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-08-25 05:10:42 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-08-25 05:10:42 -0400 |
commit | ea1c9de45ecb162841c9b4e0fa303a245d59b1c8 (patch) | |
tree | 72ef1624d8a4c581ad94a84f38f941682562030b /arch/x86/pci | |
parent | 4e1d112cac08049e764fe3c4f6d3ec92529f9f68 (diff) | |
parent | a2bd7274b47124d2fc4dfdb8c0591f545ba749dd (diff) |
Merge branch 'x86/urgent' into x86/cleanups
Diffstat (limited to 'arch/x86/pci')
-rw-r--r-- | arch/x86/pci/amd_bus.c | 52 | ||||
-rw-r--r-- | arch/x86/pci/i386.c | 78 |
2 files changed, 124 insertions, 6 deletions
diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c index dbf532369711..6a0fca78c362 100644 --- a/arch/x86/pci/amd_bus.c +++ b/arch/x86/pci/amd_bus.c | |||
@@ -1,6 +1,7 @@ | |||
1 | #include <linux/init.h> | 1 | #include <linux/init.h> |
2 | #include <linux/pci.h> | 2 | #include <linux/pci.h> |
3 | #include <linux/topology.h> | 3 | #include <linux/topology.h> |
4 | #include <linux/cpu.h> | ||
4 | #include "pci.h" | 5 | #include "pci.h" |
5 | 6 | ||
6 | #ifdef CONFIG_X86_64 | 7 | #ifdef CONFIG_X86_64 |
@@ -555,15 +556,17 @@ static int __init early_fill_mp_bus_info(void) | |||
555 | return 0; | 556 | return 0; |
556 | } | 557 | } |
557 | 558 | ||
558 | postcore_initcall(early_fill_mp_bus_info); | 559 | #else /* !CONFIG_X86_64 */ |
559 | 560 | ||
560 | #endif | 561 | static int __init early_fill_mp_bus_info(void) { return 0; } |
562 | |||
563 | #endif /* !CONFIG_X86_64 */ | ||
561 | 564 | ||
562 | /* common 32/64 bit code */ | 565 | /* common 32/64 bit code */ |
563 | 566 | ||
564 | #define ENABLE_CF8_EXT_CFG (1ULL << 46) | 567 | #define ENABLE_CF8_EXT_CFG (1ULL << 46) |
565 | 568 | ||
566 | static void enable_pci_io_ecs_per_cpu(void *unused) | 569 | static void enable_pci_io_ecs(void *unused) |
567 | { | 570 | { |
568 | u64 reg; | 571 | u64 reg; |
569 | rdmsrl(MSR_AMD64_NB_CFG, reg); | 572 | rdmsrl(MSR_AMD64_NB_CFG, reg); |
@@ -573,14 +576,51 @@ static void enable_pci_io_ecs_per_cpu(void *unused) | |||
573 | } | 576 | } |
574 | } | 577 | } |
575 | 578 | ||
576 | static int __init enable_pci_io_ecs(void) | 579 | static int __cpuinit amd_cpu_notify(struct notifier_block *self, |
580 | unsigned long action, void *hcpu) | ||
577 | { | 581 | { |
582 | int cpu = (long)hcpu; | ||
583 | switch(action) { | ||
584 | case CPU_ONLINE: | ||
585 | case CPU_ONLINE_FROZEN: | ||
586 | smp_call_function_single(cpu, enable_pci_io_ecs, NULL, 0); | ||
587 | break; | ||
588 | default: | ||
589 | break; | ||
590 | } | ||
591 | return NOTIFY_OK; | ||
592 | } | ||
593 | |||
594 | static struct notifier_block __cpuinitdata amd_cpu_notifier = { | ||
595 | .notifier_call = amd_cpu_notify, | ||
596 | }; | ||
597 | |||
598 | static int __init pci_io_ecs_init(void) | ||
599 | { | ||
600 | int cpu; | ||
601 | |||
578 | /* assume all cpus from fam10h have IO ECS */ | 602 | /* assume all cpus from fam10h have IO ECS */ |
579 | if (boot_cpu_data.x86 < 0x10) | 603 | if (boot_cpu_data.x86 < 0x10) |
580 | return 0; | 604 | return 0; |
581 | on_each_cpu(enable_pci_io_ecs_per_cpu, NULL, 1); | 605 | |
606 | register_cpu_notifier(&amd_cpu_notifier); | ||
607 | for_each_online_cpu(cpu) | ||
608 | amd_cpu_notify(&amd_cpu_notifier, (unsigned long)CPU_ONLINE, | ||
609 | (void *)(long)cpu); | ||
582 | pci_probe |= PCI_HAS_IO_ECS; | 610 | pci_probe |= PCI_HAS_IO_ECS; |
611 | |||
612 | return 0; | ||
613 | } | ||
614 | |||
615 | static int __init amd_postcore_init(void) | ||
616 | { | ||
617 | if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) | ||
618 | return 0; | ||
619 | |||
620 | early_fill_mp_bus_info(); | ||
621 | pci_io_ecs_init(); | ||
622 | |||
583 | return 0; | 623 | return 0; |
584 | } | 624 | } |
585 | 625 | ||
586 | postcore_initcall(enable_pci_io_ecs); | 626 | postcore_initcall(amd_postcore_init); |
diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c index 5807d1bc73f7..d765da913842 100644 --- a/arch/x86/pci/i386.c +++ b/arch/x86/pci/i386.c | |||
@@ -31,8 +31,11 @@ | |||
31 | #include <linux/ioport.h> | 31 | #include <linux/ioport.h> |
32 | #include <linux/errno.h> | 32 | #include <linux/errno.h> |
33 | #include <linux/bootmem.h> | 33 | #include <linux/bootmem.h> |
34 | #include <linux/acpi.h> | ||
34 | 35 | ||
35 | #include <asm/pat.h> | 36 | #include <asm/pat.h> |
37 | #include <asm/hpet.h> | ||
38 | #include <asm/io_apic.h> | ||
36 | 39 | ||
37 | #include "pci.h" | 40 | #include "pci.h" |
38 | 41 | ||
@@ -77,6 +80,77 @@ pcibios_align_resource(void *data, struct resource *res, | |||
77 | } | 80 | } |
78 | EXPORT_SYMBOL(pcibios_align_resource); | 81 | EXPORT_SYMBOL(pcibios_align_resource); |
79 | 82 | ||
83 | static int check_res_with_valid(struct pci_dev *dev, struct resource *res) | ||
84 | { | ||
85 | unsigned long base; | ||
86 | unsigned long size; | ||
87 | int i; | ||
88 | |||
89 | base = res->start; | ||
90 | size = (res->start == 0 && res->end == res->start) ? 0 : | ||
91 | (res->end - res->start + 1); | ||
92 | |||
93 | if (!base || !size) | ||
94 | return 0; | ||
95 | |||
96 | #ifdef CONFIG_HPET_TIMER | ||
97 | /* for hpet */ | ||
98 | if (base == hpet_address && (res->flags & IORESOURCE_MEM)) { | ||
99 | dev_info(&dev->dev, "BAR has HPET at %08lx-%08lx\n", | ||
100 | base, base + size - 1); | ||
101 | return 1; | ||
102 | } | ||
103 | #endif | ||
104 | |||
105 | #ifdef CONFIG_X86_IO_APIC | ||
106 | for (i = 0; i < nr_ioapics; i++) { | ||
107 | unsigned long ioapic_phys = mp_ioapics[i].mp_apicaddr; | ||
108 | |||
109 | if (base == ioapic_phys && (res->flags & IORESOURCE_MEM)) { | ||
110 | dev_info(&dev->dev, "BAR has ioapic at %08lx-%08lx\n", | ||
111 | base, base + size - 1); | ||
112 | return 1; | ||
113 | } | ||
114 | } | ||
115 | #endif | ||
116 | |||
117 | #ifdef CONFIG_PCI_MMCONFIG | ||
118 | for (i = 0; i < pci_mmcfg_config_num; i++) { | ||
119 | unsigned long addr; | ||
120 | |||
121 | addr = pci_mmcfg_config[i].address; | ||
122 | if (base == addr && (res->flags & IORESOURCE_MEM)) { | ||
123 | dev_info(&dev->dev, "BAR has MMCONFIG at %08lx-%08lx\n", | ||
124 | base, base + size - 1); | ||
125 | return 1; | ||
126 | } | ||
127 | } | ||
128 | #endif | ||
129 | |||
130 | return 0; | ||
131 | } | ||
132 | |||
133 | static int check_platform(struct pci_dev *dev, struct resource *res) | ||
134 | { | ||
135 | struct resource *root = NULL; | ||
136 | |||
137 | /* | ||
138 | * forcibly insert it into the | ||
139 | * resource tree | ||
140 | */ | ||
141 | if (res->flags & IORESOURCE_MEM) | ||
142 | root = &iomem_resource; | ||
143 | else if (res->flags & IORESOURCE_IO) | ||
144 | root = &ioport_resource; | ||
145 | |||
146 | if (root && check_res_with_valid(dev, res)) { | ||
147 | insert_resource(root, res); | ||
148 | |||
149 | return 1; | ||
150 | } | ||
151 | |||
152 | return 0; | ||
153 | } | ||
80 | /* | 154 | /* |
81 | * Handle resources of PCI devices. If the world were perfect, we could | 155 | * Handle resources of PCI devices. If the world were perfect, we could |
82 | * just allocate all the resource regions and do nothing more. It isn't. | 156 | * just allocate all the resource regions and do nothing more. It isn't. |
@@ -128,6 +202,8 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list) | |||
128 | pr = pci_find_parent_resource(dev, r); | 202 | pr = pci_find_parent_resource(dev, r); |
129 | if (!r->start || !pr || | 203 | if (!r->start || !pr || |
130 | request_resource(pr, r) < 0) { | 204 | request_resource(pr, r) < 0) { |
205 | if (check_platform(dev, r)) | ||
206 | continue; | ||
131 | dev_err(&dev->dev, "BAR %d: can't " | 207 | dev_err(&dev->dev, "BAR %d: can't " |
132 | "allocate resource\n", idx); | 208 | "allocate resource\n", idx); |
133 | /* | 209 | /* |
@@ -171,6 +247,8 @@ static void __init pcibios_allocate_resources(int pass) | |||
171 | r->flags, disabled, pass); | 247 | r->flags, disabled, pass); |
172 | pr = pci_find_parent_resource(dev, r); | 248 | pr = pci_find_parent_resource(dev, r); |
173 | if (!pr || request_resource(pr, r) < 0) { | 249 | if (!pr || request_resource(pr, r) < 0) { |
250 | if (check_platform(dev, r)) | ||
251 | continue; | ||
174 | dev_err(&dev->dev, "BAR %d: can't " | 252 | dev_err(&dev->dev, "BAR %d: can't " |
175 | "allocate resource\n", idx); | 253 | "allocate resource\n", idx); |
176 | /* We'll assign a new address later */ | 254 | /* We'll assign a new address later */ |