Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci

Pull PCI changes (including maintainer change) from Jesse Barnes:
"This pull has some good cleanups from Bjorn and Yinghai, as well as
some more code from Yinghai to better handle resource re-allocation
when enabled.

There's also a new initcall_debug feature from Arjan which will print
out quirk timing information to help identify slow quirks for fixing
or refinement (Yinghai sent in a few patches to do just that once the
new debug code landed).

Beyond that, I'm handing off PCI maintainership to Bjorn Helgaas.
He's been a core PCI and Linux contributor for some time now, and has
kindly volunteered to take over. I just don't feel I have the time
for PCI review and work that it deserves lately (I've taken on some
other projects), and haven't been as responsive lately as I'd like, so
I approached Bjorn asking if he'd like to manage things. He's going
to give it a try, and I'm confident he'll do at least as well as I
have in keeping the tree managed, patches flowing, and keeping things
stable."

Fix up some fairly trivial conflicts due to other cleanups (mips device
resource fixup cleanups clashing with list handling cleanup, ppc iseries
removal clashing with pci_probe_only cleanup etc)

* 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci: (112 commits)
PCI: Bjorn gets PCI hotplug too
PCI: hand PCI maintenance over to Bjorn Helgaas
unicore32/PCI: move <asm-generic/pci-bridge.h> include to asm/pci.h
sparc/PCI: convert devtree and arch-probed bus addresses to resource
powerpc/PCI: allow reallocation on PA Semi
powerpc/PCI: convert devtree bus addresses to resource
powerpc/PCI: compute I/O space bus-to-resource offset consistently
arm/PCI: don't export pci_flags
PCI: fix bridge I/O window bus-to-resource conversion
x86/PCI: add spinlock held check to 'pcibios_fwaddrmap_lookup()'
PCI / PCIe: Introduce command line option to disable ARI
PCI: make acpihp use __pci_remove_bus_device instead
PCI: export __pci_remove_bus_device
PCI: Rename pci_remove_behind_bridge to pci_stop_and_remove_behind_bridge
PCI: Rename pci_remove_bus_device to pci_stop_and_remove_bus_device
PCI: print out PCI device info along with duration
PCI: Move "pci reassigndev resource alignment" out of quirks.c
PCI: Use class for quirk for usb host controller fixup
PCI: Use class for quirk for ti816x class fixup
PCI: Use class for quirk for intel e100 interrupt fixup
...

