| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #include <linux/pci.h> | 
|  | 2 | #include <linux/acpi.h> | 
|  | 3 | #include <linux/init.h> | 
| Nick Piggin | b33fa1f | 2005-10-01 02:34:42 +1000 | [diff] [blame] | 4 | #include <linux/irq.h> | 
| Gary Hade | 036fff4 | 2007-10-03 15:56:14 -0700 | [diff] [blame] | 5 | #include <linux/dmi.h> | 
| Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame^] | 6 | #include <linux/slab.h> | 
| Andi Kleen | 69e1a33 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 7 | #include <asm/numa.h> | 
| Jaswinder Singh Rajput | 8248771 | 2008-12-27 18:32:28 +0530 | [diff] [blame] | 8 | #include <asm/pci_x86.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 |  | 
| Gary Hade | 62f420f | 2007-10-03 15:56:51 -0700 | [diff] [blame] | 10 | struct pci_root_info { | 
| Bjorn Helgaas | 42887b2 | 2009-10-06 15:33:49 -0600 | [diff] [blame] | 11 | struct acpi_device *bridge; | 
| Gary Hade | 62f420f | 2007-10-03 15:56:51 -0700 | [diff] [blame] | 12 | char *name; | 
|  | 13 | unsigned int res_num; | 
|  | 14 | struct resource *res; | 
|  | 15 | struct pci_bus *bus; | 
|  | 16 | int busnum; | 
|  | 17 | }; | 
|  | 18 |  | 
| Bjorn Helgaas | 7bc5e3f | 2010-02-23 10:24:41 -0700 | [diff] [blame] | 19 | static bool pci_use_crs = true; | 
|  | 20 |  | 
|  | 21 | static int __init set_use_crs(const struct dmi_system_id *id) | 
|  | 22 | { | 
|  | 23 | pci_use_crs = true; | 
|  | 24 | return 0; | 
|  | 25 | } | 
|  | 26 |  | 
|  | 27 | static const struct dmi_system_id pci_use_crs_table[] __initconst = { | 
|  | 28 | /* http://bugzilla.kernel.org/show_bug.cgi?id=14183 */ | 
|  | 29 | { | 
|  | 30 | .callback = set_use_crs, | 
|  | 31 | .ident = "IBM System x3800", | 
|  | 32 | .matches = { | 
|  | 33 | DMI_MATCH(DMI_SYS_VENDOR, "IBM"), | 
|  | 34 | DMI_MATCH(DMI_PRODUCT_NAME, "x3800"), | 
|  | 35 | }, | 
|  | 36 | }, | 
|  | 37 | {} | 
|  | 38 | }; | 
|  | 39 |  | 
|  | 40 | void __init pci_acpi_crs_quirks(void) | 
|  | 41 | { | 
|  | 42 | int year; | 
|  | 43 |  | 
|  | 44 | if (dmi_get_date(DMI_BIOS_DATE, &year, NULL, NULL) && year < 2008) | 
|  | 45 | pci_use_crs = false; | 
|  | 46 |  | 
|  | 47 | dmi_check_system(pci_use_crs_table); | 
|  | 48 |  | 
|  | 49 | /* | 
|  | 50 | * If the user specifies "pci=use_crs" or "pci=nocrs" explicitly, that | 
|  | 51 | * takes precedence over anything we figured out above. | 
|  | 52 | */ | 
|  | 53 | if (pci_probe & PCI_ROOT_NO_CRS) | 
|  | 54 | pci_use_crs = false; | 
|  | 55 | else if (pci_probe & PCI_USE__CRS) | 
|  | 56 | pci_use_crs = true; | 
|  | 57 |  | 
|  | 58 | printk(KERN_INFO "PCI: %s host bridge windows from ACPI; " | 
|  | 59 | "if necessary, use \"pci=%s\" and report a bug\n", | 
|  | 60 | pci_use_crs ? "Using" : "Ignoring", | 
|  | 61 | pci_use_crs ? "nocrs" : "use_crs"); | 
|  | 62 | } | 
|  | 63 |  | 
| Gary Hade | 62f420f | 2007-10-03 15:56:51 -0700 | [diff] [blame] | 64 | static acpi_status | 
|  | 65 | resource_to_addr(struct acpi_resource *resource, | 
|  | 66 | struct acpi_resource_address64 *addr) | 
|  | 67 | { | 
|  | 68 | acpi_status status; | 
|  | 69 |  | 
|  | 70 | status = acpi_resource_to_address64(resource, addr); | 
|  | 71 | if (ACPI_SUCCESS(status) && | 
|  | 72 | (addr->resource_type == ACPI_MEMORY_RANGE || | 
|  | 73 | addr->resource_type == ACPI_IO_RANGE) && | 
|  | 74 | addr->address_length > 0 && | 
|  | 75 | addr->producer_consumer == ACPI_PRODUCER) { | 
|  | 76 | return AE_OK; | 
|  | 77 | } | 
|  | 78 | return AE_ERROR; | 
|  | 79 | } | 
|  | 80 |  | 
|  | 81 | static acpi_status | 
|  | 82 | count_resource(struct acpi_resource *acpi_res, void *data) | 
|  | 83 | { | 
|  | 84 | struct pci_root_info *info = data; | 
|  | 85 | struct acpi_resource_address64 addr; | 
|  | 86 | acpi_status status; | 
|  | 87 |  | 
|  | 88 | status = resource_to_addr(acpi_res, &addr); | 
|  | 89 | if (ACPI_SUCCESS(status)) | 
|  | 90 | info->res_num++; | 
|  | 91 | return AE_OK; | 
|  | 92 | } | 
|  | 93 |  | 
| Bjorn Helgaas | 03db42a | 2009-11-04 10:39:18 -0700 | [diff] [blame] | 94 | static void | 
|  | 95 | align_resource(struct acpi_device *bridge, struct resource *res) | 
|  | 96 | { | 
|  | 97 | int align = (res->flags & IORESOURCE_MEM) ? 16 : 4; | 
|  | 98 |  | 
|  | 99 | /* | 
|  | 100 | * Host bridge windows are not BARs, but the decoders on the PCI side | 
|  | 101 | * that claim this address space have starting alignment and length | 
|  | 102 | * constraints, so fix any obvious BIOS goofs. | 
|  | 103 | */ | 
| Bjorn Helgaas | ea7f1b6 | 2009-11-05 11:17:11 -0600 | [diff] [blame] | 104 | if (!IS_ALIGNED(res->start, align)) { | 
| Bjorn Helgaas | 03db42a | 2009-11-04 10:39:18 -0700 | [diff] [blame] | 105 | dev_printk(KERN_DEBUG, &bridge->dev, | 
|  | 106 | "host bridge window %pR invalid; " | 
|  | 107 | "aligning start to %d-byte boundary\n", res, align); | 
|  | 108 | res->start &= ~(align - 1); | 
|  | 109 | } | 
| Bjorn Helgaas | ea7f1b6 | 2009-11-05 11:17:11 -0600 | [diff] [blame] | 110 | if (!IS_ALIGNED(res->end + 1, align)) { | 
| Bjorn Helgaas | 03db42a | 2009-11-04 10:39:18 -0700 | [diff] [blame] | 111 | dev_printk(KERN_DEBUG, &bridge->dev, | 
|  | 112 | "host bridge window %pR invalid; " | 
|  | 113 | "aligning end to %d-byte boundary\n", res, align); | 
| Bjorn Helgaas | ea7f1b6 | 2009-11-05 11:17:11 -0600 | [diff] [blame] | 114 | res->end = ALIGN(res->end, align) - 1; | 
| Bjorn Helgaas | 03db42a | 2009-11-04 10:39:18 -0700 | [diff] [blame] | 115 | } | 
|  | 116 | } | 
|  | 117 |  | 
| Gary Hade | 62f420f | 2007-10-03 15:56:51 -0700 | [diff] [blame] | 118 | static acpi_status | 
|  | 119 | setup_resource(struct acpi_resource *acpi_res, void *data) | 
|  | 120 | { | 
|  | 121 | struct pci_root_info *info = data; | 
|  | 122 | struct resource *res; | 
|  | 123 | struct acpi_resource_address64 addr; | 
|  | 124 | acpi_status status; | 
|  | 125 | unsigned long flags; | 
| Bjorn Helgaas | eb9fc8e | 2010-03-25 09:28:24 -0600 | [diff] [blame] | 126 | struct resource *root, *conflict; | 
| Bjorn Helgaas | d558b48 | 2010-03-25 09:28:30 -0600 | [diff] [blame] | 127 | u64 start, end, max_len; | 
| Yinghai Lu | 2cdb3f1 | 2009-06-24 19:01:19 -0700 | [diff] [blame] | 128 |  | 
| Gary Hade | 62f420f | 2007-10-03 15:56:51 -0700 | [diff] [blame] | 129 | status = resource_to_addr(acpi_res, &addr); | 
|  | 130 | if (!ACPI_SUCCESS(status)) | 
|  | 131 | return AE_OK; | 
|  | 132 |  | 
|  | 133 | if (addr.resource_type == ACPI_MEMORY_RANGE) { | 
|  | 134 | root = &iomem_resource; | 
|  | 135 | flags = IORESOURCE_MEM; | 
|  | 136 | if (addr.info.mem.caching == ACPI_PREFETCHABLE_MEMORY) | 
|  | 137 | flags |= IORESOURCE_PREFETCH; | 
|  | 138 | } else if (addr.resource_type == ACPI_IO_RANGE) { | 
|  | 139 | root = &ioport_resource; | 
|  | 140 | flags = IORESOURCE_IO; | 
|  | 141 | } else | 
|  | 142 | return AE_OK; | 
|  | 143 |  | 
| Bjorn Helgaas | d558b48 | 2010-03-25 09:28:30 -0600 | [diff] [blame] | 144 | max_len = addr.maximum - addr.minimum + 1; | 
|  | 145 | if (addr.address_length > max_len) { | 
|  | 146 | dev_printk(KERN_DEBUG, &info->bridge->dev, | 
|  | 147 | "host bridge window length %#llx doesn't fit in " | 
|  | 148 | "%#llx-%#llx, trimming\n", | 
|  | 149 | (unsigned long long) addr.address_length, | 
|  | 150 | (unsigned long long) addr.minimum, | 
|  | 151 | (unsigned long long) addr.maximum); | 
|  | 152 | addr.address_length = max_len; | 
|  | 153 | } | 
|  | 154 |  | 
| Yinghai Lu | 2cdb3f1 | 2009-06-24 19:01:19 -0700 | [diff] [blame] | 155 | start = addr.minimum + addr.translation_offset; | 
|  | 156 | end = start + addr.address_length - 1; | 
| Gary Hade | f9cde5f | 2009-05-27 12:41:44 -0700 | [diff] [blame] | 157 |  | 
| Yinghai Lu | 2cdb3f1 | 2009-06-24 19:01:19 -0700 | [diff] [blame] | 158 | res = &info->res[info->res_num]; | 
|  | 159 | res->name = info->name; | 
|  | 160 | res->flags = flags; | 
|  | 161 | res->start = start; | 
|  | 162 | res->end = end; | 
|  | 163 | res->child = NULL; | 
| Bjorn Helgaas | 03db42a | 2009-11-04 10:39:18 -0700 | [diff] [blame] | 164 | align_resource(info->bridge, res); | 
| Yinghai Lu | 2cdb3f1 | 2009-06-24 19:01:19 -0700 | [diff] [blame] | 165 |  | 
| Bjorn Helgaas | 7bc5e3f | 2010-02-23 10:24:41 -0700 | [diff] [blame] | 166 | if (!pci_use_crs) { | 
| Bjorn Helgaas | f1db6fd | 2009-11-04 10:39:13 -0700 | [diff] [blame] | 167 | dev_printk(KERN_DEBUG, &info->bridge->dev, | 
|  | 168 | "host bridge window %pR (ignored)\n", res); | 
|  | 169 | return AE_OK; | 
|  | 170 | } | 
|  | 171 |  | 
| Bjorn Helgaas | eb9fc8e | 2010-03-25 09:28:24 -0600 | [diff] [blame] | 172 | conflict = insert_resource_conflict(root, res); | 
|  | 173 | if (conflict) { | 
| Bjorn Helgaas | c7dabef | 2009-10-27 13:26:47 -0600 | [diff] [blame] | 174 | dev_err(&info->bridge->dev, | 
| Bjorn Helgaas | eb9fc8e | 2010-03-25 09:28:24 -0600 | [diff] [blame] | 175 | "address space collision: host bridge window %pR " | 
|  | 176 | "conflicts with %s %pR\n", | 
|  | 177 | res, conflict->name, conflict); | 
| Gary Hade | 62f420f | 2007-10-03 15:56:51 -0700 | [diff] [blame] | 178 | } else { | 
| Bjorn Helgaas | 2fe2abf | 2010-02-23 10:24:36 -0700 | [diff] [blame] | 179 | pci_bus_add_resource(info->bus, res, 0); | 
| Gary Hade | 62f420f | 2007-10-03 15:56:51 -0700 | [diff] [blame] | 180 | info->res_num++; | 
| Bjorn Helgaas | 42887b2 | 2009-10-06 15:33:49 -0600 | [diff] [blame] | 181 | if (addr.translation_offset) | 
| Bjorn Helgaas | c7dabef | 2009-10-27 13:26:47 -0600 | [diff] [blame] | 182 | dev_info(&info->bridge->dev, "host bridge window %pR " | 
| Bjorn Helgaas | 42887b2 | 2009-10-06 15:33:49 -0600 | [diff] [blame] | 183 | "(PCI address [%#llx-%#llx])\n", | 
|  | 184 | res, res->start - addr.translation_offset, | 
|  | 185 | res->end - addr.translation_offset); | 
|  | 186 | else | 
|  | 187 | dev_info(&info->bridge->dev, | 
| Bjorn Helgaas | c7dabef | 2009-10-27 13:26:47 -0600 | [diff] [blame] | 188 | "host bridge window %pR\n", res); | 
| Gary Hade | 62f420f | 2007-10-03 15:56:51 -0700 | [diff] [blame] | 189 | } | 
|  | 190 | return AE_OK; | 
|  | 191 | } | 
|  | 192 |  | 
|  | 193 | static void | 
| Gary Hade | 62f420f | 2007-10-03 15:56:51 -0700 | [diff] [blame] | 194 | get_current_resources(struct acpi_device *device, int busnum, | 
| Gary Hade | cb3576f | 2008-02-08 14:00:52 -0800 | [diff] [blame] | 195 | int domain, struct pci_bus *bus) | 
| Gary Hade | 62f420f | 2007-10-03 15:56:51 -0700 | [diff] [blame] | 196 | { | 
|  | 197 | struct pci_root_info info; | 
|  | 198 | size_t size; | 
|  | 199 |  | 
| Bjorn Helgaas | 7bc5e3f | 2010-02-23 10:24:41 -0700 | [diff] [blame] | 200 | if (pci_use_crs) | 
| Bjorn Helgaas | 2fe2abf | 2010-02-23 10:24:36 -0700 | [diff] [blame] | 201 | pci_bus_remove_resources(bus); | 
| Bjorn Helgaas | f1db6fd | 2009-11-04 10:39:13 -0700 | [diff] [blame] | 202 |  | 
| Bjorn Helgaas | 42887b2 | 2009-10-06 15:33:49 -0600 | [diff] [blame] | 203 | info.bridge = device; | 
| Gary Hade | 62f420f | 2007-10-03 15:56:51 -0700 | [diff] [blame] | 204 | info.bus = bus; | 
|  | 205 | info.res_num = 0; | 
|  | 206 | acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_resource, | 
|  | 207 | &info); | 
|  | 208 | if (!info.res_num) | 
|  | 209 | return; | 
|  | 210 |  | 
|  | 211 | size = sizeof(*info.res) * info.res_num; | 
|  | 212 | info.res = kmalloc(size, GFP_KERNEL); | 
|  | 213 | if (!info.res) | 
|  | 214 | goto res_alloc_fail; | 
|  | 215 |  | 
| Gary Hade | cb3576f | 2008-02-08 14:00:52 -0800 | [diff] [blame] | 216 | info.name = kmalloc(16, GFP_KERNEL); | 
| Gary Hade | 62f420f | 2007-10-03 15:56:51 -0700 | [diff] [blame] | 217 | if (!info.name) | 
|  | 218 | goto name_alloc_fail; | 
| Gary Hade | cb3576f | 2008-02-08 14:00:52 -0800 | [diff] [blame] | 219 | sprintf(info.name, "PCI Bus %04x:%02x", domain, busnum); | 
| Gary Hade | 62f420f | 2007-10-03 15:56:51 -0700 | [diff] [blame] | 220 |  | 
|  | 221 | info.res_num = 0; | 
|  | 222 | acpi_walk_resources(device->handle, METHOD_NAME__CRS, setup_resource, | 
|  | 223 | &info); | 
| Gary Hade | 62f420f | 2007-10-03 15:56:51 -0700 | [diff] [blame] | 224 |  | 
|  | 225 | return; | 
|  | 226 |  | 
|  | 227 | name_alloc_fail: | 
|  | 228 | kfree(info.res); | 
|  | 229 | res_alloc_fail: | 
|  | 230 | return; | 
|  | 231 | } | 
|  | 232 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int domain, int busnum) | 
|  | 234 | { | 
| Andi Kleen | 69e1a33 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 235 | struct pci_bus *bus; | 
| Muli Ben-Yehuda | 08f1c19 | 2007-07-22 00:23:39 +0300 | [diff] [blame] | 236 | struct pci_sysdata *sd; | 
| Yinghai Lu | 871d5f8 | 2008-02-19 03:20:09 -0800 | [diff] [blame] | 237 | int node; | 
|  | 238 | #ifdef CONFIG_ACPI_NUMA | 
| Muli Ben-Yehuda | 08f1c19 | 2007-07-22 00:23:39 +0300 | [diff] [blame] | 239 | int pxm; | 
| Yinghai Lu | 871d5f8 | 2008-02-19 03:20:09 -0800 | [diff] [blame] | 240 | #endif | 
| Andi Kleen | 69e1a33 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 241 |  | 
| Jeff Garzik | a79e419 | 2007-10-11 16:58:30 -0400 | [diff] [blame] | 242 | if (domain && !pci_domains_supported) { | 
| Bjorn Helgaas | 2a6bed8 | 2009-11-04 10:32:47 -0700 | [diff] [blame] | 243 | printk(KERN_WARNING "pci_bus %04x:%02x: " | 
|  | 244 | "ignored (multiple domains not supported)\n", | 
|  | 245 | domain, busnum); | 
| Jeff Garzik | a79e419 | 2007-10-11 16:58:30 -0400 | [diff] [blame] | 246 | return NULL; | 
|  | 247 | } | 
|  | 248 |  | 
| Yinghai Lu | 871d5f8 | 2008-02-19 03:20:09 -0800 | [diff] [blame] | 249 | node = -1; | 
|  | 250 | #ifdef CONFIG_ACPI_NUMA | 
|  | 251 | pxm = acpi_get_pxm(device->handle); | 
|  | 252 | if (pxm >= 0) | 
|  | 253 | node = pxm_to_node(pxm); | 
|  | 254 | if (node != -1) | 
|  | 255 | set_mp_bus_to_node(busnum, node); | 
|  | 256 | else | 
| Yinghai Lu | 871d5f8 | 2008-02-19 03:20:09 -0800 | [diff] [blame] | 257 | #endif | 
| Yinghai Lu | 871d5f8 | 2008-02-19 03:20:09 -0800 | [diff] [blame] | 258 | node = get_mp_bus_to_node(busnum); | 
| Yinghai Lu | b755de8 | 2008-02-20 12:41:52 -0800 | [diff] [blame] | 259 |  | 
|  | 260 | if (node != -1 && !node_online(node)) | 
|  | 261 | node = -1; | 
| Yinghai Lu | 871d5f8 | 2008-02-19 03:20:09 -0800 | [diff] [blame] | 262 |  | 
| Muli Ben-Yehuda | 08f1c19 | 2007-07-22 00:23:39 +0300 | [diff] [blame] | 263 | /* Allocate per-root-bus (not per bus) arch-specific data. | 
|  | 264 | * TODO: leak; this memory is never freed. | 
|  | 265 | * It's arguable whether it's worth the trouble to care. | 
|  | 266 | */ | 
|  | 267 | sd = kzalloc(sizeof(*sd), GFP_KERNEL); | 
|  | 268 | if (!sd) { | 
| Bjorn Helgaas | 2a6bed8 | 2009-11-04 10:32:47 -0700 | [diff] [blame] | 269 | printk(KERN_WARNING "pci_bus %04x:%02x: " | 
|  | 270 | "ignored (out of memory)\n", domain, busnum); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | return NULL; | 
|  | 272 | } | 
|  | 273 |  | 
| Jeff Garzik | a79e419 | 2007-10-11 16:58:30 -0400 | [diff] [blame] | 274 | sd->domain = domain; | 
| Yinghai Lu | 871d5f8 | 2008-02-19 03:20:09 -0800 | [diff] [blame] | 275 | sd->node = node; | 
| yakui.zhao@intel.com | b87e81e | 2008-04-15 14:34:49 -0700 | [diff] [blame] | 276 | /* | 
|  | 277 | * Maybe the desired pci bus has been already scanned. In such case | 
|  | 278 | * it is unnecessary to scan the pci bus with the given domain,busnum. | 
|  | 279 | */ | 
|  | 280 | bus = pci_find_bus(domain, busnum); | 
|  | 281 | if (bus) { | 
|  | 282 | /* | 
|  | 283 | * If the desired bus exits, the content of bus->sysdata will | 
|  | 284 | * be replaced by sd. | 
|  | 285 | */ | 
|  | 286 | memcpy(bus->sysdata, sd, sizeof(*sd)); | 
|  | 287 | kfree(sd); | 
| Yinghai Lu | 626fdfe | 2009-06-24 20:00:12 -0700 | [diff] [blame] | 288 | } else { | 
|  | 289 | bus = pci_create_bus(NULL, busnum, &pci_root_ops, sd); | 
|  | 290 | if (bus) { | 
| Bjorn Helgaas | f1db6fd | 2009-11-04 10:39:13 -0700 | [diff] [blame] | 291 | get_current_resources(device, busnum, domain, bus); | 
| Yinghai Lu | 626fdfe | 2009-06-24 20:00:12 -0700 | [diff] [blame] | 292 | bus->subordinate = pci_scan_child_bus(bus); | 
|  | 293 | } | 
|  | 294 | } | 
| Muli Ben-Yehuda | 08f1c19 | 2007-07-22 00:23:39 +0300 | [diff] [blame] | 295 |  | 
| Muli Ben-Yehuda | 08f1c19 | 2007-07-22 00:23:39 +0300 | [diff] [blame] | 296 | if (!bus) | 
|  | 297 | kfree(sd); | 
|  | 298 |  | 
| Yinghai Lu | dbb6152 | 2008-04-19 01:30:16 -0700 | [diff] [blame] | 299 | if (bus && node != -1) { | 
| Andi Kleen | 69e1a33 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 300 | #ifdef CONFIG_ACPI_NUMA | 
| Yinghai Lu | dbb6152 | 2008-04-19 01:30:16 -0700 | [diff] [blame] | 301 | if (pxm >= 0) | 
| Bjorn Helgaas | 2b8c2ef | 2008-12-18 16:34:51 -0700 | [diff] [blame] | 302 | dev_printk(KERN_DEBUG, &bus->dev, | 
|  | 303 | "on NUMA node %d (pxm %d)\n", node, pxm); | 
| Yinghai Lu | dbb6152 | 2008-04-19 01:30:16 -0700 | [diff] [blame] | 304 | #else | 
| Bjorn Helgaas | 2b8c2ef | 2008-12-18 16:34:51 -0700 | [diff] [blame] | 305 | dev_printk(KERN_DEBUG, &bus->dev, "on NUMA node %d\n", node); | 
| Andi Kleen | 69e1a33 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 306 | #endif | 
| Yinghai Lu | dbb6152 | 2008-04-19 01:30:16 -0700 | [diff] [blame] | 307 | } | 
| Gary Hade | 62f420f | 2007-10-03 15:56:51 -0700 | [diff] [blame] | 308 |  | 
| Andi Kleen | 69e1a33 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 309 | return bus; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | } | 
|  | 311 |  | 
| Robert Richter | 8dd779b | 2008-07-02 22:50:29 +0200 | [diff] [blame] | 312 | int __init pci_acpi_init(void) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | { | 
|  | 314 | struct pci_dev *dev = NULL; | 
|  | 315 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | if (acpi_noirq) | 
| Thomas Gleixner | b72d0db | 2009-08-29 16:24:51 +0200 | [diff] [blame] | 317 | return -ENODEV; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 |  | 
|  | 319 | printk(KERN_INFO "PCI: Using ACPI for IRQ routing\n"); | 
|  | 320 | acpi_irq_penalty_init(); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | pcibios_enable_irq = acpi_pci_irq_enable; | 
| David Shaohua Li | 87bec66 | 2005-07-27 23:02:00 -0400 | [diff] [blame] | 322 | pcibios_disable_irq = acpi_pci_irq_disable; | 
| Thomas Gleixner | ab3b379 | 2009-08-29 17:47:33 +0200 | [diff] [blame] | 323 | x86_init.pci.init_irq = x86_init_noop; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 |  | 
|  | 325 | if (pci_routeirq) { | 
|  | 326 | /* | 
|  | 327 | * PCI IRQ routing is set up by pci_enable_device(), but we | 
|  | 328 | * also do it here in case there are still broken drivers that | 
|  | 329 | * don't use pci_enable_device(). | 
|  | 330 | */ | 
|  | 331 | printk(KERN_INFO "PCI: Routing PCI interrupts for all devices because \"pci=routeirq\" specified\n"); | 
| Hanna Linder | fb37fb9 | 2005-11-06 23:39:36 -0800 | [diff] [blame] | 332 | for_each_pci_dev(dev) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | acpi_pci_irq_enable(dev); | 
| Bjorn Helgaas | 657472e9 | 2008-02-18 09:44:13 -0700 | [diff] [blame] | 334 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | return 0; | 
|  | 337 | } |