Skip to content

Commit 5e544d6

Browse files
Andi KleenAndi Kleen
authored andcommitted
[PATCH] i386/x86-64: PCI: split probing and initialization of type 1 config space access
First probe if type1/2 accesses work, but then only initialize them at the end. This is useful for a later patch that needs this information inbetween. Signed-off-by: Andi Kleen <ak@suse.de>
1 parent a15da49 commit 5e544d6

File tree

5 files changed

+29
-15
lines changed

5 files changed

+29
-15
lines changed

arch/i386/pci/direct.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,16 @@ static int __init pci_check_type2(void)
254254
return works;
255255
}
256256

257-
void __init pci_direct_init(void)
257+
void __init pci_direct_init(int type)
258+
{
259+
printk(KERN_INFO "PCI: Using configuration type %d\n", type);
260+
if (type == 1)
261+
raw_pci_ops = &pci_direct_conf1;
262+
else
263+
raw_pci_ops = &pci_direct_conf2;
264+
}
265+
266+
int __init pci_direct_probe(void)
258267
{
259268
struct resource *region, *region2;
260269

@@ -264,30 +273,28 @@ void __init pci_direct_init(void)
264273
if (!region)
265274
goto type2;
266275

267-
if (pci_check_type1()) {
268-
printk(KERN_INFO "PCI: Using configuration type 1\n");
269-
raw_pci_ops = &pci_direct_conf1;
270-
return;
271-
}
276+
if (pci_check_type1())
277+
return 1;
272278
release_resource(region);
273279

274280
type2:
275281
if ((pci_probe & PCI_PROBE_CONF2) == 0)
276-
return;
282+
return 0;
277283
region = request_region(0xCF8, 4, "PCI conf2");
278284
if (!region)
279-
return;
285+
return 0;
280286
region2 = request_region(0xC000, 0x1000, "PCI conf2");
281287
if (!region2)
282288
goto fail2;
283289

284290
if (pci_check_type2()) {
285291
printk(KERN_INFO "PCI: Using configuration type 2\n");
286292
raw_pci_ops = &pci_direct_conf2;
287-
return;
293+
return 2;
288294
}
289295

290296
release_resource(region2);
291297
fail2:
292298
release_resource(region);
299+
return 0;
293300
}

arch/i386/pci/init.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@
66
in the right sequence from here. */
77
static __init int pci_access_init(void)
88
{
9+
int type = 0;
10+
11+
#ifdef CONFIG_PCI_DIRECT
12+
type = pci_direct_probe();
13+
#endif
914
#ifdef CONFIG_PCI_MMCONFIG
10-
pci_mmcfg_init();
15+
pci_mmcfg_init(type);
1116
#endif
1217
if (raw_pci_ops)
1318
return 0;
@@ -21,7 +26,7 @@ static __init int pci_access_init(void)
2126
* fails.
2227
*/
2328
#ifdef CONFIG_PCI_DIRECT
24-
pci_direct_init();
29+
pci_direct_init(type);
2530
#endif
2631
return 0;
2732
}

arch/i386/pci/mmconfig.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ static __init void unreachable_devices(void)
187187
}
188188
}
189189

190-
void __init pci_mmcfg_init(void)
190+
void __init pci_mmcfg_init(int type)
191191
{
192192
if ((pci_probe & PCI_PROBE_MMCONF) == 0)
193193
return;

arch/i386/pci/pci.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ extern int pci_conf1_write(unsigned int seg, unsigned int bus,
8181
extern int pci_conf1_read(unsigned int seg, unsigned int bus,
8282
unsigned int devfn, int reg, int len, u32 *value);
8383

84-
extern void pci_direct_init(void);
84+
extern int pci_direct_probe(void);
85+
extern void pci_direct_init(int type);
8586
extern void pci_pcbios_init(void);
86-
extern void pci_mmcfg_init(void);
87+
extern void pci_mmcfg_init(int type);
8788
extern void pcibios_sort(void);
89+

arch/x86_64/pci/mmconfig.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ static __init void unreachable_devices(void)
163163
}
164164
}
165165

166-
void __init pci_mmcfg_init(void)
166+
void __init pci_mmcfg_init(int type)
167167
{
168168
int i;
169169

0 commit comments

Comments
 (0)