blob: 2bb885afe103c8d18a943021d070cd0af8f9cfd4 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#include <linux/pci.h>
2#include <linux/acpi.h>
3#include <linux/init.h>
Nick Pigginb33fa1f2005-10-01 02:34:42 +10004#include <linux/irq.h>
Gary Hade036fff42007-10-03 15:56:14 -07005#include <linux/dmi.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +09006#include <linux/slab.h>
Andi Kleen69e1a332005-09-12 18:49:24 +02007#include <asm/numa.h>
Jaswinder Singh Rajput82487712008-12-27 18:32:28 +05308#include <asm/pci_x86.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
Gary Hade62f420f2007-10-03 15:56:51 -070010struct pci_root_info {
Bjorn Helgaas42887b22009-10-06 15:33:49 -060011 struct acpi_device *bridge;
Yinghai Lufe057252012-04-02 18:31:53 -070012 char name[16];
Gary Hade62f420f2007-10-03 15:56:51 -070013 unsigned int res_num;
14 struct resource *res;
Yinghai Lu35cb05e2012-04-02 18:31:53 -070015 struct pci_sysdata sd;
Gary Hade62f420f2007-10-03 15:56:51 -070016};
17
Bjorn Helgaas7bc5e3f2010-02-23 10:24:41 -070018static bool pci_use_crs = true;
19
20static int __init set_use_crs(const struct dmi_system_id *id)
21{
22 pci_use_crs = true;
23 return 0;
24}
25
Dave Jones28c3c052011-12-30 14:37:05 -050026static int __init set_nouse_crs(const struct dmi_system_id *id)
27{
28 pci_use_crs = false;
29 return 0;
30}
31
Bjorn Helgaas7bc5e3f2010-02-23 10:24:41 -070032static const struct dmi_system_id pci_use_crs_table[] __initconst = {
33 /* http://bugzilla.kernel.org/show_bug.cgi?id=14183 */
34 {
35 .callback = set_use_crs,
36 .ident = "IBM System x3800",
37 .matches = {
38 DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
39 DMI_MATCH(DMI_PRODUCT_NAME, "x3800"),
40 },
41 },
Bjorn Helgaas24917622010-07-23 12:53:27 -060042 /* https://bugzilla.kernel.org/show_bug.cgi?id=16007 */
43 /* 2006 AMD HT/VIA system with two host bridges */
44 {
45 .callback = set_use_crs,
46 .ident = "ASRock ALiveSATA2-GLAN",
47 .matches = {
48 DMI_MATCH(DMI_PRODUCT_NAME, "ALiveSATA2-GLAN"),
49 },
50 },
Paul Menzel29cf7a302011-08-31 17:07:10 +020051 /* https://bugzilla.kernel.org/show_bug.cgi?id=30552 */
52 /* 2006 AMD HT/VIA system with two host bridges */
53 {
54 .callback = set_use_crs,
55 .ident = "ASUS M2V-MX SE",
56 .matches = {
57 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
58 DMI_MATCH(DMI_BOARD_NAME, "M2V-MX SE"),
59 DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
60 },
61 },
Jonathan Nieder841137172012-02-28 11:51:10 -070062 /* https://bugzilla.kernel.org/show_bug.cgi?id=42619 */
63 {
64 .callback = set_use_crs,
65 .ident = "MSI MS-7253",
66 .matches = {
67 DMI_MATCH(DMI_BOARD_VENDOR, "MICRO-STAR INTERNATIONAL CO., LTD"),
68 DMI_MATCH(DMI_BOARD_NAME, "MS-7253"),
69 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies, LTD"),
Jonathan Nieder841137172012-02-28 11:51:10 -070070 },
71 },
Dave Jones28c3c052011-12-30 14:37:05 -050072
Dave Jonese7027812012-01-04 11:33:12 -050073 /* Now for the blacklist.. */
74
75 /* https://bugzilla.redhat.com/show_bug.cgi?id=769657 */
76 {
77 .callback = set_nouse_crs,
78 .ident = "Dell Studio 1557",
79 .matches = {
80 DMI_MATCH(DMI_BOARD_VENDOR, "Dell Inc."),
81 DMI_MATCH(DMI_PRODUCT_NAME, "Studio 1557"),
82 DMI_MATCH(DMI_BIOS_VERSION, "A09"),
83 },
84 },
Dave Jones8b6a5af2012-01-04 11:30:52 -050085 /* https://bugzilla.redhat.com/show_bug.cgi?id=769657 */
86 {
87 .callback = set_nouse_crs,
88 .ident = "Thinkpad SL510",
89 .matches = {
90 DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"),
91 DMI_MATCH(DMI_BOARD_NAME, "2847DFG"),
92 DMI_MATCH(DMI_BIOS_VERSION, "6JET85WW (1.43 )"),
93 },
94 },
Bjorn Helgaas7bc5e3f2010-02-23 10:24:41 -070095 {}
96};
97
98void __init pci_acpi_crs_quirks(void)
99{
100 int year;
101
102 if (dmi_get_date(DMI_BIOS_DATE, &year, NULL, NULL) && year < 2008)
103 pci_use_crs = false;
104
105 dmi_check_system(pci_use_crs_table);
106
107 /*
108 * If the user specifies "pci=use_crs" or "pci=nocrs" explicitly, that
109 * takes precedence over anything we figured out above.
110 */
111 if (pci_probe & PCI_ROOT_NO_CRS)
112 pci_use_crs = false;
113 else if (pci_probe & PCI_USE__CRS)
114 pci_use_crs = true;
115
116 printk(KERN_INFO "PCI: %s host bridge windows from ACPI; "
117 "if necessary, use \"pci=%s\" and report a bug\n",
118 pci_use_crs ? "Using" : "Ignoring",
119 pci_use_crs ? "nocrs" : "use_crs");
120}
121
Gary Hade62f420f2007-10-03 15:56:51 -0700122static acpi_status
123resource_to_addr(struct acpi_resource *resource,
124 struct acpi_resource_address64 *addr)
125{
126 acpi_status status;
Bjorn Helgaas66528fd2010-04-20 13:52:41 -0600127 struct acpi_resource_memory24 *memory24;
128 struct acpi_resource_memory32 *memory32;
129 struct acpi_resource_fixed_memory32 *fixed_memory32;
Gary Hade62f420f2007-10-03 15:56:51 -0700130
Bjorn Helgaas66528fd2010-04-20 13:52:41 -0600131 memset(addr, 0, sizeof(*addr));
132 switch (resource->type) {
133 case ACPI_RESOURCE_TYPE_MEMORY24:
134 memory24 = &resource->data.memory24;
135 addr->resource_type = ACPI_MEMORY_RANGE;
136 addr->minimum = memory24->minimum;
137 addr->address_length = memory24->address_length;
138 addr->maximum = addr->minimum + addr->address_length - 1;
Gary Hade62f420f2007-10-03 15:56:51 -0700139 return AE_OK;
Bjorn Helgaas66528fd2010-04-20 13:52:41 -0600140 case ACPI_RESOURCE_TYPE_MEMORY32:
141 memory32 = &resource->data.memory32;
142 addr->resource_type = ACPI_MEMORY_RANGE;
143 addr->minimum = memory32->minimum;
144 addr->address_length = memory32->address_length;
145 addr->maximum = addr->minimum + addr->address_length - 1;
146 return AE_OK;
147 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
148 fixed_memory32 = &resource->data.fixed_memory32;
149 addr->resource_type = ACPI_MEMORY_RANGE;
150 addr->minimum = fixed_memory32->address;
151 addr->address_length = fixed_memory32->address_length;
152 addr->maximum = addr->minimum + addr->address_length - 1;
153 return AE_OK;
154 case ACPI_RESOURCE_TYPE_ADDRESS16:
155 case ACPI_RESOURCE_TYPE_ADDRESS32:
156 case ACPI_RESOURCE_TYPE_ADDRESS64:
157 status = acpi_resource_to_address64(resource, addr);
158 if (ACPI_SUCCESS(status) &&
159 (addr->resource_type == ACPI_MEMORY_RANGE ||
160 addr->resource_type == ACPI_IO_RANGE) &&
161 addr->address_length > 0) {
162 return AE_OK;
163 }
164 break;
Gary Hade62f420f2007-10-03 15:56:51 -0700165 }
166 return AE_ERROR;
167}
168
169static acpi_status
170count_resource(struct acpi_resource *acpi_res, void *data)
171{
172 struct pci_root_info *info = data;
173 struct acpi_resource_address64 addr;
174 acpi_status status;
175
176 status = resource_to_addr(acpi_res, &addr);
177 if (ACPI_SUCCESS(status))
178 info->res_num++;
179 return AE_OK;
180}
181
182static acpi_status
183setup_resource(struct acpi_resource *acpi_res, void *data)
184{
185 struct pci_root_info *info = data;
186 struct resource *res;
187 struct acpi_resource_address64 addr;
188 acpi_status status;
189 unsigned long flags;
Gary Hadeae5cd862011-11-14 15:42:16 -0800190 u64 start, orig_end, end;
Yinghai Lu2cdb3f12009-06-24 19:01:19 -0700191
Gary Hade62f420f2007-10-03 15:56:51 -0700192 status = resource_to_addr(acpi_res, &addr);
193 if (!ACPI_SUCCESS(status))
194 return AE_OK;
195
196 if (addr.resource_type == ACPI_MEMORY_RANGE) {
Gary Hade62f420f2007-10-03 15:56:51 -0700197 flags = IORESOURCE_MEM;
198 if (addr.info.mem.caching == ACPI_PREFETCHABLE_MEMORY)
199 flags |= IORESOURCE_PREFETCH;
200 } else if (addr.resource_type == ACPI_IO_RANGE) {
Gary Hade62f420f2007-10-03 15:56:51 -0700201 flags = IORESOURCE_IO;
202 } else
203 return AE_OK;
204
Yinghai Lu2cdb3f12009-06-24 19:01:19 -0700205 start = addr.minimum + addr.translation_offset;
Gary Hadeae5cd862011-11-14 15:42:16 -0800206 orig_end = end = addr.maximum + addr.translation_offset;
207
208 /* Exclude non-addressable range or non-addressable portion of range */
209 end = min(end, (u64)iomem_resource.end);
210 if (end <= start) {
211 dev_info(&info->bridge->dev,
212 "host bridge window [%#llx-%#llx] "
213 "(ignored, not CPU addressable)\n", start, orig_end);
214 return AE_OK;
215 } else if (orig_end != end) {
216 dev_info(&info->bridge->dev,
217 "host bridge window [%#llx-%#llx] "
218 "([%#llx-%#llx] ignored, not CPU addressable)\n",
219 start, orig_end, end + 1, orig_end);
220 }
Gary Hadef9cde5f2009-05-27 12:41:44 -0700221
Yinghai Lu2cdb3f12009-06-24 19:01:19 -0700222 res = &info->res[info->res_num];
223 res->name = info->name;
224 res->flags = flags;
225 res->start = start;
226 res->end = end;
227 res->child = NULL;
228
Bjorn Helgaas7bc5e3f2010-02-23 10:24:41 -0700229 if (!pci_use_crs) {
Bjorn Helgaasf1db6fd2009-11-04 10:39:13 -0700230 dev_printk(KERN_DEBUG, &info->bridge->dev,
231 "host bridge window %pR (ignored)\n", res);
232 return AE_OK;
233 }
234
Bjorn Helgaas4723d0f2010-09-22 11:09:19 -0600235 info->res_num++;
236 if (addr.translation_offset)
237 dev_info(&info->bridge->dev, "host bridge window %pR "
238 "(PCI address [%#llx-%#llx])\n",
239 res, res->start - addr.translation_offset,
240 res->end - addr.translation_offset);
241 else
242 dev_info(&info->bridge->dev, "host bridge window %pR\n", res);
243
Gary Hade62f420f2007-10-03 15:56:51 -0700244 return AE_OK;
245}
246
Márton Németh6e33a852011-05-14 19:27:33 +0200247static void coalesce_windows(struct pci_root_info *info, unsigned long type)
Bjorn Helgaas4723d0f2010-09-22 11:09:19 -0600248{
249 int i, j;
250 struct resource *res1, *res2;
251
252 for (i = 0; i < info->res_num; i++) {
253 res1 = &info->res[i];
254 if (!(res1->flags & type))
255 continue;
256
257 for (j = i + 1; j < info->res_num; j++) {
258 res2 = &info->res[j];
259 if (!(res2->flags & type))
260 continue;
261
262 /*
263 * I don't like throwing away windows because then
264 * our resources no longer match the ACPI _CRS, but
265 * the kernel resource tree doesn't allow overlaps.
266 */
Wei Yang74d24b22012-04-26 15:32:55 +0800267 if (resource_overlaps(res1, res2)) {
Bjorn Helgaas4723d0f2010-09-22 11:09:19 -0600268 res1->start = min(res1->start, res2->start);
269 res1->end = max(res1->end, res2->end);
270 dev_info(&info->bridge->dev,
271 "host bridge window expanded to %pR; %pR ignored\n",
272 res1, res2);
273 res2->flags = 0;
274 }
275 }
276 }
277}
278
Yinghai Lu9a03d282012-04-02 18:31:53 -0700279static void add_resources(struct pci_root_info *info,
280 struct list_head *resources)
Bjorn Helgaas4723d0f2010-09-22 11:09:19 -0600281{
282 int i;
283 struct resource *res, *root, *conflict;
284
Bjorn Helgaas4723d0f2010-09-22 11:09:19 -0600285 coalesce_windows(info, IORESOURCE_MEM);
286 coalesce_windows(info, IORESOURCE_IO);
287
288 for (i = 0; i < info->res_num; i++) {
289 res = &info->res[i];
290
291 if (res->flags & IORESOURCE_MEM)
292 root = &iomem_resource;
293 else if (res->flags & IORESOURCE_IO)
294 root = &ioport_resource;
295 else
296 continue;
297
298 conflict = insert_resource_conflict(root, res);
299 if (conflict)
Bjorn Helgaas43d786e2011-07-02 10:47:12 -0600300 dev_info(&info->bridge->dev,
301 "ignoring host bridge window %pR (conflicts with %s %pR)\n",
302 res, conflict->name, conflict);
Bjorn Helgaas4723d0f2010-09-22 11:09:19 -0600303 else
Yinghai Lu9a03d282012-04-02 18:31:53 -0700304 pci_add_resource(resources, res);
Bjorn Helgaas4723d0f2010-09-22 11:09:19 -0600305 }
306}
307
Yinghai Lufd3b0c12012-04-02 18:31:53 -0700308static void free_pci_root_info_res(struct pci_root_info *info)
Yinghai Lubaa495d2012-04-02 18:31:53 -0700309{
Yinghai Lubaa495d2012-04-02 18:31:53 -0700310 kfree(info->res);
Yinghai Lufd3b0c12012-04-02 18:31:53 -0700311 info->res = NULL;
312 info->res_num = 0;
313}
314
315static void __release_pci_root_info(struct pci_root_info *info)
316{
317 int i;
318 struct resource *res;
319
320 for (i = 0; i < info->res_num; i++) {
321 res = &info->res[i];
322
323 if (!res->parent)
324 continue;
325
326 if (!(res->flags & (IORESOURCE_MEM | IORESOURCE_IO)))
327 continue;
328
329 release_resource(res);
330 }
331
332 free_pci_root_info_res(info);
333
334 kfree(info);
335}
336static void release_pci_root_info(struct pci_host_bridge *bridge)
337{
338 struct pci_root_info *info = bridge->release_data;
339
340 __release_pci_root_info(info);
Yinghai Lubaa495d2012-04-02 18:31:53 -0700341}
342
Gary Hade62f420f2007-10-03 15:56:51 -0700343static void
Yinghai Lu9a03d282012-04-02 18:31:53 -0700344probe_pci_root_info(struct pci_root_info *info, struct acpi_device *device,
345 int busnum, int domain)
Gary Hade62f420f2007-10-03 15:56:51 -0700346{
Gary Hade62f420f2007-10-03 15:56:51 -0700347 size_t size;
348
Yinghai Lu5c1d81d2012-05-17 18:51:12 -0700349 sprintf(info->name, "PCI Bus %04x:%02x", domain, busnum);
Yinghai Lubaa495d2012-04-02 18:31:53 -0700350 info->bridge = device;
Yinghai Lu5c1d81d2012-05-17 18:51:12 -0700351
Yinghai Lubaa495d2012-04-02 18:31:53 -0700352 info->res_num = 0;
Gary Hade62f420f2007-10-03 15:56:51 -0700353 acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_resource,
Yinghai Lubaa495d2012-04-02 18:31:53 -0700354 info);
355 if (!info->res_num)
Gary Hade62f420f2007-10-03 15:56:51 -0700356 return;
357
Yinghai Lubaa495d2012-04-02 18:31:53 -0700358 size = sizeof(*info->res) * info->res_num;
Yinghai Lu9a03d282012-04-02 18:31:53 -0700359 info->res_num = 0;
Yinghai Lubaa495d2012-04-02 18:31:53 -0700360 info->res = kmalloc(size, GFP_KERNEL);
361 if (!info->res)
Bjorn Helgaas2cd69752011-10-28 16:28:14 -0600362 return;
Gary Hade62f420f2007-10-03 15:56:51 -0700363
Gary Hade62f420f2007-10-03 15:56:51 -0700364 acpi_walk_resources(device->handle, METHOD_NAME__CRS, setup_resource,
Yinghai Lubaa495d2012-04-02 18:31:53 -0700365 info);
Gary Hade62f420f2007-10-03 15:56:51 -0700366}
367
Bjorn Helgaas57283772010-03-11 12:20:11 -0700368struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369{
Bjorn Helgaas57283772010-03-11 12:20:11 -0700370 struct acpi_device *device = root->device;
Yinghai Lufd3b0c12012-04-02 18:31:53 -0700371 struct pci_root_info *info = NULL;
Bjorn Helgaas57283772010-03-11 12:20:11 -0700372 int domain = root->segment;
373 int busnum = root->secondary.start;
Bjorn Helgaas2cd69752011-10-28 16:28:14 -0600374 LIST_HEAD(resources);
Andi Kleen69e1a332005-09-12 18:49:24 +0200375 struct pci_bus *bus;
Muli Ben-Yehuda08f1c192007-07-22 00:23:39 +0300376 struct pci_sysdata *sd;
Yinghai Lu871d5f82008-02-19 03:20:09 -0800377 int node;
378#ifdef CONFIG_ACPI_NUMA
Muli Ben-Yehuda08f1c192007-07-22 00:23:39 +0300379 int pxm;
Yinghai Lu871d5f82008-02-19 03:20:09 -0800380#endif
Andi Kleen69e1a332005-09-12 18:49:24 +0200381
Jeff Garzika79e4192007-10-11 16:58:30 -0400382 if (domain && !pci_domains_supported) {
Bjorn Helgaas2a6bed82009-11-04 10:32:47 -0700383 printk(KERN_WARNING "pci_bus %04x:%02x: "
384 "ignored (multiple domains not supported)\n",
385 domain, busnum);
Jeff Garzika79e4192007-10-11 16:58:30 -0400386 return NULL;
387 }
388
Yinghai Lu871d5f82008-02-19 03:20:09 -0800389 node = -1;
390#ifdef CONFIG_ACPI_NUMA
391 pxm = acpi_get_pxm(device->handle);
392 if (pxm >= 0)
393 node = pxm_to_node(pxm);
394 if (node != -1)
395 set_mp_bus_to_node(busnum, node);
396 else
Yinghai Lu871d5f82008-02-19 03:20:09 -0800397#endif
Yinghai Lu871d5f82008-02-19 03:20:09 -0800398 node = get_mp_bus_to_node(busnum);
Yinghai Lub755de82008-02-20 12:41:52 -0800399
400 if (node != -1 && !node_online(node))
401 node = -1;
Yinghai Lu871d5f82008-02-19 03:20:09 -0800402
Yinghai Lu35cb05e2012-04-02 18:31:53 -0700403 info = kzalloc(sizeof(*info), GFP_KERNEL);
404 if (!info) {
Bjorn Helgaas2a6bed82009-11-04 10:32:47 -0700405 printk(KERN_WARNING "pci_bus %04x:%02x: "
406 "ignored (out of memory)\n", domain, busnum);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 return NULL;
408 }
409
Yinghai Lu35cb05e2012-04-02 18:31:53 -0700410 sd = &info->sd;
Jeff Garzika79e4192007-10-11 16:58:30 -0400411 sd->domain = domain;
Yinghai Lu871d5f82008-02-19 03:20:09 -0800412 sd->node = node;
yakui.zhao@intel.comb87e81e2008-04-15 14:34:49 -0700413 /*
414 * Maybe the desired pci bus has been already scanned. In such case
415 * it is unnecessary to scan the pci bus with the given domain,busnum.
416 */
417 bus = pci_find_bus(domain, busnum);
418 if (bus) {
419 /*
420 * If the desired bus exits, the content of bus->sysdata will
421 * be replaced by sd.
422 */
423 memcpy(bus->sysdata, sd, sizeof(*sd));
Yinghai Lufd3b0c12012-04-02 18:31:53 -0700424 kfree(info);
Yinghai Lu626fdfe2009-06-24 20:00:12 -0700425 } else {
Yinghai Lufd3b0c12012-04-02 18:31:53 -0700426 probe_pci_root_info(info, device, busnum, domain);
Bjorn Helgaas316d86f2012-01-17 17:41:21 -0700427
Yinghai Lu5c1d81d2012-05-17 18:51:12 -0700428 /* insert busn res at first */
429 pci_add_resource(&resources, &root->secondary);
Bjorn Helgaas316d86f2012-01-17 17:41:21 -0700430 /*
431 * _CRS with no apertures is normal, so only fall back to
432 * defaults or native bridge info if we're ignoring _CRS.
433 */
Yinghai Lu9a03d282012-04-02 18:31:53 -0700434 if (pci_use_crs)
Yinghai Lufd3b0c12012-04-02 18:31:53 -0700435 add_resources(info, &resources);
Yinghai Lu9a03d282012-04-02 18:31:53 -0700436 else {
Yinghai Lufd3b0c12012-04-02 18:31:53 -0700437 free_pci_root_info_res(info);
Bjorn Helgaas2cd69752011-10-28 16:28:14 -0600438 x86_pci_root_bus_resources(busnum, &resources);
Yinghai Lu9a03d282012-04-02 18:31:53 -0700439 }
Yinghai Lufd3b0c12012-04-02 18:31:53 -0700440
Bjorn Helgaas2cd69752011-10-28 16:28:14 -0600441 bus = pci_create_root_bus(NULL, busnum, &pci_root_ops, sd,
442 &resources);
Yinghai Lufd3b0c12012-04-02 18:31:53 -0700443 if (bus) {
Yinghai Lu5c1d81d2012-05-17 18:51:12 -0700444 pci_scan_child_bus(bus);
Yinghai Lufd3b0c12012-04-02 18:31:53 -0700445 pci_set_host_bridge_release(
446 to_pci_host_bridge(bus->bridge),
447 release_pci_root_info, info);
448 } else {
Bjorn Helgaas2cd69752011-10-28 16:28:14 -0600449 pci_free_resource_list(&resources);
Yinghai Lufd3b0c12012-04-02 18:31:53 -0700450 __release_pci_root_info(info);
451 }
Yinghai Lu626fdfe2009-06-24 20:00:12 -0700452 }
Muli Ben-Yehuda08f1c192007-07-22 00:23:39 +0300453
Jon Masonb03e7492011-07-20 15:20:54 -0500454 /* After the PCI-E bus has been walked and all devices discovered,
455 * configure any settings of the fabric that might be necessary.
456 */
457 if (bus) {
458 struct pci_bus *child;
Shyam Iyer5307f6d2011-09-08 16:41:17 -0500459 list_for_each_entry(child, &bus->children, node) {
460 struct pci_dev *self = child->self;
461 if (!self)
462 continue;
463
464 pcie_bus_configure_settings(child, self->pcie_mpss);
465 }
Jon Masonb03e7492011-07-20 15:20:54 -0500466 }
467
Yinghai Ludbb61522008-04-19 01:30:16 -0700468 if (bus && node != -1) {
Andi Kleen69e1a332005-09-12 18:49:24 +0200469#ifdef CONFIG_ACPI_NUMA
Yinghai Ludbb61522008-04-19 01:30:16 -0700470 if (pxm >= 0)
Bjorn Helgaas2b8c2ef2008-12-18 16:34:51 -0700471 dev_printk(KERN_DEBUG, &bus->dev,
472 "on NUMA node %d (pxm %d)\n", node, pxm);
Yinghai Ludbb61522008-04-19 01:30:16 -0700473#else
Bjorn Helgaas2b8c2ef2008-12-18 16:34:51 -0700474 dev_printk(KERN_DEBUG, &bus->dev, "on NUMA node %d\n", node);
Andi Kleen69e1a332005-09-12 18:49:24 +0200475#endif
Yinghai Ludbb61522008-04-19 01:30:16 -0700476 }
Gary Hade62f420f2007-10-03 15:56:51 -0700477
Andi Kleen69e1a332005-09-12 18:49:24 +0200478 return bus;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479}
480
Robert Richter8dd779b2008-07-02 22:50:29 +0200481int __init pci_acpi_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482{
483 struct pci_dev *dev = NULL;
484
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 if (acpi_noirq)
Thomas Gleixnerb72d0db2009-08-29 16:24:51 +0200486 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487
488 printk(KERN_INFO "PCI: Using ACPI for IRQ routing\n");
489 acpi_irq_penalty_init();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 pcibios_enable_irq = acpi_pci_irq_enable;
David Shaohua Li87bec662005-07-27 23:02:00 -0400491 pcibios_disable_irq = acpi_pci_irq_disable;
Thomas Gleixnerab3b3792009-08-29 17:47:33 +0200492 x86_init.pci.init_irq = x86_init_noop;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493
494 if (pci_routeirq) {
495 /*
496 * PCI IRQ routing is set up by pci_enable_device(), but we
497 * also do it here in case there are still broken drivers that
498 * don't use pci_enable_device().
499 */
500 printk(KERN_INFO "PCI: Routing PCI interrupts for all devices because \"pci=routeirq\" specified\n");
Hanna Linderfb37fb92005-11-06 23:39:36 -0800501 for_each_pci_dev(dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 acpi_pci_irq_enable(dev);
Bjorn Helgaas657472e92008-02-18 09:44:13 -0700503 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505 return 0;
506}