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

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6:
PCI: pci_slot: grab refcount on slot's bus
PCI Hotplug: acpiphp: grab refcount on p2p subordinate bus
PCI: allow PCI core hotplug to remove PCI root bus
PCI: Fix oops in pci_vpd_truncate
PCI: don't corrupt enable_cnt when doing manual resource alignment
PCI: annotate pci_rescan_bus as __ref, not __devinit
PCI-IOV: fix missing kernel-doc
PCI: Setup disabled bridges even if buses are added
PCI: SR-IOV quirk for Intel 82576 NIC

+88 -15
+5
drivers/acpi/pci_slot.c
··· 164 164 list_add(&slot->list, &slot_list); 165 165 mutex_unlock(&slot_list_lock); 166 166 167 + get_device(&pci_bus->dev); 168 + 167 169 dbg("pci_slot: %p, pci_bus: %x, device: %d, name: %s\n", 168 170 pci_slot, pci_bus->number, device, name); 169 171 ··· 312 310 acpi_pci_slot_remove(acpi_handle handle) 313 311 { 314 312 struct acpi_pci_slot *slot, *tmp; 313 + struct pci_bus *pbus; 315 314 316 315 mutex_lock(&slot_list_lock); 317 316 list_for_each_entry_safe(slot, tmp, &slot_list, list) { 318 317 if (slot->root_handle == handle) { 319 318 list_del(&slot->list); 319 + pbus = slot->pci_slot->bus; 320 320 pci_destroy_slot(slot->pci_slot); 321 + put_device(&pbus->dev); 321 322 kfree(slot); 322 323 } 323 324 }
+1 -1
drivers/pci/bus.c
··· 184 184 185 185 list_for_each_entry(dev, &bus->devices, bus_list) { 186 186 if (dev->subordinate) { 187 - if (atomic_read(&dev->enable_cnt) == 0) { 187 + if (!pci_is_enabled(dev)) { 188 188 retval = pci_enable_device(dev); 189 189 pci_set_master(dev); 190 190 }
+14
drivers/pci/hotplug/acpiphp_glue.c
··· 38 38 * - The one in acpiphp_bridge has its refcount elevated by pci_get_slot() 39 39 * when the bridge is scanned and it loses a refcount when the bridge 40 40 * is removed. 41 + * - When a P2P bridge is present, we elevate the refcount on the subordinate 42 + * bus. It loses the refcount when the the driver unloads. 41 43 */ 42 44 43 45 #include <linux/init.h> ··· 442 440 goto err; 443 441 } 444 442 443 + /* 444 + * Grab a ref to the subordinate PCI bus in case the bus is 445 + * removed via PCI core logical hotplug. The ref pins the bus 446 + * (which we access during module unload). 447 + */ 448 + get_device(&bridge->pci_bus->dev); 445 449 spin_lock_init(&bridge->res_lock); 446 450 447 451 init_bridge_misc(bridge); ··· 626 618 kfree(slot); 627 619 slot = next; 628 620 } 621 + 622 + /* 623 + * Only P2P bridges have a pci_dev 624 + */ 625 + if (bridge->pci_dev) 626 + put_device(&bridge->pci_bus->dev); 629 627 630 628 pci_dev_put(bridge->pci_dev); 631 629 list_del(&bridge->list);
+1
drivers/pci/iov.c
··· 631 631 /** 632 632 * pci_enable_sriov - enable the SR-IOV capability 633 633 * @dev: the PCI device 634 + * @nr_virtfn: number of virtual functions to enable 634 635 * 635 636 * Returns 0 on success, or negative on failure. 636 637 */
+1 -5
drivers/pci/pci-sysfs.c
··· 148 148 return -EPERM; 149 149 150 150 if (!val) { 151 - if (atomic_read(&pdev->enable_cnt) != 0) 151 + if (pci_is_enabled(pdev)) 152 152 pci_disable_device(pdev); 153 153 else 154 154 result = -EIO; ··· 277 277 { 278 278 int ret = 0; 279 279 unsigned long val; 280 - struct pci_dev *pdev = to_pci_dev(dev); 281 280 282 281 if (strict_strtoul(buf, 0, &val) < 0) 283 282 return -EINVAL; 284 - 285 - if (pci_is_root_bus(pdev->bus)) 286 - return -EBUSY; 287 283 288 284 /* An attribute cannot be unregistered by one of its own methods, 289 285 * so we have to use this roundabout approach.
+2 -2
drivers/pci/pci.c
··· 844 844 */ 845 845 int pci_reenable_device(struct pci_dev *dev) 846 846 { 847 - if (atomic_read(&dev->enable_cnt)) 847 + if (pci_is_enabled(dev)) 848 848 return do_pci_enable_device(dev, (1 << PCI_NUM_RESOURCES) - 1); 849 849 return 0; 850 850 } ··· 1042 1042 */ 1043 1043 void pci_disable_enabled_device(struct pci_dev *dev) 1044 1044 { 1045 - if (atomic_read(&dev->enable_cnt)) 1045 + if (pci_is_enabled(dev)) 1046 1046 do_pci_disable_device(dev); 1047 1047 } 1048 1048
+1 -1
drivers/pci/probe.c
··· 1220 1220 * 1221 1221 * Returns the max number of subordinate bus discovered. 1222 1222 */ 1223 - unsigned int __devinit pci_rescan_bus(struct pci_bus *bus) 1223 + unsigned int __ref pci_rescan_bus(struct pci_bus *bus) 1224 1224 { 1225 1225 unsigned int max; 1226 1226 struct pci_dev *dev;
+57 -5
drivers/pci/quirks.c
··· 36 36 37 37 #ifdef CONFIG_PCI_QUIRKS 38 38 /* 39 - * This quirk function disables the device and releases resources 40 - * which is specified by kernel's boot parameter 'pci=resource_alignment='. 39 + * This quirk function disables memory decoding and releases memory resources 40 + * of the device specified by kernel's boot parameter 'pci=resource_alignment='. 41 41 * It also rounds up size to specified alignment. 42 42 * Later on, the kernel will assign page-aligned memory resource back 43 - * to that device. 43 + * to the device. 44 44 */ 45 45 static void __devinit quirk_resource_alignment(struct pci_dev *dev) 46 46 { 47 47 int i; 48 48 struct resource *r; 49 49 resource_size_t align, size; 50 + u16 command; 50 51 51 52 if (!pci_is_reassigndev(dev)) 52 53 return; ··· 59 58 return; 60 59 } 61 60 62 - dev_info(&dev->dev, "Disabling device and release resources.\n"); 63 - pci_disable_device(dev); 61 + dev_info(&dev->dev, 62 + "Disabling memory decoding and releasing memory resources.\n"); 63 + pci_read_config_word(dev, PCI_COMMAND, &command); 64 + command &= ~PCI_COMMAND_MEMORY; 65 + pci_write_config_word(dev, PCI_COMMAND, command); 64 66 65 67 align = pci_specified_resource_alignment(dev); 66 68 for (i=0; i < PCI_BRIDGE_RESOURCES; i++) { ··· 2414 2410 quirk_msi_intx_disable_bug); 2415 2411 2416 2412 #endif /* CONFIG_PCI_MSI */ 2413 + 2414 + #ifdef CONFIG_PCI_IOV 2415 + 2416 + /* 2417 + * For Intel 82576 SR-IOV NIC, if BIOS doesn't allocate resources for the 2418 + * SR-IOV BARs, zero the Flash BAR and program the SR-IOV BARs to use the 2419 + * old Flash Memory Space. 2420 + */ 2421 + static void __devinit quirk_i82576_sriov(struct pci_dev *dev) 2422 + { 2423 + int pos, flags; 2424 + u32 bar, start, size; 2425 + 2426 + if (PAGE_SIZE > 0x10000) 2427 + return; 2428 + 2429 + flags = pci_resource_flags(dev, 0); 2430 + if ((flags & PCI_BASE_ADDRESS_SPACE) != 2431 + PCI_BASE_ADDRESS_SPACE_MEMORY || 2432 + (flags & PCI_BASE_ADDRESS_MEM_TYPE_MASK) != 2433 + PCI_BASE_ADDRESS_MEM_TYPE_32) 2434 + return; 2435 + 2436 + pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_SRIOV); 2437 + if (!pos) 2438 + return; 2439 + 2440 + pci_read_config_dword(dev, pos + PCI_SRIOV_BAR, &bar); 2441 + if (bar & PCI_BASE_ADDRESS_MEM_MASK) 2442 + return; 2443 + 2444 + start = pci_resource_start(dev, 1); 2445 + size = pci_resource_len(dev, 1); 2446 + if (!start || size != 0x400000 || start & (size - 1)) 2447 + return; 2448 + 2449 + pci_resource_flags(dev, 1) = 0; 2450 + pci_write_config_dword(dev, PCI_BASE_ADDRESS_1, 0); 2451 + pci_write_config_dword(dev, pos + PCI_SRIOV_BAR, start); 2452 + pci_write_config_dword(dev, pos + PCI_SRIOV_BAR + 12, start + size / 2); 2453 + 2454 + dev_info(&dev->dev, "use Flash Memory Space for SR-IOV BARs\n"); 2455 + } 2456 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10c9, quirk_i82576_sriov); 2457 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10e6, quirk_i82576_sriov); 2458 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10e7, quirk_i82576_sriov); 2459 + 2460 + #endif /* CONFIG_PCI_IOV */ 2417 2461 2418 2462 static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, 2419 2463 struct pci_fixup *end)
+1 -1
drivers/pci/setup-bus.c
··· 144 144 struct pci_bus_region region; 145 145 u32 l, bu, lu, io_upper16; 146 146 147 - if (!pci_is_root_bus(bus) && bus->is_added) 147 + if (pci_is_enabled(bridge)) 148 148 return; 149 149 150 150 dev_info(&bridge->dev, "PCI bridge, secondary bus %04x:%02x\n",
+5
include/linux/pci.h
··· 674 674 int __must_check pcim_enable_device(struct pci_dev *pdev); 675 675 void pcim_pin_device(struct pci_dev *pdev); 676 676 677 + static inline int pci_is_enabled(struct pci_dev *pdev) 678 + { 679 + return (atomic_read(&pdev->enable_cnt) > 0); 680 + } 681 + 677 682 static inline int pci_is_managed(struct pci_dev *pdev) 678 683 { 679 684 return pdev->is_managed;