aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386/pci
diff options
context:
space:
mode:
authorAndi Kleen <ak@suse.de>2006-03-23 17:35:12 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-03-23 17:35:12 -0500
commit92c05fc1a32e5ccef5e0e8201f32dcdab041524c (patch)
tree71c0202dffee676d3b2e0b75ea4472aaa2ffe8df /arch/i386/pci
parente4e73041ecc4a3559c42ed9489f58531c2a8646b (diff)
[PATCH] PCI: Give PCI config access initialization a defined ordering
I moved it to a separate function which is safer. This avoids problems with the linker reordering them and the less useful PCI config space access methods taking priority over the better ones. Fixes some problems with broken MMCONFIG Cc: Dave Hansen <haveblue@us.ibm.com> Signed-off-by: Andi Kleen <ak@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'arch/i386/pci')
-rw-r--r--arch/i386/pci/Makefile2
-rw-r--r--arch/i386/pci/direct.c15
-rw-r--r--arch/i386/pci/init.c25
-rw-r--r--arch/i386/pci/mmconfig.c11
-rw-r--r--arch/i386/pci/pcbios.c4
-rw-r--r--arch/i386/pci/pci.h3
6 files changed, 38 insertions, 22 deletions
diff --git a/arch/i386/pci/Makefile b/arch/i386/pci/Makefile
index 5461d4d5ea1e..62ad75c57e6a 100644
--- a/arch/i386/pci/Makefile
+++ b/arch/i386/pci/Makefile
@@ -1,4 +1,4 @@
1obj-y := i386.o 1obj-y := i386.o init.o
2 2
3obj-$(CONFIG_PCI_BIOS) += pcbios.o 3obj-$(CONFIG_PCI_BIOS) += pcbios.o
4obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o direct.o 4obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o direct.o
diff --git a/arch/i386/pci/direct.c b/arch/i386/pci/direct.c
index e3ac502bf2fb..99012b93bd12 100644
--- a/arch/i386/pci/direct.c
+++ b/arch/i386/pci/direct.c
@@ -245,7 +245,7 @@ static int __init pci_check_type2(void)
245 return works; 245 return works;
246} 246}
247 247
248static int __init pci_direct_init(void) 248void __init pci_direct_init(void)
249{ 249{
250 struct resource *region, *region2; 250 struct resource *region, *region2;
251 251
@@ -258,16 +258,16 @@ static int __init pci_direct_init(void)
258 if (pci_check_type1()) { 258 if (pci_check_type1()) {
259 printk(KERN_INFO "PCI: Using configuration type 1\n"); 259 printk(KERN_INFO "PCI: Using configuration type 1\n");
260 raw_pci_ops = &pci_direct_conf1; 260 raw_pci_ops = &pci_direct_conf1;
261 return 0; 261 return;
262 } 262 }
263 release_resource(region); 263 release_resource(region);
264 264
265 type2: 265 type2:
266 if ((pci_probe & PCI_PROBE_CONF2) == 0) 266 if ((pci_probe & PCI_PROBE_CONF2) == 0)
267 goto out; 267 return;
268 region = request_region(0xCF8, 4, "PCI conf2"); 268 region = request_region(0xCF8, 4, "PCI conf2");
269 if (!region) 269 if (!region)
270 goto out; 270 return;
271 region2 = request_region(0xC000, 0x1000, "PCI conf2"); 271 region2 = request_region(0xC000, 0x1000, "PCI conf2");
272 if (!region2) 272 if (!region2)
273 goto fail2; 273 goto fail2;
@@ -275,15 +275,10 @@ static int __init pci_direct_init(void)
275 if (pci_check_type2()) { 275 if (pci_check_type2()) {
276 printk(KERN_INFO "PCI: Using configuration type 2\n"); 276 printk(KERN_INFO "PCI: Using configuration type 2\n");
277 raw_pci_ops = &pci_direct_conf2; 277 raw_pci_ops = &pci_direct_conf2;
278 return 0; 278 return;
279 } 279 }
280 280
281 release_resource(region2); 281 release_resource(region2);
282 fail2: 282 fail2:
283 release_resource(region); 283 release_resource(region);
284
285 out:
286 return 0;
287} 284}
288
289arch_initcall(pci_direct_init);
diff --git a/arch/i386/pci/init.c b/arch/i386/pci/init.c
new file mode 100644
index 000000000000..f9156d3ac723
--- /dev/null
+++ b/arch/i386/pci/init.c
@@ -0,0 +1,25 @@
1#include <linux/config.h>
2#include <linux/pci.h>
3#include <linux/init.h>
4#include "pci.h"
5
6/* arch_initcall has too random ordering, so call the initializers
7 in the right sequence from here. */
8static __init int pci_access_init(void)
9{
10#ifdef CONFIG_PCI_MMCONFIG
11 pci_mmcfg_init();
12#endif
13 if (raw_pci_ops)
14 return 0;
15#ifdef CONFIG_PCI_BIOS
16 pci_pcbios_init();
17#endif
18 if (raw_pci_ops)
19 return 0;
20#ifdef CONFIG_PCI_DIRECT
21 pci_direct_init();
22#endif
23 return 0;
24}
25arch_initcall(pci_access_init);
diff --git a/arch/i386/pci/mmconfig.c b/arch/i386/pci/mmconfig.c
index 0ee8a983708c..613789071f30 100644
--- a/arch/i386/pci/mmconfig.c
+++ b/arch/i386/pci/mmconfig.c
@@ -172,25 +172,20 @@ static __init void unreachable_devices(void)
172 } 172 }
173} 173}
174 174
175static int __init pci_mmcfg_init(void) 175void __init pci_mmcfg_init(void)
176{ 176{
177 if ((pci_probe & PCI_PROBE_MMCONF) == 0) 177 if ((pci_probe & PCI_PROBE_MMCONF) == 0)
178 goto out; 178 return;
179 179
180 acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg); 180 acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg);
181 if ((pci_mmcfg_config_num == 0) || 181 if ((pci_mmcfg_config_num == 0) ||
182 (pci_mmcfg_config == NULL) || 182 (pci_mmcfg_config == NULL) ||
183 (pci_mmcfg_config[0].base_address == 0)) 183 (pci_mmcfg_config[0].base_address == 0))
184 goto out; 184 return;
185 185
186 printk(KERN_INFO "PCI: Using MMCONFIG\n"); 186 printk(KERN_INFO "PCI: Using MMCONFIG\n");
187 raw_pci_ops = &pci_mmcfg; 187 raw_pci_ops = &pci_mmcfg;
188 pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF; 188 pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF;
189 189
190 unreachable_devices(); 190 unreachable_devices();
191
192 out:
193 return 0;
194} 191}
195
196arch_initcall(pci_mmcfg_init);
diff --git a/arch/i386/pci/pcbios.c b/arch/i386/pci/pcbios.c
index b9d65f0bc2d1..1eec0868f4b3 100644
--- a/arch/i386/pci/pcbios.c
+++ b/arch/i386/pci/pcbios.c
@@ -476,14 +476,12 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
476} 476}
477EXPORT_SYMBOL(pcibios_set_irq_routing); 477EXPORT_SYMBOL(pcibios_set_irq_routing);
478 478
479static int __init pci_pcbios_init(void) 479void __init pci_pcbios_init(void)
480{ 480{
481 if ((pci_probe & PCI_PROBE_BIOS) 481 if ((pci_probe & PCI_PROBE_BIOS)
482 && ((raw_pci_ops = pci_find_bios()))) { 482 && ((raw_pci_ops = pci_find_bios()))) {
483 pci_probe |= PCI_BIOS_SORT; 483 pci_probe |= PCI_BIOS_SORT;
484 pci_bios_present = 1; 484 pci_bios_present = 1;
485 } 485 }
486 return 0;
487} 486}
488 487
489arch_initcall(pci_pcbios_init);
diff --git a/arch/i386/pci/pci.h b/arch/i386/pci/pci.h
index f550781ec310..12035e29108b 100644
--- a/arch/i386/pci/pci.h
+++ b/arch/i386/pci/pci.h
@@ -80,4 +80,7 @@ extern int pci_conf1_write(unsigned int seg, unsigned int bus,
80extern int pci_conf1_read(unsigned int seg, unsigned int bus, 80extern int pci_conf1_read(unsigned int seg, unsigned int bus,
81 unsigned int devfn, int reg, int len, u32 *value); 81 unsigned int devfn, int reg, int len, u32 *value);
82 82
83extern void pci_direct_init(void);
84extern void pci_pcbios_init(void);
85extern void pci_mmcfg_init(void);
83 86