+1654 -1706
+12 -2
Documentation/kernel-parameters.txt
··· 2147 2147 the default. 2148 2148 off: Turn ECRC off 2149 2149 on: Turn ECRC on. 2150 - realloc reallocate PCI resources if allocations done by BIOS 2151 - are erroneous. 2150 + realloc= Enable/disable reallocating PCI bridge resources 2151 + if allocations done by BIOS are too small to 2152 + accommodate resources required by all child 2153 + devices. 2154 + off: Turn realloc off 2155 + on: Turn realloc on 2156 + realloc same as realloc=on 2157 + noari do not use PCIe ARI. 2152 2158 2153 2159 pcie_aspm= [PCIE] Forcibly enable or disable PCIe Active State Power 2154 2160 Management. 2155 2161 off Disable ASPM. 2156 2162 force Enable ASPM even on devices that claim not to support it. 2157 2163 WARNING: Forcing ASPM on may cause system lockups. 2164 + 2165 + pcie_hp= [PCIE] PCI Express Hotplug driver options: 2166 + nomsi Do not use MSI for PCI Express Native Hotplug (this 2167 + makes all PCIe ports use INTx for hotplug services). 2158 2168 2159 2169 pcie_ports= [PCIE] PCIe ports handling: 2160 2170 auto Ask the BIOS whether or not to use native PCIe services
+2 -2
MAINTAINERS
··· 5120 5120 F: Documentation/powerpc/eeh-pci-error-recovery.txt 5121 5121 5122 5122 PCI SUBSYSTEM 5123 - M: Jesse Barnes <jbarnes@virtuousgeek.org> 5123 + M: Bjorn Helgaas <bhelgaas@google.com> 5124 5124 L: linux-pci@vger.kernel.org 5125 5125 Q: http://patchwork.kernel.org/project/linux-pci/list/ 5126 5126 T: git git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6.git ··· 5130 5130 F: include/linux/pci* 5131 5131 5132 5132 PCI HOTPLUG 5133 - M: Jesse Barnes <jbarnes@virtuousgeek.org> 5133 + M: Bjorn Helgaas <bhelgaas@google.com> 5134 5134 L: linux-pci@vger.kernel.org 5135 5135 S: Supported 5136 5136 F: drivers/pci/hotplug
+1 -6
arch/alpha/include/asm/pci.h
··· 7 7 #include <linux/dma-mapping.h> 8 8 #include <asm/scatterlist.h> 9 9 #include <asm/machvec.h> 10 + #include <asm-generic/pci-bridge.h> 10 11 11 12 /* 12 13 * The following structure is used to manage multiple PCI busses. ··· 99 98 { 100 99 return channel ? 15 : 14; 101 100 } 102 - 103 - extern void pcibios_resource_to_bus(struct pci_dev *, struct pci_bus_region *, 104 - struct resource *); 105 - 106 - extern void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 107 - struct pci_bus_region *region); 108 101 109 102 #define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index 110 103
+11 -75
arch/alpha/kernel/pci.c
··· 43 43 44 44 const char pci_hae0_name[] = "HAE0"; 45 45 46 - /* Indicate whether we respect the PCI setup left by console. */ 47 46 /* 48 - * Make this long-lived so that we know when shutting down 49 - * whether we probed only or not. 47 + * If PCI_PROBE_ONLY in pci_flags is set, we don't change any PCI resource 48 + * assignments. 50 49 */ 51 - int pci_probe_only; 52 50 53 51 /* 54 52 * The PCI controller list. ··· 213 215 struct pdev_srm_saved_conf *tmp; 214 216 static int printed = 0; 215 217 216 - if (!alpha_using_srm || pci_probe_only) 218 + if (!alpha_using_srm || pci_has_flag(PCI_PROBE_ONLY)) 217 219 return; 218 220 219 221 if (!printed) { ··· 240 242 struct pdev_srm_saved_conf *tmp; 241 243 242 244 /* No need to restore if probed only. */ 243 - if (pci_probe_only) 245 + if (pci_has_flag(PCI_PROBE_ONLY)) 244 246 return; 245 247 246 248 /* Restore SRM config. */ ··· 251 253 #endif 252 254 253 255 void __devinit 254 - pcibios_fixup_resource(struct resource *res, struct resource *root) 255 - { 256 - res->start += root->start; 257 - res->end += root->start; 258 - } 259 - 260 - void __devinit 261 - pcibios_fixup_device_resources(struct pci_dev *dev, struct pci_bus *bus) 262 - { 263 - /* Update device resources. */ 264 - struct pci_controller *hose = (struct pci_controller *)bus->sysdata; 265 - int i; 266 - 267 - for (i = 0; i < PCI_NUM_RESOURCES; i++) { 268 - if (!dev->resource[i].start) 269 - continue; 270 - if (dev->resource[i].flags & IORESOURCE_IO) 271 - pcibios_fixup_resource(&dev->resource[i], 272 - hose->io_space); 273 - else if (dev->resource[i].flags & IORESOURCE_MEM) 274 - pcibios_fixup_resource(&dev->resource[i], 275 - hose->mem_space); 276 - } 277 - } 278 - 279 - void __devinit 280 256 pcibios_fixup_bus(struct pci_bus *bus) 281 257 { 282 258 struct pci_dev *dev = bus->self; 283 259 284 - if (pci_probe_only && dev && 260 + if (pci_has_flag(PCI_PROBE_ONLY) && dev && 285 261 (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) { 286 262 pci_read_bridge_bases(bus); 287 - pcibios_fixup_device_resources(dev, bus); 288 263 } 289 264 290 265 list_for_each_entry(dev, &bus->devices, bus_list) { 291 266 pdev_save_srm_config(dev); 292 - if ((dev->class >> 8) != PCI_CLASS_BRIDGE_PCI) 293 - pcibios_fixup_device_resources(dev, bus); 294 267 } 295 268 } 296 269 ··· 270 301 { 271 302 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); 272 303 } 273 - 274 - void 275 - pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, 276 - struct resource *res) 277 - { 278 - struct pci_controller *hose = (struct pci_controller *)dev->sysdata; 279 - unsigned long offset = 0; 280 - 281 - if (res->flags & IORESOURCE_IO) 282 - offset = hose->io_space->start; 283 - else if (res->flags & IORESOURCE_MEM) 284 - offset = hose->mem_space->start; 285 - 286 - region->start = res->start - offset; 287 - region->end = res->end - offset; 288 - } 289 - 290 - void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 291 - struct pci_bus_region *region) 292 - { 293 - struct pci_controller *hose = (struct pci_controller *)dev->sysdata; 294 - unsigned long offset = 0; 295 - 296 - if (res->flags & IORESOURCE_IO) 297 - offset = hose->io_space->start; 298 - else if (res->flags & IORESOURCE_MEM) 299 - offset = hose->mem_space->start; 300 - 301 - res->start = region->start + offset; 302 - res->end = region->end + offset; 303 - } 304 - 305 - #ifdef CONFIG_HOTPLUG 306 - EXPORT_SYMBOL(pcibios_resource_to_bus); 307 - EXPORT_SYMBOL(pcibios_bus_to_resource); 308 - #endif 309 304 310 305 int 311 306 pcibios_enable_device(struct pci_dev *dev, int mask) ··· 307 374 308 375 if (r->parent || !r->start || !r->flags) 309 376 continue; 310 - if (pci_probe_only || (r->flags & IORESOURCE_PCI_FIXED)) 377 + if (pci_has_flag(PCI_PROBE_ONLY) || 378 + (r->flags & IORESOURCE_PCI_FIXED)) 311 379 pci_claim_resource(dev, i); 312 380 } 313 381 } ··· 350 416 hose->mem_space->end = end; 351 417 352 418 INIT_LIST_HEAD(&resources); 353 - pci_add_resource(&resources, hose->io_space); 354 - pci_add_resource(&resources, hose->mem_space); 419 + pci_add_resource_offset(&resources, hose->io_space, 420 + hose->io_space->start); 421 + pci_add_resource_offset(&resources, hose->mem_space, 422 + hose->mem_space->start); 355 423 356 424 bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops, 357 425 hose, &resources);
-3
arch/alpha/kernel/pci_impl.h
··· 173 173 extern struct pci_controller *hose_head, **hose_tail; 174 174 extern struct pci_controller *pci_isa_hose; 175 175 176 - /* Indicate that we trust the console to configure things properly. */ 177 - extern int pci_probe_only; 178 - 179 176 extern unsigned long alpha_agpgart_size; 180 177 181 178 extern void common_init_pci(void);
+2 -1
arch/alpha/kernel/sys_marvel.c
··· 384 384 385 385 marvel_register_error_handlers(); 386 386 387 - pci_probe_only = 1; 387 + /* Indicate that we trust the console to configure things properly */ 388 + pci_set_flags(PCI_PROBE_ONLY); 388 389 common_init_pci(); 389 390 locate_and_init_vga(NULL); 390 391
+2 -1
arch/alpha/kernel/sys_titan.c
··· 331 331 */ 332 332 titan_late_init(); 333 333 334 - pci_probe_only = 1; 334 + /* Indicate that we trust the console to configure things properly */ 335 + pci_set_flags(PCI_PROBE_ONLY); 335 336 common_init_pci(); 336 337 SMC669_Init(0); 337 338 locate_and_init_vga(NULL);
+2 -2
arch/arm/common/it8152.c
··· 299 299 goto err1; 300 300 } 301 301 302 - pci_add_resource(&sys->resources, &it8152_io); 303 - pci_add_resource(&sys->resources, &it8152_mem); 302 + pci_add_resource_offset(&sys->resources, &it8152_io, sys->io_offset); 303 + pci_add_resource_offset(&sys->resources, &it8152_mem, sys->mem_offset); 304 304 305 305 if (platform_notify || platform_notify_remove) { 306 306 printk(KERN_ERR "PCI: Can't use platform_notify\n");
-8
arch/arm/include/asm/pci.h
··· 57 57 extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, 58 58 enum pci_mmap_state mmap_state, int write_combine); 59 59 60 - extern void 61 - pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, 62 - struct resource *res); 63 - 64 - extern void 65 - pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 66 - struct pci_bus_region *region); 67 - 68 60 /* 69 61 * Dummy implementation; always return 0. 70 62 */
+7 -68
arch/arm/kernel/bios32.c
··· 16 16 #include <asm/mach/pci.h> 17 17 18 18 static int debug_pci; 19 - static int use_firmware; 20 19 21 20 /* 22 21 * We can't use pci_find_device() here since we are ··· 294 295 } 295 296 296 297 /* 297 - * Adjust the device resources from bus-centric to Linux-centric. 298 - */ 299 - static void __devinit 300 - pdev_fixup_device_resources(struct pci_sys_data *root, struct pci_dev *dev) 301 - { 302 - resource_size_t offset; 303 - int i; 304 - 305 - for (i = 0; i < PCI_NUM_RESOURCES; i++) { 306 - if (dev->resource[i].start == 0) 307 - continue; 308 - if (dev->resource[i].flags & IORESOURCE_MEM) 309 - offset = root->mem_offset; 310 - else 311 - offset = root->io_offset; 312 - 313 - dev->resource[i].start += offset; 314 - dev->resource[i].end += offset; 315 - } 316 - } 317 - 318 - /* 319 298 * pcibios_fixup_bus - Called after each bus is probed, 320 299 * but before its children are examined. 321 300 */ ··· 309 332 */ 310 333 list_for_each_entry(dev, &bus->devices, bus_list) { 311 334 u16 status; 312 - 313 - pdev_fixup_device_resources(root, dev); 314 335 315 336 pci_read_config_word(dev, PCI_STATUS, &status); 316 337 ··· 375 400 #endif 376 401 377 402 /* 378 - * Convert from Linux-centric to bus-centric addresses for bridge devices. 379 - */ 380 - void 381 - pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, 382 - struct resource *res) 383 - { 384 - struct pci_sys_data *root = dev->sysdata; 385 - unsigned long offset = 0; 386 - 387 - if (res->flags & IORESOURCE_IO) 388 - offset = root->io_offset; 389 - if (res->flags & IORESOURCE_MEM) 390 - offset = root->mem_offset; 391 - 392 - region->start = res->start - offset; 393 - region->end = res->end - offset; 394 - } 395 - EXPORT_SYMBOL(pcibios_resource_to_bus); 396 - 397 - void __devinit 398 - pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 399 - struct pci_bus_region *region) 400 - { 401 - struct pci_sys_data *root = dev->sysdata; 402 - unsigned long offset = 0; 403 - 404 - if (res->flags & IORESOURCE_IO) 405 - offset = root->io_offset; 406 - if (res->flags & IORESOURCE_MEM) 407 - offset = root->mem_offset; 408 - 409 - res->start = region->start + offset; 410 - res->end = region->end + offset; 411 - } 412 - EXPORT_SYMBOL(pcibios_bus_to_resource); 413 - 414 - /* 415 403 * Swizzle the device pin each time we cross a bridge. 416 404 * This might update pin and returns the slot number. 417 405 */ ··· 435 497 436 498 if (ret > 0) { 437 499 if (list_empty(&sys->resources)) { 438 - pci_add_resource(&sys->resources, 439 - &ioport_resource); 440 - pci_add_resource(&sys->resources, 441 - &iomem_resource); 500 + pci_add_resource_offset(&sys->resources, 501 + &ioport_resource, sys->io_offset); 502 + pci_add_resource_offset(&sys->resources, 503 + &iomem_resource, sys->mem_offset); 442 504 } 443 505 444 506 sys->bus = hw->scan(nr, sys); ··· 463 525 464 526 INIT_LIST_HEAD(&hw->buses); 465 527 528 + pci_add_flags(PCI_REASSIGN_ALL_RSRC); 466 529 if (hw->preinit) 467 530 hw->preinit(); 468 531 pcibios_init_hw(hw); ··· 475 536 list_for_each_entry(sys, &hw->buses, node) { 476 537 struct pci_bus *bus = sys->bus; 477 538 478 - if (!use_firmware) { 539 + if (!pci_has_flag(PCI_PROBE_ONLY)) { 479 540 /* 480 541 * Size the bridge windows. 481 542 */ ··· 512 573 debug_pci = 1; 513 574 return NULL; 514 575 } else if (!strcmp(str, "firmware")) { 515 - use_firmware = 1; 576 + pci_add_flags(PCI_PROBE_ONLY); 516 577 return NULL; 517 578 } 518 579 return str;
+2 -2
arch/arm/mach-cns3xxx/pcie.c
··· 155 155 BUG_ON(request_resource(&iomem_resource, res_io) || 156 156 request_resource(&iomem_resource, res_mem)); 157 157 158 - pci_add_resource(&sys->resources, res_io); 159 - pci_add_resource(&sys->resources, res_mem); 158 + pci_add_resource_offset(&sys->resources, res_io, sys->io_offset); 159 + pci_add_resource_offset(&sys->resources, res_mem, sys->mem_offset); 160 160 161 161 return 1; 162 162 }
+2 -2
arch/arm/mach-dove/pcie.c
··· 69 69 pp->res[0].flags = IORESOURCE_IO; 70 70 if (request_resource(&ioport_resource, &pp->res[0])) 71 71 panic("Request PCIe IO resource failed\n"); 72 - pci_add_resource(&sys->resources, &pp->res[0]); 72 + pci_add_resource_offset(&sys->resources, &pp->res[0], sys->io_offset); 73 73 74 74 /* 75 75 * IORESOURCE_MEM ··· 88 88 pp->res[1].flags = IORESOURCE_MEM; 89 89 if (request_resource(&iomem_resource, &pp->res[1])) 90 90 panic("Request PCIe Memory resource failed\n"); 91 - pci_add_resource(&sys->resources, &pp->res[1]); 91 + pci_add_resource_offset(&sys->resources, &pp->res[1], sys->mem_offset); 92 92 93 93 return 1; 94 94 }
+5 -3
arch/arm/mach-footbridge/dc21285.c
··· 275 275 allocate_resource(&iomem_resource, &res[0], 0x40000000, 276 276 0x80000000, 0xffffffff, 0x40000000, NULL, NULL); 277 277 278 - pci_add_resource(&sys->resources, &ioport_resource); 279 - pci_add_resource(&sys->resources, &res[0]); 280 - pci_add_resource(&sys->resources, &res[1]); 281 278 sys->mem_offset = DC21285_PCI_MEM; 279 + 280 + pci_add_resource_offset(&sys->resources, 281 + &ioport_resource, sys->io_offset); 282 + pci_add_resource_offset(&sys->resources, &res[0], sys->mem_offset); 283 + pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset); 282 284 283 285 return 1; 284 286 }
+4 -3
arch/arm/mach-integrator/pci_v3.c
··· 378 378 * the mem resource for this bus 379 379 * the prefetch mem resource for this bus 380 380 */ 381 - pci_add_resource(&sys->resources, &ioport_resource); 382 - pci_add_resource(&sys->resources, &non_mem); 383 - pci_add_resource(&sys->resources, &pre_mem); 381 + pci_add_resource_offset(&sys->resources, 382 + &ioport_resource, sys->io_offset); 383 + pci_add_resource_offset(&sys->resources, &non_mem, sys->mem_offset); 384 + pci_add_resource_offset(&sys->resources, &pre_mem, sys->mem_offset); 384 385 385 386 return 1; 386 387 }
+2 -2
arch/arm/mach-iop13xx/pci.c
··· 1084 1084 request_resource(&ioport_resource, &res[0]); 1085 1085 request_resource(&iomem_resource, &res[1]); 1086 1086 1087 - pci_add_resource(&sys->resources, &res[0]); 1088 - pci_add_resource(&sys->resources, &res[1]); 1087 + pci_add_resource_offset(&sys->resources, &res[0], sys->io_offset); 1088 + pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset); 1089 1089 1090 1090 return 1; 1091 1091 }
+2 -2
arch/arm/mach-ixp2000/ixdp2400.c
··· 134 134 135 135 if (ixdp2x00_master_npu()) { 136 136 dev = pci_get_bus_and_slot(1, IXDP2400_SLAVE_ENET_DEVFN); 137 - pci_remove_bus_device(dev); 137 + pci_stop_and_remove_bus_device(dev); 138 138 pci_dev_put(dev); 139 139 } else { 140 140 dev = pci_get_bus_and_slot(1, IXDP2400_MASTER_ENET_DEVFN); 141 - pci_remove_bus_device(dev); 141 + pci_stop_and_remove_bus_device(dev); 142 142 pci_dev_put(dev); 143 143 144 144 ixdp2x00_slave_pci_postinit();
+2 -2
arch/arm/mach-ixp2000/ixdp2800.c
··· 262 262 pci_common_init(&ixdp2800_pci); 263 263 if (ixdp2x00_master_npu()) { 264 264 dev = pci_get_bus_and_slot(1, IXDP2800_SLAVE_ENET_DEVFN); 265 - pci_remove_bus_device(dev); 265 + pci_stop_and_remove_bus_device(dev); 266 266 pci_dev_put(dev); 267 267 268 268 ixdp2800_master_enable_slave(); 269 269 ixdp2800_master_wait_for_slave_bus_scan(); 270 270 } else { 271 271 dev = pci_get_bus_and_slot(1, IXDP2800_MASTER_ENET_DEVFN); 272 - pci_remove_bus_device(dev); 272 + pci_stop_and_remove_bus_device(dev); 273 273 pci_dev_put(dev); 274 274 } 275 275 }
+2 -2
arch/arm/mach-ixp2000/ixdp2x00.c
··· 239 239 * Remove PMC device is there is one 240 240 */ 241 241 if((dev = pci_get_bus_and_slot(1, IXDP2X00_PMC_DEVFN))) { 242 - pci_remove_bus_device(dev); 242 + pci_stop_and_remove_bus_device(dev); 243 243 pci_dev_put(dev); 244 244 } 245 245 246 246 dev = pci_get_bus_and_slot(0, IXDP2X00_21555_DEVFN); 247 - pci_remove_bus_device(dev); 247 + pci_stop_and_remove_bus_device(dev); 248 248 pci_dev_put(dev); 249 249 } 250 250
+4 -2
arch/arm/mach-ixp2000/pci.c
··· 243 243 if (nr >= 1) 244 244 return 0; 245 245 246 - pci_add_resource(&sys->resources, &ixp2000_pci_io_space); 247 - pci_add_resource(&sys->resources, &ixp2000_pci_mem_space); 246 + pci_add_resource_offset(&sys->resources, 247 + &ixp2000_pci_io_space, sys->io_offset); 248 + pci_add_resource_offset(&sys->resources, 249 + &ixp2000_pci_mem_space, sys->mem_offset); 248 250 249 251 return 1; 250 252 }
+4 -2
arch/arm/mach-ixp23xx/pci.c
··· 281 281 if (nr >= 1) 282 282 return 0; 283 283 284 - pci_add_resource(&sys->resources, &ixp23xx_pci_io_space); 285 - pci_add_resource(&sys->resources, &ixp23xx_pci_mem_space); 284 + pci_add_resource_offset(&sys->resources, 285 + &ixp23xx_pci_io_space, sys->io_offset); 286 + pci_add_resource_offset(&sys->resources, 287 + &ixp23xx_pci_mem_space, sys->mem_offset); 286 288 287 289 return 1; 288 290 }
+2 -2
arch/arm/mach-ixp4xx/common-pci.c
··· 472 472 request_resource(&ioport_resource, &res[0]); 473 473 request_resource(&iomem_resource, &res[1]); 474 474 475 - pci_add_resource(&sys->resources, &res[0]); 476 - pci_add_resource(&sys->resources, &res[1]); 475 + pci_add_resource_offset(&sys->resources, &res[0], sys->io_offset); 476 + pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset); 477 477 478 478 platform_notify = ixp4xx_pci_platform_notify; 479 479 platform_notify_remove = ixp4xx_pci_platform_notify_remove;
+2 -2
arch/arm/mach-kirkwood/pcie.c
··· 198 198 if (request_resource(&iomem_resource, &pp->res[1])) 199 199 panic("Request PCIe%d Memory resource failed\n", index); 200 200 201 - pci_add_resource(&sys->resources, &pp->res[0]); 202 - pci_add_resource(&sys->resources, &pp->res[1]); 203 201 sys->io_offset = 0; 202 + pci_add_resource_offset(&sys->resources, &pp->res[0], sys->io_offset); 203 + pci_add_resource_offset(&sys->resources, &pp->res[1], sys->mem_offset); 204 204 205 205 /* 206 206 * Generic PCIe unit setup.
+2 -2
arch/arm/mach-ks8695/pci.c
··· 169 169 request_resource(&iomem_resource, &pci_mem); 170 170 request_resource(&ioport_resource, &pci_io); 171 171 172 - pci_add_resource(&sys->resources, &pci_io); 173 - pci_add_resource(&sys->resources, &pci_mem); 172 + pci_add_resource_offset(&sys->resources, &pci_io, sys->io_offset); 173 + pci_add_resource_offset(&sys->resources, &pci_mem, sys->mem_offset); 174 174 175 175 /* Assign and enable processor bridge */ 176 176 ks8695_local_writeconfig(PCI_BASE_ADDRESS_0, KS8695_PCIMEM_PA);
+2 -2
arch/arm/mach-mv78xx0/pcie.c
··· 155 155 orion_pcie_set_local_bus_nr(pp->base, sys->busnr); 156 156 orion_pcie_setup(pp->base); 157 157 158 - pci_add_resource(&sys->resources, &pp->res[0]); 159 - pci_add_resource(&sys->resources, &pp->res[1]); 158 + pci_add_resource_offset(&sys->resources, &pp->res[0], sys->io_offset); 159 + pci_add_resource_offset(&sys->resources, &pp->res[1], sys->mem_offset); 160 160 161 161 return 1; 162 162 }
+6 -8
arch/arm/mach-orion5x/pci.c
··· 171 171 /* 172 172 * IORESOURCE_IO 173 173 */ 174 + sys->io_offset = 0; 174 175 res[0].name = "PCIe I/O Space"; 175 176 res[0].flags = IORESOURCE_IO; 176 177 res[0].start = ORION5X_PCIE_IO_BUS_BASE; 177 178 res[0].end = res[0].start + ORION5X_PCIE_IO_SIZE - 1; 178 179 if (request_resource(&ioport_resource, &res[0])) 179 180 panic("Request PCIe IO resource failed\n"); 180 - pci_add_resource(&sys->resources, &res[0]); 181 + pci_add_resource_offset(&sys->resources, &res[0], sys->io_offset); 181 182 182 183 /* 183 184 * IORESOURCE_MEM ··· 189 188 res[1].end = res[1].start + ORION5X_PCIE_MEM_SIZE - 1; 190 189 if (request_resource(&iomem_resource, &res[1])) 191 190 panic("Request PCIe Memory resource failed\n"); 192 - pci_add_resource(&sys->resources, &res[1]); 193 - 194 - sys->io_offset = 0; 191 + pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset); 195 192 196 193 return 1; 197 194 } ··· 498 499 /* 499 500 * IORESOURCE_IO 500 501 */ 502 + sys->io_offset = 0; 501 503 res[0].name = "PCI I/O Space"; 502 504 res[0].flags = IORESOURCE_IO; 503 505 res[0].start = ORION5X_PCI_IO_BUS_BASE; 504 506 res[0].end = res[0].start + ORION5X_PCI_IO_SIZE - 1; 505 507 if (request_resource(&ioport_resource, &res[0])) 506 508 panic("Request PCI IO resource failed\n"); 507 - pci_add_resource(&sys->resources, &res[0]); 509 + pci_add_resource_offset(&sys->resources, &res[0], sys->io_offset); 508 510 509 511 /* 510 512 * IORESOURCE_MEM ··· 516 516 res[1].end = res[1].start + ORION5X_PCI_MEM_SIZE - 1; 517 517 if (request_resource(&iomem_resource, &res[1])) 518 518 panic("Request PCI Memory resource failed\n"); 519 - pci_add_resource(&sys->resources, &res[1]); 520 - 521 - sys->io_offset = 0; 519 + pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset); 522 520 523 521 return 1; 524 522 }
+5 -3
arch/arm/mach-sa1100/pci-nanoengine.c
··· 244 244 printk(KERN_ERR "PCI: unable to allocate prefetchable\n"); 245 245 return -EBUSY; 246 246 } 247 - pci_add_resource(&sys->resources, &pci_io_ports); 248 - pci_add_resource(&sys->resources, &pci_non_prefetchable_memory); 249 - pci_add_resource(&sys->resources, &pci_prefetchable_memory); 247 + pci_add_resource_offset(&sys->resources, &pci_io_ports, sys->io_offset); 248 + pci_add_resource_offset(&sys->resources, 249 + &pci_non_prefetchable_memory, sys->mem_offset); 250 + pci_add_resource_offset(&sys->resources, 251 + &pci_prefetchable_memory, sys->mem_offset); 250 252 251 253 return 1; 252 254 }
+3 -3
arch/arm/mach-tegra/pcie.c
··· 408 408 pp->res[0].flags = IORESOURCE_IO; 409 409 if (request_resource(&ioport_resource, &pp->res[0])) 410 410 panic("Request PCIe IO resource failed\n"); 411 - pci_add_resource(&sys->resources, &pp->res[0]); 411 + pci_add_resource_offset(&sys->resources, &pp->res[0], sys->io_offset); 412 412 413 413 /* 414 414 * IORESOURCE_MEM ··· 427 427 pp->res[1].flags = IORESOURCE_MEM; 428 428 if (request_resource(&iomem_resource, &pp->res[1])) 429 429 panic("Request PCIe Memory resource failed\n"); 430 - pci_add_resource(&sys->resources, &pp->res[1]); 430 + pci_add_resource_offset(&sys->resources, &pp->res[1], sys->mem_offset); 431 431 432 432 /* 433 433 * IORESOURCE_MEM | IORESOURCE_PREFETCH ··· 446 446 pp->res[2].flags = IORESOURCE_MEM | IORESOURCE_PREFETCH; 447 447 if (request_resource(&iomem_resource, &pp->res[2])) 448 448 panic("Request PCIe Prefetch Memory resource failed\n"); 449 - pci_add_resource(&sys->resources, &pp->res[2]); 449 + pci_add_resource_offset(&sys->resources, &pp->res[2], sys->mem_offset); 450 450 451 451 return 1; 452 452 }
+3 -3
arch/arm/mach-versatile/pci.c
··· 219 219 * the mem resource for this bus 220 220 * the prefetch mem resource for this bus 221 221 */ 222 - pci_add_resource(resources, &io_mem); 223 - pci_add_resource(resources, &non_mem); 224 - pci_add_resource(resources, &pre_mem); 222 + pci_add_resource_offset(resources, &io_mem, sys->io_offset); 223 + pci_add_resource_offset(resources, &non_mem, sys->mem_offset); 224 + pci_add_resource_offset(resources, &pre_mem, sys->mem_offset); 225 225 226 226 goto out; 227 227
-3
arch/arm/mm/iomap.c
··· 32 32 unsigned long pcibios_min_mem = 0x01000000; 33 33 EXPORT_SYMBOL(pcibios_min_mem); 34 34 35 - unsigned int pci_flags = PCI_REASSIGN_ALL_RSRC; 36 - EXPORT_SYMBOL(pci_flags); 37 - 38 35 void pci_iounmap(struct pci_dev *dev, void __iomem *addr) 39 36 { 40 37 if ((unsigned long)addr >= VMALLOC_START &&
+2 -2
arch/arm/plat-iop/pci.c
··· 215 215 sys->mem_offset = IOP3XX_PCI_LOWER_MEM_PA - *IOP3XX_OMWTVR0; 216 216 sys->io_offset = IOP3XX_PCI_LOWER_IO_PA - *IOP3XX_OIOWTVR; 217 217 218 - pci_add_resource(&sys->resources, &res[0]); 219 - pci_add_resource(&sys->resources, &res[1]); 218 + pci_add_resource_offset(&sys->resources, &res[0], sys->io_offset); 219 + pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset); 220 220 221 221 return 1; 222 222 }
-6
arch/ia64/include/asm/pci.h
··· 108 108 return (pci_domain_nr(bus) != 0); 109 109 } 110 110 111 - extern void pcibios_resource_to_bus(struct pci_dev *dev, 112 - struct pci_bus_region *region, struct resource *res); 113 - 114 - extern void pcibios_bus_to_resource(struct pci_dev *dev, 115 - struct resource *res, struct pci_bus_region *region); 116 - 117 111 static inline struct resource * 118 112 pcibios_select_root(struct pci_dev *pdev, struct resource *res) 119 113 {
+2 -53
arch/ia64/pci/pci.c
··· 320 320 * Ignore these tiny memory ranges */ 321 321 if (!((window->resource.flags & IORESOURCE_MEM) && 322 322 (window->resource.end - window->resource.start < 16))) 323 - pci_add_resource(&info->resources, &window->resource); 323 + pci_add_resource_offset(&info->resources, &window->resource, 324 + window->offset); 324 325 325 326 return AE_OK; 326 327 } ··· 396 395 return NULL; 397 396 } 398 397 399 - void pcibios_resource_to_bus(struct pci_dev *dev, 400 - struct pci_bus_region *region, struct resource *res) 401 - { 402 - struct pci_controller *controller = PCI_CONTROLLER(dev); 403 - unsigned long offset = 0; 404 - int i; 405 - 406 - for (i = 0; i < controller->windows; i++) { 407 - struct pci_window *window = &controller->window[i]; 408 - if (!(window->resource.flags & res->flags)) 409 - continue; 410 - if (window->resource.start > res->start) 411 - continue; 412 - if (window->resource.end < res->end) 413 - continue; 414 - offset = window->offset; 415 - break; 416 - } 417 - 418 - region->start = res->start - offset; 419 - region->end = res->end - offset; 420 - } 421 - EXPORT_SYMBOL(pcibios_resource_to_bus); 422 - 423 - void pcibios_bus_to_resource(struct pci_dev *dev, 424 - struct resource *res, struct pci_bus_region *region) 425 - { 426 - struct pci_controller *controller = PCI_CONTROLLER(dev); 427 - unsigned long offset = 0; 428 - int i; 429 - 430 - for (i = 0; i < controller->windows; i++) { 431 - struct pci_window *window = &controller->window[i]; 432 - if (!(window->resource.flags & res->flags)) 433 - continue; 434 - if (window->resource.start - window->offset > region->start) 435 - continue; 436 - if (window->resource.end - window->offset < region->end) 437 - continue; 438 - offset = window->offset; 439 - break; 440 - } 441 - 442 - res->start = region->start + offset; 443 - res->end = region->end + offset; 444 - } 445 - EXPORT_SYMBOL(pcibios_bus_to_resource); 446 - 447 398 static int __devinit is_valid_resource(struct pci_dev *dev, int idx) 448 399 { 449 400 unsigned int i, type_mask = IORESOURCE_IO | IORESOURCE_MEM; ··· 417 464 static void __devinit 418 465 pcibios_fixup_resources(struct pci_dev *dev, int start, int limit) 419 466 { 420 - struct pci_bus_region region; 421 467 int i; 422 468 423 469 for (i = start; i < limit; i++) { 424 470 if (!dev->resource[i].flags) 425 471 continue; 426 - region.start = dev->resource[i].start; 427 - region.end = dev->resource[i].end; 428 - pcibios_bus_to_resource(dev, &dev->resource[i], &region); 429 472 if ((is_valid_resource(dev, i))) 430 473 pci_claim_resource(dev, i); 431 474 }
+11 -5
arch/ia64/sn/kernel/io_init.c
··· 297 297 s64 status = 0; 298 298 struct pci_controller *controller; 299 299 struct pcibus_bussoft *prom_bussoft_ptr; 300 - 300 + LIST_HEAD(resources); 301 + int i; 301 302 302 303 status = sal_get_pcibus_info((u64) segment, (u64) busnum, 303 304 (u64) ia64_tpa(&prom_bussoft_ptr)); ··· 316 315 */ 317 316 controller->platform_data = prom_bussoft_ptr; 318 317 319 - bus = pci_scan_bus(busnum, &pci_root_ops, controller); 318 + sn_legacy_pci_window_fixup(controller, 319 + prom_bussoft_ptr->bs_legacy_io, 320 + prom_bussoft_ptr->bs_legacy_mem); 321 + for (i = 0; i < controller->windows; i++) 322 + pci_add_resource_offset(&resources, 323 + &controller->window[i].resource, 324 + controller->window[i].offset); 325 + bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller, 326 + &resources); 320 327 if (bus == NULL) 321 328 goto error_return; /* error, or bus already scanned */ 322 329 ··· 357 348 return; 358 349 } 359 350 sn_common_bus_fixup(bus, prom_bussoft_ptr); 360 - sn_legacy_pci_window_fixup(PCI_CONTROLLER(bus), 361 - prom_bussoft_ptr->bs_legacy_io, 362 - prom_bussoft_ptr->bs_legacy_mem); 363 351 } 364 352 list_for_each_entry(pci_dev, &bus->devices, bus_list) { 365 353 sn_io_slot_fixup(pci_dev);
-1
arch/microblaze/include/asm/pci-bridge.h
··· 10 10 #include <linux/pci.h> 11 11 #include <linux/list.h> 12 12 #include <linux/ioport.h> 13 - #include <asm-generic/pci-bridge.h> 14 13 15 14 struct device_node; 16 15
-8
arch/microblaze/include/asm/pci.h
··· 94 94 */ 95 95 #define PCI_DMA_BUS_IS_PHYS (1) 96 96 97 - extern void pcibios_resource_to_bus(struct pci_dev *dev, 98 - struct pci_bus_region *region, 99 - struct resource *res); 100 - 101 - extern void pcibios_bus_to_resource(struct pci_dev *dev, 102 - struct resource *res, 103 - struct pci_bus_region *region); 104 - 105 97 static inline struct resource *pcibios_select_root(struct pci_dev *pdev, 106 98 struct resource *res) 107 99 {
+12 -105
arch/microblaze/pci/pci-common.c
··· 46 46 /* ISA Memory physical address */ 47 47 resource_size_t isa_mem_base; 48 48 49 - /* Default PCI flags is 0 on ppc32, modified at boot on ppc64 */ 50 - unsigned int pci_flags; 51 - 52 49 static struct dma_map_ops *pci_dma_ops = &dma_direct_ops; 53 50 54 51 unsigned long isa_io_base; ··· 830 833 { 831 834 struct pci_controller *hose = pci_bus_to_host(bus); 832 835 833 - if (!(pci_flags & PCI_ENABLE_PROC_DOMAINS)) 834 - return 0; 835 - if (pci_flags & PCI_COMPAT_DOMAIN_0) 836 - return hose->global_number != 0; 837 - return 1; 838 - } 839 - 840 - void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, 841 - struct resource *res) 842 - { 843 - resource_size_t offset = 0, mask = (resource_size_t)-1; 844 - struct pci_controller *hose = pci_bus_to_host(dev->bus); 845 - 846 - if (!hose) 847 - return; 848 - if (res->flags & IORESOURCE_IO) { 849 - offset = (unsigned long)hose->io_base_virt - _IO_BASE; 850 - mask = 0xffffffffu; 851 - } else if (res->flags & IORESOURCE_MEM) 852 - offset = hose->pci_mem_offset; 853 - 854 - region->start = (res->start - offset) & mask; 855 - region->end = (res->end - offset) & mask; 856 - } 857 - EXPORT_SYMBOL(pcibios_resource_to_bus); 858 - 859 - void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 860 - struct pci_bus_region *region) 861 - { 862 - resource_size_t offset = 0, mask = (resource_size_t)-1; 863 - struct pci_controller *hose = pci_bus_to_host(dev->bus); 864 - 865 - if (!hose) 866 - return; 867 - if (res->flags & IORESOURCE_IO) { 868 - offset = (unsigned long)hose->io_base_virt - _IO_BASE; 869 - mask = 0xffffffffu; 870 - } else if (res->flags & IORESOURCE_MEM) 871 - offset = hose->pci_mem_offset; 872 - res->start = (region->start + offset) & mask; 873 - res->end = (region->end + offset) & mask; 874 - } 875 - EXPORT_SYMBOL(pcibios_bus_to_resource); 876 - 877 - /* Fixup a bus resource into a linux resource */ 878 - static void __devinit fixup_resource(struct resource *res, struct pci_dev *dev) 879 - { 880 - struct pci_controller *hose = pci_bus_to_host(dev->bus); 881 - resource_size_t offset = 0, mask = (resource_size_t)-1; 882 - 883 - if (res->flags & IORESOURCE_IO) { 884 - offset = (unsigned long)hose->io_base_virt - _IO_BASE; 885 - mask = 0xffffffffu; 886 - } else if (res->flags & IORESOURCE_MEM) 887 - offset = hose->pci_mem_offset; 888 - 889 - res->start = (res->start + offset) & mask; 890 - res->end = (res->end + offset) & mask; 836 + return 0; 891 837 } 892 838 893 839 /* This header fixup will do the resource fixup for all devices as they are ··· 850 910 struct resource *res = dev->resource + i; 851 911 if (!res->flags) 852 912 continue; 853 - /* On platforms that have PCI_PROBE_ONLY set, we don't 854 - * consider 0 as an unassigned BAR value. It's technically 855 - * a valid value, but linux doesn't like it... so when we can 856 - * re-assign things, we do so, but if we can't, we keep it 857 - * around and hope for the best... 858 - */ 859 - if (res->start == 0 && !(pci_flags & PCI_PROBE_ONLY)) { 913 + if (res->start == 0) { 860 914 pr_debug("PCI:%s Resource %d %016llx-%016llx [%x]" \ 861 915 "is unassigned\n", 862 916 pci_name(dev), i, ··· 863 929 continue; 864 930 } 865 931 866 - pr_debug("PCI:%s Resource %d %016llx-%016llx [%x] fixup...\n", 932 + pr_debug("PCI:%s Resource %d %016llx-%016llx [%x]\n", 867 933 pci_name(dev), i, 868 934 (unsigned long long)res->start,\ 869 935 (unsigned long long)res->end, 870 936 (unsigned int)res->flags); 871 - 872 - fixup_resource(res, dev); 873 - 874 - pr_debug("PCI:%s %016llx-%016llx\n", 875 - pci_name(dev), 876 - (unsigned long long)res->start, 877 - (unsigned long long)res->end); 878 937 } 879 938 } 880 939 DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pcibios_fixup_resources); ··· 885 958 resource_size_t offset; 886 959 u16 command; 887 960 int i; 888 - 889 - /* We don't do anything if PCI_PROBE_ONLY is set */ 890 - if (pci_flags & PCI_PROBE_ONLY) 891 - return 0; 892 961 893 962 /* Job is a bit different between memory and IO */ 894 963 if (res->flags & IORESOURCE_MEM) { ··· 960 1037 (unsigned long long)res->end, 961 1038 (unsigned int)res->flags); 962 1039 963 - /* Perform fixup */ 964 - fixup_resource(res, dev); 965 - 966 1040 /* Try to detect uninitialized P2P bridge resources, 967 1041 * and clear them out so they get re-assigned later 968 1042 */ ··· 1027 1107 1028 1108 static int skip_isa_ioresource_align(struct pci_dev *dev) 1029 1109 { 1030 - if ((pci_flags & PCI_CAN_SKIP_ISA_ALIGN) && 1031 - !(dev->bus->bridge_ctl & PCI_BRIDGE_CTL_ISA)) 1032 - return 1; 1033 1110 return 0; 1034 1111 } 1035 1112 ··· 1153 1236 * and as such ensure proper re-allocation 1154 1237 * later. 1155 1238 */ 1156 - if (pci_flags & PCI_REASSIGN_ALL_RSRC) 1157 - goto clear_resource; 1158 1239 pr = pci_find_parent_resource(bus->self, res); 1159 1240 if (pr == res) { 1160 1241 /* this happens when the generic PCI ··· 1337 1422 list_for_each_entry(b, &pci_root_buses, node) 1338 1423 pcibios_allocate_bus_resources(b); 1339 1424 1340 - if (!(pci_flags & PCI_REASSIGN_ALL_RSRC)) { 1341 - pcibios_allocate_resources(0); 1342 - pcibios_allocate_resources(1); 1343 - } 1425 + pcibios_allocate_resources(0); 1426 + pcibios_allocate_resources(1); 1344 1427 1345 1428 /* Before we start assigning unassigned resource, we try to reserve 1346 1429 * the low IO area and the VGA memory area if they intersect the 1347 1430 * bus available resources to avoid allocating things on top of them 1348 1431 */ 1349 - if (!(pci_flags & PCI_PROBE_ONLY)) { 1350 - list_for_each_entry(b, &pci_root_buses, node) 1351 - pcibios_reserve_legacy_regions(b); 1352 - } 1432 + list_for_each_entry(b, &pci_root_buses, node) 1433 + pcibios_reserve_legacy_regions(b); 1353 1434 1354 - /* Now, if the platform didn't decide to blindly trust the firmware, 1355 - * we proceed to assigning things that were left unassigned 1356 - */ 1357 - if (!(pci_flags & PCI_PROBE_ONLY)) { 1358 - pr_debug("PCI: Assigning unassigned resources...\n"); 1359 - pci_assign_unassigned_resources(); 1360 - } 1435 + /* Now proceed to assigning things that were left unassigned */ 1436 + pr_debug("PCI: Assigning unassigned resources...\n"); 1437 + pci_assign_unassigned_resources(); 1361 1438 } 1362 1439 1363 1440 #ifdef CONFIG_HOTPLUG ··· 1442 1535 res->end = res->start + IO_SPACE_LIMIT; 1443 1536 res->flags = IORESOURCE_IO; 1444 1537 } 1445 - pci_add_resource(resources, res); 1538 + pci_add_resource_offset(resources, res, hose->io_base_virt - _IO_BASE); 1446 1539 1447 1540 pr_debug("PCI: PHB IO resource = %016llx-%016llx [%lx]\n", 1448 1541 (unsigned long long)res->start, ··· 1465 1558 res->flags = IORESOURCE_MEM; 1466 1559 1467 1560 } 1468 - pci_add_resource(resources, res); 1561 + pci_add_resource_offset(resources, res, hose->pci_mem_offset); 1469 1562 1470 1563 pr_debug("PCI: PHB MEM resource %d = %016llx-%016llx [%lx]\n", 1471 1564 i, (unsigned long long)res->start,
+1 -8
arch/mips/include/asm/pci.h
··· 92 92 #include <asm/scatterlist.h> 93 93 #include <linux/string.h> 94 94 #include <asm/io.h> 95 + #include <asm-generic/pci-bridge.h> 95 96 96 97 struct pci_dev; 97 98 ··· 112 111 *strategy_parameter = ~0UL; 113 112 } 114 113 #endif 115 - 116 - extern void pcibios_resource_to_bus(struct pci_dev *dev, 117 - struct pci_bus_region *region, struct resource *res); 118 - 119 - extern void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 120 - struct pci_bus_region *region); 121 114 122 115 #define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index 123 116 ··· 139 144 /* MSI arch hook for OCTEON */ 140 145 #define arch_setup_msi_irqs arch_setup_msi_irqs 141 146 #endif 142 - 143 - extern int pci_probe_only; 144 147 145 148 extern char * (*pcibios_plat_setup)(char *str); 146 149
-61
arch/mips/pci/fixup-cobalt.c
··· 51 51 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_MARVELL, PCI_DEVICE_ID_MARVELL_GT64111, 52 52 qube_raq_galileo_early_fixup); 53 53 54 - static void __devinit cobalt_legacy_ide_resource_fixup(struct pci_dev *dev, 55 - struct resource *res) 56 - { 57 - struct pci_controller *hose = (struct pci_controller *)dev->sysdata; 58 - unsigned long offset = hose->io_offset; 59 - struct resource orig = *res; 60 - 61 - if (!(res->flags & IORESOURCE_IO) || 62 - !(res->flags & IORESOURCE_PCI_FIXED)) 63 - return; 64 - 65 - res->start -= offset; 66 - res->end -= offset; 67 - dev_printk(KERN_DEBUG, &dev->dev, "converted legacy %pR to bus %pR\n", 68 - &orig, res); 69 - } 70 - 71 - static void __devinit cobalt_legacy_ide_fixup(struct pci_dev *dev) 72 - { 73 - u32 class; 74 - u8 progif; 75 - 76 - /* 77 - * If the IDE controller is in legacy mode, pci_setup_device() fills in 78 - * the resources with the legacy addresses that normally appear on the 79 - * PCI bus, just as if we had read them from a BAR. 80 - * 81 - * However, with the GT-64111, those legacy addresses, e.g., 0x1f0, 82 - * will never appear on the PCI bus because it converts memory accesses 83 - * in the PCI I/O region (which is never at address zero) into I/O port 84 - * accesses with no address translation. 85 - * 86 - * For example, if GT_DEF_PCI0_IO_BASE is 0x10000000, a load or store 87 - * to physical address 0x100001f0 will become a PCI access to I/O port 88 - * 0x100001f0. There's no way to generate an access to I/O port 0x1f0, 89 - * but the VT82C586 IDE controller does respond at 0x100001f0 because 90 - * it only decodes the low 24 bits of the address. 91 - * 92 - * When this quirk runs, the pci_dev resources should contain bus 93 - * addresses, not Linux I/O port numbers, so convert legacy addresses 94 - * like 0x1f0 to bus addresses like 0x100001f0. Later, we'll convert 95 - * them back with pcibios_fixup_bus() or pcibios_bus_to_resource(). 96 - */ 97 - class = dev->class >> 8; 98 - if (class != PCI_CLASS_STORAGE_IDE) 99 - return; 100 - 101 - pci_read_config_byte(dev, PCI_CLASS_PROG, &progif); 102 - if ((progif & 1) == 0) { 103 - cobalt_legacy_ide_resource_fixup(dev, &dev->resource[0]); 104 - cobalt_legacy_ide_resource_fixup(dev, &dev->resource[1]); 105 - } 106 - if ((progif & 4) == 0) { 107 - cobalt_legacy_ide_resource_fixup(dev, &dev->resource[2]); 108 - cobalt_legacy_ide_resource_fixup(dev, &dev->resource[3]); 109 - } 110 - } 111 - 112 - DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1, 113 - cobalt_legacy_ide_fixup); 114 - 115 54 static void qube_raq_via_bmIDE_fixup(struct pci_dev *dev) 116 55 { 117 56 unsigned short cfgword;
+1 -1
arch/mips/pci/pci-bcm1480.c
··· 204 204 uint64_t reg; 205 205 206 206 /* CFE will assign PCI resources */ 207 - pci_probe_only = 1; 207 + pci_set_flags(PCI_PROBE_ONLY); 208 208 209 209 /* Avoid ISA compat ranges. */ 210 210 PCIBIOS_MIN_IO = 0x00008000UL;
+1 -1
arch/mips/pci/pci-ip27.c
··· 50 50 bridge_t *bridge; 51 51 int slot; 52 52 53 - pci_probe_only = 1; 53 + pci_set_flags(PCI_PROBE_ONLY); 54 54 55 55 printk("a bridge\n"); 56 56
+2 -1
arch/mips/pci/pci-lantiq.c
··· 270 270 { 271 271 struct ltq_pci_data *ltq_pci_data = 272 272 (struct ltq_pci_data *) pdev->dev.platform_data; 273 - pci_probe_only = 0; 273 + 274 + pci_clear_flags(PCI_PROBE_ONLY); 274 275 ltq_pci_irq_map = ltq_pci_data->irq; 275 276 ltq_pci_membase = ioremap_nocache(PCI_CR_BASE_ADDR, PCI_CR_SIZE); 276 277 ltq_pci_mapped_cfg =
+1 -1
arch/mips/pci/pci-sb1250.c
··· 213 213 uint64_t reg; 214 214 215 215 /* CFE will assign PCI resources */ 216 - pci_probe_only = 1; 216 + pci_set_flags(PCI_PROBE_ONLY); 217 217 218 218 /* Avoid ISA compat ranges. */ 219 219 PCIBIOS_MIN_IO = 0x00008000UL;
+1 -1
arch/mips/pci/pci-xlr.c
··· 292 292 static int __init pcibios_init(void) 293 293 { 294 294 /* PSB assigns PCI resources */ 295 - pci_probe_only = 1; 295 + pci_set_flags(PCI_PROBE_ONLY); 296 296 pci_config_base = ioremap(DEFAULT_PCI_CONFIG_BASE, 16 << 20); 297 297 298 298 /* Extend IO port for memory mapped io */
+9 -77
arch/mips/pci/pci.c
··· 20 20 #include <asm/cpu-info.h> 21 21 22 22 /* 23 - * Indicate whether we respect the PCI setup left by the firmware. 24 - * 25 - * Make this long-lived so that we know when shutting down 26 - * whether we probed only or not. 23 + * If PCI_PROBE_ONLY in pci_flags is set, we don't change any PCI resource 24 + * assignments. 27 25 */ 28 - int pci_probe_only; 29 - 30 - #define PCI_ASSIGN_ALL_BUSSES 1 31 - 32 - unsigned int pci_probe = PCI_ASSIGN_ALL_BUSSES; 33 26 34 27 /* 35 28 * The PCI controller list. ··· 85 92 if (!hose->iommu) 86 93 PCI_DMA_BUS_IS_PHYS = 1; 87 94 88 - if (hose->get_busno && pci_probe_only) 95 + if (hose->get_busno && pci_has_flag(PCI_PROBE_ONLY)) 89 96 next_busno = (*hose->get_busno)(); 90 97 91 - pci_add_resource(&resources, hose->mem_resource); 92 - pci_add_resource(&resources, hose->io_resource); 98 + pci_add_resource_offset(&resources, 99 + hose->mem_resource, hose->mem_offset); 100 + pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset); 93 101 bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose, 94 102 &resources); 95 103 if (!bus) ··· 109 115 need_domain_info = 1; 110 116 } 111 117 112 - if (!pci_probe_only) { 118 + if (!pci_has_flag(PCI_PROBE_ONLY)) { 113 119 pci_bus_size_bridges(bus); 114 120 pci_bus_assign_resources(bus); 115 121 pci_enable_bridges(bus); ··· 235 241 236 242 unsigned int pcibios_assign_all_busses(void) 237 243 { 238 - return (pci_probe & PCI_ASSIGN_ALL_BUSSES) ? 1 : 0; 244 + return 1; 239 245 } 240 246 241 247 int pcibios_enable_device(struct pci_dev *dev, int mask) ··· 248 254 return pcibios_plat_dev_init(dev); 249 255 } 250 256 251 - static void pcibios_fixup_device_resources(struct pci_dev *dev, 252 - struct pci_bus *bus) 253 - { 254 - /* Update device resources. */ 255 - struct pci_controller *hose = (struct pci_controller *)bus->sysdata; 256 - unsigned long offset = 0; 257 - int i; 258 - 259 - for (i = 0; i < PCI_NUM_RESOURCES; i++) { 260 - if (!dev->resource[i].start) 261 - continue; 262 - if (dev->resource[i].flags & IORESOURCE_IO) 263 - offset = hose->io_offset; 264 - else if (dev->resource[i].flags & IORESOURCE_MEM) 265 - offset = hose->mem_offset; 266 - 267 - dev->resource[i].start += offset; 268 - dev->resource[i].end += offset; 269 - } 270 - } 271 - 272 257 void __devinit pcibios_fixup_bus(struct pci_bus *bus) 273 258 { 274 - /* Propagate hose info into the subordinate devices. */ 275 - 276 259 struct pci_dev *dev = bus->self; 277 260 278 - if (pci_probe_only && dev && 261 + if (pci_has_flag(PCI_PROBE_ONLY) && dev && 279 262 (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) { 280 263 pci_read_bridge_bases(bus); 281 - pcibios_fixup_device_resources(dev, bus); 282 - } 283 - 284 - list_for_each_entry(dev, &bus->devices, bus_list) { 285 - if ((dev->class >> 8) != PCI_CLASS_BRIDGE_PCI) 286 - pcibios_fixup_device_resources(dev, bus); 287 264 } 288 265 } 289 266 ··· 264 299 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); 265 300 } 266 301 267 - void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, 268 - struct resource *res) 269 - { 270 - struct pci_controller *hose = (struct pci_controller *)dev->sysdata; 271 - unsigned long offset = 0; 272 - 273 - if (res->flags & IORESOURCE_IO) 274 - offset = hose->io_offset; 275 - else if (res->flags & IORESOURCE_MEM) 276 - offset = hose->mem_offset; 277 - 278 - region->start = res->start - offset; 279 - region->end = res->end - offset; 280 - } 281 - 282 - void __devinit 283 - pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 284 - struct pci_bus_region *region) 285 - { 286 - struct pci_controller *hose = (struct pci_controller *)dev->sysdata; 287 - unsigned long offset = 0; 288 - 289 - if (res->flags & IORESOURCE_IO) 290 - offset = hose->io_offset; 291 - else if (res->flags & IORESOURCE_MEM) 292 - offset = hose->mem_offset; 293 - 294 - res->start = region->start + offset; 295 - res->end = region->end + offset; 296 - } 297 - 298 302 #ifdef CONFIG_HOTPLUG 299 - EXPORT_SYMBOL(pcibios_resource_to_bus); 300 - EXPORT_SYMBOL(pcibios_bus_to_resource); 301 303 EXPORT_SYMBOL(PCIBIOS_MIN_IO); 302 304 EXPORT_SYMBOL(PCIBIOS_MIN_MEM); 303 305 #endif
-16
arch/mn10300/include/asm/pci.h
··· 85 85 /* implement the pci_ DMA API in terms of the generic device dma_ one */ 86 86 #include <asm-generic/pci-dma-compat.h> 87 87 88 - /** 89 - * pcibios_resource_to_bus - convert resource to PCI bus address 90 - * @dev: device which owns this resource 91 - * @region: converted bus-centric region (start,end) 92 - * @res: resource to convert 93 - * 94 - * Convert a resource to a PCI device bus address or bus window. 95 - */ 96 - extern void pcibios_resource_to_bus(struct pci_dev *dev, 97 - struct pci_bus_region *region, 98 - struct resource *res); 99 - 100 - extern void pcibios_bus_to_resource(struct pci_dev *dev, 101 - struct resource *res, 102 - struct pci_bus_region *region); 103 - 104 88 static inline struct resource * 105 89 pcibios_select_root(struct pci_dev *pdev, struct resource *res) 106 90 {
+9 -53
arch/mn10300/unit-asb2305/pci.c
··· 32 32 * insert specific PCI bus resources instead of using the platform-level bus 33 33 * resources directly for the PCI root bus. 34 34 * 35 - * These are configured and inserted by pcibios_init() and are attached to the 36 - * root bus by pcibios_fixup_bus(). 35 + * These are configured and inserted by pcibios_init(). 37 36 */ 38 37 static struct resource pci_ioport_resource = { 39 38 .name = "PCI IO", ··· 75 76 #endif 76 77 return 1; 77 78 } 78 - 79 - /* 80 - * translate Linuxcentric addresses to PCI bus addresses 81 - */ 82 - void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, 83 - struct resource *res) 84 - { 85 - if (res->flags & IORESOURCE_IO) { 86 - region->start = (res->start & 0x00ffffff); 87 - region->end = (res->end & 0x00ffffff); 88 - } 89 - 90 - if (res->flags & IORESOURCE_MEM) { 91 - region->start = (res->start & 0x03ffffff) | MEM_PAGING_REG; 92 - region->end = (res->end & 0x03ffffff) | MEM_PAGING_REG; 93 - } 94 - 95 - #if 0 96 - printk(KERN_DEBUG "RES->BUS: %lx-%lx => %lx-%lx\n", 97 - res->start, res->end, region->start, region->end); 98 - #endif 99 - } 100 - EXPORT_SYMBOL(pcibios_resource_to_bus); 101 - 102 - /* 103 - * translate PCI bus addresses to Linuxcentric addresses 104 - */ 105 - void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 106 - struct pci_bus_region *region) 107 - { 108 - if (res->flags & IORESOURCE_IO) { 109 - res->start = (region->start & 0x00ffffff) | 0xbe000000; 110 - res->end = (region->end & 0x00ffffff) | 0xbe000000; 111 - } 112 - 113 - if (res->flags & IORESOURCE_MEM) { 114 - res->start = (region->start & 0x03ffffff) | 0xb8000000; 115 - res->end = (region->end & 0x03ffffff) | 0xb8000000; 116 - } 117 - 118 - #if 0 119 - printk(KERN_INFO "BUS->RES: %lx-%lx => %lx-%lx\n", 120 - region->start, region->end, res->start, res->end); 121 - #endif 122 - } 123 - EXPORT_SYMBOL(pcibios_bus_to_resource); 124 79 125 80 /* 126 81 * ··· 317 364 if (!dev->resource[i].flags) 318 365 continue; 319 366 320 - region.start = dev->resource[i].start; 321 - region.end = dev->resource[i].end; 322 - pcibios_bus_to_resource(dev, &dev->resource[i], &region); 323 367 if (is_valid_resource(dev, i)) 324 368 pci_claim_resource(dev, i); 325 369 } ··· 347 397 */ 348 398 static int __init pcibios_init(void) 349 399 { 400 + resource_size_t io_offset, mem_offset; 350 401 LIST_HEAD(resources); 351 402 352 403 ioport_resource.start = 0xA0000000; ··· 371 420 printk(KERN_INFO "PCI: Probing PCI hardware [mempage %08x]\n", 372 421 MEM_PAGING_REG); 373 422 374 - pci_add_resource(&resources, &pci_ioport_resource); 375 - pci_add_resource(&resources, &pci_iomem_resource); 423 + io_offset = pci_ioport_resource.start - 424 + (pci_ioport_resource.start & 0x00ffffff); 425 + mem_offset = pci_iomem_resource.start - 426 + ((pci_iomem_resource.start & 0x03ffffff) | MEM_PAGING_REG); 427 + 428 + pci_add_resource_offset(&resources, &pci_ioport_resource, io_offset); 429 + pci_add_resource_offset(&resources, &pci_iomem_resource, mem_offset); 376 430 pci_root_bus = pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, 377 431 &resources); 378 432
-38
arch/parisc/include/asm/pci.h
··· 82 82 83 83 #ifdef CONFIG_64BIT 84 84 #define PCI_F_EXTEND 0xffffffff00000000UL 85 - #define PCI_IS_LMMIO(hba,a) pci_is_lmmio(hba,a) 86 - 87 - /* We need to know if an address is LMMMIO or GMMIO. 88 - * LMMIO requires mangling and GMMIO we must use as-is. 89 - */ 90 - static __inline__ int pci_is_lmmio(struct pci_hba_data *hba, unsigned long a) 91 - { 92 - return(((a) & PCI_F_EXTEND) == PCI_F_EXTEND); 93 - } 94 - 95 - /* 96 - ** Convert between PCI (IO_VIEW) addresses and processor (PA_VIEW) addresses. 97 - ** See pci.c for more conversions used by Generic PCI code. 98 - ** 99 - ** Platform characteristics/firmware guarantee that 100 - ** (1) PA_VIEW - IO_VIEW = lmmio_offset for both LMMIO and ELMMIO 101 - ** (2) PA_VIEW == IO_VIEW for GMMIO 102 - */ 103 - #define PCI_BUS_ADDR(hba,a) (PCI_IS_LMMIO(hba,a) \ 104 - ? ((a) - hba->lmmio_space_offset) /* mangle LMMIO */ \ 105 - : (a)) /* GMMIO */ 106 - #define PCI_HOST_ADDR(hba,a) (((a) & PCI_F_EXTEND) == 0 \ 107 - ? (a) + hba->lmmio_space_offset \ 108 - : (a)) 109 - 110 85 #else /* !CONFIG_64BIT */ 111 - 112 - #define PCI_BUS_ADDR(hba,a) (a) 113 - #define PCI_HOST_ADDR(hba,a) (a) 114 86 #define PCI_F_EXTEND 0UL 115 - #define PCI_IS_LMMIO(hba,a) (1) /* 32-bit doesn't support GMMIO */ 116 - 117 87 #endif /* !CONFIG_64BIT */ 118 88 119 89 /* ··· 214 244 *strategy_parameter = cacheline_size; 215 245 } 216 246 #endif 217 - 218 - extern void 219 - pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, 220 - struct resource *res); 221 - 222 - extern void 223 - pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 224 - struct pci_bus_region *region); 225 247 226 248 static inline void pcibios_penalize_isa_irq(int irq, int active) 227 249 {
-52
arch/parisc/kernel/pci.c
··· 195 195 pci_write_config_word(dev, PCI_BRIDGE_CONTROL, bridge_ctl); 196 196 } 197 197 198 - /* called by drivers/pci/setup-bus.c:pci_setup_bridge(). */ 199 - void __devinit pcibios_resource_to_bus(struct pci_dev *dev, 200 - struct pci_bus_region *region, struct resource *res) 201 - { 202 - #ifdef CONFIG_64BIT 203 - struct pci_hba_data *hba = HBA_DATA(dev->bus->bridge->platform_data); 204 - #endif 205 - 206 - if (res->flags & IORESOURCE_IO) { 207 - /* 208 - ** I/O space may see busnumbers here. Something 209 - ** in the form of 0xbbxxxx where bb is the bus num 210 - ** and xxxx is the I/O port space address. 211 - ** Remaining address translation are done in the 212 - ** PCI Host adapter specific code - ie dino_out8. 213 - */ 214 - region->start = PCI_PORT_ADDR(res->start); 215 - region->end = PCI_PORT_ADDR(res->end); 216 - } else if (res->flags & IORESOURCE_MEM) { 217 - /* Convert MMIO addr to PCI addr (undo global virtualization) */ 218 - region->start = PCI_BUS_ADDR(hba, res->start); 219 - region->end = PCI_BUS_ADDR(hba, res->end); 220 - } 221 - 222 - DBG_RES("pcibios_resource_to_bus(%02x %s [%lx,%lx])\n", 223 - dev->bus->number, res->flags & IORESOURCE_IO ? "IO" : "MEM", 224 - region->start, region->end); 225 - } 226 - 227 - void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 228 - struct pci_bus_region *region) 229 - { 230 - #ifdef CONFIG_64BIT 231 - struct pci_hba_data *hba = HBA_DATA(dev->bus->bridge->platform_data); 232 - #endif 233 - 234 - if (res->flags & IORESOURCE_MEM) { 235 - res->start = PCI_HOST_ADDR(hba, region->start); 236 - res->end = PCI_HOST_ADDR(hba, region->end); 237 - } 238 - 239 - if (res->flags & IORESOURCE_IO) { 240 - res->start = region->start; 241 - res->end = region->end; 242 - } 243 - } 244 - 245 - #ifdef CONFIG_HOTPLUG 246 - EXPORT_SYMBOL(pcibios_resource_to_bus); 247 - EXPORT_SYMBOL(pcibios_bus_to_resource); 248 - #endif 249 - 250 198 /* 251 199 * pcibios align resources() is called every time generic PCI code 252 200 * wants to generate a new address. The process of looking for
+1 -8
arch/powerpc/include/asm/pci.h
··· 154 154 155 155 #endif /* CONFIG_PPC64 */ 156 156 157 - extern void pcibios_resource_to_bus(struct pci_dev *dev, 158 - struct pci_bus_region *region, 159 - struct resource *res); 160 - 161 - extern void pcibios_bus_to_resource(struct pci_dev *dev, 162 - struct resource *res, 163 - struct pci_bus_region *region); 164 - 165 157 extern void pcibios_claim_one_bus(struct pci_bus *b); 166 158 167 159 extern void pcibios_finish_adding_to_bus(struct pci_bus *bus); ··· 182 190 const struct resource *rsrc, 183 191 resource_size_t *start, resource_size_t *end); 184 192 193 + extern resource_size_t pcibios_io_space_offset(struct pci_controller *hose); 185 194 extern void pcibios_setup_bus_devices(struct pci_bus *bus); 186 195 extern void pcibios_setup_bus_self(struct pci_bus *bus); 187 196 extern void pcibios_setup_phb_io_space(struct pci_controller *hose);
-2
arch/powerpc/include/asm/ppc-pci.h
··· 45 45 extern unsigned long get_phb_buid (struct device_node *); 46 46 extern int rtas_setup_phb(struct pci_controller *phb); 47 47 48 - extern unsigned long pci_probe_only; 49 - 50 48 #ifdef CONFIG_EEH 51 49 52 50 void pci_addr_cache_build(void);
+9 -77
arch/powerpc/kernel/pci-common.c
··· 49 49 /* ISA Memory physical address */ 50 50 resource_size_t isa_mem_base; 51 51 52 - /* Default PCI flags is 0 on ppc32, modified at boot on ppc64 */ 53 - unsigned int pci_flags = 0; 54 - 55 52 56 53 static struct dma_map_ops *pci_dma_ops = &dma_direct_ops; 57 54 ··· 831 834 return 1; 832 835 } 833 836 834 - void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, 835 - struct resource *res) 836 - { 837 - resource_size_t offset = 0, mask = (resource_size_t)-1; 838 - struct pci_controller *hose = pci_bus_to_host(dev->bus); 839 - 840 - if (!hose) 841 - return; 842 - if (res->flags & IORESOURCE_IO) { 843 - offset = (unsigned long)hose->io_base_virt - _IO_BASE; 844 - mask = 0xffffffffu; 845 - } else if (res->flags & IORESOURCE_MEM) 846 - offset = hose->pci_mem_offset; 847 - 848 - region->start = (res->start - offset) & mask; 849 - region->end = (res->end - offset) & mask; 850 - } 851 - EXPORT_SYMBOL(pcibios_resource_to_bus); 852 - 853 - void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 854 - struct pci_bus_region *region) 855 - { 856 - resource_size_t offset = 0, mask = (resource_size_t)-1; 857 - struct pci_controller *hose = pci_bus_to_host(dev->bus); 858 - 859 - if (!hose) 860 - return; 861 - if (res->flags & IORESOURCE_IO) { 862 - offset = (unsigned long)hose->io_base_virt - _IO_BASE; 863 - mask = 0xffffffffu; 864 - } else if (res->flags & IORESOURCE_MEM) 865 - offset = hose->pci_mem_offset; 866 - res->start = (region->start + offset) & mask; 867 - res->end = (region->end + offset) & mask; 868 - } 869 - EXPORT_SYMBOL(pcibios_bus_to_resource); 870 - 871 - /* Fixup a bus resource into a linux resource */ 872 - static void __devinit fixup_resource(struct resource *res, struct pci_dev *dev) 873 - { 874 - struct pci_controller *hose = pci_bus_to_host(dev->bus); 875 - resource_size_t offset = 0, mask = (resource_size_t)-1; 876 - 877 - if (res->flags & IORESOURCE_IO) { 878 - offset = (unsigned long)hose->io_base_virt - _IO_BASE; 879 - mask = 0xffffffffu; 880 - } else if (res->flags & IORESOURCE_MEM) 881 - offset = hose->pci_mem_offset; 882 - 883 - res->start = (res->start + offset) & mask; 884 - res->end = (res->end + offset) & mask; 885 - } 886 - 887 - 888 837 /* This header fixup will do the resource fixup for all devices as they are 889 838 * probed, but not for bridge ranges 890 839 */ ··· 870 927 continue; 871 928 } 872 929 873 - pr_debug("PCI:%s Resource %d %016llx-%016llx [%x] fixup...\n", 930 + pr_debug("PCI:%s Resource %d %016llx-%016llx [%x]\n", 874 931 pci_name(dev), i, 875 932 (unsigned long long)res->start,\ 876 933 (unsigned long long)res->end, 877 934 (unsigned int)res->flags); 878 - 879 - fixup_resource(res, dev); 880 - 881 - pr_debug("PCI:%s %016llx-%016llx\n", 882 - pci_name(dev), 883 - (unsigned long long)res->start, 884 - (unsigned long long)res->end); 885 935 } 886 936 887 937 /* Call machine specific resource fixup */ ··· 976 1040 continue; 977 1041 } 978 1042 979 - pr_debug("PCI:%s Bus rsrc %d %016llx-%016llx [%x] fixup...\n", 1043 + pr_debug("PCI:%s Bus rsrc %d %016llx-%016llx [%x]\n", 980 1044 pci_name(dev), i, 981 1045 (unsigned long long)res->start,\ 982 1046 (unsigned long long)res->end, 983 1047 (unsigned int)res->flags); 984 - 985 - /* Perform fixup */ 986 - fixup_resource(res, dev); 987 1048 988 1049 /* Try to detect uninitialized P2P bridge resources, 989 1050 * and clear them out so they get re-assigned later ··· 988 1055 if (pcibios_uninitialized_bridge_resource(bus, res)) { 989 1056 res->flags = 0; 990 1057 pr_debug("PCI:%s (unassigned)\n", pci_name(dev)); 991 - } else { 992 - 993 - pr_debug("PCI:%s %016llx-%016llx\n", 994 - pci_name(dev), 995 - (unsigned long long)res->start, 996 - (unsigned long long)res->end); 997 1058 } 998 1059 } 999 1060 } ··· 1477 1550 return pci_enable_resources(dev, mask); 1478 1551 } 1479 1552 1553 + resource_size_t pcibios_io_space_offset(struct pci_controller *hose) 1554 + { 1555 + return (unsigned long) hose->io_base_virt - _IO_BASE; 1556 + } 1557 + 1480 1558 static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, struct list_head *resources) 1481 1559 { 1482 1560 struct resource *res; ··· 1506 1574 (unsigned long long)res->start, 1507 1575 (unsigned long long)res->end, 1508 1576 (unsigned long)res->flags); 1509 - pci_add_resource(resources, res); 1577 + pci_add_resource_offset(resources, res, pcibios_io_space_offset(hose)); 1510 1578 1511 1579 /* Hookup PHB Memory resources */ 1512 1580 for (i = 0; i < 3; ++i) { ··· 1529 1597 (unsigned long long)res->start, 1530 1598 (unsigned long long)res->end, 1531 1599 (unsigned long)res->flags); 1532 - pci_add_resource(resources, res); 1600 + pci_add_resource_offset(resources, res, hose->pci_mem_offset); 1533 1601 } 1534 1602 1535 1603 pr_debug("PCI: PHB MEM offset = %016llx\n",
+3 -3
arch/powerpc/kernel/pci_32.c
··· 219 219 struct resource *res = &hose->io_resource; 220 220 221 221 /* Fixup IO space offset */ 222 - io_offset = (unsigned long)hose->io_base_virt - isa_io_base; 223 - res->start = (res->start + io_offset) & 0xffffffffu; 224 - res->end = (res->end + io_offset) & 0xffffffffu; 222 + io_offset = pcibios_io_space_offset(hose); 223 + res->start += io_offset; 224 + res->end += io_offset; 225 225 } 226 226 227 227 static int __init pcibios_init(void)
+1 -6
arch/powerpc/kernel/pci_64.c
··· 33 33 #include <asm/machdep.h> 34 34 #include <asm/ppc-pci.h> 35 35 36 - unsigned long pci_probe_only = 1; 37 - 38 36 /* pci_io_base -- the base address from which io bars are offsets. 39 37 * This is the lowest I/O base address (so bar values are always positive), 40 38 * and it *must* be the start of ISA space if an ISA bus exists because ··· 52 54 * later, we may move that initialization to each ppc_md 53 55 */ 54 56 ppc_md.phys_mem_access_prot = pci_phys_mem_access_prot; 55 - 56 - if (pci_probe_only) 57 - pci_add_flags(PCI_PROBE_ONLY); 58 57 59 58 /* On ppc64, we always enable PCI domains and we keep domain 0 60 59 * backward compatible in /proc for video cards ··· 168 173 return -ENOMEM; 169 174 170 175 /* Fixup hose IO resource */ 171 - io_virt_offset = (unsigned long)hose->io_base_virt - _IO_BASE; 176 + io_virt_offset = pcibios_io_space_offset(hose); 172 177 hose->io_resource.start += io_virt_offset; 173 178 hose->io_resource.end += io_virt_offset; 174 179
+8 -4
arch/powerpc/kernel/pci_of_scan.c
··· 75 75 { 76 76 u64 base, size; 77 77 unsigned int flags; 78 + struct pci_bus_region region; 78 79 struct resource *res; 79 80 const u32 *addrs; 80 81 u32 i; ··· 107 106 printk(KERN_ERR "PCI: bad cfg reg num 0x%x\n", i); 108 107 continue; 109 108 } 110 - res->start = base; 111 - res->end = base + size - 1; 112 109 res->flags = flags; 113 110 res->name = pci_name(dev); 111 + region.start = base; 112 + region.end = base + size - 1; 113 + pcibios_bus_to_resource(dev, res, &region); 114 114 } 115 115 } 116 116 ··· 211 209 struct pci_bus *bus; 212 210 const u32 *busrange, *ranges; 213 211 int len, i, mode; 212 + struct pci_bus_region region; 214 213 struct resource *res; 215 214 unsigned int flags; 216 215 u64 size; ··· 273 270 res = bus->resource[i]; 274 271 ++i; 275 272 } 276 - res->start = of_read_number(&ranges[1], 2); 277 - res->end = res->start + size - 1; 278 273 res->flags = flags; 274 + region.start = of_read_number(&ranges[1], 2); 275 + region.end = region.start + size - 1; 276 + pcibios_bus_to_resource(dev, res, &region); 279 277 } 280 278 sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus), 281 279 bus->number);
+7 -3
arch/powerpc/kernel/rtas_pci.c
··· 279 279 eeh_dev_phb_init(); 280 280 281 281 /* 282 - * pci_probe_only and pci_assign_all_buses can be set via properties 282 + * PCI_PROBE_ONLY and PCI_REASSIGN_ALL_BUS can be set via properties 283 283 * in chosen. 284 284 */ 285 285 if (of_chosen) { ··· 287 287 288 288 prop = of_get_property(of_chosen, 289 289 "linux,pci-probe-only", NULL); 290 - if (prop) 291 - pci_probe_only = *prop; 290 + if (prop) { 291 + if (*prop) 292 + pci_add_flags(PCI_PROBE_ONLY); 293 + else 294 + pci_clear_flags(PCI_PROBE_ONLY); 295 + } 292 296 293 297 #ifdef CONFIG_PPC32 /* Will be made generic soon */ 294 298 prop = of_get_property(of_chosen,
+1 -1
arch/powerpc/platforms/maple/pci.c
··· 620 620 } 621 621 622 622 /* Tell pci.c to not change any resource allocations. */ 623 - pci_probe_only = 1; 623 + pci_add_flags(PCI_PROBE_ONLY); 624 624 } 625 625 626 626 int maple_pci_get_legacy_ide_irq(struct pci_dev *pdev, int channel)
-3
arch/powerpc/platforms/pasemi/pci.c
··· 229 229 230 230 /* Setup the linkage between OF nodes and PHBs */ 231 231 pci_devs_phb_init(); 232 - 233 - /* Use the common resource allocation mechanism */ 234 - pci_probe_only = 1; 235 232 } 236 233 237 234 void __iomem *pasemi_pci_getcfgaddr(struct pci_dev *dev, int offset)
-3
arch/powerpc/platforms/powermac/pci.c
··· 1059 1059 } 1060 1060 /* pmac_check_ht_link(); */ 1061 1061 1062 - /* We can allocate missing resources if any */ 1063 - pci_probe_only = 0; 1064 - 1065 1062 #else /* CONFIG_PPC64 */ 1066 1063 init_p2pbridge(); 1067 1064 init_second_ohare();
+2 -3
arch/powerpc/platforms/powernv/pci-ioda.c
··· 1299 1299 /* Setup MSI support */ 1300 1300 pnv_pci_init_ioda_msis(phb); 1301 1301 1302 - /* We set both probe_only and PCI_REASSIGN_ALL_RSRC. This is an 1302 + /* We set both PCI_PROBE_ONLY and PCI_REASSIGN_ALL_RSRC. This is an 1303 1303 * odd combination which essentially means that we skip all resource 1304 1304 * fixups and assignments in the generic code, and do it all 1305 1305 * ourselves here 1306 1306 */ 1307 - pci_probe_only = 1; 1308 1307 ppc_md.pcibios_fixup_phb = pnv_pci_ioda_fixup_phb; 1309 1308 ppc_md.pcibios_enable_device_hook = pnv_pci_enable_device_hook; 1310 - pci_add_flags(PCI_REASSIGN_ALL_RSRC); 1309 + pci_add_flags(PCI_PROBE_ONLY | PCI_REASSIGN_ALL_RSRC); 1311 1310 1312 1311 /* Reset IODA tables to a clean state */ 1313 1312 rc = opal_pci_reset(phb_id, OPAL_PCI_IODA_TABLE_RESET, OPAL_ASSERT_RESET);
+1 -4
arch/powerpc/platforms/powernv/pci.c
··· 562 562 { 563 563 struct device_node *np; 564 564 565 - pci_set_flags(PCI_CAN_SKIP_ISA_ALIGN); 566 - 567 - /* We do not want to just probe */ 568 - pci_probe_only = 0; 565 + pci_add_flags(PCI_CAN_SKIP_ISA_ALIGN); 569 566 570 567 /* OPAL absent, try POPAL first then RTAS detection of PHBs */ 571 568 if (!firmware_has_feature(FW_FEATURE_OPAL)) {
+1 -1
arch/powerpc/platforms/pseries/pci_dlpar.c
··· 84 84 list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) { 85 85 pr_debug(" * Removing %s...\n", pci_name(dev)); 86 86 eeh_remove_bus_device(dev); 87 - pci_remove_bus_device(dev); 87 + pci_stop_and_remove_bus_device(dev); 88 88 } 89 89 } 90 90 EXPORT_SYMBOL_GPL(pcibios_remove_pci_devices);
+3
arch/powerpc/platforms/pseries/setup.c
··· 383 383 384 384 fwnmi_init(); 385 385 386 + /* By default, only probe PCI (can be overriden by rtas_pci) */ 387 + pci_add_flags(PCI_PROBE_ONLY); 388 + 386 389 /* Find and initialize PCI host bridges */ 387 390 init_pci_config_tokens(); 388 391 eeh_pseries_init();
-1
arch/powerpc/platforms/wsp/wsp_pci.c
··· 682 682 /* XXX Force re-assigning of everything for now */ 683 683 pci_add_flags(PCI_REASSIGN_ALL_BUS | PCI_REASSIGN_ALL_RSRC | 684 684 PCI_ENABLE_PROC_DOMAINS); 685 - pci_probe_only = 0; 686 685 687 686 /* Calculate how the TCE space is divided */ 688 687 phb->dma32_base = 0;
+11 -64
arch/sh/drivers/pci/pci.c
··· 37 37 static int next_busno; 38 38 static int need_domain_info; 39 39 LIST_HEAD(resources); 40 + struct resource *res; 41 + resource_size_t offset; 40 42 int i; 41 43 struct pci_bus *bus; 42 44 43 - for (i = 0; i < hose->nr_resources; i++) 44 - pci_add_resource(&resources, hose->resources + i); 45 + for (i = 0; i < hose->nr_resources; i++) { 46 + res = hose->resources + i; 47 + offset = 0; 48 + if (res->flags & IORESOURCE_IO) 49 + offset = hose->io_offset; 50 + else if (res->flags & IORESOURCE_MEM) 51 + offset = hose->mem_offset; 52 + pci_add_resource_offset(&resources, res, offset); 53 + } 45 54 46 55 bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose, 47 56 &resources); ··· 152 143 } 153 144 subsys_initcall(pcibios_init); 154 145 155 - static void pcibios_fixup_device_resources(struct pci_dev *dev, 156 - struct pci_bus *bus) 157 - { 158 - /* Update device resources. */ 159 - struct pci_channel *hose = bus->sysdata; 160 - unsigned long offset = 0; 161 - int i; 162 - 163 - for (i = 0; i < PCI_NUM_RESOURCES; i++) { 164 - if (!dev->resource[i].start) 165 - continue; 166 - if (dev->resource[i].flags & IORESOURCE_IO) 167 - offset = hose->io_offset; 168 - else if (dev->resource[i].flags & IORESOURCE_MEM) 169 - offset = hose->mem_offset; 170 - 171 - dev->resource[i].start += offset; 172 - dev->resource[i].end += offset; 173 - } 174 - } 175 - 176 146 /* 177 147 * Called after each bus is probed, but before its children 178 148 * are examined. 179 149 */ 180 150 void __devinit pcibios_fixup_bus(struct pci_bus *bus) 181 151 { 182 - struct pci_dev *dev; 183 - struct list_head *ln; 184 - 185 - for (ln = bus->devices.next; ln != &bus->devices; ln = ln->next) { 186 - dev = pci_dev_b(ln); 187 - 188 - if ((dev->class >> 8) != PCI_CLASS_BRIDGE_PCI) 189 - pcibios_fixup_device_resources(dev, bus); 190 - } 191 152 } 192 153 193 154 /* ··· 185 206 } 186 207 187 208 return start; 188 - } 189 - 190 - void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, 191 - struct resource *res) 192 - { 193 - struct pci_channel *hose = dev->sysdata; 194 - unsigned long offset = 0; 195 - 196 - if (res->flags & IORESOURCE_IO) 197 - offset = hose->io_offset; 198 - else if (res->flags & IORESOURCE_MEM) 199 - offset = hose->mem_offset; 200 - 201 - region->start = res->start - offset; 202 - region->end = res->end - offset; 203 - } 204 - 205 - void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 206 - struct pci_bus_region *region) 207 - { 208 - struct pci_channel *hose = dev->sysdata; 209 - unsigned long offset = 0; 210 - 211 - if (res->flags & IORESOURCE_IO) 212 - offset = hose->io_offset; 213 - else if (res->flags & IORESOURCE_MEM) 214 - offset = hose->mem_offset; 215 - 216 - res->start = region->start + offset; 217 - res->end = region->end + offset; 218 209 } 219 210 220 211 int pcibios_enable_device(struct pci_dev *dev, int mask) ··· 330 381 #endif /* CONFIG_GENERIC_IOMAP */ 331 382 332 383 #ifdef CONFIG_HOTPLUG 333 - EXPORT_SYMBOL(pcibios_resource_to_bus); 334 - EXPORT_SYMBOL(pcibios_bus_to_resource); 335 384 EXPORT_SYMBOL(PCIBIOS_MIN_IO); 336 385 EXPORT_SYMBOL(PCIBIOS_MIN_MEM); 337 386 #endif
-6
arch/sh/include/asm/pci.h
··· 114 114 /* Board-specific fixup routines. */ 115 115 int pcibios_map_platform_irq(const struct pci_dev *dev, u8 slot, u8 pin); 116 116 117 - extern void pcibios_resource_to_bus(struct pci_dev *dev, 118 - struct pci_bus_region *region, struct resource *res); 119 - 120 - extern void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 121 - struct pci_bus_region *region); 122 - 123 117 #define pci_domain_nr(bus) ((struct pci_channel *)(bus)->sysdata)->index 124 118 125 119 static inline int pci_proc_domain(struct pci_bus *bus)
-8
arch/sparc/include/asm/pci_32.h
··· 52 52 * 64Kbytes by the Host controller. 53 53 */ 54 54 55 - extern void 56 - pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, 57 - struct resource *res); 58 - 59 - extern void 60 - pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 61 - struct pci_bus_region *region); 62 - 63 55 static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) 64 56 { 65 57 return PCI_IRQ_NONE;
-8
arch/sparc/include/asm/pci_64.h
··· 73 73 enum pci_mmap_state mmap_state, 74 74 int write_combine); 75 75 76 - extern void 77 - pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, 78 - struct resource *res); 79 - 80 - extern void 81 - pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 82 - struct pci_bus_region *region); 83 - 84 76 static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) 85 77 { 86 78 return PCI_IRQ_NONE;
+7 -40
arch/sparc/kernel/leon_pci.c
··· 15 15 16 16 /* The LEON architecture does not rely on a BIOS or bootloader to setup 17 17 * PCI for us. The Linux generic routines are used to setup resources, 18 - * reset values of confuration-space registers settings ae preseved. 18 + * reset values of configuration-space register settings are preserved. 19 + * 20 + * PCI Memory and Prefetchable Memory is direct-mapped. However I/O Space is 21 + * accessed through a Window which is translated to low 64KB in PCI space, the 22 + * first 4KB is not used so 60KB is available. 19 23 */ 20 24 void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info) 21 25 { 22 26 LIST_HEAD(resources); 23 27 struct pci_bus *root_bus; 24 28 25 - pci_add_resource(&resources, &info->io_space); 29 + pci_add_resource_offset(&resources, &info->io_space, 30 + info->io_space.start - 0x1000); 26 31 pci_add_resource(&resources, &info->mem_space); 27 32 28 33 root_bus = pci_scan_root_bus(&ofdev->dev, 0, info->ops, info, ··· 42 37 pci_free_resource_list(&resources); 43 38 } 44 39 } 45 - 46 - /* PCI Memory and Prefetchable Memory is direct-mapped. However I/O Space is 47 - * accessed through a Window which is translated to low 64KB in PCI space, the 48 - * first 4KB is not used so 60KB is available. 49 - * 50 - * This function is used by generic code to translate resource addresses into 51 - * PCI addresses. 52 - */ 53 - void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, 54 - struct resource *res) 55 - { 56 - struct leon_pci_info *info = dev->bus->sysdata; 57 - 58 - region->start = res->start; 59 - region->end = res->end; 60 - 61 - if (res->flags & IORESOURCE_IO) { 62 - region->start -= (info->io_space.start - 0x1000); 63 - region->end -= (info->io_space.start - 0x1000); 64 - } 65 - } 66 - EXPORT_SYMBOL(pcibios_resource_to_bus); 67 - 68 - /* see pcibios_resource_to_bus() comment */ 69 - void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 70 - struct pci_bus_region *region) 71 - { 72 - struct leon_pci_info *info = dev->bus->sysdata; 73 - 74 - res->start = region->start; 75 - res->end = region->end; 76 - 77 - if (res->flags & IORESOURCE_IO) { 78 - res->start += (info->io_space.start - 0x1000); 79 - res->end += (info->io_space.start - 0x1000); 80 - } 81 - } 82 - EXPORT_SYMBOL(pcibios_bus_to_resource); 83 40 84 41 void __devinit pcibios_fixup_bus(struct pci_bus *pbus) 85 42 {
+29 -77
arch/sparc/kernel/pci.c
··· 375 375 *last_p = last; 376 376 } 377 377 378 - static void pci_resource_adjust(struct resource *res, 379 - struct resource *root) 380 - { 381 - res->start += root->start; 382 - res->end += root->start; 383 - } 384 - 385 378 /* For PCI bus devices which lack a 'ranges' property we interrogate 386 379 * the config space values to set the resources, just like the generic 387 380 * Linux PCI probing code does. ··· 383 390 struct pci_bus *bus, 384 391 struct pci_pbm_info *pbm) 385 392 { 386 - struct resource *res; 393 + struct pci_bus_region region; 394 + struct resource *res, res2; 387 395 u8 io_base_lo, io_limit_lo; 388 396 u16 mem_base_lo, mem_limit_lo; 389 397 unsigned long base, limit; ··· 406 412 res = bus->resource[0]; 407 413 if (base <= limit) { 408 414 res->flags = (io_base_lo & PCI_IO_RANGE_TYPE_MASK) | IORESOURCE_IO; 415 + res2.flags = res->flags; 416 + region.start = base; 417 + region.end = limit + 0xfff; 418 + pcibios_bus_to_resource(dev, &res2, &region); 409 419 if (!res->start) 410 - res->start = base; 420 + res->start = res2.start; 411 421 if (!res->end) 412 - res->end = limit + 0xfff; 413 - pci_resource_adjust(res, &pbm->io_space); 422 + res->end = res2.end; 414 423 } 415 424 416 425 pci_read_config_word(dev, PCI_MEMORY_BASE, &mem_base_lo); ··· 425 428 if (base <= limit) { 426 429 res->flags = ((mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | 427 430 IORESOURCE_MEM); 428 - res->start = base; 429 - res->end = limit + 0xfffff; 430 - pci_resource_adjust(res, &pbm->mem_space); 431 + region.start = base; 432 + region.end = limit + 0xfffff; 433 + pcibios_bus_to_resource(dev, res, &region); 431 434 } 432 435 433 436 pci_read_config_word(dev, PCI_PREF_MEMORY_BASE, &mem_base_lo); ··· 456 459 if (base <= limit) { 457 460 res->flags = ((mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | 458 461 IORESOURCE_MEM | IORESOURCE_PREFETCH); 459 - res->start = base; 460 - res->end = limit + 0xfffff; 461 - pci_resource_adjust(res, &pbm->mem_space); 462 + region.start = base; 463 + region.end = limit + 0xfffff; 464 + pcibios_bus_to_resource(dev, res, &region); 462 465 } 463 466 } 464 467 ··· 469 472 struct pci_bus *bus, 470 473 struct pci_pbm_info *pbm) 471 474 { 475 + struct pci_bus_region region; 472 476 struct resource *res; 473 477 u32 first, last; 474 478 u8 map; ··· 477 479 pci_read_config_byte(dev, APB_IO_ADDRESS_MAP, &map); 478 480 apb_calc_first_last(map, &first, &last); 479 481 res = bus->resource[0]; 480 - res->start = (first << 21); 481 - res->end = (last << 21) + ((1 << 21) - 1); 482 482 res->flags = IORESOURCE_IO; 483 - pci_resource_adjust(res, &pbm->io_space); 483 + region.start = (first << 21); 484 + region.end = (last << 21) + ((1 << 21) - 1); 485 + pcibios_bus_to_resource(dev, res, &region); 484 486 485 487 pci_read_config_byte(dev, APB_MEM_ADDRESS_MAP, &map); 486 488 apb_calc_first_last(map, &first, &last); 487 489 res = bus->resource[1]; 488 - res->start = (first << 21); 489 - res->end = (last << 21) + ((1 << 21) - 1); 490 490 res->flags = IORESOURCE_MEM; 491 - pci_resource_adjust(res, &pbm->mem_space); 491 + region.start = (first << 21); 492 + region.end = (last << 21) + ((1 << 21) - 1); 493 + pcibios_bus_to_resource(dev, res, &region); 492 494 } 493 495 494 496 static void __devinit pci_of_scan_bus(struct pci_pbm_info *pbm, ··· 504 506 struct pci_bus *bus; 505 507 const u32 *busrange, *ranges; 506 508 int len, i, simba; 509 + struct pci_bus_region region; 507 510 struct resource *res; 508 511 unsigned int flags; 509 512 u64 size; ··· 555 556 } 556 557 i = 1; 557 558 for (; len >= 32; len -= 32, ranges += 8) { 558 - struct resource *root; 559 - 560 559 flags = pci_parse_of_flags(ranges[0]); 561 560 size = GET_64BIT(ranges, 6); 562 561 if (flags == 0 || size == 0) ··· 566 569 " for bridge %s\n", node->full_name); 567 570 continue; 568 571 } 569 - root = &pbm->io_space; 570 572 } else { 571 573 if (i >= PCI_NUM_RESOURCES - PCI_BRIDGE_RESOURCES) { 572 574 printk(KERN_ERR "PCI: too many memory ranges" ··· 574 578 } 575 579 res = bus->resource[i]; 576 580 ++i; 577 - root = &pbm->mem_space; 578 581 } 579 582 580 - res->start = GET_64BIT(ranges, 1); 581 - res->end = res->start + size - 1; 582 583 res->flags = flags; 583 - 584 - /* Another way to implement this would be to add an of_device 585 - * layer routine that can calculate a resource for a given 586 - * range property value in a PCI device. 587 - */ 588 - pci_resource_adjust(res, root); 584 + region.start = GET_64BIT(ranges, 1); 585 + region.end = region.start + size - 1; 586 + pcibios_bus_to_resource(dev, res, &region); 589 587 } 590 588 after_ranges: 591 589 sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus), ··· 681 691 682 692 printk("PCI: Scanning PBM %s\n", node->full_name); 683 693 684 - pci_add_resource(&resources, &pbm->io_space); 685 - pci_add_resource(&resources, &pbm->mem_space); 694 + pci_add_resource_offset(&resources, &pbm->io_space, 695 + pbm->io_space.start); 696 + pci_add_resource_offset(&resources, &pbm->mem_space, 697 + pbm->mem_space.start); 686 698 bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops, 687 699 pbm, &resources); 688 700 if (!bus) { ··· 746 754 } 747 755 return 0; 748 756 } 749 - 750 - void pcibios_resource_to_bus(struct pci_dev *pdev, struct pci_bus_region *region, 751 - struct resource *res) 752 - { 753 - struct pci_pbm_info *pbm = pdev->bus->sysdata; 754 - struct resource zero_res, *root; 755 - 756 - zero_res.start = 0; 757 - zero_res.end = 0; 758 - zero_res.flags = res->flags; 759 - 760 - if (res->flags & IORESOURCE_IO) 761 - root = &pbm->io_space; 762 - else 763 - root = &pbm->mem_space; 764 - 765 - pci_resource_adjust(&zero_res, root); 766 - 767 - region->start = res->start - zero_res.start; 768 - region->end = res->end - zero_res.start; 769 - } 770 - EXPORT_SYMBOL(pcibios_resource_to_bus); 771 - 772 - void pcibios_bus_to_resource(struct pci_dev *pdev, struct resource *res, 773 - struct pci_bus_region *region) 774 - { 775 - struct pci_pbm_info *pbm = pdev->bus->sysdata; 776 - struct resource *root; 777 - 778 - res->start = region->start; 779 - res->end = region->end; 780 - 781 - if (res->flags & IORESOURCE_IO) 782 - root = &pbm->io_space; 783 - else 784 - root = &pbm->mem_space; 785 - 786 - pci_resource_adjust(res, root); 787 - } 788 - EXPORT_SYMBOL(pcibios_bus_to_resource); 789 757 790 758 char * __devinit pcibios_setup(char *str) 791 759 {
+1
arch/unicore32/include/asm/pci.h
··· 14 14 15 15 #ifdef __KERNEL__ 16 16 #include <asm-generic/pci-dma-compat.h> 17 + #include <asm-generic/pci-bridge.h> 17 18 #include <asm-generic/pci.h> 18 19 #include <mach/hardware.h> /* for PCIBIOS_MIN_* */ 19 20
+2 -3
arch/unicore32/kernel/pci.c
··· 21 21 #include <linux/io.h> 22 22 23 23 static int debug_pci; 24 - static int use_firmware; 25 24 26 25 #define CONFIG_CMD(bus, devfn, where) \ 27 26 (0x80000000 | (bus->number << 16) | (devfn << 8) | (where & ~3)) ··· 275 276 276 277 pci_fixup_irqs(pci_common_swizzle, pci_puv3_map_irq); 277 278 278 - if (!use_firmware) { 279 + if (!pci_has_flag(PCI_PROBE_ONLY)) { 279 280 /* 280 281 * Size the bridge windows. 281 282 */ ··· 302 303 debug_pci = 1; 303 304 return NULL; 304 305 } else if (!strcmp(str, "firmware")) { 305 - use_firmware = 1; 306 + pci_add_flags(PCI_PROBE_ONLY); 306 307 return NULL; 307 308 } 308 309 return str;
+3 -2
arch/x86/kernel/pci-dma.c
··· 262 262 263 263 static __devinit void via_no_dac(struct pci_dev *dev) 264 264 { 265 - if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI && forbid_dac == 0) { 265 + if (forbid_dac == 0) { 266 266 dev_info(&dev->dev, "disabling DAC on VIA PCI bridge\n"); 267 267 forbid_dac = 1; 268 268 } 269 269 } 270 - DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_ANY_ID, via_no_dac); 270 + DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_VIA, PCI_ANY_ID, 271 + PCI_CLASS_BRIDGE_PCI, 8, via_no_dac); 271 272 #endif
+6 -1
arch/x86/pci/acpi.c
··· 416 416 kfree(sd); 417 417 } else { 418 418 get_current_resources(device, busnum, domain, &resources); 419 - if (list_empty(&resources)) 419 + 420 + /* 421 + * _CRS with no apertures is normal, so only fall back to 422 + * defaults or native bridge info if we're ignoring _CRS. 423 + */ 424 + if (!pci_use_crs) 420 425 x86_pci_root_bus_resources(busnum, &resources); 421 426 bus = pci_create_root_bus(NULL, busnum, &pci_root_ops, sd, 422 427 &resources);
+5 -7
arch/x86/pci/fixup.c
··· 164 164 */ 165 165 static void __devinit pci_fixup_transparent_bridge(struct pci_dev *dev) 166 166 { 167 - if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI && 168 - (dev->device & 0xff00) == 0x2400) 167 + if ((dev->device & 0xff00) == 0x2400) 169 168 dev->transparent = 1; 170 169 } 171 - DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, pci_fixup_transparent_bridge); 170 + DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, 171 + PCI_CLASS_BRIDGE_PCI, 8, pci_fixup_transparent_bridge); 172 172 173 173 /* 174 174 * Fixup for C1 Halt Disconnect problem on nForce2 systems. ··· 322 322 struct pci_bus *bus; 323 323 u16 config; 324 324 325 - if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA) 326 - return; 327 - 328 325 /* Is VGA routed to us? */ 329 326 bus = pdev->bus; 330 327 while (bus) { ··· 350 353 dev_printk(KERN_DEBUG, &pdev->dev, "Boot video device\n"); 351 354 } 352 355 } 353 - DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, pci_fixup_video); 356 + DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID, 357 + PCI_CLASS_DISPLAY_VGA, 8, pci_fixup_video); 354 358 355 359 356 360 static const struct dmi_system_id __devinitconst msi_k8t_dmi_table[] = {
+84 -1
arch/x86/pci/i386.c
··· 39 39 #include <asm/io_apic.h> 40 40 41 41 42 + /* 43 + * This list of dynamic mappings is for temporarily maintaining 44 + * original BIOS BAR addresses for possible reinstatement. 45 + */ 46 + struct pcibios_fwaddrmap { 47 + struct list_head list; 48 + struct pci_dev *dev; 49 + resource_size_t fw_addr[DEVICE_COUNT_RESOURCE]; 50 + }; 51 + 52 + static LIST_HEAD(pcibios_fwaddrmappings); 53 + static DEFINE_SPINLOCK(pcibios_fwaddrmap_lock); 54 + 55 + /* Must be called with 'pcibios_fwaddrmap_lock' lock held. */ 56 + static struct pcibios_fwaddrmap *pcibios_fwaddrmap_lookup(struct pci_dev *dev) 57 + { 58 + struct pcibios_fwaddrmap *map; 59 + 60 + WARN_ON(!spin_is_locked(&pcibios_fwaddrmap_lock)); 61 + 62 + list_for_each_entry(map, &pcibios_fwaddrmappings, list) 63 + if (map->dev == dev) 64 + return map; 65 + 66 + return NULL; 67 + } 68 + 69 + static void 70 + pcibios_save_fw_addr(struct pci_dev *dev, int idx, resource_size_t fw_addr) 71 + { 72 + unsigned long flags; 73 + struct pcibios_fwaddrmap *map; 74 + 75 + spin_lock_irqsave(&pcibios_fwaddrmap_lock, flags); 76 + map = pcibios_fwaddrmap_lookup(dev); 77 + if (!map) { 78 + spin_unlock_irqrestore(&pcibios_fwaddrmap_lock, flags); 79 + map = kzalloc(sizeof(*map), GFP_KERNEL); 80 + if (!map) 81 + return; 82 + 83 + map->dev = pci_dev_get(dev); 84 + map->fw_addr[idx] = fw_addr; 85 + INIT_LIST_HEAD(&map->list); 86 + 87 + spin_lock_irqsave(&pcibios_fwaddrmap_lock, flags); 88 + list_add_tail(&map->list, &pcibios_fwaddrmappings); 89 + } else 90 + map->fw_addr[idx] = fw_addr; 91 + spin_unlock_irqrestore(&pcibios_fwaddrmap_lock, flags); 92 + } 93 + 94 + resource_size_t pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx) 95 + { 96 + unsigned long flags; 97 + struct pcibios_fwaddrmap *map; 98 + resource_size_t fw_addr = 0; 99 + 100 + spin_lock_irqsave(&pcibios_fwaddrmap_lock, flags); 101 + map = pcibios_fwaddrmap_lookup(dev); 102 + if (map) 103 + fw_addr = map->fw_addr[idx]; 104 + spin_unlock_irqrestore(&pcibios_fwaddrmap_lock, flags); 105 + 106 + return fw_addr; 107 + } 108 + 109 + static void pcibios_fw_addr_list_del(void) 110 + { 111 + unsigned long flags; 112 + struct pcibios_fwaddrmap *entry, *next; 113 + 114 + spin_lock_irqsave(&pcibios_fwaddrmap_lock, flags); 115 + list_for_each_entry_safe(entry, next, &pcibios_fwaddrmappings, list) { 116 + list_del(&entry->list); 117 + pci_dev_put(entry->dev); 118 + kfree(entry); 119 + } 120 + spin_unlock_irqrestore(&pcibios_fwaddrmap_lock, flags); 121 + } 122 + 42 123 static int 43 124 skip_isa_ioresource_align(struct pci_dev *dev) { 44 125 ··· 263 182 idx, r, disabled, pass); 264 183 if (pci_claim_resource(dev, idx) < 0) { 265 184 /* We'll assign a new address later */ 266 - dev->fw_addr[idx] = r->start; 185 + pcibios_save_fw_addr(dev, 186 + idx, r->start); 267 187 r->end -= r->start; 268 188 r->start = 0; 269 189 } ··· 310 228 } 311 229 312 230 pci_assign_unassigned_resources(); 231 + pcibios_fw_addr_list_del(); 313 232 314 233 return 0; 315 234 }
+38 -2
arch/x86/pci/mrst.c
··· 43 43 #define PCI_FIXED_BAR_4_SIZE 0x14 44 44 #define PCI_FIXED_BAR_5_SIZE 0x1c 45 45 46 + static int pci_soc_mode = 0; 47 + 46 48 /** 47 49 * fixed_bar_cap - return the offset of the fixed BAR cap if found 48 50 * @bus: PCI bus ··· 150 148 */ 151 149 if (reg >= 0x100 || reg == PCI_STATUS || reg == PCI_HEADER_TYPE) 152 150 return 0; 153 - if (bus == 0 && (devfn == PCI_DEVFN(2, 0) || devfn == PCI_DEVFN(0, 0))) 151 + if (bus == 0 && (devfn == PCI_DEVFN(2, 0) 152 + || devfn == PCI_DEVFN(0, 0) 153 + || devfn == PCI_DEVFN(3, 0))) 154 154 return 1; 155 155 return 0; /* langwell on others */ 156 156 } ··· 235 231 */ 236 232 int __init pci_mrst_init(void) 237 233 { 238 - printk(KERN_INFO "Moorestown platform detected, using MRST PCI ops\n"); 234 + printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n"); 239 235 pci_mmcfg_late_init(); 240 236 pcibios_enable_irq = mrst_pci_irq_enable; 241 237 pci_root_ops = pci_mrst_ops; 238 + pci_soc_mode = 1; 242 239 /* Continue with standard init */ 243 240 return 1; 244 241 } 242 + 243 + /* Langwell devices are not true pci devices, they are not subject to 10 ms 244 + * d3 to d0 delay required by pci spec. 245 + */ 246 + static void __devinit pci_d3delay_fixup(struct pci_dev *dev) 247 + { 248 + /* PCI fixups are effectively decided compile time. If we have a dual 249 + SoC/non-SoC kernel we don't want to mangle d3 on non SoC devices */ 250 + if (!pci_soc_mode) 251 + return; 252 + /* true pci devices in lincroft should allow type 1 access, the rest 253 + * are langwell fake pci devices. 254 + */ 255 + if (type1_access_ok(dev->bus->number, dev->devfn, PCI_DEVICE_ID)) 256 + return; 257 + dev->d3_delay = 0; 258 + } 259 + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, pci_d3delay_fixup); 260 + 261 + static void __devinit mrst_power_off_unused_dev(struct pci_dev *dev) 262 + { 263 + pci_set_power_state(dev, PCI_D3cold); 264 + } 265 + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0801, mrst_power_off_unused_dev); 266 + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0809, mrst_power_off_unused_dev); 267 + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x080C, mrst_power_off_unused_dev); 268 + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0812, mrst_power_off_unused_dev); 269 + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0815, mrst_power_off_unused_dev); 245 270 246 271 /* 247 272 * Langwell devices reside at fixed offsets, don't try to move them. ··· 280 247 unsigned long offset; 281 248 u32 size; 282 249 int i; 250 + 251 + if (!pci_soc_mode) 252 + return; 283 253 284 254 /* Must have extended configuration space */ 285 255 if (dev->cfg_size < PCIE_CAP_OFFSET + 4)
+1 -16
arch/xtensa/kernel/pci.c
··· 153 153 } 154 154 res->start += io_offset; 155 155 res->end += io_offset; 156 - pci_add_resource(resources, res); 156 + pci_add_resource_offset(resources, res, io_offset); 157 157 158 158 for (i = 0; i < 3; i++) { 159 159 res = &pci_ctrl->mem_resources[i]; ··· 200 200 201 201 void __init pcibios_fixup_bus(struct pci_bus *bus) 202 202 { 203 - struct pci_controller *pci_ctrl = bus->sysdata; 204 - struct resource *res; 205 - unsigned long io_offset; 206 - int i; 207 - 208 - io_offset = (unsigned long)pci_ctrl->io_space.base; 209 203 if (bus->parent) { 210 204 /* This is a subordinate bridge */ 211 205 pci_read_bridge_bases(bus); 212 - 213 - for (i = 0; i < 4; i++) { 214 - if ((res = bus->resource[i]) == NULL || !res->flags) 215 - continue; 216 - if (io_offset && (res->flags & IORESOURCE_IO)) { 217 - res->start += io_offset; 218 - res->end += io_offset; 219 - } 220 - } 221 206 } 222 207 } 223 208
+1 -1
drivers/message/fusion/mptbase.c
··· 346 346 if ((pdev == NULL)) 347 347 return -1; 348 348 349 - pci_remove_bus_device(pdev); 349 + pci_stop_and_remove_bus_device(pdev); 350 350 return 0; 351 351 } 352 352
+6 -21
drivers/parisc/dino.c
··· 553 553 struct list_head *ln; 554 554 struct pci_dev *dev; 555 555 struct dino_device *dino_dev = DINO_DEV(parisc_walk_tree(bus->bridge)); 556 - int port_base = HBA_PORT_BASE(dino_dev->hba.hba_num); 557 556 558 557 DBG(KERN_WARNING "%s(0x%p) bus %d platform_data 0x%p\n", 559 558 __func__, bus, bus->secondary, ··· 598 599 599 600 600 601 list_for_each(ln, &bus->devices) { 601 - int i; 602 - 603 602 dev = pci_dev_b(ln); 604 603 if (is_card_dino(&dino_dev->hba.dev->id)) 605 604 dino_card_fixup(dev); ··· 609 612 if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) 610 613 continue; 611 614 612 - /* Adjust the I/O Port space addresses */ 613 - for (i = 0; i < PCI_NUM_RESOURCES; i++) { 614 - struct resource *res = &dev->resource[i]; 615 - if (res->flags & IORESOURCE_IO) { 616 - res->start |= port_base; 617 - res->end |= port_base; 618 - } 619 - #ifdef __LP64__ 620 - /* Sign Extend MMIO addresses */ 621 - else if (res->flags & IORESOURCE_MEM) { 622 - res->start |= F_EXTEND(0UL); 623 - res->end |= F_EXTEND(0UL); 624 - } 625 - #endif 626 - } 627 615 /* null out the ROM resource if there is one (we don't 628 616 * care about an expansion rom on parisc, since it 629 617 * usually contains (x86) bios code) */ ··· 973 991 974 992 dev->dev.platform_data = dino_dev; 975 993 976 - pci_add_resource(&resources, &dino_dev->hba.io_space); 994 + pci_add_resource_offset(&resources, &dino_dev->hba.io_space, 995 + HBA_PORT_BASE(dino_dev->hba.hba_num)); 977 996 if (dino_dev->hba.lmmio_space.flags) 978 - pci_add_resource(&resources, &dino_dev->hba.lmmio_space); 997 + pci_add_resource_offset(&resources, &dino_dev->hba.lmmio_space, 998 + dino_dev->hba.lmmio_space_offset); 979 999 if (dino_dev->hba.elmmio_space.flags) 980 - pci_add_resource(&resources, &dino_dev->hba.elmmio_space); 1000 + pci_add_resource_offset(&resources, &dino_dev->hba.elmmio_space, 1001 + dino_dev->hba.lmmio_space_offset); 981 1002 if (dino_dev->hba.gmmio_space.flags) 982 1003 pci_add_resource(&resources, &dino_dev->hba.gmmio_space); 983 1004
+6 -25
drivers/parisc/lba_pci.c
··· 635 635 u16 status; 636 636 #endif 637 637 struct lba_device *ldev = LBA_DEV(parisc_walk_tree(bus->bridge)); 638 - int lba_portbase = HBA_PORT_BASE(ldev->hba.hba_num); 639 638 640 639 DBG("lba_fixup_bus(0x%p) bus %d platform_data 0x%p\n", 641 640 bus, bus->secondary, bus->bridge->platform_data); ··· 724 725 /* If resource not allocated - skip it */ 725 726 if (!res->start) 726 727 continue; 727 - 728 - if (res->flags & IORESOURCE_IO) { 729 - DBG("lba_fixup_bus() I/O Ports [%lx/%lx] -> ", 730 - res->start, res->end); 731 - res->start |= lba_portbase; 732 - res->end |= lba_portbase; 733 - DBG("[%lx/%lx]\n", res->start, res->end); 734 - } else if (res->flags & IORESOURCE_MEM) { 735 - /* 736 - ** Convert PCI (IO_VIEW) addresses to 737 - ** processor (PA_VIEW) addresses 738 - */ 739 - DBG("lba_fixup_bus() MMIO [%lx/%lx] -> ", 740 - res->start, res->end); 741 - res->start = PCI_HOST_ADDR(HBA_DATA(ldev), res->start); 742 - res->end = PCI_HOST_ADDR(HBA_DATA(ldev), res->end); 743 - DBG("[%lx/%lx]\n", res->start, res->end); 744 - } else { 745 - DBG("lba_fixup_bus() WTF? 0x%lx [%lx/%lx] XXX", 746 - res->flags, res->start, res->end); 747 - } 748 728 749 729 /* 750 730 ** FIXME: this will result in whinging for devices ··· 1492 1514 lba_dev->hba.lmmio_space.flags = 0; 1493 1515 } 1494 1516 1495 - pci_add_resource(&resources, &lba_dev->hba.io_space); 1517 + pci_add_resource_offset(&resources, &lba_dev->hba.io_space, 1518 + HBA_PORT_BASE(lba_dev->hba.hba_num)); 1496 1519 if (lba_dev->hba.elmmio_space.start) 1497 - pci_add_resource(&resources, &lba_dev->hba.elmmio_space); 1520 + pci_add_resource_offset(&resources, &lba_dev->hba.elmmio_space, 1521 + lba_dev->hba.lmmio_space_offset); 1498 1522 if (lba_dev->hba.lmmio_space.flags) 1499 - pci_add_resource(&resources, &lba_dev->hba.lmmio_space); 1523 + pci_add_resource_offset(&resources, &lba_dev->hba.lmmio_space, 1524 + lba_dev->hba.lmmio_space_offset); 1500 1525 if (lba_dev->hba.gmmio_space.flags) 1501 1526 pci_add_resource(&resources, &lba_dev->hba.gmmio_space); 1502 1527
+13
drivers/pci/Kconfig
··· 31 31 32 32 When in doubt, say N. 33 33 34 + config PCI_REALLOC_ENABLE_AUTO 35 + bool "Enable PCI resource re-allocation detection" 36 + depends on PCI 37 + help 38 + Say Y here if you want the PCI core to detect if PCI resource 39 + re-allocation needs to be enabled. You can always use pci=realloc=on 40 + or pci=realloc=off to override it. Note this feature is a no-op 41 + unless PCI_IOV support is also enabled; in that case it will 42 + automatically re-allocate PCI resources if SR-IOV BARs have not 43 + been allocated by the BIOS. 44 + 45 + When in doubt, say N. 46 + 34 47 config PCI_STUB 35 48 tristate "PCI Stub driver" 36 49 depends on PCI
+19 -11
drivers/pci/bus.c
··· 18 18 19 19 #include "pci.h" 20 20 21 - void pci_add_resource(struct list_head *resources, struct resource *res) 21 + void pci_add_resource_offset(struct list_head *resources, struct resource *res, 22 + resource_size_t offset) 22 23 { 23 - struct pci_bus_resource *bus_res; 24 + struct pci_host_bridge_window *window; 24 25 25 - bus_res = kzalloc(sizeof(struct pci_bus_resource), GFP_KERNEL); 26 - if (!bus_res) { 27 - printk(KERN_ERR "PCI: can't add bus resource %pR\n", res); 26 + window = kzalloc(sizeof(struct pci_host_bridge_window), GFP_KERNEL); 27 + if (!window) { 28 + printk(KERN_ERR "PCI: can't add host bridge window %pR\n", res); 28 29 return; 29 30 } 30 31 31 - bus_res->res = res; 32 - list_add_tail(&bus_res->list, resources); 32 + window->res = res; 33 + window->offset = offset; 34 + list_add_tail(&window->list, resources); 35 + } 36 + EXPORT_SYMBOL(pci_add_resource_offset); 37 + 38 + void pci_add_resource(struct list_head *resources, struct resource *res) 39 + { 40 + pci_add_resource_offset(resources, res, 0); 33 41 } 34 42 EXPORT_SYMBOL(pci_add_resource); 35 43 36 44 void pci_free_resource_list(struct list_head *resources) 37 45 { 38 - struct pci_bus_resource *bus_res, *tmp; 46 + struct pci_host_bridge_window *window, *tmp; 39 47 40 - list_for_each_entry_safe(bus_res, tmp, resources, list) { 41 - list_del(&bus_res->list); 42 - kfree(bus_res); 48 + list_for_each_entry_safe(window, tmp, resources, list) { 49 + list_del(&window->list); 50 + kfree(window); 43 51 } 44 52 } 45 53 EXPORT_SYMBOL(pci_free_resource_list);
+15 -18
drivers/pci/hotplug/acpiphp_glue.c
··· 800 800 if (slot->flags & SLOT_ENABLED) 801 801 goto err_exit; 802 802 803 - /* sanity check: dev should be NULL when hot-plugged in */ 804 - dev = pci_get_slot(bus, PCI_DEVFN(slot->device, 0)); 805 - if (dev) { 806 - /* This case shouldn't happen */ 807 - err("pci_dev structure already exists.\n"); 808 - pci_dev_put(dev); 809 - retval = -1; 810 - goto err_exit; 811 - } 812 - 813 803 num = pci_scan_slot(bus, PCI_DEVFN(slot->device, 0)); 814 804 if (num == 0) { 815 - err("No new device found\n"); 816 - retval = -1; 805 + /* Maybe only part of funcs are added. */ 806 + dbg("No new device found\n"); 817 807 goto err_exit; 818 808 } 819 809 ··· 838 848 839 849 pci_bus_add_devices(bus); 840 850 851 + slot->flags |= SLOT_ENABLED; 841 852 list_for_each_entry(func, &slot->funcs, sibling) { 842 853 dev = pci_get_slot(bus, PCI_DEVFN(slot->device, 843 854 func->function)); 844 - if (!dev) 855 + if (!dev) { 856 + /* Do not set SLOT_ENABLED flag if some funcs 857 + are not added. */ 858 + slot->flags &= (~SLOT_ENABLED); 845 859 continue; 860 + } 846 861 847 862 if (dev->hdr_type != PCI_HEADER_TYPE_BRIDGE && 848 863 dev->hdr_type != PCI_HEADER_TYPE_CARDBUS) { ··· 862 867 pci_dev_put(dev); 863 868 } 864 869 865 - slot->flags |= SLOT_ENABLED; 866 870 867 871 err_exit: 868 872 return retval; ··· 886 892 { 887 893 struct acpiphp_func *func; 888 894 struct pci_dev *pdev; 895 + struct pci_bus *bus = slot->bridge->pci_bus; 889 896 890 - /* is this slot already disabled? */ 891 - if (!(slot->flags & SLOT_ENABLED)) 897 + /* The slot will be enabled when func 0 is added, so check 898 + func 0 before disable the slot. */ 899 + pdev = pci_get_slot(bus, PCI_DEVFN(slot->device, 0)); 900 + if (!pdev) 892 901 goto err_exit; 893 902 894 903 list_for_each_entry(func, &slot->funcs, sibling) { ··· 910 913 disable_bridges(pdev->subordinate); 911 914 pci_disable_device(pdev); 912 915 } 913 - pci_remove_bus_device(pdev); 916 + __pci_remove_bus_device(pdev); 914 917 pci_dev_put(pdev); 915 918 } 916 919 } ··· 1067 1070 res->end) { 1068 1071 /* Could not assign a required resources 1069 1072 * for this device, remove it */ 1070 - pci_remove_bus_device(dev); 1073 + pci_stop_and_remove_bus_device(dev); 1071 1074 break; 1072 1075 } 1073 1076 }
+1 -1
drivers/pci/hotplug/cpci_hotplug_pci.c
··· 341 341 dev = pci_get_slot(slot->bus, 342 342 PCI_DEVFN(PCI_SLOT(slot->devfn), i)); 343 343 if (dev) { 344 - pci_remove_bus_device(dev); 344 + pci_stop_and_remove_bus_device(dev); 345 345 pci_dev_put(dev); 346 346 } 347 347 }
+1 -1
drivers/pci/hotplug/cpcihp_generic.c
··· 62 62 #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) 63 63 64 64 /* local variables */ 65 - static int debug; 65 + static bool debug; 66 66 static char *bridge; 67 67 static u8 bridge_busnr; 68 68 static u8 bridge_slot;
+1 -1
drivers/pci/hotplug/cpqphp_pci.c
··· 127 127 struct pci_dev* temp = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, j)); 128 128 if (temp) { 129 129 pci_dev_put(temp); 130 - pci_remove_bus_device(temp); 130 + pci_stop_and_remove_bus_device(temp); 131 131 } 132 132 } 133 133 return 0;
+1 -1
drivers/pci/hotplug/fakephp.c
··· 40 40 41 41 static void remove_callback(void *data) 42 42 { 43 - pci_remove_bus_device((struct pci_dev *)data); 43 + pci_stop_and_remove_bus_device((struct pci_dev *)data); 44 44 } 45 45 46 46 static ssize_t legacy_store(struct kobject *kobj, struct attribute *attr,
+1 -1
drivers/pci/hotplug/ibmphp_core.c
··· 721 721 for (j = 0; j < 0x08; j++) { 722 722 temp = pci_get_bus_and_slot(func->busno, (func->device << 3) | j); 723 723 if (temp) { 724 - pci_remove_bus_device(temp); 724 + pci_stop_and_remove_bus_device(temp); 725 725 pci_dev_put(temp); 726 726 } 727 727 }
+4 -2
drivers/pci/hotplug/ibmphp_ebda.c
··· 368 368 debug ("rio blk id: %x\n", blk_id); 369 369 370 370 rio_table_ptr = kzalloc(sizeof(struct rio_table_hdr), GFP_KERNEL); 371 - if (!rio_table_ptr) 372 - return -ENOMEM; 371 + if (!rio_table_ptr) { 372 + rc = -ENOMEM; 373 + goto out; 374 + } 373 375 rio_table_ptr->ver_num = readb (io_mem + offset); 374 376 rio_table_ptr->scal_count = readb (io_mem + offset + 1); 375 377 rio_table_ptr->riodev_count = readb (io_mem + offset + 2);
+109 -24
drivers/pci/hotplug/pciehp_hpc.c
··· 241 241 return retval; 242 242 } 243 243 244 - static inline int check_link_active(struct controller *ctrl) 244 + static bool check_link_active(struct controller *ctrl) 245 245 { 246 - u16 link_status; 246 + bool ret = false; 247 + u16 lnk_status; 247 248 248 - if (pciehp_readw(ctrl, PCI_EXP_LNKSTA, &link_status)) 249 - return 0; 250 - return !!(link_status & PCI_EXP_LNKSTA_DLLLA); 249 + if (pciehp_readw(ctrl, PCI_EXP_LNKSTA, &lnk_status)) 250 + return ret; 251 + 252 + ret = !!(lnk_status & PCI_EXP_LNKSTA_DLLLA); 253 + 254 + if (ret) 255 + ctrl_dbg(ctrl, "%s: lnk_status = %x\n", __func__, lnk_status); 256 + 257 + return ret; 251 258 } 252 259 253 - static void pcie_wait_link_active(struct controller *ctrl) 260 + static void __pcie_wait_link_active(struct controller *ctrl, bool active) 254 261 { 255 262 int timeout = 1000; 256 263 257 - if (check_link_active(ctrl)) 264 + if (check_link_active(ctrl) == active) 258 265 return; 259 266 while (timeout > 0) { 260 267 msleep(10); 261 268 timeout -= 10; 262 - if (check_link_active(ctrl)) 269 + if (check_link_active(ctrl) == active) 263 270 return; 264 271 } 265 - ctrl_dbg(ctrl, "Data Link Layer Link Active not set in 1000 msec\n"); 272 + ctrl_dbg(ctrl, "Data Link Layer Link Active not %s in 1000 msec\n", 273 + active ? "set" : "cleared"); 274 + } 275 + 276 + static void pcie_wait_link_active(struct controller *ctrl) 277 + { 278 + __pcie_wait_link_active(ctrl, true); 279 + } 280 + 281 + static void pcie_wait_link_not_active(struct controller *ctrl) 282 + { 283 + __pcie_wait_link_active(ctrl, false); 284 + } 285 + 286 + static bool pci_bus_check_dev(struct pci_bus *bus, int devfn) 287 + { 288 + u32 l; 289 + int count = 0; 290 + int delay = 1000, step = 20; 291 + bool found = false; 292 + 293 + do { 294 + found = pci_bus_read_dev_vendor_id(bus, devfn, &l, 0); 295 + count++; 296 + 297 + if (found) 298 + break; 299 + 300 + msleep(step); 301 + delay -= step; 302 + } while (delay > 0); 303 + 304 + if (count > 1 && pciehp_debug) 305 + printk(KERN_DEBUG "pci %04x:%02x:%02x.%d id reading try %d times with interval %d ms to get %08x\n", 306 + pci_domain_nr(bus), bus->number, PCI_SLOT(devfn), 307 + PCI_FUNC(devfn), count, step, l); 308 + 309 + return found; 266 310 } 267 311 268 312 int pciehp_check_link_status(struct controller *ctrl) 269 313 { 270 314 u16 lnk_status; 271 315 int retval = 0; 316 + bool found = false; 272 317 273 318 /* 274 319 * Data Link Layer Link Active Reporting must be capable for ··· 325 280 else 326 281 msleep(1000); 327 282 328 - /* 329 - * Need to wait for 1000 ms after Data Link Layer Link Active 330 - * (DLLLA) bit reads 1b before sending configuration request. 331 - * We need it before checking Link Training (LT) bit becuase 332 - * LT is still set even after DLLLA bit is set on some platform. 333 - */ 334 - msleep(1000); 283 + /* wait 100ms before read pci conf, and try in 1s */ 284 + msleep(100); 285 + found = pci_bus_check_dev(ctrl->pcie->port->subordinate, 286 + PCI_DEVFN(0, 0)); 335 287 336 288 retval = pciehp_readw(ctrl, PCI_EXP_LNKSTA, &lnk_status); 337 289 if (retval) { ··· 344 302 return retval; 345 303 } 346 304 347 - /* 348 - * If the port supports Link speeds greater than 5.0 GT/s, we 349 - * must wait for 100 ms after Link training completes before 350 - * sending configuration request. 351 - */ 352 - if (ctrl->pcie->port->subordinate->max_bus_speed > PCIE_SPEED_5_0GT) 353 - msleep(100); 354 - 355 305 pcie_update_link_speed(ctrl->pcie->port->subordinate, lnk_status); 356 306 307 + if (!found && !retval) 308 + retval = -1; 309 + 357 310 return retval; 311 + } 312 + 313 + static int __pciehp_link_set(struct controller *ctrl, bool enable) 314 + { 315 + u16 lnk_ctrl; 316 + int retval = 0; 317 + 318 + retval = pciehp_readw(ctrl, PCI_EXP_LNKCTL, &lnk_ctrl); 319 + if (retval) { 320 + ctrl_err(ctrl, "Cannot read LNKCTRL register\n"); 321 + return retval; 322 + } 323 + 324 + if (enable) 325 + lnk_ctrl &= ~PCI_EXP_LNKCTL_LD; 326 + else 327 + lnk_ctrl |= PCI_EXP_LNKCTL_LD; 328 + 329 + retval = pciehp_writew(ctrl, PCI_EXP_LNKCTL, lnk_ctrl); 330 + if (retval) { 331 + ctrl_err(ctrl, "Cannot write LNKCTRL register\n"); 332 + return retval; 333 + } 334 + ctrl_dbg(ctrl, "%s: lnk_ctrl = %x\n", __func__, lnk_ctrl); 335 + 336 + return retval; 337 + } 338 + 339 + static int pciehp_link_enable(struct controller *ctrl) 340 + { 341 + return __pciehp_link_set(ctrl, true); 342 + } 343 + 344 + static int pciehp_link_disable(struct controller *ctrl) 345 + { 346 + return __pciehp_link_set(ctrl, false); 358 347 } 359 348 360 349 int pciehp_get_attention_status(struct slot *slot, u8 *status) ··· 606 533 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__, 607 534 pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, slot_cmd); 608 535 536 + retval = pciehp_link_enable(ctrl); 537 + if (retval) 538 + ctrl_err(ctrl, "%s: Can not enable the link!\n", __func__); 539 + 609 540 return retval; 610 541 } 611 542 ··· 619 542 u16 slot_cmd; 620 543 u16 cmd_mask; 621 544 int retval; 545 + 546 + /* Disable the link at first */ 547 + pciehp_link_disable(ctrl); 548 + /* wait the link is down */ 549 + if (ctrl->link_active_reporting) 550 + pcie_wait_link_not_active(ctrl); 551 + else 552 + msleep(1000); 622 553 623 554 slot_cmd = POWER_OFF; 624 555 cmd_mask = PCI_EXP_SLTCTL_PCC;
+1 -1
drivers/pci/hotplug/pciehp_pci.c
··· 141 141 break; 142 142 } 143 143 } 144 - pci_remove_bus_device(temp); 144 + pci_stop_and_remove_bus_device(temp); 145 145 /* 146 146 * Ensure that no new Requests will be generated from 147 147 * the device.
+1 -1
drivers/pci/hotplug/rpadlpar_core.c
··· 389 389 BUG_ON(!bus->self); 390 390 pr_debug("PCI: Now removing bridge device %s\n", pci_name(bus->self)); 391 391 eeh_remove_bus_device(bus->self); 392 - pci_remove_bus_device(bus->self); 392 + pci_stop_and_remove_bus_device(bus->self); 393 393 394 394 return 0; 395 395 }
+1 -1
drivers/pci/hotplug/sgi_hotplug.c
··· 554 554 PCI_FUNC(func))); 555 555 if (dev) { 556 556 sn_bus_free_data(dev); 557 - pci_remove_bus_device(dev); 557 + pci_stop_and_remove_bus_device(dev); 558 558 pci_dev_put(dev); 559 559 } 560 560 }
+1 -1
drivers/pci/hotplug/shpchp_pci.c
··· 124 124 break; 125 125 } 126 126 } 127 - pci_remove_bus_device(temp); 127 + pci_stop_and_remove_bus_device(temp); 128 128 pci_dev_put(temp); 129 129 } 130 130 return rc;
+9 -3
drivers/pci/iov.c
··· 142 142 failed1: 143 143 pci_dev_put(dev); 144 144 mutex_lock(&iov->dev->sriov->lock); 145 - pci_remove_bus_device(virtfn); 145 + pci_stop_and_remove_bus_device(virtfn); 146 146 virtfn_remove_bus(dev->bus, virtfn_bus(dev, id)); 147 147 mutex_unlock(&iov->dev->sriov->lock); 148 148 ··· 173 173 174 174 sprintf(buf, "virtfn%u", id); 175 175 sysfs_remove_link(&dev->dev.kobj, buf); 176 - sysfs_remove_link(&virtfn->dev.kobj, "physfn"); 176 + /* 177 + * pci_stop_dev() could have been called for this virtfn already, 178 + * so the directory for the virtfn may have been removed before. 179 + * Double check to avoid spurious sysfs warnings. 180 + */ 181 + if (virtfn->dev.kobj.sd) 182 + sysfs_remove_link(&virtfn->dev.kobj, "physfn"); 177 183 178 184 mutex_lock(&iov->dev->sriov->lock); 179 - pci_remove_bus_device(virtfn); 185 + pci_stop_and_remove_bus_device(virtfn); 180 186 virtfn_remove_bus(dev->bus, virtfn_bus(dev, id)); 181 187 mutex_unlock(&iov->dev->sriov->lock); 182 188
+10
drivers/pci/pci-driver.c
··· 419 419 drv->shutdown(pci_dev); 420 420 pci_msi_shutdown(pci_dev); 421 421 pci_msix_shutdown(pci_dev); 422 + 423 + /* 424 + * Devices may be enabled to wake up by runtime PM, but they need not 425 + * be supposed to wake up the system from its "power off" state (e.g. 426 + * ACPI S5). Therefore disable wakeup for all devices that aren't 427 + * supposed to wake up the system at this point. The state argument 428 + * will be ignored by pci_enable_wake(). 429 + */ 430 + if (!device_may_wakeup(dev)) 431 + pci_enable_wake(pci_dev, PCI_UNKNOWN, false); 422 432 } 423 433 424 434 #ifdef CONFIG_PM
+5 -2
drivers/pci/pci-sysfs.c
··· 330 330 struct pci_dev *pdev = to_pci_dev(dev); 331 331 332 332 mutex_lock(&pci_remove_rescan_mutex); 333 - pci_remove_bus_device(pdev); 333 + pci_stop_and_remove_bus_device(pdev); 334 334 mutex_unlock(&pci_remove_rescan_mutex); 335 335 } 336 336 ··· 366 366 367 367 if (val) { 368 368 mutex_lock(&pci_remove_rescan_mutex); 369 - pci_rescan_bus(bus); 369 + if (!pci_is_root_bus(bus) && list_empty(&bus->devices)) 370 + pci_rescan_bus_bridge_resize(bus->self); 371 + else 372 + pci_rescan_bus(bus); 370 373 mutex_unlock(&pci_remove_rescan_mutex); 371 374 } 372 375 return count;
+105 -3
drivers/pci/pci.c
··· 94 94 */ 95 95 unsigned int pcibios_max_latency = 255; 96 96 97 + /* If set, the PCIe ARI capability will not be used. */ 98 + static bool pcie_ari_disabled; 99 + 97 100 /** 98 101 * pci_bus_max_busnr - returns maximum PCI bus number of given bus' children 99 102 * @bus: pointer to PCI bus structure to search ··· 828 825 #define pcie_cap_has_sltctl2(type, flags) \ 829 826 ((flags & PCI_EXP_FLAGS_VERS) > 1) 830 827 828 + static struct pci_cap_saved_state *pci_find_saved_cap( 829 + struct pci_dev *pci_dev, char cap) 830 + { 831 + struct pci_cap_saved_state *tmp; 832 + struct hlist_node *pos; 833 + 834 + hlist_for_each_entry(tmp, pos, &pci_dev->saved_cap_space, next) { 835 + if (tmp->cap.cap_nr == cap) 836 + return tmp; 837 + } 838 + return NULL; 839 + } 840 + 831 841 static int pci_save_pcie_state(struct pci_dev *dev) 832 842 { 833 843 int pos, i = 0; ··· 975 959 { 976 960 int i; 977 961 u32 val; 962 + int tries; 978 963 979 964 if (!dev->state_saved) 980 965 return; ··· 990 973 */ 991 974 for (i = 15; i >= 0; i--) { 992 975 pci_read_config_dword(dev, i * 4, &val); 993 - if (val != dev->saved_config_space[i]) { 976 + tries = 10; 977 + while (tries && val != dev->saved_config_space[i]) { 994 978 dev_dbg(&dev->dev, "restoring config " 995 979 "space at offset %#x (was %#x, writing %#x)\n", 996 980 i, val, (int)dev->saved_config_space[i]); 997 981 pci_write_config_dword(dev,i * 4, 998 982 dev->saved_config_space[i]); 983 + pci_read_config_dword(dev, i * 4, &val); 984 + mdelay(10); 985 + tries--; 999 986 } 1000 987 } 1001 988 pci_restore_pcix_state(dev); ··· 1885 1864 platform_pci_sleep_wake(dev, false); 1886 1865 } 1887 1866 1867 + static void pci_add_saved_cap(struct pci_dev *pci_dev, 1868 + struct pci_cap_saved_state *new_cap) 1869 + { 1870 + hlist_add_head(&new_cap->next, &pci_dev->saved_cap_space); 1871 + } 1872 + 1888 1873 /** 1889 1874 * pci_add_save_buffer - allocate buffer for saving given capability registers 1890 1875 * @dev: the PCI device ··· 1938 1911 "unable to preallocate PCI-X save buffer\n"); 1939 1912 } 1940 1913 1914 + void pci_free_cap_save_buffers(struct pci_dev *dev) 1915 + { 1916 + struct pci_cap_saved_state *tmp; 1917 + struct hlist_node *pos, *n; 1918 + 1919 + hlist_for_each_entry_safe(tmp, pos, n, &dev->saved_cap_space, next) 1920 + kfree(tmp); 1921 + } 1922 + 1941 1923 /** 1942 1924 * pci_enable_ari - enable ARI forwarding if hardware support it 1943 1925 * @dev: the PCI device ··· 1958 1922 u16 flags, ctrl; 1959 1923 struct pci_dev *bridge; 1960 1924 1961 - if (!pci_is_pcie(dev) || dev->devfn) 1925 + if (pcie_ari_disabled || !pci_is_pcie(dev) || dev->devfn) 1962 1926 return; 1963 1927 1964 1928 pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ARI); ··· 3697 3661 return (pci_specified_resource_alignment(dev) != 0); 3698 3662 } 3699 3663 3664 + /* 3665 + * This function disables memory decoding and releases memory resources 3666 + * of the device specified by kernel's boot parameter 'pci=resource_alignment='. 3667 + * It also rounds up size to specified alignment. 3668 + * Later on, the kernel will assign page-aligned memory resource back 3669 + * to the device. 3670 + */ 3671 + void pci_reassigndev_resource_alignment(struct pci_dev *dev) 3672 + { 3673 + int i; 3674 + struct resource *r; 3675 + resource_size_t align, size; 3676 + u16 command; 3677 + 3678 + if (!pci_is_reassigndev(dev)) 3679 + return; 3680 + 3681 + if (dev->hdr_type == PCI_HEADER_TYPE_NORMAL && 3682 + (dev->class >> 8) == PCI_CLASS_BRIDGE_HOST) { 3683 + dev_warn(&dev->dev, 3684 + "Can't reassign resources to host bridge.\n"); 3685 + return; 3686 + } 3687 + 3688 + dev_info(&dev->dev, 3689 + "Disabling memory decoding and releasing memory resources.\n"); 3690 + pci_read_config_word(dev, PCI_COMMAND, &command); 3691 + command &= ~PCI_COMMAND_MEMORY; 3692 + pci_write_config_word(dev, PCI_COMMAND, command); 3693 + 3694 + align = pci_specified_resource_alignment(dev); 3695 + for (i = 0; i < PCI_BRIDGE_RESOURCES; i++) { 3696 + r = &dev->resource[i]; 3697 + if (!(r->flags & IORESOURCE_MEM)) 3698 + continue; 3699 + size = resource_size(r); 3700 + if (size < align) { 3701 + size = align; 3702 + dev_info(&dev->dev, 3703 + "Rounding up size of resource #%d to %#llx.\n", 3704 + i, (unsigned long long)size); 3705 + } 3706 + r->end = size - 1; 3707 + r->start = 0; 3708 + } 3709 + /* Need to disable bridge's resource window, 3710 + * to enable the kernel to reassign new resource 3711 + * window later on. 3712 + */ 3713 + if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE && 3714 + (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) { 3715 + for (i = PCI_BRIDGE_RESOURCES; i < PCI_NUM_RESOURCES; i++) { 3716 + r = &dev->resource[i]; 3717 + if (!(r->flags & IORESOURCE_MEM)) 3718 + continue; 3719 + r->end = resource_size(r) - 1; 3720 + r->start = 0; 3721 + } 3722 + pci_disable_bridge_window(dev); 3723 + } 3724 + } 3725 + 3700 3726 ssize_t pci_set_resource_alignment_param(const char *buf, size_t count) 3701 3727 { 3702 3728 if (count > RESOURCE_ALIGNMENT_PARAM_SIZE - 1) ··· 3837 3739 pci_no_msi(); 3838 3740 } else if (!strcmp(str, "noaer")) { 3839 3741 pci_no_aer(); 3742 + } else if (!strncmp(str, "realloc=", 8)) { 3743 + pci_realloc_get_opt(str + 8); 3840 3744 } else if (!strncmp(str, "realloc", 7)) { 3841 - pci_realloc(); 3745 + pci_realloc_get_opt("on"); 3842 3746 } else if (!strcmp(str, "nodomains")) { 3843 3747 pci_no_domains(); 3748 + } else if (!strncmp(str, "noari", 5)) { 3749 + pcie_ari_disabled = true; 3844 3750 } else if (!strncmp(str, "cbiosize=", 9)) { 3845 3751 pci_cardbus_io_size = memparse(str + 9, &str); 3846 3752 } else if (!strncmp(str, "cbmemsize=", 10)) {
+5 -5
drivers/pci/pci.h
··· 73 73 extern void pci_pm_init(struct pci_dev *dev); 74 74 extern void platform_pci_wakeup_init(struct pci_dev *dev); 75 75 extern void pci_allocate_cap_save_buffers(struct pci_dev *dev); 76 + void pci_free_cap_save_buffers(struct pci_dev *dev); 76 77 77 78 static inline void pci_wakeup_event(struct pci_dev *dev) 78 79 { ··· 149 148 static inline void pci_msi_init_pci_dev(struct pci_dev *dev) { } 150 149 #endif 151 150 152 - extern void pci_realloc(void); 151 + void pci_realloc_get_opt(char *); 153 152 154 153 static inline int pci_no_d1d2(struct pci_dev *dev) 155 154 { ··· 208 207 pci_bar_mem64, /* A 64-bit memory BAR */ 209 208 }; 210 209 210 + bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *pl, 211 + int crs_timeout); 211 212 extern int pci_setup_device(struct pci_dev *dev); 212 213 extern int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, 213 214 struct resource *res, unsigned int reg); ··· 228 225 return bus->self && bus->self->ari_enabled; 229 226 } 230 227 231 - #ifdef CONFIG_PCI_QUIRKS 232 - extern int pci_is_reassigndev(struct pci_dev *dev); 233 - resource_size_t pci_specified_resource_alignment(struct pci_dev *dev); 228 + void pci_reassigndev_resource_alignment(struct pci_dev *dev); 234 229 extern void pci_disable_bridge_window(struct pci_dev *dev); 235 - #endif 236 230 237 231 /* Single Root I/O Virtualization */ 238 232 struct pci_sriov {
+25
drivers/pci/pcie/Kconfig
··· 55 55 This enables PCI Express ASPM debug support. It will add per-device 56 56 interface to control ASPM. 57 57 58 + choice 59 + prompt "Default ASPM policy" 60 + default PCIEASPM_DEFAULT 61 + depends on PCIEASPM 62 + 63 + config PCIEASPM_DEFAULT 64 + bool "BIOS default" 65 + depends on PCIEASPM 66 + help 67 + Use the BIOS defaults for PCI Express ASPM. 68 + 69 + config PCIEASPM_POWERSAVE 70 + bool "Powersave" 71 + depends on PCIEASPM 72 + help 73 + Enable PCI Express ASPM L0s and L1 where possible, even if the 74 + BIOS did not. 75 + 76 + config PCIEASPM_PERFORMANCE 77 + bool "Performance" 78 + depends on PCIEASPM 79 + help 80 + Disable PCI Express ASPM L0s and L1, even if the BIOS enabled them. 81 + endchoice 82 + 58 83 config PCIE_PME 59 84 def_bool y 60 85 depends on PCIEPORTBUS && PM_RUNTIME && EXPERIMENTAL && ACPI
+8
drivers/pci/pcie/aspm.c
··· 76 76 #define POLICY_DEFAULT 0 /* BIOS default setting */ 77 77 #define POLICY_PERFORMANCE 1 /* high performance */ 78 78 #define POLICY_POWERSAVE 2 /* high power saving */ 79 + 80 + #ifdef CONFIG_PCIEASPM_PERFORMANCE 81 + static int aspm_policy = POLICY_PERFORMANCE; 82 + #elif defined CONFIG_PCIEASPM_POWERSAVE 83 + static int aspm_policy = POLICY_POWERSAVE; 84 + #else 79 85 static int aspm_policy; 86 + #endif 87 + 80 88 static const char *policy_str[] = { 81 89 [POLICY_DEFAULT] = "default", 82 90 [POLICY_PERFORMANCE] = "performance",
+12
drivers/pci/pcie/portdrv.h
··· 34 34 35 35 extern void pcie_clear_root_pme_status(struct pci_dev *dev); 36 36 37 + #ifdef CONFIG_HOTPLUG_PCI_PCIE 38 + extern bool pciehp_msi_disabled; 39 + 40 + static inline bool pciehp_no_msi(void) 41 + { 42 + return pciehp_msi_disabled; 43 + } 44 + 45 + #else /* !CONFIG_HOTPLUG_PCI_PCIE */ 46 + static inline bool pciehp_no_msi(void) { return false; } 47 + #endif /* !CONFIG_HOTPLUG_PCI_PCIE */ 48 + 37 49 #ifdef CONFIG_PCIE_PME 38 50 extern bool pcie_pme_msi_disabled; 39 51
+14 -2
drivers/pci/pcie/portdrv_core.c
··· 19 19 #include "../pci.h" 20 20 #include "portdrv.h" 21 21 22 + bool pciehp_msi_disabled; 23 + 24 + static int __init pciehp_setup(char *str) 25 + { 26 + if (!strncmp(str, "nomsi", 5)) 27 + pciehp_msi_disabled = true; 28 + 29 + return 1; 30 + } 31 + __setup("pcie_hp=", pciehp_setup); 32 + 22 33 /** 23 34 * release_pcie_device - free PCI Express port service device structure 24 35 * @dev: Port service device to release ··· 200 189 { 201 190 int i, irq = -1; 202 191 203 - /* We have to use INTx if MSI cannot be used for PCIe PME. */ 204 - if ((mask & PCIE_PORT_SERVICE_PME) && pcie_pme_no_msi()) { 192 + /* We have to use INTx if MSI cannot be used for PCIe PME or pciehp. */ 193 + if (((mask & PCIE_PORT_SERVICE_PME) && pcie_pme_no_msi()) || 194 + ((mask & PCIE_PORT_SERVICE_HP) && pciehp_no_msi())) { 205 195 if (dev->pin) 206 196 irq = dev->irq; 207 197 goto no_msi;
+222 -88
drivers/pci/probe.c
··· 15 15 #define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */ 16 16 #define CARDBUS_RESERVE_BUSNR 3 17 17 18 + static LIST_HEAD(pci_host_bridges); 19 + 18 20 /* Ugh. Need to stop exporting this to modules. */ 19 21 LIST_HEAD(pci_root_buses); 20 22 EXPORT_SYMBOL(pci_root_buses); ··· 43 41 return no_devices; 44 42 } 45 43 EXPORT_SYMBOL(no_pci_devices); 44 + 45 + static struct pci_host_bridge *pci_host_bridge(struct pci_dev *dev) 46 + { 47 + struct pci_bus *bus; 48 + struct pci_host_bridge *bridge; 49 + 50 + bus = dev->bus; 51 + while (bus->parent) 52 + bus = bus->parent; 53 + 54 + list_for_each_entry(bridge, &pci_host_bridges, list) { 55 + if (bridge->bus == bus) 56 + return bridge; 57 + } 58 + 59 + return NULL; 60 + } 61 + 62 + static bool resource_contains(struct resource *res1, struct resource *res2) 63 + { 64 + return res1->start <= res2->start && res1->end >= res2->end; 65 + } 66 + 67 + void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, 68 + struct resource *res) 69 + { 70 + struct pci_host_bridge *bridge = pci_host_bridge(dev); 71 + struct pci_host_bridge_window *window; 72 + resource_size_t offset = 0; 73 + 74 + list_for_each_entry(window, &bridge->windows, list) { 75 + if (resource_type(res) != resource_type(window->res)) 76 + continue; 77 + 78 + if (resource_contains(window->res, res)) { 79 + offset = window->offset; 80 + break; 81 + } 82 + } 83 + 84 + region->start = res->start - offset; 85 + region->end = res->end - offset; 86 + } 87 + EXPORT_SYMBOL(pcibios_resource_to_bus); 88 + 89 + static bool region_contains(struct pci_bus_region *region1, 90 + struct pci_bus_region *region2) 91 + { 92 + return region1->start <= region2->start && region1->end >= region2->end; 93 + } 94 + 95 + void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 96 + struct pci_bus_region *region) 97 + { 98 + struct pci_host_bridge *bridge = pci_host_bridge(dev); 99 + struct pci_host_bridge_window *window; 100 + struct pci_bus_region bus_region; 101 + resource_size_t offset = 0; 102 + 103 + list_for_each_entry(window, &bridge->windows, list) { 104 + if (resource_type(res) != resource_type(window->res)) 105 + continue; 106 + 107 + bus_region.start = window->res->start - window->offset; 108 + bus_region.end = window->res->end - window->offset; 109 + 110 + if (region_contains(&bus_region, region)) { 111 + offset = window->offset; 112 + break; 113 + } 114 + } 115 + 116 + res->start = region->start + offset; 117 + res->end = region->end + offset; 118 + } 119 + EXPORT_SYMBOL(pcibios_bus_to_resource); 46 120 47 121 /* 48 122 * PCI Bus Class ··· 213 135 { 214 136 u32 l, sz, mask; 215 137 u16 orig_cmd; 138 + struct pci_bus_region region; 216 139 217 140 mask = type ? PCI_ROM_ADDRESS_MASK : ~0; 218 141 ··· 293 214 /* Address above 32-bit boundary; disable the BAR */ 294 215 pci_write_config_dword(dev, pos, 0); 295 216 pci_write_config_dword(dev, pos + 4, 0); 296 - res->start = 0; 297 - res->end = sz64; 217 + region.start = 0; 218 + region.end = sz64; 219 + pcibios_bus_to_resource(dev, res, &region); 298 220 } else { 299 - res->start = l64; 300 - res->end = l64 + sz64; 221 + region.start = l64; 222 + region.end = l64 + sz64; 223 + pcibios_bus_to_resource(dev, res, &region); 301 224 dev_printk(KERN_DEBUG, &dev->dev, "reg %x: %pR\n", 302 225 pos, res); 303 226 } ··· 309 228 if (!sz) 310 229 goto fail; 311 230 312 - res->start = l; 313 - res->end = l + sz; 231 + region.start = l; 232 + region.end = l + sz; 233 + pcibios_bus_to_resource(dev, res, &region); 314 234 315 235 dev_printk(KERN_DEBUG, &dev->dev, "reg %x: %pR\n", pos, res); 316 236 } ··· 348 266 struct pci_dev *dev = child->self; 349 267 u8 io_base_lo, io_limit_lo; 350 268 unsigned long base, limit; 351 - struct resource *res; 269 + struct pci_bus_region region; 270 + struct resource *res, res2; 352 271 353 272 res = child->resource[0]; 354 273 pci_read_config_byte(dev, PCI_IO_BASE, &io_base_lo); ··· 367 284 368 285 if (base && base <= limit) { 369 286 res->flags = (io_base_lo & PCI_IO_RANGE_TYPE_MASK) | IORESOURCE_IO; 287 + res2.flags = res->flags; 288 + region.start = base; 289 + region.end = limit + 0xfff; 290 + pcibios_bus_to_resource(dev, &res2, &region); 370 291 if (!res->start) 371 - res->start = base; 292 + res->start = res2.start; 372 293 if (!res->end) 373 - res->end = limit + 0xfff; 294 + res->end = res2.end; 374 295 dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res); 375 296 } 376 297 } ··· 384 297 struct pci_dev *dev = child->self; 385 298 u16 mem_base_lo, mem_limit_lo; 386 299 unsigned long base, limit; 300 + struct pci_bus_region region; 387 301 struct resource *res; 388 302 389 303 res = child->resource[1]; ··· 394 306 limit = (mem_limit_lo & PCI_MEMORY_RANGE_MASK) << 16; 395 307 if (base && base <= limit) { 396 308 res->flags = (mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | IORESOURCE_MEM; 397 - res->start = base; 398 - res->end = limit + 0xfffff; 309 + region.start = base; 310 + region.end = limit + 0xfffff; 311 + pcibios_bus_to_resource(dev, res, &region); 399 312 dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res); 400 313 } 401 314 } ··· 406 317 struct pci_dev *dev = child->self; 407 318 u16 mem_base_lo, mem_limit_lo; 408 319 unsigned long base, limit; 320 + struct pci_bus_region region; 409 321 struct resource *res; 410 322 411 323 res = child->resource[2]; ··· 443 353 IORESOURCE_MEM | IORESOURCE_PREFETCH; 444 354 if (res->flags & PCI_PREF_RANGE_TYPE_64) 445 355 res->flags |= IORESOURCE_MEM_64; 446 - res->start = base; 447 - res->end = limit + 0xfffff; 356 + region.start = base; 357 + region.end = limit + 0xfffff; 358 + pcibios_bus_to_resource(dev, res, &region); 448 359 dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res); 449 360 } 450 361 } ··· 991 900 u8 hdr_type; 992 901 struct pci_slot *slot; 993 902 int pos = 0; 903 + struct pci_bus_region region; 904 + struct resource *res; 994 905 995 906 if (pci_read_config_byte(dev, PCI_HEADER_TYPE, &hdr_type)) 996 907 return -EIO; ··· 1019 926 1020 927 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class); 1021 928 dev->revision = class & 0xff; 1022 - class >>= 8; /* upper 3 bytes */ 1023 - dev->class = class; 1024 - class >>= 8; 929 + dev->class = class >> 8; /* upper 3 bytes */ 1025 930 1026 - dev_printk(KERN_DEBUG, &dev->dev, "[%04x:%04x] type %d class %#08x\n", 1027 - dev->vendor, dev->device, dev->hdr_type, class); 931 + dev_printk(KERN_DEBUG, &dev->dev, "[%04x:%04x] type %02x class %#08x\n", 932 + dev->vendor, dev->device, dev->hdr_type, dev->class); 1028 933 1029 934 /* need to have dev->class ready */ 1030 935 dev->cfg_size = pci_cfg_space_size(dev); ··· 1054 963 u8 progif; 1055 964 pci_read_config_byte(dev, PCI_CLASS_PROG, &progif); 1056 965 if ((progif & 1) == 0) { 1057 - dev->resource[0].start = 0x1F0; 1058 - dev->resource[0].end = 0x1F7; 1059 - dev->resource[0].flags = LEGACY_IO_RESOURCE; 1060 - dev->resource[1].start = 0x3F6; 1061 - dev->resource[1].end = 0x3F6; 1062 - dev->resource[1].flags = LEGACY_IO_RESOURCE; 966 + region.start = 0x1F0; 967 + region.end = 0x1F7; 968 + res = &dev->resource[0]; 969 + res->flags = LEGACY_IO_RESOURCE; 970 + pcibios_bus_to_resource(dev, res, &region); 971 + region.start = 0x3F6; 972 + region.end = 0x3F6; 973 + res = &dev->resource[1]; 974 + res->flags = LEGACY_IO_RESOURCE; 975 + pcibios_bus_to_resource(dev, res, &region); 1063 976 } 1064 977 if ((progif & 4) == 0) { 1065 - dev->resource[2].start = 0x170; 1066 - dev->resource[2].end = 0x177; 1067 - dev->resource[2].flags = LEGACY_IO_RESOURCE; 1068 - dev->resource[3].start = 0x376; 1069 - dev->resource[3].end = 0x376; 1070 - dev->resource[3].flags = LEGACY_IO_RESOURCE; 978 + region.start = 0x170; 979 + region.end = 0x177; 980 + res = &dev->resource[2]; 981 + res->flags = LEGACY_IO_RESOURCE; 982 + pcibios_bus_to_resource(dev, res, &region); 983 + region.start = 0x376; 984 + region.end = 0x376; 985 + res = &dev->resource[3]; 986 + res->flags = LEGACY_IO_RESOURCE; 987 + pcibios_bus_to_resource(dev, res, &region); 1071 988 } 1072 989 } 1073 990 break; ··· 1112 1013 return -EIO; 1113 1014 1114 1015 bad: 1115 - dev_err(&dev->dev, "ignoring class %02x (doesn't match header " 1116 - "type %02x)\n", class, dev->hdr_type); 1016 + dev_err(&dev->dev, "ignoring class %#08x (doesn't match header " 1017 + "type %02x)\n", dev->class, dev->hdr_type); 1117 1018 dev->class = PCI_CLASS_NOT_DEFINED; 1118 1019 } 1119 1020 ··· 1125 1026 { 1126 1027 pci_vpd_release(dev); 1127 1028 pci_iov_release(dev); 1029 + pci_free_cap_save_buffers(dev); 1128 1030 } 1129 1031 1130 1032 /** ··· 1218 1118 } 1219 1119 EXPORT_SYMBOL(alloc_pci_dev); 1220 1120 1121 + bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l, 1122 + int crs_timeout) 1123 + { 1124 + int delay = 1; 1125 + 1126 + if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, l)) 1127 + return false; 1128 + 1129 + /* some broken boards return 0 or ~0 if a slot is empty: */ 1130 + if (*l == 0xffffffff || *l == 0x00000000 || 1131 + *l == 0x0000ffff || *l == 0xffff0000) 1132 + return false; 1133 + 1134 + /* Configuration request Retry Status */ 1135 + while (*l == 0xffff0001) { 1136 + if (!crs_timeout) 1137 + return false; 1138 + 1139 + msleep(delay); 1140 + delay *= 2; 1141 + if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, l)) 1142 + return false; 1143 + /* Card hasn't responded in 60 seconds? Must be stuck. */ 1144 + if (delay > crs_timeout) { 1145 + printk(KERN_WARNING "pci %04x:%02x:%02x.%d: not " 1146 + "responding\n", pci_domain_nr(bus), 1147 + bus->number, PCI_SLOT(devfn), 1148 + PCI_FUNC(devfn)); 1149 + return false; 1150 + } 1151 + } 1152 + 1153 + return true; 1154 + } 1155 + EXPORT_SYMBOL(pci_bus_read_dev_vendor_id); 1156 + 1221 1157 /* 1222 1158 * Read the config data for a PCI device, sanity-check it 1223 1159 * and fill in the dev structure... ··· 1262 1126 { 1263 1127 struct pci_dev *dev; 1264 1128 u32 l; 1265 - int delay = 1; 1266 1129 1267 - if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, &l)) 1130 + if (!pci_bus_read_dev_vendor_id(bus, devfn, &l, 60*1000)) 1268 1131 return NULL; 1269 - 1270 - /* some broken boards return 0 or ~0 if a slot is empty: */ 1271 - if (l == 0xffffffff || l == 0x00000000 || 1272 - l == 0x0000ffff || l == 0xffff0000) 1273 - return NULL; 1274 - 1275 - /* Configuration request Retry Status */ 1276 - while (l == 0xffff0001) { 1277 - msleep(delay); 1278 - delay *= 2; 1279 - if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, &l)) 1280 - return NULL; 1281 - /* Card hasn't responded in 60 seconds? Must be stuck. */ 1282 - if (delay > 60 * 1000) { 1283 - printk(KERN_WARNING "pci %04x:%02x:%02x.%d: not " 1284 - "responding\n", pci_domain_nr(bus), 1285 - bus->number, PCI_SLOT(devfn), 1286 - PCI_FUNC(devfn)); 1287 - return NULL; 1288 - } 1289 - } 1290 1132 1291 1133 dev = alloc_pci_dev(); 1292 1134 if (!dev) ··· 1325 1211 1326 1212 /* Fix up broken headers */ 1327 1213 pci_fixup_device(pci_fixup_header, dev); 1214 + 1215 + /* moved out from quirk header fixup code */ 1216 + pci_reassigndev_resource_alignment(dev); 1328 1217 1329 1218 /* Clear the state_saved flag. */ 1330 1219 dev->state_saved = false; ··· 1647 1530 struct pci_bus *pci_create_root_bus(struct device *parent, int bus, 1648 1531 struct pci_ops *ops, void *sysdata, struct list_head *resources) 1649 1532 { 1650 - int error, i; 1533 + int error; 1534 + struct pci_host_bridge *bridge; 1651 1535 struct pci_bus *b, *b2; 1652 1536 struct device *dev; 1653 - struct pci_bus_resource *bus_res, *n; 1537 + struct pci_host_bridge_window *window, *n; 1654 1538 struct resource *res; 1539 + resource_size_t offset; 1540 + char bus_addr[64]; 1541 + char *fmt; 1542 + 1543 + bridge = kzalloc(sizeof(*bridge), GFP_KERNEL); 1544 + if (!bridge) 1545 + return NULL; 1655 1546 1656 1547 b = pci_alloc_bus(); 1657 1548 if (!b) 1658 - return NULL; 1549 + goto err_bus; 1659 1550 1660 1551 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 1661 - if (!dev) { 1662 - kfree(b); 1663 - return NULL; 1664 - } 1552 + if (!dev) 1553 + goto err_dev; 1665 1554 1666 1555 b->sysdata = sysdata; 1667 1556 b->ops = ops; ··· 1678 1555 dev_dbg(&b2->dev, "bus already known\n"); 1679 1556 goto err_out; 1680 1557 } 1681 - 1682 - down_write(&pci_bus_sem); 1683 - list_add_tail(&b->node, &pci_root_buses); 1684 - up_write(&pci_bus_sem); 1685 1558 1686 1559 dev->parent = parent; 1687 1560 dev->release = pci_release_bus_bridge_dev; ··· 1704 1585 1705 1586 b->number = b->secondary = bus; 1706 1587 1707 - /* Add initial resources to the bus */ 1708 - list_for_each_entry_safe(bus_res, n, resources, list) 1709 - list_move_tail(&bus_res->list, &b->resources); 1588 + bridge->bus = b; 1589 + INIT_LIST_HEAD(&bridge->windows); 1710 1590 1711 1591 if (parent) 1712 1592 dev_info(parent, "PCI host bridge to bus %s\n", dev_name(&b->dev)); 1713 1593 else 1714 1594 printk(KERN_INFO "PCI host bridge to bus %s\n", dev_name(&b->dev)); 1715 1595 1716 - pci_bus_for_each_resource(b, res, i) { 1717 - if (res) 1718 - dev_info(&b->dev, "root bus resource %pR\n", res); 1596 + /* Add initial resources to the bus */ 1597 + list_for_each_entry_safe(window, n, resources, list) { 1598 + list_move_tail(&window->list, &bridge->windows); 1599 + res = window->res; 1600 + offset = window->offset; 1601 + pci_bus_add_resource(b, res, 0); 1602 + if (offset) { 1603 + if (resource_type(res) == IORESOURCE_IO) 1604 + fmt = " (bus address [%#06llx-%#06llx])"; 1605 + else 1606 + fmt = " (bus address [%#010llx-%#010llx])"; 1607 + snprintf(bus_addr, sizeof(bus_addr), fmt, 1608 + (unsigned long long) (res->start - offset), 1609 + (unsigned long long) (res->end - offset)); 1610 + } else 1611 + bus_addr[0] = '\0'; 1612 + dev_info(&b->dev, "root bus resource %pR%s\n", res, bus_addr); 1719 1613 } 1614 + 1615 + down_write(&pci_bus_sem); 1616 + list_add_tail(&bridge->list, &pci_host_bridges); 1617 + list_add_tail(&b->node, &pci_root_buses); 1618 + up_write(&pci_bus_sem); 1720 1619 1721 1620 return b; 1722 1621 ··· 1742 1605 device_unregister(dev); 1743 1606 dev_reg_err: 1744 1607 down_write(&pci_bus_sem); 1608 + list_del(&bridge->list); 1745 1609 list_del(&b->node); 1746 1610 up_write(&pci_bus_sem); 1747 1611 err_out: 1748 1612 kfree(dev); 1613 + err_dev: 1749 1614 kfree(b); 1615 + err_bus: 1616 + kfree(bridge); 1750 1617 return NULL; 1751 1618 } 1752 1619 ··· 1808 1667 1809 1668 #ifdef CONFIG_HOTPLUG 1810 1669 /** 1811 - * pci_rescan_bus - scan a PCI bus for devices. 1812 - * @bus: PCI bus to scan 1670 + * pci_rescan_bus_bridge_resize - scan a PCI bus for devices. 1671 + * @bridge: PCI bridge for the bus to scan 1813 1672 * 1814 - * Scan a PCI bus and child buses for new devices, adds them, 1815 - * and enables them. 1673 + * Scan a PCI bus and child buses for new devices, add them, 1674 + * and enable them, resizing bridge mmio/io resource if necessary 1675 + * and possible. The caller must ensure the child devices are already 1676 + * removed for resizing to occur. 1816 1677 * 1817 1678 * Returns the max number of subordinate bus discovered. 1818 1679 */ 1819 - unsigned int __ref pci_rescan_bus(struct pci_bus *bus) 1680 + unsigned int __ref pci_rescan_bus_bridge_resize(struct pci_dev *bridge) 1820 1681 { 1821 1682 unsigned int max; 1822 - struct pci_dev *dev; 1683 + struct pci_bus *bus = bridge->subordinate; 1823 1684 1824 1685 max = pci_scan_child_bus(bus); 1825 1686 1826 - down_read(&pci_bus_sem); 1827 - list_for_each_entry(dev, &bus->devices, bus_list) 1828 - if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || 1829 - dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) 1830 - if (dev->subordinate) 1831 - pci_bus_size_bridges(dev->subordinate); 1832 - up_read(&pci_bus_sem); 1687 + pci_assign_unassigned_bridge_resources(bridge); 1833 1688 1834 - pci_bus_assign_resources(bus); 1835 - pci_enable_bridges(bus); 1836 1689 pci_bus_add_devices(bus); 1837 1690 1838 1691 return max; 1839 1692 } 1840 - EXPORT_SYMBOL_GPL(pci_rescan_bus); 1841 1693 1842 1694 EXPORT_SYMBOL(pci_add_new_bus); 1843 1695 EXPORT_SYMBOL(pci_scan_slot);
+90 -92
drivers/pci/quirks.c
··· 26 26 #include <linux/dmi.h> 27 27 #include <linux/pci-aspm.h> 28 28 #include <linux/ioport.h> 29 + #include <linux/sched.h> 30 + #include <linux/ktime.h> 29 31 #include <asm/dma.h> /* isa_dma_bridge_buggy */ 30 32 #include "pci.h" 31 - 32 - /* 33 - * This quirk function disables memory decoding and releases memory resources 34 - * of the device specified by kernel's boot parameter 'pci=resource_alignment='. 35 - * It also rounds up size to specified alignment. 36 - * Later on, the kernel will assign page-aligned memory resource back 37 - * to the device. 38 - */ 39 - static void __devinit quirk_resource_alignment(struct pci_dev *dev) 40 - { 41 - int i; 42 - struct resource *r; 43 - resource_size_t align, size; 44 - u16 command; 45 - 46 - if (!pci_is_reassigndev(dev)) 47 - return; 48 - 49 - if (dev->hdr_type == PCI_HEADER_TYPE_NORMAL && 50 - (dev->class >> 8) == PCI_CLASS_BRIDGE_HOST) { 51 - dev_warn(&dev->dev, 52 - "Can't reassign resources to host bridge.\n"); 53 - return; 54 - } 55 - 56 - dev_info(&dev->dev, 57 - "Disabling memory decoding and releasing memory resources.\n"); 58 - pci_read_config_word(dev, PCI_COMMAND, &command); 59 - command &= ~PCI_COMMAND_MEMORY; 60 - pci_write_config_word(dev, PCI_COMMAND, command); 61 - 62 - align = pci_specified_resource_alignment(dev); 63 - for (i=0; i < PCI_BRIDGE_RESOURCES; i++) { 64 - r = &dev->resource[i]; 65 - if (!(r->flags & IORESOURCE_MEM)) 66 - continue; 67 - size = resource_size(r); 68 - if (size < align) { 69 - size = align; 70 - dev_info(&dev->dev, 71 - "Rounding up size of resource #%d to %#llx.\n", 72 - i, (unsigned long long)size); 73 - } 74 - r->end = size - 1; 75 - r->start = 0; 76 - } 77 - /* Need to disable bridge's resource window, 78 - * to enable the kernel to reassign new resource 79 - * window later on. 80 - */ 81 - if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE && 82 - (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) { 83 - for (i = PCI_BRIDGE_RESOURCES; i < PCI_NUM_RESOURCES; i++) { 84 - r = &dev->resource[i]; 85 - if (!(r->flags & IORESOURCE_MEM)) 86 - continue; 87 - r->end = resource_size(r) - 1; 88 - r->start = 0; 89 - } 90 - pci_disable_bridge_window(dev); 91 - } 92 - } 93 - DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, quirk_resource_alignment); 94 33 95 34 /* 96 35 * Decoding should be disabled for a PCI device during BAR sizing to avoid ··· 39 100 */ 40 101 static void __devinit quirk_mmio_always_on(struct pci_dev *dev) 41 102 { 42 - if ((dev->class >> 8) == PCI_CLASS_BRIDGE_HOST) 43 - dev->mmio_always_on = 1; 103 + dev->mmio_always_on = 1; 44 104 } 45 - DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_ANY_ID, quirk_mmio_always_on); 105 + DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_ANY_ID, PCI_ANY_ID, 106 + PCI_CLASS_BRIDGE_HOST, 8, quirk_mmio_always_on); 46 107 47 108 /* The Mellanox Tavor device gives false positive parity errors 48 109 * Mark this device with a broken_parity_status, to allow ··· 941 1002 */ 942 1003 static void quirk_cardbus_legacy(struct pci_dev *dev) 943 1004 { 944 - if ((PCI_CLASS_BRIDGE_CARDBUS << 8) ^ dev->class) 945 - return; 946 1005 pci_write_config_dword(dev, PCI_CB_LEGACY_MODE_BASE, 0); 947 1006 } 948 - DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, quirk_cardbus_legacy); 949 - DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_ANY_ID, PCI_ANY_ID, quirk_cardbus_legacy); 1007 + DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID, 1008 + PCI_CLASS_BRIDGE_CARDBUS, 8, quirk_cardbus_legacy); 1009 + DECLARE_PCI_FIXUP_CLASS_RESUME_EARLY(PCI_ANY_ID, PCI_ANY_ID, 1010 + PCI_CLASS_BRIDGE_CARDBUS, 8, quirk_cardbus_legacy); 950 1011 951 1012 /* 952 1013 * Following the PCI ordering rules is optional on the AMD762. I'm not ··· 1103 1164 1104 1165 static void __devinit quirk_no_ata_d3(struct pci_dev *pdev) 1105 1166 { 1106 - /* Quirk the legacy ATA devices only. The AHCI ones are ok */ 1107 - if ((pdev->class >> 8) == PCI_CLASS_STORAGE_IDE) 1108 - pdev->dev_flags |= PCI_DEV_FLAGS_NO_D3; 1167 + pdev->dev_flags |= PCI_DEV_FLAGS_NO_D3; 1109 1168 } 1110 - DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, PCI_ANY_ID, quirk_no_ata_d3); 1111 - DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_ATI, PCI_ANY_ID, quirk_no_ata_d3); 1169 + /* Quirk the legacy ATA devices only. The AHCI ones are ok */ 1170 + DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_SERVERWORKS, PCI_ANY_ID, 1171 + PCI_CLASS_STORAGE_IDE, 8, quirk_no_ata_d3); 1172 + DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_ATI, PCI_ANY_ID, 1173 + PCI_CLASS_STORAGE_IDE, 8, quirk_no_ata_d3); 1112 1174 /* ALi loses some register settings that we cannot then restore */ 1113 - DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_AL, PCI_ANY_ID, quirk_no_ata_d3); 1175 + DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AL, PCI_ANY_ID, 1176 + PCI_CLASS_STORAGE_IDE, 8, quirk_no_ata_d3); 1114 1177 /* VIA comes back fine but we need to keep it alive or ACPI GTM failures 1115 1178 occur when mode detecting */ 1116 - DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_VIA, PCI_ANY_ID, quirk_no_ata_d3); 1179 + DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_VIA, PCI_ANY_ID, 1180 + PCI_CLASS_STORAGE_IDE, 8, quirk_no_ata_d3); 1117 1181 1118 1182 /* This was originally an Alpha specific thing, but it really fits here. 1119 1183 * The i82375 PCI/EISA bridge appears as non-classified. Fix that. ··· 1815 1873 case PCI_DEVICE_ID_NETMOS_9745: 1816 1874 case PCI_DEVICE_ID_NETMOS_9845: 1817 1875 case PCI_DEVICE_ID_NETMOS_9855: 1818 - if ((dev->class >> 8) == PCI_CLASS_COMMUNICATION_SERIAL && 1819 - num_parallel) { 1876 + if (num_parallel) { 1820 1877 dev_info(&dev->dev, "Netmos %04x (%u parallel, " 1821 1878 "%u serial); changing class SERIAL to OTHER " 1822 1879 "(use parport_serial)\n", ··· 1825 1884 } 1826 1885 } 1827 1886 } 1828 - DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NETMOS, PCI_ANY_ID, quirk_netmos); 1887 + DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_NETMOS, PCI_ANY_ID, 1888 + PCI_CLASS_COMMUNICATION_SERIAL, 8, quirk_netmos); 1829 1889 1830 1890 static void __devinit quirk_e100_interrupt(struct pci_dev *dev) 1831 1891 { ··· 1894 1952 1895 1953 iounmap(csr); 1896 1954 } 1897 - DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, quirk_e100_interrupt); 1955 + DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, 1956 + PCI_CLASS_NETWORK_ETHERNET, 8, quirk_e100_interrupt); 1898 1957 1899 1958 /* 1900 1959 * The 82575 and 82598 may experience data corruption issues when transitioning ··· 2777 2834 static void __devinit fixup_ti816x_class(struct pci_dev* dev) 2778 2835 { 2779 2836 /* TI 816x devices do not have class code set when in PCIe boot mode */ 2780 - if (dev->class == PCI_CLASS_NOT_DEFINED) { 2781 - dev_info(&dev->dev, "Setting PCI class for 816x PCIe device\n"); 2782 - dev->class = PCI_CLASS_MULTIMEDIA_VIDEO; 2783 - } 2837 + dev_info(&dev->dev, "Setting PCI class for 816x PCIe device\n"); 2838 + dev->class = PCI_CLASS_MULTIMEDIA_VIDEO; 2784 2839 } 2785 - DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_TI, 0xb800, fixup_ti816x_class); 2840 + DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_TI, 0xb800, 2841 + PCI_CLASS_NOT_DEFINED, 0, fixup_ti816x_class); 2786 2842 2787 2843 /* Some PCIe devices do not work reliably with the claimed maximum 2788 2844 * payload size supported. ··· 2866 2924 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65f9, quirk_intel_mc_errata); 2867 2925 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65fa, quirk_intel_mc_errata); 2868 2926 2927 + 2928 + static void do_one_fixup_debug(void (*fn)(struct pci_dev *dev), struct pci_dev *dev) 2929 + { 2930 + ktime_t calltime, delta, rettime; 2931 + unsigned long long duration; 2932 + 2933 + printk(KERN_DEBUG "calling %pF @ %i for %s\n", 2934 + fn, task_pid_nr(current), dev_name(&dev->dev)); 2935 + calltime = ktime_get(); 2936 + fn(dev); 2937 + rettime = ktime_get(); 2938 + delta = ktime_sub(rettime, calltime); 2939 + duration = (unsigned long long) ktime_to_ns(delta) >> 10; 2940 + printk(KERN_DEBUG "pci fixup %pF returned after %lld usecs for %s\n", 2941 + fn, duration, dev_name(&dev->dev)); 2942 + } 2943 + 2944 + /* 2945 + * Some BIOS implementations leave the Intel GPU interrupts enabled, 2946 + * even though no one is handling them (f.e. i915 driver is never loaded). 2947 + * Additionally the interrupt destination is not set up properly 2948 + * and the interrupt ends up -somewhere-. 2949 + * 2950 + * These spurious interrupts are "sticky" and the kernel disables 2951 + * the (shared) interrupt line after 100.000+ generated interrupts. 2952 + * 2953 + * Fix it by disabling the still enabled interrupts. 2954 + * This resolves crashes often seen on monitor unplug. 2955 + */ 2956 + #define I915_DEIER_REG 0x4400c 2957 + static void __devinit disable_igfx_irq(struct pci_dev *dev) 2958 + { 2959 + void __iomem *regs = pci_iomap(dev, 0, 0); 2960 + if (regs == NULL) { 2961 + dev_warn(&dev->dev, "igfx quirk: Can't iomap PCI device\n"); 2962 + return; 2963 + } 2964 + 2965 + /* Check if any interrupt line is still enabled */ 2966 + if (readl(regs + I915_DEIER_REG) != 0) { 2967 + dev_warn(&dev->dev, "BIOS left Intel GPU interrupts enabled; " 2968 + "disabling\n"); 2969 + 2970 + writel(0, regs + I915_DEIER_REG); 2971 + } 2972 + 2973 + pci_iounmap(dev, regs); 2974 + } 2975 + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0102, disable_igfx_irq); 2976 + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x010a, disable_igfx_irq); 2977 + 2869 2978 static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, 2870 2979 struct pci_fixup *end) 2871 2980 { 2872 - while (f < end) { 2873 - if ((f->vendor == dev->vendor || f->vendor == (u16) PCI_ANY_ID) && 2874 - (f->device == dev->device || f->device == (u16) PCI_ANY_ID)) { 2981 + for (; f < end; f++) 2982 + if ((f->class == (u32) (dev->class >> f->class_shift) || 2983 + f->class == (u32) PCI_ANY_ID) && 2984 + (f->vendor == dev->vendor || 2985 + f->vendor == (u16) PCI_ANY_ID) && 2986 + (f->device == dev->device || 2987 + f->device == (u16) PCI_ANY_ID)) { 2875 2988 dev_dbg(&dev->dev, "calling %pF\n", f->hook); 2876 - f->hook(dev); 2989 + if (initcall_debug) 2990 + do_one_fixup_debug(f->hook, dev); 2991 + else 2992 + f->hook(dev); 2877 2993 } 2878 - f++; 2879 - } 2880 2994 } 2881 2995 2882 2996 extern struct pci_fixup __start_pci_fixups_early[];
+19 -8
drivers/pci/remove.c
··· 79 79 80 80 static void __pci_remove_behind_bridge(struct pci_dev *dev); 81 81 /** 82 - * pci_remove_bus_device - remove a PCI device and any children 82 + * pci_stop_and_remove_bus_device - remove a PCI device and any children 83 83 * @dev: the device to remove 84 84 * 85 85 * Remove a PCI device from the device lists, informing the drivers ··· 90 90 * device lists, remove the /proc entry, and notify userspace 91 91 * (/sbin/hotplug). 92 92 */ 93 - static void __pci_remove_bus_device(struct pci_dev *dev) 93 + void __pci_remove_bus_device(struct pci_dev *dev) 94 94 { 95 95 if (dev->subordinate) { 96 96 struct pci_bus *b = dev->subordinate; ··· 102 102 103 103 pci_destroy_dev(dev); 104 104 } 105 - void pci_remove_bus_device(struct pci_dev *dev) 105 + EXPORT_SYMBOL(__pci_remove_bus_device); 106 + 107 + void pci_stop_and_remove_bus_device(struct pci_dev *dev) 106 108 { 107 109 pci_stop_bus_device(dev); 108 110 __pci_remove_bus_device(dev); ··· 129 127 } 130 128 131 129 /** 132 - * pci_remove_behind_bridge - remove all devices behind a PCI bridge 130 + * pci_stop_and_remove_behind_bridge - stop and remove all devices behind 131 + * a PCI bridge 133 132 * @dev: PCI bridge device 134 133 * 135 134 * Remove all devices on the bus, except for the parent bridge. 136 135 * This also removes any child buses, and any devices they may 137 136 * contain in a depth-first manner. 138 137 */ 139 - void pci_remove_behind_bridge(struct pci_dev *dev) 138 + void pci_stop_and_remove_behind_bridge(struct pci_dev *dev) 140 139 { 141 140 pci_stop_behind_bridge(dev); 142 141 __pci_remove_behind_bridge(dev); ··· 147 144 { 148 145 struct list_head *l, *n; 149 146 150 - list_for_each_safe(l, n, &bus->devices) { 147 + /* 148 + * VFs could be removed by pci_stop_and_remove_bus_device() in the 149 + * pci_stop_bus_devices() code path for PF. 150 + * aka, bus->devices get updated in the process. 151 + * but VFs are inserted after PFs when SRIOV is enabled for PF, 152 + * We can iterate the list backwards to get prev valid PF instead 153 + * of removed VF. 154 + */ 155 + list_for_each_prev_safe(l, n, &bus->devices) { 151 156 struct pci_dev *dev = pci_dev_b(l); 152 157 pci_stop_bus_device(dev); 153 158 } ··· 177 166 pci_stop_dev(dev); 178 167 } 179 168 180 - EXPORT_SYMBOL(pci_remove_bus_device); 181 - EXPORT_SYMBOL(pci_remove_behind_bridge); 169 + EXPORT_SYMBOL(pci_stop_and_remove_bus_device); 170 + EXPORT_SYMBOL(pci_stop_and_remove_behind_bridge); 182 171 EXPORT_SYMBOL_GPL(pci_stop_bus_device);
+458 -200
drivers/pci/setup-bus.c
··· 25 25 #include <linux/ioport.h> 26 26 #include <linux/cache.h> 27 27 #include <linux/slab.h> 28 + #include <asm-generic/pci-bridge.h> 28 29 #include "pci.h" 29 30 30 - struct resource_list_x { 31 - struct resource_list_x *next; 31 + unsigned int pci_flags; 32 + 33 + struct pci_dev_resource { 34 + struct list_head list; 32 35 struct resource *res; 33 36 struct pci_dev *dev; 34 37 resource_size_t start; ··· 41 38 unsigned long flags; 42 39 }; 43 40 44 - #define free_list(type, head) do { \ 45 - struct type *list, *tmp; \ 46 - for (list = (head)->next; list;) { \ 47 - tmp = list; \ 48 - list = list->next; \ 49 - kfree(tmp); \ 50 - } \ 51 - (head)->next = NULL; \ 52 - } while (0) 53 - 54 - int pci_realloc_enable = 0; 55 - #define pci_realloc_enabled() pci_realloc_enable 56 - void pci_realloc(void) 41 + static void free_list(struct list_head *head) 57 42 { 58 - pci_realloc_enable = 1; 43 + struct pci_dev_resource *dev_res, *tmp; 44 + 45 + list_for_each_entry_safe(dev_res, tmp, head, list) { 46 + list_del(&dev_res->list); 47 + kfree(dev_res); 48 + } 59 49 } 60 50 61 51 /** ··· 60 64 * @add_size: additional size to be optionally added 61 65 * to the resource 62 66 */ 63 - static void add_to_list(struct resource_list_x *head, 67 + static int add_to_list(struct list_head *head, 64 68 struct pci_dev *dev, struct resource *res, 65 69 resource_size_t add_size, resource_size_t min_align) 66 70 { 67 - struct resource_list_x *list = head; 68 - struct resource_list_x *ln = list->next; 69 - struct resource_list_x *tmp; 71 + struct pci_dev_resource *tmp; 70 72 71 - tmp = kmalloc(sizeof(*tmp), GFP_KERNEL); 73 + tmp = kzalloc(sizeof(*tmp), GFP_KERNEL); 72 74 if (!tmp) { 73 75 pr_warning("add_to_list: kmalloc() failed!\n"); 74 - return; 76 + return -ENOMEM; 75 77 } 76 78 77 - tmp->next = ln; 78 79 tmp->res = res; 79 80 tmp->dev = dev; 80 81 tmp->start = res->start; ··· 79 86 tmp->flags = res->flags; 80 87 tmp->add_size = add_size; 81 88 tmp->min_align = min_align; 82 - list->next = tmp; 89 + 90 + list_add(&tmp->list, head); 91 + 92 + return 0; 83 93 } 84 94 85 - static void add_to_failed_list(struct resource_list_x *head, 86 - struct pci_dev *dev, struct resource *res) 95 + static void remove_from_list(struct list_head *head, 96 + struct resource *res) 87 97 { 88 - add_to_list(head, dev, res, 89 - 0 /* dont care */, 90 - 0 /* dont care */); 98 + struct pci_dev_resource *dev_res, *tmp; 99 + 100 + list_for_each_entry_safe(dev_res, tmp, head, list) { 101 + if (dev_res->res == res) { 102 + list_del(&dev_res->list); 103 + kfree(dev_res); 104 + break; 105 + } 106 + } 107 + } 108 + 109 + static resource_size_t get_res_add_size(struct list_head *head, 110 + struct resource *res) 111 + { 112 + struct pci_dev_resource *dev_res; 113 + 114 + list_for_each_entry(dev_res, head, list) { 115 + if (dev_res->res == res) { 116 + int idx = res - &dev_res->dev->resource[0]; 117 + 118 + dev_printk(KERN_DEBUG, &dev_res->dev->dev, 119 + "res[%d]=%pR get_res_add_size add_size %llx\n", 120 + idx, dev_res->res, 121 + (unsigned long long)dev_res->add_size); 122 + 123 + return dev_res->add_size; 124 + } 125 + } 126 + 127 + return 0; 128 + } 129 + 130 + /* Sort resources by alignment */ 131 + static void pdev_sort_resources(struct pci_dev *dev, struct list_head *head) 132 + { 133 + int i; 134 + 135 + for (i = 0; i < PCI_NUM_RESOURCES; i++) { 136 + struct resource *r; 137 + struct pci_dev_resource *dev_res, *tmp; 138 + resource_size_t r_align; 139 + struct list_head *n; 140 + 141 + r = &dev->resource[i]; 142 + 143 + if (r->flags & IORESOURCE_PCI_FIXED) 144 + continue; 145 + 146 + if (!(r->flags) || r->parent) 147 + continue; 148 + 149 + r_align = pci_resource_alignment(dev, r); 150 + if (!r_align) { 151 + dev_warn(&dev->dev, "BAR %d: %pR has bogus alignment\n", 152 + i, r); 153 + continue; 154 + } 155 + 156 + tmp = kzalloc(sizeof(*tmp), GFP_KERNEL); 157 + if (!tmp) 158 + panic("pdev_sort_resources(): " 159 + "kmalloc() failed!\n"); 160 + tmp->res = r; 161 + tmp->dev = dev; 162 + 163 + /* fallback is smallest one or list is empty*/ 164 + n = head; 165 + list_for_each_entry(dev_res, head, list) { 166 + resource_size_t align; 167 + 168 + align = pci_resource_alignment(dev_res->dev, 169 + dev_res->res); 170 + 171 + if (r_align > align) { 172 + n = &dev_res->list; 173 + break; 174 + } 175 + } 176 + /* Insert it just before n*/ 177 + list_add_tail(&tmp->list, n); 178 + } 91 179 } 92 180 93 181 static void __dev_sort_resources(struct pci_dev *dev, 94 - struct resource_list *head) 182 + struct list_head *head) 95 183 { 96 184 u16 class = dev->class >> 8; 97 185 ··· 210 136 * additional resources for the element, provided the element 211 137 * is in the head list. 212 138 */ 213 - static void reassign_resources_sorted(struct resource_list_x *realloc_head, 214 - struct resource_list *head) 139 + static void reassign_resources_sorted(struct list_head *realloc_head, 140 + struct list_head *head) 215 141 { 216 142 struct resource *res; 217 - struct resource_list_x *list, *tmp, *prev; 218 - struct resource_list *hlist; 143 + struct pci_dev_resource *add_res, *tmp; 144 + struct pci_dev_resource *dev_res; 219 145 resource_size_t add_size; 220 146 int idx; 221 147 222 - prev = realloc_head; 223 - for (list = realloc_head->next; list;) { 224 - res = list->res; 148 + list_for_each_entry_safe(add_res, tmp, realloc_head, list) { 149 + bool found_match = false; 150 + 151 + res = add_res->res; 225 152 /* skip resource that has been reset */ 226 153 if (!res->flags) 227 154 goto out; 228 155 229 156 /* skip this resource if not found in head list */ 230 - for (hlist = head->next; hlist && hlist->res != res; 231 - hlist = hlist->next); 232 - if (!hlist) { /* just skip */ 233 - prev = list; 234 - list = list->next; 235 - continue; 157 + list_for_each_entry(dev_res, head, list) { 158 + if (dev_res->res == res) { 159 + found_match = true; 160 + break; 161 + } 236 162 } 163 + if (!found_match)/* just skip */ 164 + continue; 237 165 238 - idx = res - &list->dev->resource[0]; 239 - add_size=list->add_size; 166 + idx = res - &add_res->dev->resource[0]; 167 + add_size = add_res->add_size; 240 168 if (!resource_size(res)) { 241 - res->start = list->start; 169 + res->start = add_res->start; 242 170 res->end = res->start + add_size - 1; 243 - if(pci_assign_resource(list->dev, idx)) 171 + if (pci_assign_resource(add_res->dev, idx)) 244 172 reset_resource(res); 245 173 } else { 246 - resource_size_t align = list->min_align; 247 - res->flags |= list->flags & (IORESOURCE_STARTALIGN|IORESOURCE_SIZEALIGN); 248 - if (pci_reassign_resource(list->dev, idx, add_size, align)) 249 - dev_printk(KERN_DEBUG, &list->dev->dev, "failed to add optional resources res=%pR\n", 250 - res); 174 + resource_size_t align = add_res->min_align; 175 + res->flags |= add_res->flags & 176 + (IORESOURCE_STARTALIGN|IORESOURCE_SIZEALIGN); 177 + if (pci_reassign_resource(add_res->dev, idx, 178 + add_size, align)) 179 + dev_printk(KERN_DEBUG, &add_res->dev->dev, 180 + "failed to add %llx res[%d]=%pR\n", 181 + (unsigned long long)add_size, 182 + idx, res); 251 183 } 252 184 out: 253 - tmp = list; 254 - prev->next = list = list->next; 255 - kfree(tmp); 185 + list_del(&add_res->list); 186 + kfree(add_res); 256 187 } 257 188 } 258 189 ··· 271 192 * Satisfy resource requests of each element in the list. Add 272 193 * requests that could not satisfied to the failed_list. 273 194 */ 274 - static void assign_requested_resources_sorted(struct resource_list *head, 275 - struct resource_list_x *fail_head) 195 + static void assign_requested_resources_sorted(struct list_head *head, 196 + struct list_head *fail_head) 276 197 { 277 198 struct resource *res; 278 - struct resource_list *list; 199 + struct pci_dev_resource *dev_res; 279 200 int idx; 280 201 281 - for (list = head->next; list; list = list->next) { 282 - res = list->res; 283 - idx = res - &list->dev->resource[0]; 284 - if (resource_size(res) && pci_assign_resource(list->dev, idx)) { 285 - if (fail_head && !pci_is_root_bus(list->dev->bus)) { 202 + list_for_each_entry(dev_res, head, list) { 203 + res = dev_res->res; 204 + idx = res - &dev_res->dev->resource[0]; 205 + if (resource_size(res) && 206 + pci_assign_resource(dev_res->dev, idx)) { 207 + if (fail_head && !pci_is_root_bus(dev_res->dev->bus)) { 286 208 /* 287 209 * if the failed res is for ROM BAR, and it will 288 210 * be enabled later, don't add it to the list 289 211 */ 290 212 if (!((idx == PCI_ROM_RESOURCE) && 291 213 (!(res->flags & IORESOURCE_ROM_ENABLE)))) 292 - add_to_failed_list(fail_head, list->dev, res); 214 + add_to_list(fail_head, 215 + dev_res->dev, res, 216 + 0 /* dont care */, 217 + 0 /* dont care */); 293 218 } 294 219 reset_resource(res); 295 220 } 296 221 } 297 222 } 298 223 299 - static void __assign_resources_sorted(struct resource_list *head, 300 - struct resource_list_x *realloc_head, 301 - struct resource_list_x *fail_head) 224 + static void __assign_resources_sorted(struct list_head *head, 225 + struct list_head *realloc_head, 226 + struct list_head *fail_head) 302 227 { 228 + /* 229 + * Should not assign requested resources at first. 230 + * they could be adjacent, so later reassign can not reallocate 231 + * them one by one in parent resource window. 232 + * Try to assign requested + add_size at begining 233 + * if could do that, could get out early. 234 + * if could not do that, we still try to assign requested at first, 235 + * then try to reassign add_size for some resources. 236 + */ 237 + LIST_HEAD(save_head); 238 + LIST_HEAD(local_fail_head); 239 + struct pci_dev_resource *save_res; 240 + struct pci_dev_resource *dev_res; 241 + 242 + /* Check if optional add_size is there */ 243 + if (!realloc_head || list_empty(realloc_head)) 244 + goto requested_and_reassign; 245 + 246 + /* Save original start, end, flags etc at first */ 247 + list_for_each_entry(dev_res, head, list) { 248 + if (add_to_list(&save_head, dev_res->dev, dev_res->res, 0, 0)) { 249 + free_list(&save_head); 250 + goto requested_and_reassign; 251 + } 252 + } 253 + 254 + /* Update res in head list with add_size in realloc_head list */ 255 + list_for_each_entry(dev_res, head, list) 256 + dev_res->res->end += get_res_add_size(realloc_head, 257 + dev_res->res); 258 + 259 + /* Try updated head list with add_size added */ 260 + assign_requested_resources_sorted(head, &local_fail_head); 261 + 262 + /* all assigned with add_size ? */ 263 + if (list_empty(&local_fail_head)) { 264 + /* Remove head list from realloc_head list */ 265 + list_for_each_entry(dev_res, head, list) 266 + remove_from_list(realloc_head, dev_res->res); 267 + free_list(&save_head); 268 + free_list(head); 269 + return; 270 + } 271 + 272 + free_list(&local_fail_head); 273 + /* Release assigned resource */ 274 + list_for_each_entry(dev_res, head, list) 275 + if (dev_res->res->parent) 276 + release_resource(dev_res->res); 277 + /* Restore start/end/flags from saved list */ 278 + list_for_each_entry(save_res, &save_head, list) { 279 + struct resource *res = save_res->res; 280 + 281 + res->start = save_res->start; 282 + res->end = save_res->end; 283 + res->flags = save_res->flags; 284 + } 285 + free_list(&save_head); 286 + 287 + requested_and_reassign: 303 288 /* Satisfy the must-have resource requests */ 304 289 assign_requested_resources_sorted(head, fail_head); 305 290 ··· 371 228 requests */ 372 229 if (realloc_head) 373 230 reassign_resources_sorted(realloc_head, head); 374 - free_list(resource_list, head); 231 + free_list(head); 375 232 } 376 233 377 234 static void pdev_assign_resources_sorted(struct pci_dev *dev, 378 - struct resource_list_x *fail_head) 235 + struct list_head *add_head, 236 + struct list_head *fail_head) 379 237 { 380 - struct resource_list head; 238 + LIST_HEAD(head); 381 239 382 - head.next = NULL; 383 240 __dev_sort_resources(dev, &head); 384 - __assign_resources_sorted(&head, NULL, fail_head); 241 + __assign_resources_sorted(&head, add_head, fail_head); 385 242 386 243 } 387 244 388 245 static void pbus_assign_resources_sorted(const struct pci_bus *bus, 389 - struct resource_list_x *realloc_head, 390 - struct resource_list_x *fail_head) 246 + struct list_head *realloc_head, 247 + struct list_head *fail_head) 391 248 { 392 249 struct pci_dev *dev; 393 - struct resource_list head; 250 + LIST_HEAD(head); 394 251 395 - head.next = NULL; 396 252 list_for_each_entry(dev, &bus->devices, bus_list) 397 253 __dev_sort_resources(dev, &head); 398 254 ··· 690 548 return size; 691 549 } 692 550 693 - static resource_size_t get_res_add_size(struct resource_list_x *realloc_head, 694 - struct resource *res) 695 - { 696 - struct resource_list_x *list; 697 - 698 - /* check if it is in realloc_head list */ 699 - for (list = realloc_head->next; list && list->res != res; 700 - list = list->next); 701 - if (list) 702 - return list->add_size; 703 - 704 - return 0; 705 - } 706 - 707 551 /** 708 552 * pbus_size_io() - size the io window of a given bus 709 553 * ··· 704 576 * We must be careful with the ISA aliasing though. 705 577 */ 706 578 static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size, 707 - resource_size_t add_size, struct resource_list_x *realloc_head) 579 + resource_size_t add_size, struct list_head *realloc_head) 708 580 { 709 581 struct pci_dev *dev; 710 582 struct resource *b_res = find_free_bus_resource(bus, IORESOURCE_IO); ··· 740 612 if (children_add_size > add_size) 741 613 add_size = children_add_size; 742 614 size1 = (!realloc_head || (realloc_head && !add_size)) ? size0 : 743 - calculate_iosize(size, min_size+add_size, size1, 615 + calculate_iosize(size, min_size, add_size + size1, 744 616 resource_size(b_res), 4096); 745 617 if (!size0 && !size1) { 746 618 if (b_res->start || b_res->end) ··· 754 626 b_res->start = 4096; 755 627 b_res->end = b_res->start + size0 - 1; 756 628 b_res->flags |= IORESOURCE_STARTALIGN; 757 - if (size1 > size0 && realloc_head) 629 + if (size1 > size0 && realloc_head) { 758 630 add_to_list(realloc_head, bus->self, b_res, size1-size0, 4096); 631 + dev_printk(KERN_DEBUG, &bus->self->dev, "bridge window " 632 + "%pR to [bus %02x-%02x] add_size %lx\n", b_res, 633 + bus->secondary, bus->subordinate, size1-size0); 634 + } 759 635 } 760 636 761 637 /** ··· 776 644 static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, 777 645 unsigned long type, resource_size_t min_size, 778 646 resource_size_t add_size, 779 - struct resource_list_x *realloc_head) 647 + struct list_head *realloc_head) 780 648 { 781 649 struct pci_dev *dev; 782 650 resource_size_t min_align, align, size, size0, size1; ··· 858 726 if (children_add_size > add_size) 859 727 add_size = children_add_size; 860 728 size1 = (!realloc_head || (realloc_head && !add_size)) ? size0 : 861 - calculate_memsize(size, min_size+add_size, 0, 729 + calculate_memsize(size, min_size, add_size, 862 730 resource_size(b_res), min_align); 863 731 if (!size0 && !size1) { 864 732 if (b_res->start || b_res->end) ··· 871 739 b_res->start = min_align; 872 740 b_res->end = size0 + min_align - 1; 873 741 b_res->flags |= IORESOURCE_STARTALIGN | mem64_mask; 874 - if (size1 > size0 && realloc_head) 742 + if (size1 > size0 && realloc_head) { 875 743 add_to_list(realloc_head, bus->self, b_res, size1-size0, min_align); 744 + dev_printk(KERN_DEBUG, &bus->self->dev, "bridge window " 745 + "%pR to [bus %02x-%02x] add_size %llx\n", b_res, 746 + bus->secondary, bus->subordinate, (unsigned long long)size1-size0); 747 + } 876 748 return 1; 877 749 } 878 750 ··· 890 754 } 891 755 892 756 static void pci_bus_size_cardbus(struct pci_bus *bus, 893 - struct resource_list_x *realloc_head) 757 + struct list_head *realloc_head) 894 758 { 895 759 struct pci_dev *bridge = bus->self; 896 760 struct resource *b_res = &bridge->resource[PCI_BRIDGE_RESOURCES]; 761 + resource_size_t b_res_3_size = pci_cardbus_mem_size * 2; 897 762 u16 ctrl; 898 763 764 + if (b_res[0].parent) 765 + goto handle_b_res_1; 899 766 /* 900 767 * Reserve some resources for CardBus. We reserve 901 768 * a fixed amount of bus space for CardBus bridges. 902 769 */ 903 - b_res[0].start = 0; 904 - b_res[0].flags |= IORESOURCE_IO | IORESOURCE_SIZEALIGN; 905 - if (realloc_head) 906 - add_to_list(realloc_head, bridge, b_res, pci_cardbus_io_size, 0 /* dont care */); 770 + b_res[0].start = pci_cardbus_io_size; 771 + b_res[0].end = b_res[0].start + pci_cardbus_io_size - 1; 772 + b_res[0].flags |= IORESOURCE_IO | IORESOURCE_STARTALIGN; 773 + if (realloc_head) { 774 + b_res[0].end -= pci_cardbus_io_size; 775 + add_to_list(realloc_head, bridge, b_res, pci_cardbus_io_size, 776 + pci_cardbus_io_size); 777 + } 907 778 908 - b_res[1].start = 0; 909 - b_res[1].flags |= IORESOURCE_IO | IORESOURCE_SIZEALIGN; 910 - if (realloc_head) 911 - add_to_list(realloc_head, bridge, b_res+1, pci_cardbus_io_size, 0 /* dont care */); 779 + handle_b_res_1: 780 + if (b_res[1].parent) 781 + goto handle_b_res_2; 782 + b_res[1].start = pci_cardbus_io_size; 783 + b_res[1].end = b_res[1].start + pci_cardbus_io_size - 1; 784 + b_res[1].flags |= IORESOURCE_IO | IORESOURCE_STARTALIGN; 785 + if (realloc_head) { 786 + b_res[1].end -= pci_cardbus_io_size; 787 + add_to_list(realloc_head, bridge, b_res+1, pci_cardbus_io_size, 788 + pci_cardbus_io_size); 789 + } 790 + 791 + handle_b_res_2: 792 + /* MEM1 must not be pref mmio */ 793 + pci_read_config_word(bridge, PCI_CB_BRIDGE_CONTROL, &ctrl); 794 + if (ctrl & PCI_CB_BRIDGE_CTL_PREFETCH_MEM1) { 795 + ctrl &= ~PCI_CB_BRIDGE_CTL_PREFETCH_MEM1; 796 + pci_write_config_word(bridge, PCI_CB_BRIDGE_CONTROL, ctrl); 797 + pci_read_config_word(bridge, PCI_CB_BRIDGE_CONTROL, &ctrl); 798 + } 912 799 913 800 /* 914 801 * Check whether prefetchable memory is supported ··· 944 785 pci_read_config_word(bridge, PCI_CB_BRIDGE_CONTROL, &ctrl); 945 786 } 946 787 788 + if (b_res[2].parent) 789 + goto handle_b_res_3; 947 790 /* 948 791 * If we have prefetchable memory support, allocate 949 792 * two regions. Otherwise, allocate one region of 950 793 * twice the size. 951 794 */ 952 795 if (ctrl & PCI_CB_BRIDGE_CTL_PREFETCH_MEM0) { 953 - b_res[2].start = 0; 954 - b_res[2].flags |= IORESOURCE_MEM | IORESOURCE_PREFETCH | IORESOURCE_SIZEALIGN; 955 - if (realloc_head) 956 - add_to_list(realloc_head, bridge, b_res+2, pci_cardbus_mem_size, 0 /* dont care */); 796 + b_res[2].start = pci_cardbus_mem_size; 797 + b_res[2].end = b_res[2].start + pci_cardbus_mem_size - 1; 798 + b_res[2].flags |= IORESOURCE_MEM | IORESOURCE_PREFETCH | 799 + IORESOURCE_STARTALIGN; 800 + if (realloc_head) { 801 + b_res[2].end -= pci_cardbus_mem_size; 802 + add_to_list(realloc_head, bridge, b_res+2, 803 + pci_cardbus_mem_size, pci_cardbus_mem_size); 804 + } 957 805 958 - b_res[3].start = 0; 959 - b_res[3].flags |= IORESOURCE_MEM | IORESOURCE_SIZEALIGN; 960 - if (realloc_head) 961 - add_to_list(realloc_head, bridge, b_res+3, pci_cardbus_mem_size, 0 /* dont care */); 962 - } else { 963 - b_res[3].start = 0; 964 - b_res[3].flags |= IORESOURCE_MEM | IORESOURCE_SIZEALIGN; 965 - if (realloc_head) 966 - add_to_list(realloc_head, bridge, b_res+3, pci_cardbus_mem_size * 2, 0 /* dont care */); 806 + /* reduce that to half */ 807 + b_res_3_size = pci_cardbus_mem_size; 967 808 } 968 809 969 - /* set the size of the resource to zero, so that the resource does not 970 - * get assigned during required-resource allocation cycle but gets assigned 971 - * during the optional-resource allocation cycle. 972 - */ 973 - b_res[0].start = b_res[1].start = b_res[2].start = b_res[3].start = 1; 974 - b_res[0].end = b_res[1].end = b_res[2].end = b_res[3].end = 0; 810 + handle_b_res_3: 811 + if (b_res[3].parent) 812 + goto handle_done; 813 + b_res[3].start = pci_cardbus_mem_size; 814 + b_res[3].end = b_res[3].start + b_res_3_size - 1; 815 + b_res[3].flags |= IORESOURCE_MEM | IORESOURCE_STARTALIGN; 816 + if (realloc_head) { 817 + b_res[3].end -= b_res_3_size; 818 + add_to_list(realloc_head, bridge, b_res+3, b_res_3_size, 819 + pci_cardbus_mem_size); 820 + } 821 + 822 + handle_done: 823 + ; 975 824 } 976 825 977 826 void __ref __pci_bus_size_bridges(struct pci_bus *bus, 978 - struct resource_list_x *realloc_head) 827 + struct list_head *realloc_head) 979 828 { 980 829 struct pci_dev *dev; 981 830 unsigned long mask, prefmask; ··· 1025 858 * Follow thru 1026 859 */ 1027 860 default: 1028 - pbus_size_io(bus, 0, additional_io_size, realloc_head); 861 + pbus_size_io(bus, realloc_head ? 0 : additional_io_size, 862 + additional_io_size, realloc_head); 1029 863 /* If the bridge supports prefetchable range, size it 1030 864 separately. If it doesn't, or its prefetchable window 1031 865 has already been allocated by arch code, try ··· 1034 866 resources. */ 1035 867 mask = IORESOURCE_MEM; 1036 868 prefmask = IORESOURCE_MEM | IORESOURCE_PREFETCH; 1037 - if (pbus_size_mem(bus, prefmask, prefmask, 0, additional_mem_size, realloc_head)) 869 + if (pbus_size_mem(bus, prefmask, prefmask, 870 + realloc_head ? 0 : additional_mem_size, 871 + additional_mem_size, realloc_head)) 1038 872 mask = prefmask; /* Success, size non-prefetch only. */ 1039 873 else 1040 874 additional_mem_size += additional_mem_size; 1041 - pbus_size_mem(bus, mask, IORESOURCE_MEM, 0, additional_mem_size, realloc_head); 875 + pbus_size_mem(bus, mask, IORESOURCE_MEM, 876 + realloc_head ? 0 : additional_mem_size, 877 + additional_mem_size, realloc_head); 1042 878 break; 1043 879 } 1044 880 } ··· 1054 882 EXPORT_SYMBOL(pci_bus_size_bridges); 1055 883 1056 884 static void __ref __pci_bus_assign_resources(const struct pci_bus *bus, 1057 - struct resource_list_x *realloc_head, 1058 - struct resource_list_x *fail_head) 885 + struct list_head *realloc_head, 886 + struct list_head *fail_head) 1059 887 { 1060 888 struct pci_bus *b; 1061 889 struct pci_dev *dev; ··· 1094 922 EXPORT_SYMBOL(pci_bus_assign_resources); 1095 923 1096 924 static void __ref __pci_bridge_assign_resources(const struct pci_dev *bridge, 1097 - struct resource_list_x *fail_head) 925 + struct list_head *add_head, 926 + struct list_head *fail_head) 1098 927 { 1099 928 struct pci_bus *b; 1100 929 1101 - pdev_assign_resources_sorted((struct pci_dev *)bridge, fail_head); 930 + pdev_assign_resources_sorted((struct pci_dev *)bridge, 931 + add_head, fail_head); 1102 932 1103 933 b = bridge->subordinate; 1104 934 if (!b) 1105 935 return; 1106 936 1107 - __pci_bus_assign_resources(b, NULL, fail_head); 937 + __pci_bus_assign_resources(b, add_head, fail_head); 1108 938 1109 939 switch (bridge->class >> 8) { 1110 940 case PCI_CLASS_BRIDGE_PCI: ··· 1269 1095 return depth; 1270 1096 } 1271 1097 1098 + /* 1099 + * -1: undefined, will auto detect later 1100 + * 0: disabled by user 1101 + * 1: disabled by auto detect 1102 + * 2: enabled by user 1103 + * 3: enabled by auto detect 1104 + */ 1105 + enum enable_type { 1106 + undefined = -1, 1107 + user_disabled, 1108 + auto_disabled, 1109 + user_enabled, 1110 + auto_enabled, 1111 + }; 1112 + 1113 + static enum enable_type pci_realloc_enable __initdata = undefined; 1114 + void __init pci_realloc_get_opt(char *str) 1115 + { 1116 + if (!strncmp(str, "off", 3)) 1117 + pci_realloc_enable = user_disabled; 1118 + else if (!strncmp(str, "on", 2)) 1119 + pci_realloc_enable = user_enabled; 1120 + } 1121 + static bool __init pci_realloc_enabled(void) 1122 + { 1123 + return pci_realloc_enable >= user_enabled; 1124 + } 1125 + 1126 + static void __init pci_realloc_detect(void) 1127 + { 1128 + #if defined(CONFIG_PCI_IOV) && defined(CONFIG_PCI_REALLOC_ENABLE_AUTO) 1129 + struct pci_dev *dev = NULL; 1130 + 1131 + if (pci_realloc_enable != undefined) 1132 + return; 1133 + 1134 + for_each_pci_dev(dev) { 1135 + int i; 1136 + 1137 + for (i = PCI_IOV_RESOURCES; i <= PCI_IOV_RESOURCE_END; i++) { 1138 + struct resource *r = &dev->resource[i]; 1139 + 1140 + /* Not assigned, or rejected by kernel ? */ 1141 + if (r->flags && !r->start) { 1142 + pci_realloc_enable = auto_enabled; 1143 + 1144 + return; 1145 + } 1146 + } 1147 + } 1148 + #endif 1149 + } 1272 1150 1273 1151 /* 1274 1152 * first try will not touch pci bridge res ··· 1331 1105 pci_assign_unassigned_resources(void) 1332 1106 { 1333 1107 struct pci_bus *bus; 1334 - struct resource_list_x realloc_list; /* list of resources that 1108 + LIST_HEAD(realloc_head); /* list of resources that 1335 1109 want additional resources */ 1110 + struct list_head *add_list = NULL; 1336 1111 int tried_times = 0; 1337 1112 enum release_type rel_type = leaf_only; 1338 - struct resource_list_x head, *list; 1113 + LIST_HEAD(fail_head); 1114 + struct pci_dev_resource *fail_res; 1339 1115 unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM | 1340 1116 IORESOURCE_PREFETCH; 1341 - unsigned long failed_type; 1342 - int max_depth = pci_get_max_depth(); 1343 - int pci_try_num; 1117 + int pci_try_num = 1; 1344 1118 1119 + /* don't realloc if asked to do so */ 1120 + pci_realloc_detect(); 1121 + if (pci_realloc_enabled()) { 1122 + int max_depth = pci_get_max_depth(); 1345 1123 1346 - head.next = NULL; 1347 - realloc_list.next = NULL; 1348 - 1349 - pci_try_num = max_depth + 1; 1350 - printk(KERN_DEBUG "PCI: max bus depth: %d pci_try_num: %d\n", 1351 - max_depth, pci_try_num); 1124 + pci_try_num = max_depth + 1; 1125 + printk(KERN_DEBUG "PCI: max bus depth: %d pci_try_num: %d\n", 1126 + max_depth, pci_try_num); 1127 + } 1352 1128 1353 1129 again: 1130 + /* 1131 + * last try will use add_list, otherwise will try good to have as 1132 + * must have, so can realloc parent bridge resource 1133 + */ 1134 + if (tried_times + 1 == pci_try_num) 1135 + add_list = &realloc_head; 1354 1136 /* Depth first, calculate sizes and alignments of all 1355 1137 subordinate buses. */ 1356 1138 list_for_each_entry(bus, &pci_root_buses, node) 1357 - __pci_bus_size_bridges(bus, &realloc_list); 1139 + __pci_bus_size_bridges(bus, add_list); 1358 1140 1359 1141 /* Depth last, allocate resources and update the hardware. */ 1360 1142 list_for_each_entry(bus, &pci_root_buses, node) 1361 - __pci_bus_assign_resources(bus, &realloc_list, &head); 1362 - BUG_ON(realloc_list.next); 1143 + __pci_bus_assign_resources(bus, add_list, &fail_head); 1144 + if (add_list) 1145 + BUG_ON(!list_empty(add_list)); 1363 1146 tried_times++; 1364 1147 1365 1148 /* any device complain? */ 1366 - if (!head.next) 1149 + if (list_empty(&fail_head)) 1367 1150 goto enable_and_dump; 1368 1151 1369 - /* don't realloc if asked to do so */ 1370 - if (!pci_realloc_enabled()) { 1371 - free_list(resource_list_x, &head); 1372 - goto enable_and_dump; 1373 - } 1152 + if (tried_times >= pci_try_num) { 1153 + if (pci_realloc_enable == undefined) 1154 + printk(KERN_INFO "Some PCI device resources are unassigned, try booting with pci=realloc\n"); 1155 + else if (pci_realloc_enable == auto_enabled) 1156 + printk(KERN_INFO "Automatically enabled pci realloc, if you have problem, try booting with pci=realloc=off\n"); 1374 1157 1375 - failed_type = 0; 1376 - for (list = head.next; list;) { 1377 - failed_type |= list->flags; 1378 - list = list->next; 1379 - } 1380 - /* 1381 - * io port are tight, don't try extra 1382 - * or if reach the limit, don't want to try more 1383 - */ 1384 - failed_type &= type_mask; 1385 - if ((failed_type == IORESOURCE_IO) || (tried_times >= pci_try_num)) { 1386 - free_list(resource_list_x, &head); 1158 + free_list(&fail_head); 1387 1159 goto enable_and_dump; 1388 1160 } 1389 1161 ··· 1396 1172 * Try to release leaf bridge's resources that doesn't fit resource of 1397 1173 * child device under that bridge 1398 1174 */ 1399 - for (list = head.next; list;) { 1400 - bus = list->dev->bus; 1401 - pci_bus_release_bridge_resources(bus, list->flags & type_mask, 1402 - rel_type); 1403 - list = list->next; 1175 + list_for_each_entry(fail_res, &fail_head, list) { 1176 + bus = fail_res->dev->bus; 1177 + pci_bus_release_bridge_resources(bus, 1178 + fail_res->flags & type_mask, 1179 + rel_type); 1404 1180 } 1405 1181 /* restore size and flags */ 1406 - for (list = head.next; list;) { 1407 - struct resource *res = list->res; 1182 + list_for_each_entry(fail_res, &fail_head, list) { 1183 + struct resource *res = fail_res->res; 1408 1184 1409 - res->start = list->start; 1410 - res->end = list->end; 1411 - res->flags = list->flags; 1412 - if (list->dev->subordinate) 1185 + res->start = fail_res->start; 1186 + res->end = fail_res->end; 1187 + res->flags = fail_res->flags; 1188 + if (fail_res->dev->subordinate) 1413 1189 res->flags = 0; 1414 - 1415 - list = list->next; 1416 1190 } 1417 - free_list(resource_list_x, &head); 1191 + free_list(&fail_head); 1418 1192 1419 1193 goto again; 1420 1194 ··· 1429 1207 void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge) 1430 1208 { 1431 1209 struct pci_bus *parent = bridge->subordinate; 1210 + LIST_HEAD(add_list); /* list of resources that 1211 + want additional resources */ 1432 1212 int tried_times = 0; 1433 - struct resource_list_x head, *list; 1213 + LIST_HEAD(fail_head); 1214 + struct pci_dev_resource *fail_res; 1434 1215 int retval; 1435 1216 unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM | 1436 1217 IORESOURCE_PREFETCH; 1437 1218 1438 - head.next = NULL; 1439 - 1440 1219 again: 1441 - pci_bus_size_bridges(parent); 1442 - __pci_bridge_assign_resources(bridge, &head); 1443 - 1220 + __pci_bus_size_bridges(parent, &add_list); 1221 + __pci_bridge_assign_resources(bridge, &add_list, &fail_head); 1222 + BUG_ON(!list_empty(&add_list)); 1444 1223 tried_times++; 1445 1224 1446 - if (!head.next) 1225 + if (list_empty(&fail_head)) 1447 1226 goto enable_all; 1448 1227 1449 1228 if (tried_times >= 2) { 1450 1229 /* still fail, don't need to try more */ 1451 - free_list(resource_list_x, &head); 1230 + free_list(&fail_head); 1452 1231 goto enable_all; 1453 1232 } 1454 1233 ··· 1460 1237 * Try to release leaf bridge's resources that doesn't fit resource of 1461 1238 * child device under that bridge 1462 1239 */ 1463 - for (list = head.next; list;) { 1464 - struct pci_bus *bus = list->dev->bus; 1465 - unsigned long flags = list->flags; 1240 + list_for_each_entry(fail_res, &fail_head, list) { 1241 + struct pci_bus *bus = fail_res->dev->bus; 1242 + unsigned long flags = fail_res->flags; 1466 1243 1467 1244 pci_bus_release_bridge_resources(bus, flags & type_mask, 1468 1245 whole_subtree); 1469 - list = list->next; 1470 1246 } 1471 1247 /* restore size and flags */ 1472 - for (list = head.next; list;) { 1473 - struct resource *res = list->res; 1248 + list_for_each_entry(fail_res, &fail_head, list) { 1249 + struct resource *res = fail_res->res; 1474 1250 1475 - res->start = list->start; 1476 - res->end = list->end; 1477 - res->flags = list->flags; 1478 - if (list->dev->subordinate) 1251 + res->start = fail_res->start; 1252 + res->end = fail_res->end; 1253 + res->flags = fail_res->flags; 1254 + if (fail_res->dev->subordinate) 1479 1255 res->flags = 0; 1480 - 1481 - list = list->next; 1482 1256 } 1483 - free_list(resource_list_x, &head); 1257 + free_list(&fail_head); 1484 1258 1485 1259 goto again; 1486 1260 ··· 1487 1267 pci_enable_bridges(parent); 1488 1268 } 1489 1269 EXPORT_SYMBOL_GPL(pci_assign_unassigned_bridge_resources); 1270 + 1271 + #ifdef CONFIG_HOTPLUG 1272 + /** 1273 + * pci_rescan_bus - scan a PCI bus for devices. 1274 + * @bus: PCI bus to scan 1275 + * 1276 + * Scan a PCI bus and child buses for new devices, adds them, 1277 + * and enables them. 1278 + * 1279 + * Returns the max number of subordinate bus discovered. 1280 + */ 1281 + unsigned int __ref pci_rescan_bus(struct pci_bus *bus) 1282 + { 1283 + unsigned int max; 1284 + struct pci_dev *dev; 1285 + LIST_HEAD(add_list); /* list of resources that 1286 + want additional resources */ 1287 + 1288 + max = pci_scan_child_bus(bus); 1289 + 1290 + down_read(&pci_bus_sem); 1291 + list_for_each_entry(dev, &bus->devices, bus_list) 1292 + if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || 1293 + dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) 1294 + if (dev->subordinate) 1295 + __pci_bus_size_bridges(dev->subordinate, 1296 + &add_list); 1297 + up_read(&pci_bus_sem); 1298 + __pci_bus_assign_resources(bus, &add_list, NULL); 1299 + BUG_ON(!list_empty(&add_list)); 1300 + 1301 + pci_enable_bridges(bus); 1302 + pci_bus_add_devices(bus); 1303 + 1304 + return max; 1305 + } 1306 + EXPORT_SYMBOL_GPL(pci_rescan_bus); 1307 + #endif
+33 -61
drivers/pci/setup-res.c
··· 114 114 } 115 115 EXPORT_SYMBOL(pci_claim_resource); 116 116 117 - #ifdef CONFIG_PCI_QUIRKS 118 117 void pci_disable_bridge_window(struct pci_dev *dev) 119 118 { 120 119 dev_info(&dev->dev, "disabling bridge mem windows\n"); ··· 126 127 pci_write_config_dword(dev, PCI_PREF_MEMORY_BASE, 0x0000fff0); 127 128 pci_write_config_dword(dev, PCI_PREF_BASE_UPPER32, 0xffffffff); 128 129 } 129 - #endif /* CONFIG_PCI_QUIRKS */ 130 - 131 - 132 130 133 131 static int __pci_assign_resource(struct pci_bus *bus, struct pci_dev *dev, 134 132 int resno, resource_size_t size, resource_size_t align) ··· 154 158 return ret; 155 159 } 156 160 161 + /* 162 + * Generic function that returns a value indicating that the device's 163 + * original BIOS BAR address was not saved and so is not available for 164 + * reinstatement. 165 + * 166 + * Can be over-ridden by architecture specific code that implements 167 + * reinstatement functionality rather than leaving it disabled when 168 + * normal allocation attempts fail. 169 + */ 170 + resource_size_t __weak pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx) 171 + { 172 + return 0; 173 + } 174 + 157 175 static int pci_revert_fw_address(struct resource *res, struct pci_dev *dev, 158 176 int resno, resource_size_t size) 159 177 { 160 178 struct resource *root, *conflict; 161 - resource_size_t start, end; 179 + resource_size_t fw_addr, start, end; 162 180 int ret = 0; 163 181 164 - if (res->flags & IORESOURCE_IO) 165 - root = &ioport_resource; 166 - else 167 - root = &iomem_resource; 182 + fw_addr = pcibios_retrieve_fw_addr(dev, resno); 183 + if (!fw_addr) 184 + return 1; 168 185 169 186 start = res->start; 170 187 end = res->end; 171 - res->start = dev->fw_addr[resno]; 188 + res->start = fw_addr; 172 189 res->end = res->start + size - 1; 190 + 191 + root = pci_find_parent_resource(dev, res); 192 + if (!root) { 193 + if (res->flags & IORESOURCE_IO) 194 + root = &ioport_resource; 195 + else 196 + root = &iomem_resource; 197 + } 198 + 173 199 dev_info(&dev->dev, "BAR %d: trying firmware assignment %pR\n", 174 200 resno, res); 175 201 conflict = request_resource_conflict(root, res); ··· 246 228 int ret; 247 229 248 230 if (!res->parent) { 249 - dev_info(&dev->dev, "BAR %d: can't reassign an unassigned resouce %pR " 231 + dev_info(&dev->dev, "BAR %d: can't reassign an unassigned resource %pR " 250 232 "\n", resno, res); 251 233 return -EINVAL; 252 234 } 253 235 254 - new_size = resource_size(res) + addsize + min_align; 236 + /* already aligned with min_align */ 237 + new_size = resource_size(res) + addsize; 255 238 ret = _pci_assign_resource(dev, resno, new_size, min_align); 256 239 if (!ret) { 257 240 res->flags &= ~IORESOURCE_STARTALIGN; 258 - dev_info(&dev->dev, "BAR %d: assigned %pR\n", resno, res); 241 + dev_info(&dev->dev, "BAR %d: reassigned %pR\n", resno, res); 259 242 if (resno < PCI_BRIDGE_RESOURCES) 260 243 pci_update_resource(dev, resno); 261 244 } ··· 286 267 * where firmware left it. That at least has a chance of 287 268 * working, which is better than just leaving it disabled. 288 269 */ 289 - if (ret < 0 && dev->fw_addr[resno]) 270 + if (ret < 0) 290 271 ret = pci_revert_fw_address(res, dev, resno, size); 291 272 292 273 if (!ret) { ··· 296 277 pci_update_resource(dev, resno); 297 278 } 298 279 return ret; 299 - } 300 - 301 - 302 - /* Sort resources by alignment */ 303 - void pdev_sort_resources(struct pci_dev *dev, struct resource_list *head) 304 - { 305 - int i; 306 - 307 - for (i = 0; i < PCI_NUM_RESOURCES; i++) { 308 - struct resource *r; 309 - struct resource_list *list, *tmp; 310 - resource_size_t r_align; 311 - 312 - r = &dev->resource[i]; 313 - 314 - if (r->flags & IORESOURCE_PCI_FIXED) 315 - continue; 316 - 317 - if (!(r->flags) || r->parent) 318 - continue; 319 - 320 - r_align = pci_resource_alignment(dev, r); 321 - if (!r_align) { 322 - dev_warn(&dev->dev, "BAR %d: %pR has bogus alignment\n", 323 - i, r); 324 - continue; 325 - } 326 - for (list = head; ; list = list->next) { 327 - resource_size_t align = 0; 328 - struct resource_list *ln = list->next; 329 - 330 - if (ln) 331 - align = pci_resource_alignment(ln->dev, ln->res); 332 - 333 - if (r_align > align) { 334 - tmp = kmalloc(sizeof(*tmp), GFP_KERNEL); 335 - if (!tmp) 336 - panic("pdev_sort_resources(): " 337 - "kmalloc() failed!\n"); 338 - tmp->next = ln; 339 - tmp->res = r; 340 - tmp->dev = dev; 341 - list->next = tmp; 342 - break; 343 - } 344 - } 345 - } 346 280 } 347 281 348 282 int pci_enable_resources(struct pci_dev *dev, int mask)
+2 -2
drivers/pci/xen-pcifront.c
··· 544 544 dev = container_of(bus->devices.next, struct pci_dev, 545 545 bus_list); 546 546 dev_dbg(&dev->dev, "removing device\n"); 547 - pci_remove_bus_device(dev); 547 + pci_stop_and_remove_bus_device(dev); 548 548 } 549 549 } 550 550 ··· 1044 1044 domain, bus, slot, func); 1045 1045 continue; 1046 1046 } 1047 - pci_remove_bus_device(pci_dev); 1047 + pci_stop_and_remove_bus_device(pci_dev); 1048 1048 pci_dev_put(pci_dev); 1049 1049 1050 1050 dev_dbg(&pdev->xdev->dev,
+1 -1
drivers/pcmcia/cardbus.c
··· 108 108 struct pci_dev *bridge = s->cb_dev; 109 109 110 110 if (bridge) 111 - pci_remove_behind_bridge(bridge); 111 + pci_stop_and_remove_behind_bridge(bridge); 112 112 }
+1 -1
drivers/platform/x86/asus-wmi.c
··· 571 571 } else { 572 572 dev = pci_get_slot(bus, 0); 573 573 if (dev) { 574 - pci_remove_bus_device(dev); 574 + pci_stop_and_remove_bus_device(dev); 575 575 pci_dev_put(dev); 576 576 } 577 577 }
+1 -1
drivers/platform/x86/eeepc-laptop.c
··· 646 646 } else { 647 647 dev = pci_get_slot(bus, 0); 648 648 if (dev) { 649 - pci_remove_bus_device(dev); 649 + pci_stop_and_remove_bus_device(dev); 650 650 pci_dev_put(dev); 651 651 } 652 652 }
+1 -1
drivers/scsi/mpt2sas/mpt2sas_base.c
··· 132 132 pdev = ioc->pdev; 133 133 if ((pdev == NULL)) 134 134 return -1; 135 - pci_remove_bus_device(pdev); 135 + pci_stop_and_remove_bus_device(pdev); 136 136 return 0; 137 137 } 138 138
+2 -1
drivers/usb/host/pci-quirks.c
··· 893 893 quirk_usb_handoff_xhci(pdev); 894 894 pci_disable_device(pdev); 895 895 } 896 - DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, quirk_usb_early_handoff); 896 + DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID, 897 + PCI_CLASS_SERIAL_USB, 8, quirk_usb_early_handoff);
+6
include/asm-generic/pci-bridge.h
··· 45 45 pci_flags |= flags; 46 46 } 47 47 48 + static inline void pci_clear_flags(int flags) 49 + { 50 + pci_flags &= ~flags; 51 + } 52 + 48 53 static inline int pci_has_flag(int flag) 49 54 { 50 55 return pci_flags & flag; ··· 57 52 #else 58 53 static inline void pci_set_flags(int flags) { } 59 54 static inline void pci_add_flags(int flags) { } 55 + static inline void pci_clear_flags(int flags) { } 60 56 static inline int pci_has_flag(int flag) 61 57 { 62 58 return 0;
-24
include/asm-generic/pci.h
··· 6 6 #ifndef _ASM_GENERIC_PCI_H 7 7 #define _ASM_GENERIC_PCI_H 8 8 9 - /** 10 - * pcibios_resource_to_bus - convert resource to PCI bus address 11 - * @dev: device which owns this resource 12 - * @region: converted bus-centric region (start,end) 13 - * @res: resource to convert 14 - * 15 - * Convert a resource to a PCI device bus address or bus window. 16 - */ 17 - static inline void 18 - pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, 19 - struct resource *res) 20 - { 21 - region->start = res->start; 22 - region->end = res->end; 23 - } 24 - 25 - static inline void 26 - pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 27 - struct pci_bus_region *region) 28 - { 29 - res->start = region->start; 30 - res->end = region->end; 31 - } 32 - 33 9 static inline struct resource * 34 10 pcibios_select_root(struct pci_dev *pdev, struct resource *res) 35 11 {
-6
include/linux/ioport.h
··· 23 23 struct resource *parent, *sibling, *child; 24 24 }; 25 25 26 - struct resource_list { 27 - struct resource_list *next; 28 - struct resource *res; 29 - struct pci_dev *dev; 30 - }; 31 - 32 26 /* 33 27 * IO resources have these defined flags. 34 28 */
+73 -32
include/linux/pci.h
··· 299 299 */ 300 300 unsigned int irq; 301 301 struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */ 302 - resource_size_t fw_addr[DEVICE_COUNT_RESOURCE]; /* FW-assigned addr */ 303 302 304 303 /* These fields are used by common fixups */ 305 304 unsigned int transparent:1; /* Transparent PCI bridge */ ··· 368 369 return (pdev->error_state != pci_channel_io_normal); 369 370 } 370 371 371 - static inline struct pci_cap_saved_state *pci_find_saved_cap( 372 - struct pci_dev *pci_dev, char cap) 373 - { 374 - struct pci_cap_saved_state *tmp; 375 - struct hlist_node *pos; 372 + struct pci_host_bridge_window { 373 + struct list_head list; 374 + struct resource *res; /* host bridge aperture (CPU address) */ 375 + resource_size_t offset; /* bus address + offset = CPU address */ 376 + }; 376 377 377 - hlist_for_each_entry(tmp, pos, &pci_dev->saved_cap_space, next) { 378 - if (tmp->cap.cap_nr == cap) 379 - return tmp; 380 - } 381 - return NULL; 382 - } 383 - 384 - static inline void pci_add_saved_cap(struct pci_dev *pci_dev, 385 - struct pci_cap_saved_state *new_cap) 386 - { 387 - hlist_add_head(&new_cap->next, &pci_dev->saved_cap_space); 388 - } 378 + struct pci_host_bridge { 379 + struct list_head list; 380 + struct pci_bus *bus; /* root bus */ 381 + struct list_head windows; /* pci_host_bridge_windows */ 382 + }; 389 383 390 384 /* 391 385 * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond ··· 648 656 649 657 /* Generic PCI functions used internally */ 650 658 659 + void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, 660 + struct resource *res); 661 + void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 662 + struct pci_bus_region *region); 651 663 void pcibios_scan_specific_bus(int busn); 652 664 extern struct pci_bus *pci_find_bus(int domain, int busnr); 653 665 void pci_bus_add_devices(const struct pci_bus *bus); ··· 686 690 extern struct pci_dev *pci_dev_get(struct pci_dev *dev); 687 691 extern void pci_dev_put(struct pci_dev *dev); 688 692 extern void pci_remove_bus(struct pci_bus *b); 689 - extern void pci_remove_bus_device(struct pci_dev *dev); 693 + extern void __pci_remove_bus_device(struct pci_dev *dev); 694 + extern void pci_stop_and_remove_bus_device(struct pci_dev *dev); 690 695 extern void pci_stop_bus_device(struct pci_dev *dev); 691 696 void pci_setup_cardbus(struct pci_bus *bus); 692 697 extern void pci_sort_breadthfirst(void); ··· 880 883 /* Functions for PCI Hotplug drivers to use */ 881 884 int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap); 882 885 #ifdef CONFIG_HOTPLUG 886 + unsigned int pci_rescan_bus_bridge_resize(struct pci_dev *bridge); 883 887 unsigned int pci_rescan_bus(struct pci_bus *bus); 884 888 #endif 885 889 ··· 890 892 int pci_vpd_truncate(struct pci_dev *dev, size_t size); 891 893 892 894 /* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */ 895 + resource_size_t pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx); 893 896 void pci_bus_assign_resources(const struct pci_bus *bus); 894 897 void pci_bus_size_bridges(struct pci_bus *bus); 895 898 int pci_claim_resource(struct pci_dev *, int); 896 899 void pci_assign_unassigned_resources(void); 897 900 void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge); 898 901 void pdev_enable_device(struct pci_dev *); 899 - void pdev_sort_resources(struct pci_dev *, struct resource_list *); 900 902 int pci_enable_resources(struct pci_dev *, int mask); 901 903 void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *), 902 904 int (*)(const struct pci_dev *, u8, u8)); ··· 913 915 914 916 /* drivers/pci/bus.c */ 915 917 void pci_add_resource(struct list_head *resources, struct resource *res); 918 + void pci_add_resource_offset(struct list_head *resources, struct resource *res, 919 + resource_size_t offset); 916 920 void pci_free_resource_list(struct list_head *resources); 917 921 void pci_bus_add_resource(struct pci_bus *bus, struct resource *res, unsigned int flags); 918 922 struct resource *pci_bus_resource_n(const struct pci_bus *bus, int n); ··· 960 960 module_driver(__pci_driver, pci_register_driver, \ 961 961 pci_unregister_driver) 962 962 963 - void pci_remove_behind_bridge(struct pci_dev *dev); 963 + void pci_stop_and_remove_behind_bridge(struct pci_dev *dev); 964 964 struct pci_driver *pci_dev_driver(const struct pci_dev *dev); 965 965 int pci_add_dynid(struct pci_driver *drv, 966 966 unsigned int vendor, unsigned int device, ··· 1396 1396 */ 1397 1397 1398 1398 struct pci_fixup { 1399 - u16 vendor, device; /* You can use PCI_ANY_ID here of course */ 1399 + u16 vendor; /* You can use PCI_ANY_ID here of course */ 1400 + u16 device; /* You can use PCI_ANY_ID here of course */ 1401 + u32 class; /* You can use PCI_ANY_ID here too */ 1402 + unsigned int class_shift; /* should be 0, 8, 16 */ 1400 1403 void (*hook)(struct pci_dev *dev); 1401 1404 }; 1402 1405 ··· 1414 1411 }; 1415 1412 1416 1413 /* Anonymous variables would be nice... */ 1417 - #define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, hook) \ 1418 - static const struct pci_fixup __pci_fixup_##name __used \ 1419 - __attribute__((__section__(#section))) = { vendor, device, hook }; 1414 + #define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, class, \ 1415 + class_shift, hook) \ 1416 + static const struct pci_fixup const __pci_fixup_##name __used \ 1417 + __attribute__((__section__(#section), aligned((sizeof(void *))))) \ 1418 + = { vendor, device, class, class_shift, hook }; 1419 + 1420 + #define DECLARE_PCI_FIXUP_CLASS_EARLY(vendor, device, class, \ 1421 + class_shift, hook) \ 1422 + DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \ 1423 + vendor##device##hook, vendor, device, class, class_shift, hook) 1424 + #define DECLARE_PCI_FIXUP_CLASS_HEADER(vendor, device, class, \ 1425 + class_shift, hook) \ 1426 + DECLARE_PCI_FIXUP_SECTION(.pci_fixup_header, \ 1427 + vendor##device##hook, vendor, device, class, class_shift, hook) 1428 + #define DECLARE_PCI_FIXUP_CLASS_FINAL(vendor, device, class, \ 1429 + class_shift, hook) \ 1430 + DECLARE_PCI_FIXUP_SECTION(.pci_fixup_final, \ 1431 + vendor##device##hook, vendor, device, class, class_shift, hook) 1432 + #define DECLARE_PCI_FIXUP_CLASS_ENABLE(vendor, device, class, \ 1433 + class_shift, hook) \ 1434 + DECLARE_PCI_FIXUP_SECTION(.pci_fixup_enable, \ 1435 + vendor##device##hook, vendor, device, class, class_shift, hook) 1436 + #define DECLARE_PCI_FIXUP_CLASS_RESUME(vendor, device, class, \ 1437 + class_shift, hook) \ 1438 + DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \ 1439 + resume##vendor##device##hook, vendor, device, class, \ 1440 + class_shift, hook) 1441 + #define DECLARE_PCI_FIXUP_CLASS_RESUME_EARLY(vendor, device, class, \ 1442 + class_shift, hook) \ 1443 + DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early, \ 1444 + resume_early##vendor##device##hook, vendor, device, \ 1445 + class, class_shift, hook) 1446 + #define DECLARE_PCI_FIXUP_CLASS_SUSPEND(vendor, device, class, \ 1447 + class_shift, hook) \ 1448 + DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \ 1449 + suspend##vendor##device##hook, vendor, device, class, \ 1450 + class_shift, hook) 1451 + 1420 1452 #define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook) \ 1421 1453 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \ 1422 - vendor##device##hook, vendor, device, hook) 1454 + vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook) 1423 1455 #define DECLARE_PCI_FIXUP_HEADER(vendor, device, hook) \ 1424 1456 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_header, \ 1425 - vendor##device##hook, vendor, device, hook) 1457 + vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook) 1426 1458 #define DECLARE_PCI_FIXUP_FINAL(vendor, device, hook) \ 1427 1459 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_final, \ 1428 - vendor##device##hook, vendor, device, hook) 1460 + vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook) 1429 1461 #define DECLARE_PCI_FIXUP_ENABLE(vendor, device, hook) \ 1430 1462 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_enable, \ 1431 - vendor##device##hook, vendor, device, hook) 1463 + vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook) 1432 1464 #define DECLARE_PCI_FIXUP_RESUME(vendor, device, hook) \ 1433 1465 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \ 1434 - resume##vendor##device##hook, vendor, device, hook) 1466 + resume##vendor##device##hook, vendor, device, \ 1467 + PCI_ANY_ID, 0, hook) 1435 1468 #define DECLARE_PCI_FIXUP_RESUME_EARLY(vendor, device, hook) \ 1436 1469 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early, \ 1437 - resume_early##vendor##device##hook, vendor, device, hook) 1470 + resume_early##vendor##device##hook, vendor, device, \ 1471 + PCI_ANY_ID, 0, hook) 1438 1472 #define DECLARE_PCI_FIXUP_SUSPEND(vendor, device, hook) \ 1439 1473 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \ 1440 - suspend##vendor##device##hook, vendor, device, hook) 1474 + suspend##vendor##device##hook, vendor, device, \ 1475 + PCI_ANY_ID, 0, hook) 1441 1476 1442 1477 #ifdef CONFIG_PCI_QUIRKS 1443 1478 void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev);
+1
include/linux/pci_regs.h
··· 391 391 #define PCI_EXP_TYPE_UPSTREAM 0x5 /* Upstream Port */ 392 392 #define PCI_EXP_TYPE_DOWNSTREAM 0x6 /* Downstream Port */ 393 393 #define PCI_EXP_TYPE_PCI_BRIDGE 0x7 /* PCI/PCI-X Bridge */ 394 + #define PCI_EXP_TYPE_PCIE_BRIDGE 0x8 /* PCI/PCI-X to PCIE Bridge */ 394 395 #define PCI_EXP_TYPE_RC_END 0x9 /* Root Complex Integrated Endpoint */ 395 396 #define PCI_EXP_TYPE_RC_EC 0xa /* Root Complex Event Collector */ 396 397 #define PCI_EXP_FLAGS_SLOT 0x0100 /* Slot implemented */