xref: /openbmc/linux/arch/x86/pci/common.c (revision c5f9ee3d)
1fb9aa6f1SThomas Gleixner /*
2fb9aa6f1SThomas Gleixner  *	Low-Level PCI Support for PC
3fb9aa6f1SThomas Gleixner  *
4fb9aa6f1SThomas Gleixner  *	(c) 1999--2000 Martin Mares <mj@ucw.cz>
5fb9aa6f1SThomas Gleixner  */
6fb9aa6f1SThomas Gleixner 
7fb9aa6f1SThomas Gleixner #include <linux/sched.h>
8fb9aa6f1SThomas Gleixner #include <linux/pci.h>
989016506SJiang Liu #include <linux/pci-acpi.h>
10fb9aa6f1SThomas Gleixner #include <linux/ioport.h>
11fb9aa6f1SThomas Gleixner #include <linux/init.h>
12fb9aa6f1SThomas Gleixner #include <linux/dmi.h>
135a0e3ad6STejun Heo #include <linux/slab.h>
14fb9aa6f1SThomas Gleixner 
15284f5f9dSBjorn Helgaas #include <asm-generic/pci-bridge.h>
16fb9aa6f1SThomas Gleixner #include <asm/acpi.h>
17fb9aa6f1SThomas Gleixner #include <asm/segment.h>
18fb9aa6f1SThomas Gleixner #include <asm/io.h>
19fb9aa6f1SThomas Gleixner #include <asm/smp.h>
2082487711SJaswinder Singh Rajput #include <asm/pci_x86.h>
21f9a37be0SMatthew Garrett #include <asm/setup.h>
22fb9aa6f1SThomas Gleixner 
23fb9aa6f1SThomas Gleixner unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 |
24fb9aa6f1SThomas Gleixner 				PCI_PROBE_MMCONF;
25fb9aa6f1SThomas Gleixner 
26e3f2baebSYinghai Lu unsigned int pci_early_dump_regs;
27fb9aa6f1SThomas Gleixner static int pci_bf_sort;
286e8af08dSNarendra_K@Dell.com static int smbios_type_b1_flag;
29fb9aa6f1SThomas Gleixner int pci_routeirq;
30a9322f64SStefan Assmann int noioapicquirk;
3141b9eb26SStefan Assmann #ifdef CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS
3241b9eb26SStefan Assmann int noioapicreroute = 0;
3341b9eb26SStefan Assmann #else
349197979bSStefan Assmann int noioapicreroute = 1;
3541b9eb26SStefan Assmann #endif
36fb9aa6f1SThomas Gleixner int pcibios_last_bus = -1;
37fb9aa6f1SThomas Gleixner unsigned long pirq_table_addr;
3872da0b07SJan Beulich const struct pci_raw_ops *__read_mostly raw_pci_ops;
3972da0b07SJan Beulich const struct pci_raw_ops *__read_mostly raw_pci_ext_ops;
40b6ce068aSMatthew Wilcox 
41b6ce068aSMatthew Wilcox int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn,
42b6ce068aSMatthew Wilcox 						int reg, int len, u32 *val)
43b6ce068aSMatthew Wilcox {
44beef3129SMatthew Wilcox 	if (domain == 0 && reg < 256 && raw_pci_ops)
45b6ce068aSMatthew Wilcox 		return raw_pci_ops->read(domain, bus, devfn, reg, len, val);
46b6ce068aSMatthew Wilcox 	if (raw_pci_ext_ops)
47b6ce068aSMatthew Wilcox 		return raw_pci_ext_ops->read(domain, bus, devfn, reg, len, val);
48b6ce068aSMatthew Wilcox 	return -EINVAL;
49b6ce068aSMatthew Wilcox }
50b6ce068aSMatthew Wilcox 
51b6ce068aSMatthew Wilcox int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn,
52b6ce068aSMatthew Wilcox 						int reg, int len, u32 val)
53b6ce068aSMatthew Wilcox {
54beef3129SMatthew Wilcox 	if (domain == 0 && reg < 256 && raw_pci_ops)
55b6ce068aSMatthew Wilcox 		return raw_pci_ops->write(domain, bus, devfn, reg, len, val);
56b6ce068aSMatthew Wilcox 	if (raw_pci_ext_ops)
57b6ce068aSMatthew Wilcox 		return raw_pci_ext_ops->write(domain, bus, devfn, reg, len, val);
58b6ce068aSMatthew Wilcox 	return -EINVAL;
59b6ce068aSMatthew Wilcox }
60fb9aa6f1SThomas Gleixner 
61fb9aa6f1SThomas Gleixner static int pci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
62fb9aa6f1SThomas Gleixner {
63b6ce068aSMatthew Wilcox 	return raw_pci_read(pci_domain_nr(bus), bus->number,
64a79e4198SJeff Garzik 				 devfn, where, size, value);
65fb9aa6f1SThomas Gleixner }
66fb9aa6f1SThomas Gleixner 
67fb9aa6f1SThomas Gleixner static int pci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value)
68fb9aa6f1SThomas Gleixner {
69b6ce068aSMatthew Wilcox 	return raw_pci_write(pci_domain_nr(bus), bus->number,
70a79e4198SJeff Garzik 				  devfn, where, size, value);
71fb9aa6f1SThomas Gleixner }
72fb9aa6f1SThomas Gleixner 
73fb9aa6f1SThomas Gleixner struct pci_ops pci_root_ops = {
74fb9aa6f1SThomas Gleixner 	.read = pci_read,
75fb9aa6f1SThomas Gleixner 	.write = pci_write,
76fb9aa6f1SThomas Gleixner };
77fb9aa6f1SThomas Gleixner 
78fb9aa6f1SThomas Gleixner /*
79fb9aa6f1SThomas Gleixner  * This interrupt-safe spinlock protects all accesses to PCI
80fb9aa6f1SThomas Gleixner  * configuration space.
81fb9aa6f1SThomas Gleixner  */
82d19f61f0SThomas Gleixner DEFINE_RAW_SPINLOCK(pci_config_lock);
83fb9aa6f1SThomas Gleixner 
84a18e3690SGreg Kroah-Hartman static int can_skip_ioresource_align(const struct dmi_system_id *d)
8513a6ddb0SYinghai Lu {
8613a6ddb0SYinghai Lu 	pci_probe |= PCI_CAN_SKIP_ISA_ALIGN;
8713a6ddb0SYinghai Lu 	printk(KERN_INFO "PCI: %s detected, can skip ISA alignment\n", d->ident);
8813a6ddb0SYinghai Lu 	return 0;
8913a6ddb0SYinghai Lu }
9013a6ddb0SYinghai Lu 
91a18e3690SGreg Kroah-Hartman static const struct dmi_system_id can_skip_pciprobe_dmi_table[] = {
9213a6ddb0SYinghai Lu /*
9313a6ddb0SYinghai Lu  * Systems where PCI IO resource ISA alignment can be skipped
9413a6ddb0SYinghai Lu  * when the ISA enable bit in the bridge control is not set
9513a6ddb0SYinghai Lu  */
9613a6ddb0SYinghai Lu 	{
9713a6ddb0SYinghai Lu 		.callback = can_skip_ioresource_align,
9813a6ddb0SYinghai Lu 		.ident = "IBM System x3800",
9913a6ddb0SYinghai Lu 		.matches = {
10013a6ddb0SYinghai Lu 			DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
10113a6ddb0SYinghai Lu 			DMI_MATCH(DMI_PRODUCT_NAME, "x3800"),
10213a6ddb0SYinghai Lu 		},
10313a6ddb0SYinghai Lu 	},
10413a6ddb0SYinghai Lu 	{
10513a6ddb0SYinghai Lu 		.callback = can_skip_ioresource_align,
10613a6ddb0SYinghai Lu 		.ident = "IBM System x3850",
10713a6ddb0SYinghai Lu 		.matches = {
10813a6ddb0SYinghai Lu 			DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
10913a6ddb0SYinghai Lu 			DMI_MATCH(DMI_PRODUCT_NAME, "x3850"),
11013a6ddb0SYinghai Lu 		},
11113a6ddb0SYinghai Lu 	},
11213a6ddb0SYinghai Lu 	{
11313a6ddb0SYinghai Lu 		.callback = can_skip_ioresource_align,
11413a6ddb0SYinghai Lu 		.ident = "IBM System x3950",
11513a6ddb0SYinghai Lu 		.matches = {
11613a6ddb0SYinghai Lu 			DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
11713a6ddb0SYinghai Lu 			DMI_MATCH(DMI_PRODUCT_NAME, "x3950"),
11813a6ddb0SYinghai Lu 		},
11913a6ddb0SYinghai Lu 	},
12013a6ddb0SYinghai Lu 	{}
12113a6ddb0SYinghai Lu };
12213a6ddb0SYinghai Lu 
12313a6ddb0SYinghai Lu void __init dmi_check_skip_isa_align(void)
12413a6ddb0SYinghai Lu {
12513a6ddb0SYinghai Lu 	dmi_check_system(can_skip_pciprobe_dmi_table);
12613a6ddb0SYinghai Lu }
12713a6ddb0SYinghai Lu 
128a18e3690SGreg Kroah-Hartman static void pcibios_fixup_device_resources(struct pci_dev *dev)
129bb71ad88SGary Hade {
130bb71ad88SGary Hade 	struct resource *rom_r = &dev->resource[PCI_ROM_RESOURCE];
1317bd1c365SMike Habeck 	struct resource *bar_r;
1327bd1c365SMike Habeck 	int bar;
1337bd1c365SMike Habeck 
1347bd1c365SMike Habeck 	if (pci_probe & PCI_NOASSIGN_BARS) {
1357bd1c365SMike Habeck 		/*
1367bd1c365SMike Habeck 		* If the BIOS did not assign the BAR, zero out the
1377bd1c365SMike Habeck 		* resource so the kernel doesn't attmept to assign
1387bd1c365SMike Habeck 		* it later on in pci_assign_unassigned_resources
1397bd1c365SMike Habeck 		*/
1407bd1c365SMike Habeck 		for (bar = 0; bar <= PCI_STD_RESOURCE_END; bar++) {
1417bd1c365SMike Habeck 			bar_r = &dev->resource[bar];
1427bd1c365SMike Habeck 			if (bar_r->start == 0 && bar_r->end != 0) {
1437bd1c365SMike Habeck 				bar_r->flags = 0;
1447bd1c365SMike Habeck 				bar_r->end = 0;
1457bd1c365SMike Habeck 			}
1467bd1c365SMike Habeck 		}
1477bd1c365SMike Habeck 	}
148bb71ad88SGary Hade 
149bb71ad88SGary Hade 	if (pci_probe & PCI_NOASSIGN_ROMS) {
150bb71ad88SGary Hade 		if (rom_r->parent)
151bb71ad88SGary Hade 			return;
152bb71ad88SGary Hade 		if (rom_r->start) {
153bb71ad88SGary Hade 			/* we deal with BIOS assigned ROM later */
154bb71ad88SGary Hade 			return;
155bb71ad88SGary Hade 		}
156bb71ad88SGary Hade 		rom_r->start = rom_r->end = rom_r->flags = 0;
157bb71ad88SGary Hade 	}
158bb71ad88SGary Hade }
159bb71ad88SGary Hade 
160fb9aa6f1SThomas Gleixner /*
161fb9aa6f1SThomas Gleixner  *  Called after each bus is probed, but before its children
162fb9aa6f1SThomas Gleixner  *  are examined.
163fb9aa6f1SThomas Gleixner  */
164fb9aa6f1SThomas Gleixner 
165a18e3690SGreg Kroah-Hartman void pcibios_fixup_bus(struct pci_bus *b)
166fb9aa6f1SThomas Gleixner {
167bb71ad88SGary Hade 	struct pci_dev *dev;
168bb71ad88SGary Hade 
169fb9aa6f1SThomas Gleixner 	pci_read_bridge_bases(b);
170bb71ad88SGary Hade 	list_for_each_entry(dev, &b->devices, bus_list)
171bb71ad88SGary Hade 		pcibios_fixup_device_resources(dev);
172fb9aa6f1SThomas Gleixner }
173fb9aa6f1SThomas Gleixner 
17489016506SJiang Liu void pcibios_add_bus(struct pci_bus *bus)
17589016506SJiang Liu {
17689016506SJiang Liu 	acpi_pci_add_bus(bus);
17789016506SJiang Liu }
17889016506SJiang Liu 
17989016506SJiang Liu void pcibios_remove_bus(struct pci_bus *bus)
18089016506SJiang Liu {
18189016506SJiang Liu 	acpi_pci_remove_bus(bus);
18289016506SJiang Liu }
18389016506SJiang Liu 
184fb9aa6f1SThomas Gleixner /*
185fb9aa6f1SThomas Gleixner  * Only use DMI information to set this if nothing was passed
186fb9aa6f1SThomas Gleixner  * on the kernel command line (which was parsed earlier).
187fb9aa6f1SThomas Gleixner  */
188fb9aa6f1SThomas Gleixner 
189a18e3690SGreg Kroah-Hartman static int set_bf_sort(const struct dmi_system_id *d)
190fb9aa6f1SThomas Gleixner {
191fb9aa6f1SThomas Gleixner 	if (pci_bf_sort == pci_bf_sort_default) {
192fb9aa6f1SThomas Gleixner 		pci_bf_sort = pci_dmi_bf;
193fb9aa6f1SThomas Gleixner 		printk(KERN_INFO "PCI: %s detected, enabling pci=bfsort.\n", d->ident);
194fb9aa6f1SThomas Gleixner 	}
195fb9aa6f1SThomas Gleixner 	return 0;
196fb9aa6f1SThomas Gleixner }
197fb9aa6f1SThomas Gleixner 
198a18e3690SGreg Kroah-Hartman static void read_dmi_type_b1(const struct dmi_header *dm,
1996e8af08dSNarendra_K@Dell.com 				       void *private_data)
2006e8af08dSNarendra_K@Dell.com {
2016e8af08dSNarendra_K@Dell.com 	u8 *d = (u8 *)dm + 4;
2026e8af08dSNarendra_K@Dell.com 
2036e8af08dSNarendra_K@Dell.com 	if (dm->type != 0xB1)
2046e8af08dSNarendra_K@Dell.com 		return;
2056e8af08dSNarendra_K@Dell.com 	switch (((*(u32 *)d) >> 9) & 0x03) {
2066e8af08dSNarendra_K@Dell.com 	case 0x00:
2076e8af08dSNarendra_K@Dell.com 		printk(KERN_INFO "dmi type 0xB1 record - unknown flag\n");
2086e8af08dSNarendra_K@Dell.com 		break;
2096e8af08dSNarendra_K@Dell.com 	case 0x01: /* set pci=bfsort */
2106e8af08dSNarendra_K@Dell.com 		smbios_type_b1_flag = 1;
2116e8af08dSNarendra_K@Dell.com 		break;
2126e8af08dSNarendra_K@Dell.com 	case 0x02: /* do not set pci=bfsort */
2136e8af08dSNarendra_K@Dell.com 		smbios_type_b1_flag = 2;
2146e8af08dSNarendra_K@Dell.com 		break;
2156e8af08dSNarendra_K@Dell.com 	default:
2166e8af08dSNarendra_K@Dell.com 		break;
2176e8af08dSNarendra_K@Dell.com 	}
2186e8af08dSNarendra_K@Dell.com }
2196e8af08dSNarendra_K@Dell.com 
220a18e3690SGreg Kroah-Hartman static int find_sort_method(const struct dmi_system_id *d)
2216e8af08dSNarendra_K@Dell.com {
2226e8af08dSNarendra_K@Dell.com 	dmi_walk(read_dmi_type_b1, NULL);
2236e8af08dSNarendra_K@Dell.com 
2246e8af08dSNarendra_K@Dell.com 	if (smbios_type_b1_flag == 1) {
2256e8af08dSNarendra_K@Dell.com 		set_bf_sort(d);
2266e8af08dSNarendra_K@Dell.com 		return 0;
2276e8af08dSNarendra_K@Dell.com 	}
2286e8af08dSNarendra_K@Dell.com 	return -1;
2296e8af08dSNarendra_K@Dell.com }
2306e8af08dSNarendra_K@Dell.com 
231fb9aa6f1SThomas Gleixner /*
232fb9aa6f1SThomas Gleixner  * Enable renumbering of PCI bus# ranges to reach all PCI busses (Cardbus)
233fb9aa6f1SThomas Gleixner  */
234fb9aa6f1SThomas Gleixner #ifdef __i386__
235a18e3690SGreg Kroah-Hartman static int assign_all_busses(const struct dmi_system_id *d)
236fb9aa6f1SThomas Gleixner {
237fb9aa6f1SThomas Gleixner 	pci_probe |= PCI_ASSIGN_ALL_BUSSES;
238fb9aa6f1SThomas Gleixner 	printk(KERN_INFO "%s detected: enabling PCI bus# renumbering"
239fb9aa6f1SThomas Gleixner 			" (pci=assign-busses)\n", d->ident);
240fb9aa6f1SThomas Gleixner 	return 0;
241fb9aa6f1SThomas Gleixner }
242fb9aa6f1SThomas Gleixner #endif
243fb9aa6f1SThomas Gleixner 
244a18e3690SGreg Kroah-Hartman static int set_scan_all(const struct dmi_system_id *d)
245284f5f9dSBjorn Helgaas {
246284f5f9dSBjorn Helgaas 	printk(KERN_INFO "PCI: %s detected, enabling pci=pcie_scan_all\n",
247284f5f9dSBjorn Helgaas 	       d->ident);
248284f5f9dSBjorn Helgaas 	pci_add_flags(PCI_SCAN_ALL_PCIE_DEVS);
249284f5f9dSBjorn Helgaas 	return 0;
250284f5f9dSBjorn Helgaas }
251284f5f9dSBjorn Helgaas 
252a18e3690SGreg Kroah-Hartman static const struct dmi_system_id pciprobe_dmi_table[] = {
253fb9aa6f1SThomas Gleixner #ifdef __i386__
254fb9aa6f1SThomas Gleixner /*
255fb9aa6f1SThomas Gleixner  * Laptops which need pci=assign-busses to see Cardbus cards
256fb9aa6f1SThomas Gleixner  */
257fb9aa6f1SThomas Gleixner 	{
258fb9aa6f1SThomas Gleixner 		.callback = assign_all_busses,
259fb9aa6f1SThomas Gleixner 		.ident = "Samsung X20 Laptop",
260fb9aa6f1SThomas Gleixner 		.matches = {
261fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_SYS_VENDOR, "Samsung Electronics"),
262fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_PRODUCT_NAME, "SX20S"),
263fb9aa6f1SThomas Gleixner 		},
264fb9aa6f1SThomas Gleixner 	},
265fb9aa6f1SThomas Gleixner #endif		/* __i386__ */
266fb9aa6f1SThomas Gleixner 	{
267fb9aa6f1SThomas Gleixner 		.callback = set_bf_sort,
268fb9aa6f1SThomas Gleixner 		.ident = "Dell PowerEdge 1950",
269fb9aa6f1SThomas Gleixner 		.matches = {
270fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
271fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1950"),
272fb9aa6f1SThomas Gleixner 		},
273fb9aa6f1SThomas Gleixner 	},
274fb9aa6f1SThomas Gleixner 	{
275fb9aa6f1SThomas Gleixner 		.callback = set_bf_sort,
276fb9aa6f1SThomas Gleixner 		.ident = "Dell PowerEdge 1955",
277fb9aa6f1SThomas Gleixner 		.matches = {
278fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
279fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1955"),
280fb9aa6f1SThomas Gleixner 		},
281fb9aa6f1SThomas Gleixner 	},
282fb9aa6f1SThomas Gleixner 	{
283fb9aa6f1SThomas Gleixner 		.callback = set_bf_sort,
284fb9aa6f1SThomas Gleixner 		.ident = "Dell PowerEdge 2900",
285fb9aa6f1SThomas Gleixner 		.matches = {
286fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
287fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2900"),
288fb9aa6f1SThomas Gleixner 		},
289fb9aa6f1SThomas Gleixner 	},
290fb9aa6f1SThomas Gleixner 	{
291fb9aa6f1SThomas Gleixner 		.callback = set_bf_sort,
292fb9aa6f1SThomas Gleixner 		.ident = "Dell PowerEdge 2950",
293fb9aa6f1SThomas Gleixner 		.matches = {
294fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
295fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2950"),
296fb9aa6f1SThomas Gleixner 		},
297fb9aa6f1SThomas Gleixner 	},
298fb9aa6f1SThomas Gleixner 	{
299fb9aa6f1SThomas Gleixner 		.callback = set_bf_sort,
300fb9aa6f1SThomas Gleixner 		.ident = "Dell PowerEdge R900",
301fb9aa6f1SThomas Gleixner 		.matches = {
302fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
303fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge R900"),
304fb9aa6f1SThomas Gleixner 		},
305fb9aa6f1SThomas Gleixner 	},
306fb9aa6f1SThomas Gleixner 	{
3079b373ed1SNarendra_K@Dell.com 		.callback = find_sort_method,
3089b373ed1SNarendra_K@Dell.com 		.ident = "Dell System",
3099b373ed1SNarendra_K@Dell.com 		.matches = {
3109b373ed1SNarendra_K@Dell.com 			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
3119b373ed1SNarendra_K@Dell.com 		},
3129b373ed1SNarendra_K@Dell.com 	},
3139b373ed1SNarendra_K@Dell.com 	{
314fb9aa6f1SThomas Gleixner 		.callback = set_bf_sort,
315fb9aa6f1SThomas Gleixner 		.ident = "HP ProLiant BL20p G3",
316fb9aa6f1SThomas Gleixner 		.matches = {
317fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
318fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL20p G3"),
319fb9aa6f1SThomas Gleixner 		},
320fb9aa6f1SThomas Gleixner 	},
321fb9aa6f1SThomas Gleixner 	{
322fb9aa6f1SThomas Gleixner 		.callback = set_bf_sort,
323fb9aa6f1SThomas Gleixner 		.ident = "HP ProLiant BL20p G4",
324fb9aa6f1SThomas Gleixner 		.matches = {
325fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
326fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL20p G4"),
327fb9aa6f1SThomas Gleixner 		},
328fb9aa6f1SThomas Gleixner 	},
329fb9aa6f1SThomas Gleixner 	{
330fb9aa6f1SThomas Gleixner 		.callback = set_bf_sort,
331fb9aa6f1SThomas Gleixner 		.ident = "HP ProLiant BL30p G1",
332fb9aa6f1SThomas Gleixner 		.matches = {
333fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
334fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL30p G1"),
335fb9aa6f1SThomas Gleixner 		},
336fb9aa6f1SThomas Gleixner 	},
337fb9aa6f1SThomas Gleixner 	{
338fb9aa6f1SThomas Gleixner 		.callback = set_bf_sort,
339fb9aa6f1SThomas Gleixner 		.ident = "HP ProLiant BL25p G1",
340fb9aa6f1SThomas Gleixner 		.matches = {
341fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
342fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL25p G1"),
343fb9aa6f1SThomas Gleixner 		},
344fb9aa6f1SThomas Gleixner 	},
345fb9aa6f1SThomas Gleixner 	{
346fb9aa6f1SThomas Gleixner 		.callback = set_bf_sort,
347fb9aa6f1SThomas Gleixner 		.ident = "HP ProLiant BL35p G1",
348fb9aa6f1SThomas Gleixner 		.matches = {
349fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
350fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL35p G1"),
351fb9aa6f1SThomas Gleixner 		},
352fb9aa6f1SThomas Gleixner 	},
353fb9aa6f1SThomas Gleixner 	{
354fb9aa6f1SThomas Gleixner 		.callback = set_bf_sort,
355fb9aa6f1SThomas Gleixner 		.ident = "HP ProLiant BL45p G1",
356fb9aa6f1SThomas Gleixner 		.matches = {
357fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
358fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL45p G1"),
359fb9aa6f1SThomas Gleixner 		},
360fb9aa6f1SThomas Gleixner 	},
361fb9aa6f1SThomas Gleixner 	{
362fb9aa6f1SThomas Gleixner 		.callback = set_bf_sort,
363fb9aa6f1SThomas Gleixner 		.ident = "HP ProLiant BL45p G2",
364fb9aa6f1SThomas Gleixner 		.matches = {
365fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
366fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL45p G2"),
367fb9aa6f1SThomas Gleixner 		},
368fb9aa6f1SThomas Gleixner 	},
369fb9aa6f1SThomas Gleixner 	{
370fb9aa6f1SThomas Gleixner 		.callback = set_bf_sort,
371fb9aa6f1SThomas Gleixner 		.ident = "HP ProLiant BL460c G1",
372fb9aa6f1SThomas Gleixner 		.matches = {
373fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
374fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL460c G1"),
375fb9aa6f1SThomas Gleixner 		},
376fb9aa6f1SThomas Gleixner 	},
377fb9aa6f1SThomas Gleixner 	{
378fb9aa6f1SThomas Gleixner 		.callback = set_bf_sort,
379fb9aa6f1SThomas Gleixner 		.ident = "HP ProLiant BL465c G1",
380fb9aa6f1SThomas Gleixner 		.matches = {
381fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
382fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL465c G1"),
383fb9aa6f1SThomas Gleixner 		},
384fb9aa6f1SThomas Gleixner 	},
385fb9aa6f1SThomas Gleixner 	{
386fb9aa6f1SThomas Gleixner 		.callback = set_bf_sort,
387fb9aa6f1SThomas Gleixner 		.ident = "HP ProLiant BL480c G1",
388fb9aa6f1SThomas Gleixner 		.matches = {
389fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
390fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL480c G1"),
391fb9aa6f1SThomas Gleixner 		},
392fb9aa6f1SThomas Gleixner 	},
393fb9aa6f1SThomas Gleixner 	{
394fb9aa6f1SThomas Gleixner 		.callback = set_bf_sort,
395fb9aa6f1SThomas Gleixner 		.ident = "HP ProLiant BL685c G1",
396fb9aa6f1SThomas Gleixner 		.matches = {
397fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
398fb9aa6f1SThomas Gleixner 			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL685c G1"),
399fb9aa6f1SThomas Gleixner 		},
400fb9aa6f1SThomas Gleixner 	},
4018f8ae1a7SMichal Schmidt 	{
4028f8ae1a7SMichal Schmidt 		.callback = set_bf_sort,
4038d64c781STony Camuso 		.ident = "HP ProLiant DL360",
4048f8ae1a7SMichal Schmidt 		.matches = {
4058f8ae1a7SMichal Schmidt 			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
4068d64c781STony Camuso 			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL360"),
4078f8ae1a7SMichal Schmidt 		},
4088f8ae1a7SMichal Schmidt 	},
4098f8ae1a7SMichal Schmidt 	{
4108f8ae1a7SMichal Schmidt 		.callback = set_bf_sort,
4118d64c781STony Camuso 		.ident = "HP ProLiant DL380",
4128f8ae1a7SMichal Schmidt 		.matches = {
4138f8ae1a7SMichal Schmidt 			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
4148d64c781STony Camuso 			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL380"),
4158f8ae1a7SMichal Schmidt 		},
4168f8ae1a7SMichal Schmidt 	},
4175b1ea82fSJuha Laiho #ifdef __i386__
4185b1ea82fSJuha Laiho 	{
4195b1ea82fSJuha Laiho 		.callback = assign_all_busses,
4205b1ea82fSJuha Laiho 		.ident = "Compaq EVO N800c",
4215b1ea82fSJuha Laiho 		.matches = {
4225b1ea82fSJuha Laiho 			DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
4235b1ea82fSJuha Laiho 			DMI_MATCH(DMI_PRODUCT_NAME, "EVO N800c"),
4245b1ea82fSJuha Laiho 		},
4255b1ea82fSJuha Laiho 	},
4265b1ea82fSJuha Laiho #endif
427c82bc5adSMichal Schmidt 	{
428c82bc5adSMichal Schmidt 		.callback = set_bf_sort,
429739db07fSJesse Barnes 		.ident = "HP ProLiant DL385 G2",
430c82bc5adSMichal Schmidt 		.matches = {
431c82bc5adSMichal Schmidt 			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
432739db07fSJesse Barnes 			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL385 G2"),
433c82bc5adSMichal Schmidt 		},
434c82bc5adSMichal Schmidt 	},
435c82bc5adSMichal Schmidt 	{
436c82bc5adSMichal Schmidt 		.callback = set_bf_sort,
437739db07fSJesse Barnes 		.ident = "HP ProLiant DL585 G2",
438c82bc5adSMichal Schmidt 		.matches = {
439c82bc5adSMichal Schmidt 			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
440739db07fSJesse Barnes 			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL585 G2"),
441c82bc5adSMichal Schmidt 		},
442c82bc5adSMichal Schmidt 	},
443284f5f9dSBjorn Helgaas 	{
444284f5f9dSBjorn Helgaas 		.callback = set_scan_all,
445284f5f9dSBjorn Helgaas 		.ident = "Stratus/NEC ftServer",
446284f5f9dSBjorn Helgaas 		.matches = {
4471278998fSMyron Stowe 			DMI_MATCH(DMI_SYS_VENDOR, "Stratus"),
4481278998fSMyron Stowe 			DMI_MATCH(DMI_PRODUCT_NAME, "ftServer"),
449284f5f9dSBjorn Helgaas 		},
450284f5f9dSBjorn Helgaas 	},
451fb9aa6f1SThomas Gleixner 	{}
452fb9aa6f1SThomas Gleixner };
453fb9aa6f1SThomas Gleixner 
4540df18ff3SYinghai Lu void __init dmi_check_pciprobe(void)
4550df18ff3SYinghai Lu {
4560df18ff3SYinghai Lu 	dmi_check_system(pciprobe_dmi_table);
4570df18ff3SYinghai Lu }
4580df18ff3SYinghai Lu 
459a18e3690SGreg Kroah-Hartman struct pci_bus *pcibios_scan_root(int busnum)
460fb9aa6f1SThomas Gleixner {
461fb9aa6f1SThomas Gleixner 	struct pci_bus *bus = NULL;
462fb9aa6f1SThomas Gleixner 
463fb9aa6f1SThomas Gleixner 	while ((bus = pci_find_next_bus(bus)) != NULL) {
464fb9aa6f1SThomas Gleixner 		if (bus->number == busnum) {
465fb9aa6f1SThomas Gleixner 			/* Already scanned */
466fb9aa6f1SThomas Gleixner 			return bus;
467fb9aa6f1SThomas Gleixner 		}
468fb9aa6f1SThomas Gleixner 	}
469fb9aa6f1SThomas Gleixner 
470c57ca65aSYinghai Lu 	return pci_scan_bus_on_node(busnum, &pci_root_ops,
471c57ca65aSYinghai Lu 					get_mp_bus_to_node(busnum));
472fb9aa6f1SThomas Gleixner }
473fb9aa6f1SThomas Gleixner 
47444de3395SAlex Nixon void __init pcibios_set_cache_line_size(void)
475fb9aa6f1SThomas Gleixner {
476fb9aa6f1SThomas Gleixner 	struct cpuinfo_x86 *c = &boot_cpu_data;
477fb9aa6f1SThomas Gleixner 
478fb9aa6f1SThomas Gleixner 	/*
47976b1a87bSDave Jones 	 * Set PCI cacheline size to that of the CPU if the CPU has reported it.
48076b1a87bSDave Jones 	 * (For older CPUs that don't support cpuid, we se it to 32 bytes
48176b1a87bSDave Jones 	 * It's also good for 386/486s (which actually have 16)
482fb9aa6f1SThomas Gleixner 	 * as quite a few PCI devices do not support smaller values.
483fb9aa6f1SThomas Gleixner 	 */
48476b1a87bSDave Jones 	if (c->x86_clflush_size > 0) {
48576b1a87bSDave Jones 		pci_dfl_cache_line_size = c->x86_clflush_size >> 2;
48676b1a87bSDave Jones 		printk(KERN_DEBUG "PCI: pci_cache_line_size set to %d bytes\n",
48776b1a87bSDave Jones 			pci_dfl_cache_line_size << 2);
48876b1a87bSDave Jones 	} else {
489ac1aa47bSJesse Barnes  		pci_dfl_cache_line_size = 32 >> 2;
49076b1a87bSDave Jones 		printk(KERN_DEBUG "PCI: Unknown cacheline size. Setting to 32 bytes\n");
49176b1a87bSDave Jones 	}
49244de3395SAlex Nixon }
493fb9aa6f1SThomas Gleixner 
49444de3395SAlex Nixon int __init pcibios_init(void)
49544de3395SAlex Nixon {
49644de3395SAlex Nixon 	if (!raw_pci_ops) {
49744de3395SAlex Nixon 		printk(KERN_WARNING "PCI: System does not support PCI\n");
49844de3395SAlex Nixon 		return 0;
49944de3395SAlex Nixon 	}
50044de3395SAlex Nixon 
50144de3395SAlex Nixon 	pcibios_set_cache_line_size();
502fb9aa6f1SThomas Gleixner 	pcibios_resource_survey();
503fb9aa6f1SThomas Gleixner 
504fb9aa6f1SThomas Gleixner 	if (pci_bf_sort >= pci_force_bf)
505fb9aa6f1SThomas Gleixner 		pci_sort_breadthfirst();
506fb9aa6f1SThomas Gleixner 	return 0;
507fb9aa6f1SThomas Gleixner }
508fb9aa6f1SThomas Gleixner 
50915fa325bSMyron Stowe char * __init pcibios_setup(char *str)
510fb9aa6f1SThomas Gleixner {
511fb9aa6f1SThomas Gleixner 	if (!strcmp(str, "off")) {
512fb9aa6f1SThomas Gleixner 		pci_probe = 0;
513fb9aa6f1SThomas Gleixner 		return NULL;
514fb9aa6f1SThomas Gleixner 	} else if (!strcmp(str, "bfsort")) {
515fb9aa6f1SThomas Gleixner 		pci_bf_sort = pci_force_bf;
516fb9aa6f1SThomas Gleixner 		return NULL;
517fb9aa6f1SThomas Gleixner 	} else if (!strcmp(str, "nobfsort")) {
518fb9aa6f1SThomas Gleixner 		pci_bf_sort = pci_force_nobf;
519fb9aa6f1SThomas Gleixner 		return NULL;
520fb9aa6f1SThomas Gleixner 	}
521fb9aa6f1SThomas Gleixner #ifdef CONFIG_PCI_BIOS
522fb9aa6f1SThomas Gleixner 	else if (!strcmp(str, "bios")) {
523fb9aa6f1SThomas Gleixner 		pci_probe = PCI_PROBE_BIOS;
524fb9aa6f1SThomas Gleixner 		return NULL;
525fb9aa6f1SThomas Gleixner 	} else if (!strcmp(str, "nobios")) {
526fb9aa6f1SThomas Gleixner 		pci_probe &= ~PCI_PROBE_BIOS;
527fb9aa6f1SThomas Gleixner 		return NULL;
528fb9aa6f1SThomas Gleixner 	} else if (!strcmp(str, "biosirq")) {
529fb9aa6f1SThomas Gleixner 		pci_probe |= PCI_BIOS_IRQ_SCAN;
530fb9aa6f1SThomas Gleixner 		return NULL;
531fb9aa6f1SThomas Gleixner 	} else if (!strncmp(str, "pirqaddr=", 9)) {
532fb9aa6f1SThomas Gleixner 		pirq_table_addr = simple_strtoul(str+9, NULL, 0);
533fb9aa6f1SThomas Gleixner 		return NULL;
534fb9aa6f1SThomas Gleixner 	}
535fb9aa6f1SThomas Gleixner #endif
536fb9aa6f1SThomas Gleixner #ifdef CONFIG_PCI_DIRECT
537fb9aa6f1SThomas Gleixner 	else if (!strcmp(str, "conf1")) {
538fb9aa6f1SThomas Gleixner 		pci_probe = PCI_PROBE_CONF1 | PCI_NO_CHECKS;
539fb9aa6f1SThomas Gleixner 		return NULL;
540fb9aa6f1SThomas Gleixner 	}
541fb9aa6f1SThomas Gleixner 	else if (!strcmp(str, "conf2")) {
542fb9aa6f1SThomas Gleixner 		pci_probe = PCI_PROBE_CONF2 | PCI_NO_CHECKS;
543fb9aa6f1SThomas Gleixner 		return NULL;
544fb9aa6f1SThomas Gleixner 	}
545fb9aa6f1SThomas Gleixner #endif
546fb9aa6f1SThomas Gleixner #ifdef CONFIG_PCI_MMCONFIG
547fb9aa6f1SThomas Gleixner 	else if (!strcmp(str, "nommconf")) {
548fb9aa6f1SThomas Gleixner 		pci_probe &= ~PCI_PROBE_MMCONF;
549fb9aa6f1SThomas Gleixner 		return NULL;
550fb9aa6f1SThomas Gleixner 	}
5515f0b2976SYinghai Lu 	else if (!strcmp(str, "check_enable_amd_mmconf")) {
5525f0b2976SYinghai Lu 		pci_probe |= PCI_CHECK_ENABLE_AMD_MMCONF;
5535f0b2976SYinghai Lu 		return NULL;
5545f0b2976SYinghai Lu 	}
555fb9aa6f1SThomas Gleixner #endif
556fb9aa6f1SThomas Gleixner 	else if (!strcmp(str, "noacpi")) {
557fb9aa6f1SThomas Gleixner 		acpi_noirq_set();
558fb9aa6f1SThomas Gleixner 		return NULL;
559fb9aa6f1SThomas Gleixner 	}
560fb9aa6f1SThomas Gleixner 	else if (!strcmp(str, "noearly")) {
561fb9aa6f1SThomas Gleixner 		pci_probe |= PCI_PROBE_NOEARLY;
562fb9aa6f1SThomas Gleixner 		return NULL;
563fb9aa6f1SThomas Gleixner 	}
564fb9aa6f1SThomas Gleixner 	else if (!strcmp(str, "usepirqmask")) {
565fb9aa6f1SThomas Gleixner 		pci_probe |= PCI_USE_PIRQ_MASK;
566fb9aa6f1SThomas Gleixner 		return NULL;
567fb9aa6f1SThomas Gleixner 	} else if (!strncmp(str, "irqmask=", 8)) {
568fb9aa6f1SThomas Gleixner 		pcibios_irq_mask = simple_strtol(str+8, NULL, 0);
569fb9aa6f1SThomas Gleixner 		return NULL;
570fb9aa6f1SThomas Gleixner 	} else if (!strncmp(str, "lastbus=", 8)) {
571fb9aa6f1SThomas Gleixner 		pcibios_last_bus = simple_strtol(str+8, NULL, 0);
572fb9aa6f1SThomas Gleixner 		return NULL;
573c5f9ee3dSH. Peter Anvin 	} else if (!strcmp(str, "rom")) {
574fb9aa6f1SThomas Gleixner 		pci_probe |= PCI_ASSIGN_ROMS;
575fb9aa6f1SThomas Gleixner 		return NULL;
576bb71ad88SGary Hade 	} else if (!strcmp(str, "norom")) {
577bb71ad88SGary Hade 		pci_probe |= PCI_NOASSIGN_ROMS;
578bb71ad88SGary Hade 		return NULL;
5797bd1c365SMike Habeck 	} else if (!strcmp(str, "nobar")) {
5807bd1c365SMike Habeck 		pci_probe |= PCI_NOASSIGN_BARS;
5817bd1c365SMike Habeck 		return NULL;
582fb9aa6f1SThomas Gleixner 	} else if (!strcmp(str, "assign-busses")) {
583fb9aa6f1SThomas Gleixner 		pci_probe |= PCI_ASSIGN_ALL_BUSSES;
584fb9aa6f1SThomas Gleixner 		return NULL;
585236e946bSLinus Torvalds 	} else if (!strcmp(str, "use_crs")) {
586236e946bSLinus Torvalds 		pci_probe |= PCI_USE__CRS;
58762f420f8SGary Hade 		return NULL;
5887bc5e3f2SBjorn Helgaas 	} else if (!strcmp(str, "nocrs")) {
5897bc5e3f2SBjorn Helgaas 		pci_probe |= PCI_ROOT_NO_CRS;
5907bc5e3f2SBjorn Helgaas 		return NULL;
591e3f2baebSYinghai Lu 	} else if (!strcmp(str, "earlydump")) {
592e3f2baebSYinghai Lu 		pci_early_dump_regs = 1;
593e3f2baebSYinghai Lu 		return NULL;
594fb9aa6f1SThomas Gleixner 	} else if (!strcmp(str, "routeirq")) {
595fb9aa6f1SThomas Gleixner 		pci_routeirq = 1;
596fb9aa6f1SThomas Gleixner 		return NULL;
59713a6ddb0SYinghai Lu 	} else if (!strcmp(str, "skip_isa_align")) {
59813a6ddb0SYinghai Lu 		pci_probe |= PCI_CAN_SKIP_ISA_ALIGN;
59913a6ddb0SYinghai Lu 		return NULL;
600a9322f64SStefan Assmann 	} else if (!strcmp(str, "noioapicquirk")) {
601a9322f64SStefan Assmann 		noioapicquirk = 1;
602a9322f64SStefan Assmann 		return NULL;
6039197979bSStefan Assmann 	} else if (!strcmp(str, "ioapicreroute")) {
6049197979bSStefan Assmann 		if (noioapicreroute != -1)
6059197979bSStefan Assmann 			noioapicreroute = 0;
6069197979bSStefan Assmann 		return NULL;
60741b9eb26SStefan Assmann 	} else if (!strcmp(str, "noioapicreroute")) {
60841b9eb26SStefan Assmann 		if (noioapicreroute != -1)
60941b9eb26SStefan Assmann 			noioapicreroute = 1;
61041b9eb26SStefan Assmann 		return NULL;
611fb9aa6f1SThomas Gleixner 	}
612fb9aa6f1SThomas Gleixner 	return str;
613fb9aa6f1SThomas Gleixner }
614fb9aa6f1SThomas Gleixner 
615fb9aa6f1SThomas Gleixner unsigned int pcibios_assign_all_busses(void)
616fb9aa6f1SThomas Gleixner {
617fb9aa6f1SThomas Gleixner 	return (pci_probe & PCI_ASSIGN_ALL_BUSSES) ? 1 : 0;
618fb9aa6f1SThomas Gleixner }
619fb9aa6f1SThomas Gleixner 
620f9a37be0SMatthew Garrett int pcibios_add_device(struct pci_dev *dev)
621f9a37be0SMatthew Garrett {
622f9a37be0SMatthew Garrett 	struct setup_data *data;
623f9a37be0SMatthew Garrett 	struct pci_setup_rom *rom;
624f9a37be0SMatthew Garrett 	u64 pa_data;
625f9a37be0SMatthew Garrett 
626f9a37be0SMatthew Garrett 	pa_data = boot_params.hdr.setup_data;
627f9a37be0SMatthew Garrett 	while (pa_data) {
62865694c5aSMatt Fleming 		data = ioremap(pa_data, sizeof(*rom));
62965694c5aSMatt Fleming 		if (!data)
63065694c5aSMatt Fleming 			return -ENOMEM;
631f9a37be0SMatthew Garrett 
632f9a37be0SMatthew Garrett 		if (data->type == SETUP_PCI) {
633f9a37be0SMatthew Garrett 			rom = (struct pci_setup_rom *)data;
634f9a37be0SMatthew Garrett 
635f9a37be0SMatthew Garrett 			if ((pci_domain_nr(dev->bus) == rom->segment) &&
636f9a37be0SMatthew Garrett 			    (dev->bus->number == rom->bus) &&
637f9a37be0SMatthew Garrett 			    (PCI_SLOT(dev->devfn) == rom->device) &&
638f9a37be0SMatthew Garrett 			    (PCI_FUNC(dev->devfn) == rom->function) &&
639f9a37be0SMatthew Garrett 			    (dev->vendor == rom->vendor) &&
640f9a37be0SMatthew Garrett 			    (dev->device == rom->devid)) {
641dbd3fc33SBjorn Helgaas 				dev->rom = pa_data +
642dbd3fc33SBjorn Helgaas 				      offsetof(struct pci_setup_rom, romdata);
643f9a37be0SMatthew Garrett 				dev->romlen = rom->pcilen;
644f9a37be0SMatthew Garrett 			}
645f9a37be0SMatthew Garrett 		}
646f9a37be0SMatthew Garrett 		pa_data = data->next;
64765694c5aSMatt Fleming 		iounmap(data);
648f9a37be0SMatthew Garrett 	}
649f9a37be0SMatthew Garrett 	return 0;
650f9a37be0SMatthew Garrett }
651f9a37be0SMatthew Garrett 
652fb9aa6f1SThomas Gleixner int pcibios_enable_device(struct pci_dev *dev, int mask)
653fb9aa6f1SThomas Gleixner {
654fb9aa6f1SThomas Gleixner 	int err;
655fb9aa6f1SThomas Gleixner 
656b81d988cSBjorn Helgaas 	if ((err = pci_enable_resources(dev, mask)) < 0)
657fb9aa6f1SThomas Gleixner 		return err;
658fb9aa6f1SThomas Gleixner 
65916cf0ebcSRafael J. Wysocki 	if (!pci_dev_msi_enabled(dev))
660fb9aa6f1SThomas Gleixner 		return pcibios_enable_irq(dev);
661fb9aa6f1SThomas Gleixner 	return 0;
662fb9aa6f1SThomas Gleixner }
663fb9aa6f1SThomas Gleixner 
664fb9aa6f1SThomas Gleixner void pcibios_disable_device (struct pci_dev *dev)
665fb9aa6f1SThomas Gleixner {
66616cf0ebcSRafael J. Wysocki 	if (!pci_dev_msi_enabled(dev) && pcibios_disable_irq)
667fb9aa6f1SThomas Gleixner 		pcibios_disable_irq(dev);
668fb9aa6f1SThomas Gleixner }
669fb9aa6f1SThomas Gleixner 
670642c92daSTaku Izumi int pci_ext_cfg_avail(void)
6710ef5f8f6SAndrew Patterson {
6720ef5f8f6SAndrew Patterson 	if (raw_pci_ext_ops)
6730ef5f8f6SAndrew Patterson 		return 1;
6740ef5f8f6SAndrew Patterson 	else
6750ef5f8f6SAndrew Patterson 		return 0;
6760ef5f8f6SAndrew Patterson }
6770ef5f8f6SAndrew Patterson 
678a18e3690SGreg Kroah-Hartman struct pci_bus *pci_scan_bus_on_node(int busno, struct pci_ops *ops, int node)
679fb9aa6f1SThomas Gleixner {
6802cd6975aSBjorn Helgaas 	LIST_HEAD(resources);
681fb9aa6f1SThomas Gleixner 	struct pci_bus *bus = NULL;
682fb9aa6f1SThomas Gleixner 	struct pci_sysdata *sd;
683fb9aa6f1SThomas Gleixner 
684fb9aa6f1SThomas Gleixner 	/*
685fb9aa6f1SThomas Gleixner 	 * Allocate per-root-bus (not per bus) arch-specific data.
686fb9aa6f1SThomas Gleixner 	 * TODO: leak; this memory is never freed.
687fb9aa6f1SThomas Gleixner 	 * It's arguable whether it's worth the trouble to care.
688fb9aa6f1SThomas Gleixner 	 */
689fb9aa6f1SThomas Gleixner 	sd = kzalloc(sizeof(*sd), GFP_KERNEL);
690fb9aa6f1SThomas Gleixner 	if (!sd) {
691fb9aa6f1SThomas Gleixner 		printk(KERN_ERR "PCI: OOM, skipping PCI bus %02x\n", busno);
692fb9aa6f1SThomas Gleixner 		return NULL;
693fb9aa6f1SThomas Gleixner 	}
694871d5f8dSYinghai Lu 	sd->node = node;
6952cd6975aSBjorn Helgaas 	x86_pci_root_bus_resources(busno, &resources);
696c57ca65aSYinghai Lu 	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busno);
6972cd6975aSBjorn Helgaas 	bus = pci_scan_root_bus(NULL, busno, ops, sd, &resources);
6982cd6975aSBjorn Helgaas 	if (!bus) {
6992cd6975aSBjorn Helgaas 		pci_free_resource_list(&resources);
700fb9aa6f1SThomas Gleixner 		kfree(sd);
7012cd6975aSBjorn Helgaas 	}
702fb9aa6f1SThomas Gleixner 
703fb9aa6f1SThomas Gleixner 	return bus;
704fb9aa6f1SThomas Gleixner }
705871d5f8dSYinghai Lu 
706a18e3690SGreg Kroah-Hartman struct pci_bus *pci_scan_bus_with_sysdata(int busno)
707871d5f8dSYinghai Lu {
708871d5f8dSYinghai Lu 	return pci_scan_bus_on_node(busno, &pci_root_ops, -1);
709871d5f8dSYinghai Lu }
7102547089cSJesse Barnes 
7112547089cSJesse Barnes /*
7122547089cSJesse Barnes  * NUMA info for PCI busses
7132547089cSJesse Barnes  *
7142547089cSJesse Barnes  * Early arch code is responsible for filling in reasonable values here.
7152547089cSJesse Barnes  * A node id of "-1" means "use current node".  In other words, if a bus
7162547089cSJesse Barnes  * has a -1 node id, it's not tightly coupled to any particular chunk
7172547089cSJesse Barnes  * of memory (as is the case on some Nehalem systems).
7182547089cSJesse Barnes  */
7192547089cSJesse Barnes #ifdef CONFIG_NUMA
7202547089cSJesse Barnes 
7212547089cSJesse Barnes #define BUS_NR 256
7222547089cSJesse Barnes 
7232547089cSJesse Barnes #ifdef CONFIG_X86_64
7242547089cSJesse Barnes 
7252547089cSJesse Barnes static int mp_bus_to_node[BUS_NR] = {
7262547089cSJesse Barnes 	[0 ... BUS_NR - 1] = -1
7272547089cSJesse Barnes };
7282547089cSJesse Barnes 
7292547089cSJesse Barnes void set_mp_bus_to_node(int busnum, int node)
7302547089cSJesse Barnes {
7312547089cSJesse Barnes 	if (busnum >= 0 &&  busnum < BUS_NR)
7322547089cSJesse Barnes 		mp_bus_to_node[busnum] = node;
7332547089cSJesse Barnes }
7342547089cSJesse Barnes 
7352547089cSJesse Barnes int get_mp_bus_to_node(int busnum)
7362547089cSJesse Barnes {
7372547089cSJesse Barnes 	int node = -1;
7382547089cSJesse Barnes 
7392547089cSJesse Barnes 	if (busnum < 0 || busnum > (BUS_NR - 1))
7402547089cSJesse Barnes 		return node;
7412547089cSJesse Barnes 
7422547089cSJesse Barnes 	node = mp_bus_to_node[busnum];
7432547089cSJesse Barnes 
7442547089cSJesse Barnes 	/*
7452547089cSJesse Barnes 	 * let numa_node_id to decide it later in dma_alloc_pages
7462547089cSJesse Barnes 	 * if there is no ram on that node
7472547089cSJesse Barnes 	 */
7482547089cSJesse Barnes 	if (node != -1 && !node_online(node))
7492547089cSJesse Barnes 		node = -1;
7502547089cSJesse Barnes 
7512547089cSJesse Barnes 	return node;
7522547089cSJesse Barnes }
7532547089cSJesse Barnes 
7542547089cSJesse Barnes #else /* CONFIG_X86_32 */
7552547089cSJesse Barnes 
75676baeebfSJesse Barnes static int mp_bus_to_node[BUS_NR] = {
7572547089cSJesse Barnes 	[0 ... BUS_NR - 1] = -1
7582547089cSJesse Barnes };
7592547089cSJesse Barnes 
7602547089cSJesse Barnes void set_mp_bus_to_node(int busnum, int node)
7612547089cSJesse Barnes {
7622547089cSJesse Barnes 	if (busnum >= 0 &&  busnum < BUS_NR)
7632547089cSJesse Barnes 	mp_bus_to_node[busnum] = (unsigned char) node;
7642547089cSJesse Barnes }
7652547089cSJesse Barnes 
7662547089cSJesse Barnes int get_mp_bus_to_node(int busnum)
7672547089cSJesse Barnes {
7682547089cSJesse Barnes 	int node;
7692547089cSJesse Barnes 
7702547089cSJesse Barnes 	if (busnum < 0 || busnum > (BUS_NR - 1))
7712547089cSJesse Barnes 		return 0;
7722547089cSJesse Barnes 	node = mp_bus_to_node[busnum];
7732547089cSJesse Barnes 	return node;
7742547089cSJesse Barnes }
7752547089cSJesse Barnes 
7762547089cSJesse Barnes #endif /* CONFIG_X86_32 */
7772547089cSJesse Barnes 
7782547089cSJesse Barnes #endif /* CONFIG_NUMA */
779