blob: 2b74a161d215dd71c598c51872cd5549d8502f0a [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;
Gary Hade62f420f2007-10-03 15:56:51 -070012 char *name;
13 unsigned int res_num;
14 struct resource *res;
Gary Hade62f420f2007-10-03 15:56:51 -070015 int busnum;
16};
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
Bjorn Helgaas4723d0f2010-09-22 11:09:19 -0600247static bool resource_contains(struct resource *res, resource_size_t point)
248{
249 if (res->start <= point && point <= res->end)
250 return true;
251 return false;
252}
253
Márton Németh6e33a852011-05-14 19:27:33 +0200254static void coalesce_windows(struct pci_root_info *info, unsigned long type)
Bjorn Helgaas4723d0f2010-09-22 11:09:19 -0600255{
256 int i, j;
257 struct resource *res1, *res2;
258
259 for (i = 0; i < info->res_num; i++) {
260 res1 = &info->res[i];
261 if (!(res1->flags & type))
262 continue;
263
264 for (j = i + 1; j < info->res_num; j++) {
265 res2 = &info->res[j];
266 if (!(res2->flags & type))
267 continue;
268
269 /*
270 * I don't like throwing away windows because then
271 * our resources no longer match the ACPI _CRS, but
272 * the kernel resource tree doesn't allow overlaps.
273 */
274 if (resource_contains(res1, res2->start) ||
275 resource_contains(res1, res2->end) ||
276 resource_contains(res2, res1->start) ||
277 resource_contains(res2, res1->end)) {
278 res1->start = min(res1->start, res2->start);
279 res1->end = max(res1->end, res2->end);
280 dev_info(&info->bridge->dev,
281 "host bridge window expanded to %pR; %pR ignored\n",
282 res1, res2);
283 res2->flags = 0;
284 }
285 }
286 }
287}
288
Yinghai Lu9a03d282012-04-02 18:31:53 -0700289static void add_resources(struct pci_root_info *info,
290 struct list_head *resources)
Bjorn Helgaas4723d0f2010-09-22 11:09:19 -0600291{
292 int i;
293 struct resource *res, *root, *conflict;
294
Bjorn Helgaas4723d0f2010-09-22 11:09:19 -0600295 coalesce_windows(info, IORESOURCE_MEM);
296 coalesce_windows(info, IORESOURCE_IO);
297
298 for (i = 0; i < info->res_num; i++) {
299 res = &info->res[i];
300
301 if (res->flags & IORESOURCE_MEM)
302 root = &iomem_resource;
303 else if (res->flags & IORESOURCE_IO)
304 root = &ioport_resource;
305 else
306 continue;
307
308 conflict = insert_resource_conflict(root, res);
309 if (conflict)
Bjorn Helgaas43d786e2011-07-02 10:47:12 -0600310 dev_info(&info->bridge->dev,
311 "ignoring host bridge window %pR (conflicts with %s %pR)\n",
312 res, conflict->name, conflict);
Bjorn Helgaas4723d0f2010-09-22 11:09:19 -0600313 else
Yinghai Lu9a03d282012-04-02 18:31:53 -0700314 pci_add_resource(resources, res);
Bjorn Helgaas4723d0f2010-09-22 11:09:19 -0600315 }
316}
317
Yinghai Lufd3b0c12012-04-02 18:31:53 -0700318static void free_pci_root_info_res(struct pci_root_info *info)
Yinghai Lubaa495d2012-04-02 18:31:53 -0700319{
320 kfree(info->name);
321 kfree(info->res);
Yinghai Lufd3b0c12012-04-02 18:31:53 -0700322 info->res = NULL;
323 info->res_num = 0;
324}
325
326static void __release_pci_root_info(struct pci_root_info *info)
327{
328 int i;
329 struct resource *res;
330
331 for (i = 0; i < info->res_num; i++) {
332 res = &info->res[i];
333
334 if (!res->parent)
335 continue;
336
337 if (!(res->flags & (IORESOURCE_MEM | IORESOURCE_IO)))
338 continue;
339
340 release_resource(res);
341 }
342
343 free_pci_root_info_res(info);
344
345 kfree(info);
346}
347static void release_pci_root_info(struct pci_host_bridge *bridge)
348{
349 struct pci_root_info *info = bridge->release_data;
350
351 __release_pci_root_info(info);
Yinghai Lubaa495d2012-04-02 18:31:53 -0700352}
353
Gary Hade62f420f2007-10-03 15:56:51 -0700354static void
Yinghai Lu9a03d282012-04-02 18:31:53 -0700355probe_pci_root_info(struct pci_root_info *info, struct acpi_device *device,
356 int busnum, int domain)
Gary Hade62f420f2007-10-03 15:56:51 -0700357{
Gary Hade62f420f2007-10-03 15:56:51 -0700358 size_t size;
359
Yinghai Lubaa495d2012-04-02 18:31:53 -0700360 info->bridge = device;
361 info->res_num = 0;
Gary Hade62f420f2007-10-03 15:56:51 -0700362 acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_resource,
Yinghai Lubaa495d2012-04-02 18:31:53 -0700363 info);
364 if (!info->res_num)
Gary Hade62f420f2007-10-03 15:56:51 -0700365 return;
366
Yinghai Lubaa495d2012-04-02 18:31:53 -0700367 size = sizeof(*info->res) * info->res_num;
Yinghai Lu9a03d282012-04-02 18:31:53 -0700368 info->res_num = 0;
Yinghai Lubaa495d2012-04-02 18:31:53 -0700369 info->res = kmalloc(size, GFP_KERNEL);
370 if (!info->res)
Bjorn Helgaas2cd69752011-10-28 16:28:14 -0600371 return;
Gary Hade62f420f2007-10-03 15:56:51 -0700372
Yinghai Lubaa495d2012-04-02 18:31:53 -0700373 info->name = kasprintf(GFP_KERNEL, "PCI Bus %04x:%02x", domain, busnum);
374 if (!info->name)
Yinghai Lu9a03d282012-04-02 18:31:53 -0700375 return;
Gary Hade62f420f2007-10-03 15:56:51 -0700376
Gary Hade62f420f2007-10-03 15:56:51 -0700377 acpi_walk_resources(device->handle, METHOD_NAME__CRS, setup_resource,
Yinghai Lubaa495d2012-04-02 18:31:53 -0700378 info);
Gary Hade62f420f2007-10-03 15:56:51 -0700379}
380
Bjorn Helgaas57283772010-03-11 12:20:11 -0700381struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382{
Bjorn Helgaas57283772010-03-11 12:20:11 -0700383 struct acpi_device *device = root->device;
Yinghai Lufd3b0c12012-04-02 18:31:53 -0700384 struct pci_root_info *info = NULL;
Bjorn Helgaas57283772010-03-11 12:20:11 -0700385 int domain = root->segment;
386 int busnum = root->secondary.start;
Bjorn Helgaas2cd69752011-10-28 16:28:14 -0600387 LIST_HEAD(resources);
Andi Kleen69e1a332005-09-12 18:49:24 +0200388 struct pci_bus *bus;
Muli Ben-Yehuda08f1c192007-07-22 00:23:39 +0300389 struct pci_sysdata *sd;
Yinghai Lu871d5f82008-02-19 03:20:09 -0800390 int node;
391#ifdef CONFIG_ACPI_NUMA
Muli Ben-Yehuda08f1c192007-07-22 00:23:39 +0300392 int pxm;
Yinghai Lu871d5f82008-02-19 03:20:09 -0800393#endif
Andi Kleen69e1a332005-09-12 18:49:24 +0200394
Jeff Garzika79e4192007-10-11 16:58:30 -0400395 if (domain && !pci_domains_supported) {
Bjorn Helgaas2a6bed82009-11-04 10:32:47 -0700396 printk(KERN_WARNING "pci_bus %04x:%02x: "
397 "ignored (multiple domains not supported)\n",
398 domain, busnum);
Jeff Garzika79e4192007-10-11 16:58:30 -0400399 return NULL;
400 }
401
Yinghai Lu871d5f82008-02-19 03:20:09 -0800402 node = -1;
403#ifdef CONFIG_ACPI_NUMA
404 pxm = acpi_get_pxm(device->handle);
405 if (pxm >= 0)
406 node = pxm_to_node(pxm);
407 if (node != -1)
408 set_mp_bus_to_node(busnum, node);
409 else
Yinghai Lu871d5f82008-02-19 03:20:09 -0800410#endif
Yinghai Lu871d5f82008-02-19 03:20:09 -0800411 node = get_mp_bus_to_node(busnum);
Yinghai Lub755de82008-02-20 12:41:52 -0800412
413 if (node != -1 && !node_online(node))
414 node = -1;
Yinghai Lu871d5f82008-02-19 03:20:09 -0800415
Muli Ben-Yehuda08f1c192007-07-22 00:23:39 +0300416 /* Allocate per-root-bus (not per bus) arch-specific data.
417 * TODO: leak; this memory is never freed.
418 * It's arguable whether it's worth the trouble to care.
419 */
420 sd = kzalloc(sizeof(*sd), GFP_KERNEL);
421 if (!sd) {
Bjorn Helgaas2a6bed82009-11-04 10:32:47 -0700422 printk(KERN_WARNING "pci_bus %04x:%02x: "
423 "ignored (out of memory)\n", domain, busnum);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424 return NULL;
425 }
426
Jeff Garzika79e4192007-10-11 16:58:30 -0400427 sd->domain = domain;
Yinghai Lu871d5f82008-02-19 03:20:09 -0800428 sd->node = node;
Yinghai Lufd3b0c12012-04-02 18:31:53 -0700429 info = kzalloc(sizeof(*info), GFP_KERNEL);
430 if (!info) {
431 kfree(sd);
432 printk(KERN_WARNING "pci_bus %04x:%02x: "
433 "ignored (out of memory)\n", domain, busnum);
434 return NULL;
435 }
yakui.zhao@intel.comb87e81e2008-04-15 14:34:49 -0700436 /*
437 * Maybe the desired pci bus has been already scanned. In such case
438 * it is unnecessary to scan the pci bus with the given domain,busnum.
439 */
440 bus = pci_find_bus(domain, busnum);
441 if (bus) {
442 /*
443 * If the desired bus exits, the content of bus->sysdata will
444 * be replaced by sd.
445 */
446 memcpy(bus->sysdata, sd, sizeof(*sd));
Yinghai Lufd3b0c12012-04-02 18:31:53 -0700447 kfree(info);
yakui.zhao@intel.comb87e81e2008-04-15 14:34:49 -0700448 kfree(sd);
Yinghai Lu626fdfe2009-06-24 20:00:12 -0700449 } else {
Yinghai Lufd3b0c12012-04-02 18:31:53 -0700450 probe_pci_root_info(info, device, busnum, domain);
Bjorn Helgaas316d86f2012-01-17 17:41:21 -0700451
452 /*
453 * _CRS with no apertures is normal, so only fall back to
454 * defaults or native bridge info if we're ignoring _CRS.
455 */
Yinghai Lu9a03d282012-04-02 18:31:53 -0700456 if (pci_use_crs)
Yinghai Lufd3b0c12012-04-02 18:31:53 -0700457 add_resources(info, &resources);
Yinghai Lu9a03d282012-04-02 18:31:53 -0700458 else {
Yinghai Lufd3b0c12012-04-02 18:31:53 -0700459 free_pci_root_info_res(info);
Bjorn Helgaas2cd69752011-10-28 16:28:14 -0600460 x86_pci_root_bus_resources(busnum, &resources);
Yinghai Lu9a03d282012-04-02 18:31:53 -0700461 }
Yinghai Lufd3b0c12012-04-02 18:31:53 -0700462
Bjorn Helgaas2cd69752011-10-28 16:28:14 -0600463 bus = pci_create_root_bus(NULL, busnum, &pci_root_ops, sd,
464 &resources);
Yinghai Lufd3b0c12012-04-02 18:31:53 -0700465 if (bus) {
Yinghai Lu626fdfe2009-06-24 20:00:12 -0700466 bus->subordinate = pci_scan_child_bus(bus);
Yinghai Lufd3b0c12012-04-02 18:31:53 -0700467 pci_set_host_bridge_release(
468 to_pci_host_bridge(bus->bridge),
469 release_pci_root_info, info);
470 } else {
Bjorn Helgaas2cd69752011-10-28 16:28:14 -0600471 pci_free_resource_list(&resources);
Yinghai Lufd3b0c12012-04-02 18:31:53 -0700472 __release_pci_root_info(info);
473 }
Yinghai Lu626fdfe2009-06-24 20:00:12 -0700474 }
Muli Ben-Yehuda08f1c192007-07-22 00:23:39 +0300475
Jon Masonb03e7492011-07-20 15:20:54 -0500476 /* After the PCI-E bus has been walked and all devices discovered,
477 * configure any settings of the fabric that might be necessary.
478 */
479 if (bus) {
480 struct pci_bus *child;
Shyam Iyer5307f6d2011-09-08 16:41:17 -0500481 list_for_each_entry(child, &bus->children, node) {
482 struct pci_dev *self = child->self;
483 if (!self)
484 continue;
485
486 pcie_bus_configure_settings(child, self->pcie_mpss);
487 }
Jon Masonb03e7492011-07-20 15:20:54 -0500488 }
489
Muli Ben-Yehuda08f1c192007-07-22 00:23:39 +0300490 if (!bus)
491 kfree(sd);
492
Yinghai Ludbb61522008-04-19 01:30:16 -0700493 if (bus && node != -1) {
Andi Kleen69e1a332005-09-12 18:49:24 +0200494#ifdef CONFIG_ACPI_NUMA
Yinghai Ludbb61522008-04-19 01:30:16 -0700495 if (pxm >= 0)
Bjorn Helgaas2b8c2ef2008-12-18 16:34:51 -0700496 dev_printk(KERN_DEBUG, &bus->dev,
497 "on NUMA node %d (pxm %d)\n", node, pxm);
Yinghai Ludbb61522008-04-19 01:30:16 -0700498#else
Bjorn Helgaas2b8c2ef2008-12-18 16:34:51 -0700499 dev_printk(KERN_DEBUG, &bus->dev, "on NUMA node %d\n", node);
Andi Kleen69e1a332005-09-12 18:49:24 +0200500#endif
Yinghai Ludbb61522008-04-19 01:30:16 -0700501 }
Gary Hade62f420f2007-10-03 15:56:51 -0700502
Andi Kleen69e1a332005-09-12 18:49:24 +0200503 return bus;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504}
505
Robert Richter8dd779b2008-07-02 22:50:29 +0200506int __init pci_acpi_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507{
508 struct pci_dev *dev = NULL;
509
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 if (acpi_noirq)
Thomas Gleixnerb72d0db2009-08-29 16:24:51 +0200511 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512
513 printk(KERN_INFO "PCI: Using ACPI for IRQ routing\n");
514 acpi_irq_penalty_init();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 pcibios_enable_irq = acpi_pci_irq_enable;
David Shaohua Li87bec662005-07-27 23:02:00 -0400516 pcibios_disable_irq = acpi_pci_irq_disable;
Thomas Gleixnerab3b3792009-08-29 17:47:33 +0200517 x86_init.pci.init_irq = x86_init_noop;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518
519 if (pci_routeirq) {
520 /*
521 * PCI IRQ routing is set up by pci_enable_device(), but we
522 * also do it here in case there are still broken drivers that
523 * don't use pci_enable_device().
524 */
525 printk(KERN_INFO "PCI: Routing PCI interrupts for all devices because \"pci=routeirq\" specified\n");
Hanna Linderfb37fb92005-11-06 23:39:36 -0800526 for_each_pci_dev(dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 acpi_pci_irq_enable(dev);
Bjorn Helgaas657472e92008-02-18 09:44:13 -0700528 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530 return 0;
531}