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

Merge tag 'for-3.7' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci

Pull PCI changes from Bjorn Helgaas:
"Host bridge hotplug
- Protect acpi_pci_drivers and acpi_pci_roots (Taku Izumi)
- Clear host bridge resource info to avoid issue when releasing
(Yinghai Lu)
- Notify acpi_pci_drivers when hot-plugging host bridges (Jiang Liu)
- Use standard list ops for acpi_pci_drivers (Jiang Liu)

Device hotplug
- Use pci_get_domain_bus_and_slot() to close hotplug races (Jiang
Liu)
- Remove fakephp driver (Bjorn Helgaas)
- Fix VGA ref count in hotplug remove path (Yinghai Lu)
- Allow acpiphp to handle PCIe ports without native hotplug (Jiang
Liu)
- Implement resume regardless of pciehp_force param (Oliver Neukum)
- Make pci_fixup_irqs() work after init (Thierry Reding)

Miscellaneous
- Add pci_pcie_type(dev) and remove pci_dev.pcie_type (Yijing Wang)
- Factor out PCI Express Capability accessors (Jiang Liu)
- Add pcibios_window_alignment() so powerpc EEH can use generic
resource assignment (Gavin Shan)
- Make pci_error_handlers const (Stephen Hemminger)
- Cleanup drivers/pci/remove.c (Bjorn Helgaas)
- Improve Vendor-Specific Extended Capability support (Bjorn
Helgaas)
- Use standard list ops for bus->devices (Bjorn Helgaas)
- Avoid kmalloc in pci_get_subsys() and pci_get_class() (Feng Tang)
- Reassign invalid bus number ranges (Intel DP43BF workaround)
(Yinghai Lu)"

* tag 'for-3.7' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (102 commits)
PCI: acpiphp: Handle PCIe ports without native hotplug capability
PCI/ACPI: Use acpi_driver_data() rather than searching acpi_pci_roots
PCI/ACPI: Protect acpi_pci_roots list with mutex
PCI/ACPI: Use acpi_pci_root info rather than looking it up again
PCI/ACPI: Pass acpi_pci_root to acpi_pci_drivers' add/remove interface
PCI/ACPI: Protect acpi_pci_drivers list with mutex
PCI/ACPI: Notify acpi_pci_drivers when hot-plugging PCI root bridges
PCI/ACPI: Use normal list for struct acpi_pci_driver
PCI/ACPI: Use DEVICE_ACPI_HANDLE rather than searching acpi_pci_roots
PCI: Fix default vga ref_count
ia64/PCI: Clear host bridge aperture struct resource
x86/PCI: Clear host bridge aperture struct resource
PCI: Stop all children first, before removing all children
Revert "PCI: Use hotplug-safe pci_get_domain_bus_and_slot()"
PCI: Provide a default pcibios_update_irq()
PCI: Discard __init annotations for pci_fixup_irqs() and related functions
PCI: Use correct type when freeing bus resource list
PCI: Check P2P bridge for invalid secondary/subordinate range
PCI: Convert "new_id"/"remove_id" into generic pci_bus driver attributes
xen-pcifront: Use hotplug-safe pci_get_domain_bus_and_slot()
...

+1092 -1764
-32
Documentation/feature-removal-schedule.txt
··· 253 253 254 254 ----------------------------- 255 255 256 - What: fakephp and associated sysfs files in /sys/bus/pci/slots/ 257 - When: 2011 258 - Why: In 2.6.27, the semantics of /sys/bus/pci/slots was redefined to 259 - represent a machine's physical PCI slots. The change in semantics 260 - had userspace implications, as the hotplug core no longer allowed 261 - drivers to create multiple sysfs files per physical slot (required 262 - for multi-function devices, e.g.). fakephp was seen as a developer's 263 - tool only, and its interface changed. Too late, we learned that 264 - there were some users of the fakephp interface. 265 - 266 - In 2.6.30, the original fakephp interface was restored. At the same 267 - time, the PCI core gained the ability that fakephp provided, namely 268 - function-level hot-remove and hot-add. 269 - 270 - Since the PCI core now provides the same functionality, exposed in: 271 - 272 - /sys/bus/pci/rescan 273 - /sys/bus/pci/devices/.../remove 274 - /sys/bus/pci/devices/.../rescan 275 - 276 - there is no functional reason to maintain fakephp as well. 277 - 278 - We will keep the existing module so that 'modprobe fakephp' will 279 - present the old /sys/bus/pci/slots/... interface for compatibility, 280 - but users are urged to migrate their applications to the API above. 281 - 282 - After a reasonable transition period, we will remove the legacy 283 - fakephp interface. 284 - Who: Alex Chiang <achiang@hp.com> 285 - 286 - --------------------------- 287 - 288 256 What: CONFIG_RFKILL_INPUT 289 257 When: 2.6.33 290 258 Why: Should be implemented in userspace, policy daemon.
-6
arch/alpha/kernel/pci.c
··· 256 256 } 257 257 } 258 258 259 - void __init 260 - pcibios_update_irq(struct pci_dev *dev, int irq) 261 - { 262 - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); 263 - } 264 - 265 259 int 266 260 pcibios_enable_device(struct pci_dev *dev, int mask) 267 261 {
-9
arch/arm/kernel/bios32.c
··· 270 270 } 271 271 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ITE, PCI_DEVICE_ID_ITE_8152, pci_fixup_it8152); 272 272 273 - 274 - 275 - void __devinit pcibios_update_irq(struct pci_dev *dev, int irq) 276 - { 277 - if (debug_pci) 278 - printk("PCI: Assigning IRQ %02d to %s\n", irq, pci_name(dev)); 279 - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); 280 - } 281 - 282 273 /* 283 274 * If the bus contains any of these devices, then we must not turn on 284 275 * parity checking of any kind. Currently this is CyberPro 20x0 only.
+1 -11
arch/arm/mach-tegra/pcie.c
··· 367 367 /* Tegra PCIE requires relaxed ordering */ 368 368 static void __devinit tegra_pcie_relax_enable(struct pci_dev *dev) 369 369 { 370 - u16 val16; 371 - int pos = pci_find_capability(dev, PCI_CAP_ID_EXP); 372 - 373 - if (pos <= 0) { 374 - dev_err(&dev->dev, "skipping relaxed ordering fixup\n"); 375 - return; 376 - } 377 - 378 - pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &val16); 379 - val16 |= PCI_EXP_DEVCTL_RELAX_EN; 380 - pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, val16); 370 + pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_RELAX_EN); 381 371 } 382 372 DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, tegra_pcie_relax_enable); 383 373
+1 -3
arch/frv/mb93090-mb00/pci-vdk.c
··· 330 330 pci_read_bridge_bases(bus); 331 331 332 332 if (bus->number == 0) { 333 - struct list_head *ln; 334 333 struct pci_dev *dev; 335 - for (ln=bus->devices.next; ln != &bus->devices; ln=ln->next) { 336 - dev = pci_dev_b(ln); 334 + list_for_each_entry(dev, &bus->devices, bus_list) { 337 335 if (dev->devfn == 0) { 338 336 dev->resource[0].start = 0; 339 337 dev->resource[0].end = 0;
+1 -10
arch/ia64/pci/pci.c
··· 295 295 window->resource.flags = flags; 296 296 window->resource.start = addr.minimum + offset; 297 297 window->resource.end = window->resource.start + addr.address_length - 1; 298 - window->resource.child = NULL; 299 298 window->offset = offset; 300 299 301 300 if (insert_resource(root, &window->resource)) { ··· 356 357 &windows); 357 358 if (windows) { 358 359 controller->window = 359 - kmalloc_node(sizeof(*controller->window) * windows, 360 + kzalloc_node(sizeof(*controller->window) * windows, 360 361 GFP_KERNEL, controller->node); 361 362 if (!controller->window) 362 363 goto out2; ··· 458 459 void pcibios_set_master (struct pci_dev *dev) 459 460 { 460 461 /* No special bus mastering setup handling */ 461 - } 462 - 463 - void __devinit 464 - pcibios_update_irq (struct pci_dev *dev, int irq) 465 - { 466 - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); 467 - 468 - /* ??? FIXME -- record old value for shutdown. */ 469 462 } 470 463 471 464 int
+1 -3
arch/ia64/sn/kernel/io_common.c
··· 229 229 { 230 230 int segment = pci_domain_nr(dev->bus); 231 231 struct pcibus_bussoft *bs; 232 - struct pci_bus *host_pci_bus; 233 232 struct pci_dev *host_pci_dev; 234 233 unsigned int bus_no, devfn; 235 234 ··· 244 245 245 246 bus_no = (pcidev_info->pdi_slot_host_handle >> 32) & 0xff; 246 247 devfn = pcidev_info->pdi_slot_host_handle & 0xffffffff; 247 - host_pci_bus = pci_find_bus(segment, bus_no); 248 - host_pci_dev = pci_get_slot(host_pci_bus, devfn); 248 + host_pci_dev = pci_get_domain_bus_and_slot(segment, bus_no, devfn); 249 249 250 250 pcidev_info->host_pci_dev = host_pci_dev; 251 251 pcidev_info->pdi_linux_pcidev = dev;
-5
arch/m68k/kernel/pcibios.c
··· 87 87 return 0; 88 88 } 89 89 90 - void pcibios_update_irq(struct pci_dev *dev, int irq) 91 - { 92 - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); 93 - } 94 - 95 90 void __devinit pcibios_fixup_bus(struct pci_bus *bus) 96 91 { 97 92 struct pci_dev *dev;
+5 -10
arch/mips/pci/pci-octeon.c
··· 117 117 } 118 118 119 119 /* Enable the PCIe normal error reporting */ 120 - pos = pci_find_capability(dev, PCI_CAP_ID_EXP); 121 - if (pos) { 122 - /* Update Device Control */ 123 - pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &config); 124 - config |= PCI_EXP_DEVCTL_CERE; /* Correctable Error Reporting */ 125 - config |= PCI_EXP_DEVCTL_NFERE; /* Non-Fatal Error Reporting */ 126 - config |= PCI_EXP_DEVCTL_FERE; /* Fatal Error Reporting */ 127 - config |= PCI_EXP_DEVCTL_URRE; /* Unsupported Request */ 128 - pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, config); 129 - } 120 + config = PCI_EXP_DEVCTL_CERE; /* Correctable Error Reporting */ 121 + config |= PCI_EXP_DEVCTL_NFERE; /* Non-Fatal Error Reporting */ 122 + config |= PCI_EXP_DEVCTL_FERE; /* Fatal Error Reporting */ 123 + config |= PCI_EXP_DEVCTL_URRE; /* Unsupported Request */ 124 + pcie_capability_set_word(dev, PCI_EXP_DEVCTL, config); 130 125 131 126 /* Find the Advanced Error Reporting capability */ 132 127 pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
-6
arch/mips/pci/pci.c
··· 313 313 } 314 314 } 315 315 316 - void __init 317 - pcibios_update_irq(struct pci_dev *dev, int irq) 318 - { 319 - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); 320 - } 321 - 322 316 #ifdef CONFIG_HOTPLUG 323 317 EXPORT_SYMBOL(PCIBIOS_MIN_IO); 324 318 EXPORT_SYMBOL(PCIBIOS_MIN_MEM);
+3
arch/powerpc/include/asm/machdep.h
··· 214 214 /* Called after scan and before resource survey */ 215 215 void (*pcibios_fixup_phb)(struct pci_controller *hose); 216 216 217 + /* Called during PCI resource reassignment */ 218 + resource_size_t (*pcibios_window_alignment)(struct pci_bus *, unsigned long type); 219 + 217 220 /* Called to shutdown machine specific hardware not already controlled 218 221 * by other drivers. 219 222 */
+20
arch/powerpc/kernel/pci-common.c
··· 99 99 kfree(phb); 100 100 } 101 101 102 + /* 103 + * The function is used to return the minimal alignment 104 + * for memory or I/O windows of the associated P2P bridge. 105 + * By default, 4KiB alignment for I/O windows and 1MiB for 106 + * memory windows. 107 + */ 108 + resource_size_t pcibios_window_alignment(struct pci_bus *bus, 109 + unsigned long type) 110 + { 111 + if (ppc_md.pcibios_window_alignment) 112 + return ppc_md.pcibios_window_alignment(bus, type); 113 + 114 + /* 115 + * PCI core will figure out the default 116 + * alignment: 4KiB for I/O and 1MiB for 117 + * memory window. 118 + */ 119 + return 1; 120 + } 121 + 102 122 static resource_size_t pcibios_io_size(const struct pci_controller *hose) 103 123 { 104 124 #ifdef CONFIG_PPC64
+40 -1
arch/powerpc/platforms/powernv/pci-ioda.c
··· 855 855 if (pe == NULL) 856 856 continue; 857 857 /* Leaving the PCIe domain ... single PE# */ 858 - if (dev->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) 858 + if (pci_pcie_type(dev) == PCI_EXP_TYPE_PCI_BRIDGE) 859 859 pnv_ioda_setup_bus_PE(dev, pe); 860 860 else if (dev->subordinate) 861 861 pnv_ioda_setup_PEs(dev->subordinate); ··· 1139 1139 } 1140 1140 } 1141 1141 1142 + /* 1143 + * Returns the alignment for I/O or memory windows for P2P 1144 + * bridges. That actually depends on how PEs are segmented. 1145 + * For now, we return I/O or M32 segment size for PE sensitive 1146 + * P2P bridges. Otherwise, the default values (4KiB for I/O, 1147 + * 1MiB for memory) will be returned. 1148 + * 1149 + * The current PCI bus might be put into one PE, which was 1150 + * create against the parent PCI bridge. For that case, we 1151 + * needn't enlarge the alignment so that we can save some 1152 + * resources. 1153 + */ 1154 + static resource_size_t pnv_pci_window_alignment(struct pci_bus *bus, 1155 + unsigned long type) 1156 + { 1157 + struct pci_dev *bridge; 1158 + struct pci_controller *hose = pci_bus_to_host(bus); 1159 + struct pnv_phb *phb = hose->private_data; 1160 + int num_pci_bridges = 0; 1161 + 1162 + bridge = bus->self; 1163 + while (bridge) { 1164 + if (pci_pcie_type(bridge) == PCI_EXP_TYPE_PCI_BRIDGE) { 1165 + num_pci_bridges++; 1166 + if (num_pci_bridges >= 2) 1167 + return 1; 1168 + } 1169 + 1170 + bridge = bridge->bus->self; 1171 + } 1172 + 1173 + /* We need support prefetchable memory window later */ 1174 + if (type & IORESOURCE_MEM) 1175 + return phb->ioda.m32_segsize; 1176 + 1177 + return phb->ioda.io_segsize; 1178 + } 1179 + 1142 1180 /* Prevent enabling devices for which we couldn't properly 1143 1181 * assign a PE 1144 1182 */ ··· 1344 1306 */ 1345 1307 ppc_md.pcibios_fixup_phb = pnv_pci_ioda_fixup_phb; 1346 1308 ppc_md.pcibios_enable_device_hook = pnv_pci_enable_device_hook; 1309 + ppc_md.pcibios_window_alignment = pnv_pci_window_alignment; 1347 1310 pci_add_flags(PCI_PROBE_ONLY | PCI_REASSIGN_ALL_RSRC); 1348 1311 1349 1312 /* Reset IODA tables to a clean state */
-5
arch/sh/drivers/pci/pci.c
··· 192 192 return pci_enable_resources(dev, mask); 193 193 } 194 194 195 - void __init pcibios_update_irq(struct pci_dev *dev, int irq) 196 - { 197 - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); 198 - } 199 - 200 195 static void __init 201 196 pcibios_bus_report_status_early(struct pci_channel *hose, 202 197 int top_bus, int current_bus,
-9
arch/sparc/kernel/leon_pci.c
··· 102 102 return pci_enable_resources(dev, mask); 103 103 } 104 104 105 - void __devinit pcibios_update_irq(struct pci_dev *dev, int irq) 106 - { 107 - #ifdef CONFIG_PCI_DEBUG 108 - printk(KERN_DEBUG "LEONPCI: Assigning IRQ %02d to %s\n", irq, 109 - pci_name(dev)); 110 - #endif 111 - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); 112 - } 113 - 114 105 /* in/out routines taken from pcic.c 115 106 * 116 107 * This probably belongs here rather than ioport.c because
-4
arch/sparc/kernel/pci.c
··· 622 622 { 623 623 } 624 624 625 - void pcibios_update_irq(struct pci_dev *pdev, int irq) 626 - { 627 - } 628 - 629 625 resource_size_t pcibios_align_resource(void *data, const struct resource *res, 630 626 resource_size_t size, resource_size_t align) 631 627 {
+6 -28
arch/tile/kernel/pci.c
··· 246 246 247 247 /* Scan for the smallest maximum payload size. */ 248 248 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { 249 - int pcie_caps_offset; 250 249 u32 devcap; 251 250 int max_payload; 252 251 253 - pcie_caps_offset = pci_find_capability(dev, PCI_CAP_ID_EXP); 254 - if (pcie_caps_offset == 0) 252 + if (!pci_is_pcie(dev)) 255 253 continue; 256 254 257 - pci_read_config_dword(dev, pcie_caps_offset + PCI_EXP_DEVCAP, 258 - &devcap); 255 + pcie_capability_read_dword(dev, PCI_EXP_DEVCAP, &devcap); 259 256 max_payload = devcap & PCI_EXP_DEVCAP_PAYLOAD; 260 257 if (max_payload < smallest_max_payload) 261 258 smallest_max_payload = max_payload; ··· 260 263 261 264 /* Now, set the max_payload_size for all devices to that value. */ 262 265 new_values = (max_read_size << 12) | (smallest_max_payload << 5); 263 - while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { 264 - int pcie_caps_offset; 265 - u16 devctl; 266 - 267 - pcie_caps_offset = pci_find_capability(dev, PCI_CAP_ID_EXP); 268 - if (pcie_caps_offset == 0) 269 - continue; 270 - 271 - pci_read_config_word(dev, pcie_caps_offset + PCI_EXP_DEVCTL, 272 - &devctl); 273 - devctl &= ~(PCI_EXP_DEVCTL_PAYLOAD | PCI_EXP_DEVCTL_READRQ); 274 - devctl |= new_values; 275 - pci_write_config_word(dev, pcie_caps_offset + PCI_EXP_DEVCTL, 276 - devctl); 277 - } 266 + while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) 267 + pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL, 268 + PCI_EXP_DEVCTL_PAYLOAD | PCI_EXP_DEVCTL_READRQ, 269 + new_values); 278 270 } 279 271 280 272 ··· 387 401 void pcibios_set_master(struct pci_dev *dev) 388 402 { 389 403 /* No special bus mastering setup handling. */ 390 - } 391 - 392 - /* 393 - * This is called from the generic Linux layer. 394 - */ 395 - void __devinit pcibios_update_irq(struct pci_dev *dev, int irq) 396 - { 397 - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); 398 404 } 399 405 400 406 /*
-8
arch/tile/kernel/pci_gx.c
··· 1034 1034 } 1035 1035 1036 1036 /* 1037 - * This is called from the generic Linux layer. 1038 - */ 1039 - void __devinit pcibios_update_irq(struct pci_dev *dev, int irq) 1040 - { 1041 - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); 1042 - } 1043 - 1044 - /* 1045 1037 * Enable memory address decoding, as appropriate, for the 1046 1038 * device described by the 'dev' struct. The I/O decoding 1047 1039 * is disabled, though the TILE-Gx supports I/O addressing.
-8
arch/unicore32/kernel/pci.c
··· 154 154 zhole_size[0] = 0; 155 155 } 156 156 157 - void __devinit pcibios_update_irq(struct pci_dev *dev, int irq) 158 - { 159 - if (debug_pci) 160 - printk(KERN_DEBUG "PCI: Assigning IRQ %02d to %s\n", 161 - irq, pci_name(dev)); 162 - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); 163 - } 164 - 165 157 /* 166 158 * If the bus contains any of these devices, then we must not turn on 167 159 * parity checking of any kind.
+1 -2
arch/x86/pci/acpi.c
··· 305 305 res->flags = flags; 306 306 res->start = start; 307 307 res->end = end; 308 - res->child = NULL; 309 308 310 309 if (!pci_use_crs) { 311 310 dev_printk(KERN_DEBUG, &info->bridge->dev, ··· 433 434 434 435 size = sizeof(*info->res) * info->res_num; 435 436 info->res_num = 0; 436 - info->res = kmalloc(size, GFP_KERNEL); 437 + info->res = kzalloc(size, GFP_KERNEL); 437 438 if (!info->res) 438 439 return; 439 440
-5
arch/x86/pci/visws.c
··· 62 62 return irq; 63 63 } 64 64 65 - void __init pcibios_update_irq(struct pci_dev *dev, int irq) 66 - { 67 - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); 68 - } 69 - 70 65 int __init pci_visws_init(void) 71 66 { 72 67 pcibios_enable_irq = &pci_visws_enable_irq;
-8
arch/xtensa/kernel/pci.c
··· 210 210 /* No special bus mastering setup handling */ 211 211 } 212 212 213 - /* the next one is stolen from the alpha port... */ 214 - 215 - void __init 216 - pcibios_update_irq(struct pci_dev *dev, int irq) 217 - { 218 - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); 219 - } 220 - 221 213 int pcibios_enable_device(struct pci_dev *dev, int mask) 222 214 { 223 215 u16 cmd, old_cmd;
+58 -43
drivers/acpi/pci_root.c
··· 27 27 #include <linux/module.h> 28 28 #include <linux/init.h> 29 29 #include <linux/types.h> 30 - #include <linux/spinlock.h> 30 + #include <linux/mutex.h> 31 31 #include <linux/pm.h> 32 32 #include <linux/pm_runtime.h> 33 33 #include <linux/pci.h> ··· 71 71 }, 72 72 }; 73 73 74 + /* Lock to protect both acpi_pci_roots and acpi_pci_drivers lists */ 75 + static DEFINE_MUTEX(acpi_pci_root_lock); 74 76 static LIST_HEAD(acpi_pci_roots); 77 + static LIST_HEAD(acpi_pci_drivers); 75 78 76 - static struct acpi_pci_driver *sub_driver; 77 79 static DEFINE_MUTEX(osc_lock); 78 80 79 81 int acpi_pci_register_driver(struct acpi_pci_driver *driver) ··· 83 81 int n = 0; 84 82 struct acpi_pci_root *root; 85 83 86 - struct acpi_pci_driver **pptr = &sub_driver; 87 - while (*pptr) 88 - pptr = &(*pptr)->next; 89 - *pptr = driver; 90 - 91 - if (!driver->add) 92 - return 0; 93 - 94 - list_for_each_entry(root, &acpi_pci_roots, node) { 95 - driver->add(root->device->handle); 96 - n++; 97 - } 84 + mutex_lock(&acpi_pci_root_lock); 85 + list_add_tail(&driver->node, &acpi_pci_drivers); 86 + if (driver->add) 87 + list_for_each_entry(root, &acpi_pci_roots, node) { 88 + driver->add(root); 89 + n++; 90 + } 91 + mutex_unlock(&acpi_pci_root_lock); 98 92 99 93 return n; 100 94 } 101 - 102 95 EXPORT_SYMBOL(acpi_pci_register_driver); 103 96 104 97 void acpi_pci_unregister_driver(struct acpi_pci_driver *driver) 105 98 { 106 99 struct acpi_pci_root *root; 107 100 108 - struct acpi_pci_driver **pptr = &sub_driver; 109 - while (*pptr) { 110 - if (*pptr == driver) 111 - break; 112 - pptr = &(*pptr)->next; 113 - } 114 - BUG_ON(!*pptr); 115 - *pptr = (*pptr)->next; 116 - 117 - if (!driver->remove) 118 - return; 119 - 120 - list_for_each_entry(root, &acpi_pci_roots, node) 121 - driver->remove(root->device->handle); 101 + mutex_lock(&acpi_pci_root_lock); 102 + list_del(&driver->node); 103 + if (driver->remove) 104 + list_for_each_entry(root, &acpi_pci_roots, node) 105 + driver->remove(root); 106 + mutex_unlock(&acpi_pci_root_lock); 122 107 } 123 - 124 108 EXPORT_SYMBOL(acpi_pci_unregister_driver); 125 109 126 110 acpi_handle acpi_get_pci_rootbridge_handle(unsigned int seg, unsigned int bus) 127 111 { 128 112 struct acpi_pci_root *root; 113 + acpi_handle handle = NULL; 129 114 115 + mutex_lock(&acpi_pci_root_lock); 130 116 list_for_each_entry(root, &acpi_pci_roots, node) 131 117 if ((root->segment == (u16) seg) && 132 - (root->secondary.start == (u16) bus)) 133 - return root->device->handle; 134 - return NULL; 118 + (root->secondary.start == (u16) bus)) { 119 + handle = root->device->handle; 120 + break; 121 + } 122 + mutex_unlock(&acpi_pci_root_lock); 123 + return handle; 135 124 } 136 125 137 126 EXPORT_SYMBOL_GPL(acpi_get_pci_rootbridge_handle); ··· 270 277 struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle) 271 278 { 272 279 struct acpi_pci_root *root; 280 + struct acpi_device *device; 273 281 274 - list_for_each_entry(root, &acpi_pci_roots, node) { 275 - if (root->device->handle == handle) 276 - return root; 277 - } 278 - return NULL; 282 + if (acpi_bus_get_device(handle, &device) || 283 + acpi_match_device_ids(device, root_device_ids)) 284 + return NULL; 285 + 286 + root = acpi_driver_data(device); 287 + 288 + return root; 279 289 } 280 290 EXPORT_SYMBOL_GPL(acpi_pci_find_root); 281 291 ··· 514 518 * TBD: Need PCI interface for enumeration/configuration of roots. 515 519 */ 516 520 517 - /* TBD: Locking */ 521 + mutex_lock(&acpi_pci_root_lock); 518 522 list_add_tail(&root->node, &acpi_pci_roots); 523 + mutex_unlock(&acpi_pci_root_lock); 519 524 520 525 printk(KERN_INFO PREFIX "%s [%s] (domain %04x %pR)\n", 521 526 acpi_device_name(device), acpi_device_bid(device), ··· 535 538 "Bus %04x:%02x not present in PCI namespace\n", 536 539 root->segment, (unsigned int)root->secondary.start); 537 540 result = -ENODEV; 538 - goto end; 541 + goto out_del_root; 539 542 } 540 543 541 544 /* ··· 545 548 */ 546 549 result = acpi_pci_bind_root(device); 547 550 if (result) 548 - goto end; 551 + goto out_del_root; 549 552 550 553 /* 551 554 * PCI Routing Table ··· 630 633 631 634 return 0; 632 635 636 + out_del_root: 637 + mutex_lock(&acpi_pci_root_lock); 638 + list_del(&root->node); 639 + mutex_unlock(&acpi_pci_root_lock); 633 640 end: 634 - if (!list_empty(&root->node)) 635 - list_del(&root->node); 636 641 kfree(root); 637 642 return result; 638 643 } ··· 642 643 static int acpi_pci_root_start(struct acpi_device *device) 643 644 { 644 645 struct acpi_pci_root *root = acpi_driver_data(device); 646 + struct acpi_pci_driver *driver; 647 + 648 + mutex_lock(&acpi_pci_root_lock); 649 + list_for_each_entry(driver, &acpi_pci_drivers, node) 650 + if (driver->add) 651 + driver->add(root); 652 + mutex_unlock(&acpi_pci_root_lock); 645 653 646 654 pci_bus_add_devices(root->bus); 655 + 647 656 return 0; 648 657 } 649 658 650 659 static int acpi_pci_root_remove(struct acpi_device *device, int type) 651 660 { 652 661 struct acpi_pci_root *root = acpi_driver_data(device); 662 + struct acpi_pci_driver *driver; 663 + 664 + mutex_lock(&acpi_pci_root_lock); 665 + list_for_each_entry(driver, &acpi_pci_drivers, node) 666 + if (driver->remove) 667 + driver->remove(root); 653 668 654 669 device_set_run_wake(root->bus->bridge, false); 655 670 pci_acpi_remove_bus_pm_notifier(device); 656 671 672 + list_del(&root->node); 673 + mutex_unlock(&acpi_pci_root_lock); 657 674 kfree(root); 658 675 return 0; 659 676 }
+10 -34
drivers/acpi/pci_slot.c
··· 67 67 struct list_head list; /* node in the list of slots */ 68 68 }; 69 69 70 - static int acpi_pci_slot_add(acpi_handle handle); 71 - static void acpi_pci_slot_remove(acpi_handle handle); 70 + static int acpi_pci_slot_add(struct acpi_pci_root *root); 71 + static void acpi_pci_slot_remove(struct acpi_pci_root *root); 72 72 73 73 static LIST_HEAD(slot_list); 74 74 static DEFINE_MUTEX(slot_list_lock); ··· 233 233 234 234 /* 235 235 * walk_root_bridge - generic root bridge walker 236 - * @handle: points to an acpi_pci_root 236 + * @root: poiner of an acpi_pci_root 237 237 * @user_function: user callback for slot objects 238 238 * 239 239 * Call user_function for all objects underneath this root bridge. 240 240 * Walk p2p bridges underneath us and call user_function on those too. 241 241 */ 242 242 static int 243 - walk_root_bridge(acpi_handle handle, acpi_walk_callback user_function) 243 + walk_root_bridge(struct acpi_pci_root *root, acpi_walk_callback user_function) 244 244 { 245 - int seg, bus; 246 - unsigned long long tmp; 247 245 acpi_status status; 248 - acpi_handle dummy_handle; 249 - struct pci_bus *pci_bus; 246 + acpi_handle handle = root->device->handle; 247 + struct pci_bus *pci_bus = root->bus; 250 248 struct callback_args context; 251 - 252 - /* If the bridge doesn't have _STA, we assume it is always there */ 253 - status = acpi_get_handle(handle, "_STA", &dummy_handle); 254 - if (ACPI_SUCCESS(status)) { 255 - status = acpi_evaluate_integer(handle, "_STA", NULL, &tmp); 256 - if (ACPI_FAILURE(status)) { 257 - info("%s: _STA evaluation failure\n", __func__); 258 - return 0; 259 - } 260 - if ((tmp & ACPI_STA_DEVICE_FUNCTIONING) == 0) 261 - /* don't register this object */ 262 - return 0; 263 - } 264 - 265 - status = acpi_evaluate_integer(handle, "_SEG", NULL, &tmp); 266 - seg = ACPI_SUCCESS(status) ? tmp : 0; 267 - 268 - status = acpi_evaluate_integer(handle, "_BBN", NULL, &tmp); 269 - bus = ACPI_SUCCESS(status) ? tmp : 0; 270 - 271 - pci_bus = pci_find_bus(seg, bus); 272 - if (!pci_bus) 273 - return 0; 274 249 275 250 context.pci_bus = pci_bus; 276 251 context.user_function = user_function; ··· 270 295 * @handle: points to an acpi_pci_root 271 296 */ 272 297 static int 273 - acpi_pci_slot_add(acpi_handle handle) 298 + acpi_pci_slot_add(struct acpi_pci_root *root) 274 299 { 275 300 acpi_status status; 276 301 277 - status = walk_root_bridge(handle, register_slot); 302 + status = walk_root_bridge(root, register_slot); 278 303 if (ACPI_FAILURE(status)) 279 304 err("%s: register_slot failure - %d\n", __func__, status); 280 305 ··· 286 311 * @handle: points to an acpi_pci_root 287 312 */ 288 313 static void 289 - acpi_pci_slot_remove(acpi_handle handle) 314 + acpi_pci_slot_remove(struct acpi_pci_root *root) 290 315 { 291 316 struct acpi_pci_slot *slot, *tmp; 292 317 struct pci_bus *pbus; 318 + acpi_handle handle = root->device->handle; 293 319 294 320 mutex_lock(&slot_list_lock); 295 321 list_for_each_entry_safe(slot, tmp, &slot_list, list) {
+1 -1
drivers/block/nvme.c
··· 1726 1726 #define nvme_suspend NULL 1727 1727 #define nvme_resume NULL 1728 1728 1729 - static struct pci_error_handlers nvme_err_handler = { 1729 + static const struct pci_error_handlers nvme_err_handler = { 1730 1730 .error_detected = nvme_error_detected, 1731 1731 .mmio_enabled = nvme_dump_registers, 1732 1732 .link_reset = nvme_link_reset,
+2 -3
drivers/char/agp/sgi-agp.c
··· 289 289 290 290 j = 0; 291 291 list_for_each_entry(info, &tioca_list, ca_list) { 292 - struct list_head *tmp; 293 292 if (list_empty(info->ca_devices)) 294 293 continue; 295 - list_for_each(tmp, info->ca_devices) { 294 + list_for_each_entry(pdev, info->ca_devices, bus_list) { 296 295 u8 cap_ptr; 297 - pdev = pci_dev_b(tmp); 296 + 298 297 if (pdev->class != (PCI_CLASS_DISPLAY_VGA << 8)) 299 298 continue; 300 299 cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP);
+3 -7
drivers/gpu/drm/radeon/evergreen.c
··· 77 77 void evergreen_fix_pci_max_read_req_size(struct radeon_device *rdev) 78 78 { 79 79 u16 ctl, v; 80 - int cap, err; 80 + int err; 81 81 82 - cap = pci_pcie_cap(rdev->pdev); 83 - if (!cap) 84 - return; 85 - 86 - err = pci_read_config_word(rdev->pdev, cap + PCI_EXP_DEVCTL, &ctl); 82 + err = pcie_capability_read_word(rdev->pdev, PCI_EXP_DEVCTL, &ctl); 87 83 if (err) 88 84 return; 89 85 ··· 91 95 if ((v == 0) || (v == 6) || (v == 7)) { 92 96 ctl &= ~PCI_EXP_DEVCTL_READRQ; 93 97 ctl |= (2 << 12); 94 - pci_write_config_word(rdev->pdev, cap + PCI_EXP_DEVCTL, ctl); 98 + pcie_capability_write_word(rdev->pdev, PCI_EXP_DEVCTL, ctl); 95 99 } 96 100 } 97 101
+11 -18
drivers/gpu/vga/vgaarb.c
··· 141 141 142 142 void vga_set_default_device(struct pci_dev *pdev) 143 143 { 144 - vga_default = pdev; 144 + if (vga_default == pdev) 145 + return; 146 + 147 + pci_dev_put(vga_default); 148 + vga_default = pci_dev_get(pdev); 145 149 } 146 150 #endif 147 151 ··· 581 577 #ifndef __ARCH_HAS_VGA_DEFAULT_DEVICE 582 578 if (vga_default == NULL && 583 579 ((vgadev->owns & VGA_RSRC_LEGACY_MASK) == VGA_RSRC_LEGACY_MASK)) 584 - vga_default = pci_dev_get(pdev); 580 + vga_set_default_device(pdev); 585 581 #endif 586 582 587 583 vga_arbiter_check_bridge_sharing(vgadev); ··· 617 613 } 618 614 619 615 #ifndef __ARCH_HAS_VGA_DEFAULT_DEVICE 620 - if (vga_default == pdev) { 621 - pci_dev_put(vga_default); 622 - vga_default = NULL; 623 - } 616 + if (vga_default == pdev) 617 + vga_set_default_device(NULL); 624 618 #endif 625 619 626 620 if (vgadev->decodes & (VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM)) ··· 1068 1066 } 1069 1067 1070 1068 } else if (strncmp(curr_pos, "target ", 7) == 0) { 1071 - struct pci_bus *pbus; 1072 1069 unsigned int domain, bus, devfn; 1073 1070 struct vga_device *vgadev; 1074 1071 ··· 1086 1085 pr_debug("vgaarb: %s ==> %x:%x:%x.%x\n", curr_pos, 1087 1086 domain, bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); 1088 1087 1089 - pbus = pci_find_bus(domain, bus); 1090 - pr_debug("vgaarb: pbus %p\n", pbus); 1091 - if (pbus == NULL) { 1092 - pr_err("vgaarb: invalid PCI domain and/or bus address %x:%x\n", 1093 - domain, bus); 1094 - ret_val = -ENODEV; 1095 - goto done; 1096 - } 1097 - pdev = pci_get_slot(pbus, devfn); 1088 + pdev = pci_get_domain_bus_and_slot(domain, bus, devfn); 1098 1089 pr_debug("vgaarb: pdev %p\n", pdev); 1099 1090 if (!pdev) { 1100 - pr_err("vgaarb: invalid PCI address %x:%x\n", 1101 - bus, devfn); 1091 + pr_err("vgaarb: invalid PCI address %x:%x:%x\n", 1092 + domain, bus, devfn); 1102 1093 ret_val = -ENODEV; 1103 1094 goto done; 1104 1095 }
+4 -4
drivers/infiniband/hw/mthca/mthca_reset.c
··· 241 241 242 242 if (hca_pcie_cap) { 243 243 devctl = hca_header[(hca_pcie_cap + PCI_EXP_DEVCTL) / 4]; 244 - if (pci_write_config_word(mdev->pdev, hca_pcie_cap + PCI_EXP_DEVCTL, 245 - devctl)) { 244 + if (pcie_capability_write_word(mdev->pdev, PCI_EXP_DEVCTL, 245 + devctl)) { 246 246 err = -ENODEV; 247 247 mthca_err(mdev, "Couldn't restore HCA PCI Express " 248 248 "Device Control register, aborting.\n"); 249 249 goto out; 250 250 } 251 251 linkctl = hca_header[(hca_pcie_cap + PCI_EXP_LNKCTL) / 4]; 252 - if (pci_write_config_word(mdev->pdev, hca_pcie_cap + PCI_EXP_LNKCTL, 253 - linkctl)) { 252 + if (pcie_capability_write_word(mdev->pdev, PCI_EXP_LNKCTL, 253 + linkctl)) { 254 254 err = -ENODEV; 255 255 mthca_err(mdev, "Couldn't restore HCA PCI Express " 256 256 "Link control register, aborting.\n");
+1 -1
drivers/infiniband/hw/qib/qib.h
··· 87 87 }; 88 88 89 89 extern struct qlogic_ib_stats qib_stats; 90 - extern struct pci_error_handlers qib_pci_err_handler; 90 + extern const struct pci_error_handlers qib_pci_err_handler; 91 91 extern struct pci_driver qib_driver; 92 92 93 93 #define QIB_CHIP_SWVERSION QIB_CHIP_VERS_MAJ
+16 -24
drivers/infiniband/hw/qib/qib_pcie.c
··· 273 273 struct qib_msix_entry *entry) 274 274 { 275 275 u16 linkstat, speed; 276 - int pos = 0, pose, ret = 1; 276 + int pos = 0, ret = 1; 277 277 278 - pose = pci_pcie_cap(dd->pcidev); 279 - if (!pose) { 278 + if (!pci_is_pcie(dd->pcidev)) { 280 279 qib_dev_err(dd, "Can't find PCI Express capability!\n"); 281 280 /* set up something... */ 282 281 dd->lbus_width = 1; ··· 297 298 if (!pos) 298 299 qib_enable_intx(dd->pcidev); 299 300 300 - pci_read_config_word(dd->pcidev, pose + PCI_EXP_LNKSTA, &linkstat); 301 + pcie_capability_read_word(dd->pcidev, PCI_EXP_LNKSTA, &linkstat); 301 302 /* 302 303 * speed is bits 0-3, linkwidth is bits 4-8 303 304 * no defines for them in headers ··· 515 516 { 516 517 int r; 517 518 struct pci_dev *parent; 518 - int ppos; 519 519 u16 devid; 520 520 u32 mask, bits, val; 521 521 ··· 527 529 qib_devinfo(dd->pcidev, "Parent not root\n"); 528 530 return 1; 529 531 } 530 - ppos = pci_pcie_cap(parent); 531 - if (!ppos) 532 + if (!pci_is_pcie(parent)) 532 533 return 1; 533 534 if (parent->vendor != 0x8086) 534 535 return 1; ··· 584 587 { 585 588 int ret = 1; /* Assume the worst */ 586 589 struct pci_dev *parent; 587 - int ppos, epos; 588 590 u16 pcaps, pctl, ecaps, ectl; 589 591 int rc_sup, ep_sup; 590 592 int rc_cur, ep_cur; ··· 594 598 qib_devinfo(dd->pcidev, "Parent not root\n"); 595 599 goto bail; 596 600 } 597 - ppos = pci_pcie_cap(parent); 598 - if (ppos) { 599 - pci_read_config_word(parent, ppos + PCI_EXP_DEVCAP, &pcaps); 600 - pci_read_config_word(parent, ppos + PCI_EXP_DEVCTL, &pctl); 601 - } else 601 + 602 + if (!pci_is_pcie(parent) || !pci_is_pcie(dd->pcidev)) 602 603 goto bail; 604 + pcie_capability_read_word(parent, PCI_EXP_DEVCAP, &pcaps); 605 + pcie_capability_read_word(parent, PCI_EXP_DEVCTL, &pctl); 603 606 /* Find out supported and configured values for endpoint (us) */ 604 - epos = pci_pcie_cap(dd->pcidev); 605 - if (epos) { 606 - pci_read_config_word(dd->pcidev, epos + PCI_EXP_DEVCAP, &ecaps); 607 - pci_read_config_word(dd->pcidev, epos + PCI_EXP_DEVCTL, &ectl); 608 - } else 609 - goto bail; 607 + pcie_capability_read_word(dd->pcidev, PCI_EXP_DEVCAP, &ecaps); 608 + pcie_capability_read_word(dd->pcidev, PCI_EXP_DEVCTL, &ectl); 609 + 610 610 ret = 0; 611 611 /* Find max payload supported by root, endpoint */ 612 612 rc_sup = fld2val(pcaps, PCI_EXP_DEVCAP_PAYLOAD); ··· 621 629 rc_cur = rc_sup; 622 630 pctl = (pctl & ~PCI_EXP_DEVCTL_PAYLOAD) | 623 631 val2fld(rc_cur, PCI_EXP_DEVCTL_PAYLOAD); 624 - pci_write_config_word(parent, ppos + PCI_EXP_DEVCTL, pctl); 632 + pcie_capability_write_word(parent, PCI_EXP_DEVCTL, pctl); 625 633 } 626 634 /* If less than (allowed, supported), bump endpoint payload */ 627 635 if (rc_sup > ep_cur) { 628 636 ep_cur = rc_sup; 629 637 ectl = (ectl & ~PCI_EXP_DEVCTL_PAYLOAD) | 630 638 val2fld(ep_cur, PCI_EXP_DEVCTL_PAYLOAD); 631 - pci_write_config_word(dd->pcidev, epos + PCI_EXP_DEVCTL, ectl); 639 + pcie_capability_write_word(dd->pcidev, PCI_EXP_DEVCTL, ectl); 632 640 } 633 641 634 642 /* ··· 646 654 rc_cur = rc_sup; 647 655 pctl = (pctl & ~PCI_EXP_DEVCTL_READRQ) | 648 656 val2fld(rc_cur, PCI_EXP_DEVCTL_READRQ); 649 - pci_write_config_word(parent, ppos + PCI_EXP_DEVCTL, pctl); 657 + pcie_capability_write_word(parent, PCI_EXP_DEVCTL, pctl); 650 658 } 651 659 if (rc_sup > ep_cur) { 652 660 ep_cur = rc_sup; 653 661 ectl = (ectl & ~PCI_EXP_DEVCTL_READRQ) | 654 662 val2fld(ep_cur, PCI_EXP_DEVCTL_READRQ); 655 - pci_write_config_word(dd->pcidev, epos + PCI_EXP_DEVCTL, ectl); 663 + pcie_capability_write_word(dd->pcidev, PCI_EXP_DEVCTL, ectl); 656 664 } 657 665 bail: 658 666 return ret; ··· 745 753 qib_init(dd, 1); /* same as re-init after reset */ 746 754 } 747 755 748 - struct pci_error_handlers qib_pci_err_handler = { 756 + const struct pci_error_handlers qib_pci_err_handler = { 749 757 .error_detected = qib_pci_error_detected, 750 758 .mmio_enabled = qib_pci_mmio_enabled, 751 759 .link_reset = qib_pci_link_reset,
+3 -3
drivers/iommu/intel-iommu.c
··· 2351 2351 return 0; 2352 2352 if (pdev->class >> 8 == PCI_CLASS_BRIDGE_PCI) 2353 2353 return 0; 2354 - } else if (pdev->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) 2354 + } else if (pci_pcie_type(pdev) == PCI_EXP_TYPE_PCI_BRIDGE) 2355 2355 return 0; 2356 2356 2357 2357 /* ··· 3546 3546 struct pci_dev *bridge = bus->self; 3547 3547 3548 3548 if (!bridge || !pci_is_pcie(bridge) || 3549 - bridge->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) 3549 + pci_pcie_type(bridge) == PCI_EXP_TYPE_PCI_BRIDGE) 3550 3550 return 0; 3551 3551 3552 - if (bridge->pcie_type == PCI_EXP_TYPE_ROOT_PORT) { 3552 + if (pci_pcie_type(bridge) == PCI_EXP_TYPE_ROOT_PORT) { 3553 3553 for (i = 0; i < atsru->devices_cnt; i++) 3554 3554 if (atsru->devices[i] == bridge) 3555 3555 return 1;
+1 -1
drivers/media/dvb/ngene/ngene-cards.c
··· 524 524 printk(KERN_INFO DEVICE_NAME ": resume\n"); 525 525 } 526 526 527 - static struct pci_error_handlers ngene_errors = { 527 + static const struct pci_error_handlers ngene_errors = { 528 528 .error_detected = ngene_error_detected, 529 529 .link_reset = ngene_link_reset, 530 530 .slot_reset = ngene_slot_reset,
+2 -2
drivers/net/ethernet/atheros/atl1c/atl1c_main.c
··· 149 149 data &= ~(PCI_ERR_UNC_DLP | PCI_ERR_UNC_FCP); 150 150 pci_write_config_dword(pdev, pos + PCI_ERR_UNCOR_SEVER, data); 151 151 /* clear error status */ 152 - pci_write_config_word(pdev, pci_pcie_cap(pdev) + PCI_EXP_DEVSTA, 152 + pcie_capability_write_word(pdev, PCI_EXP_DEVSTA, 153 153 PCI_EXP_DEVSTA_NFED | 154 154 PCI_EXP_DEVSTA_FED | 155 155 PCI_EXP_DEVSTA_CED | ··· 2685 2685 netif_device_attach(netdev); 2686 2686 } 2687 2687 2688 - static struct pci_error_handlers atl1c_err_handler = { 2688 + static const struct pci_error_handlers atl1c_err_handler = { 2689 2689 .error_detected = atl1c_io_error_detected, 2690 2690 .slot_reset = atl1c_io_slot_reset, 2691 2691 .resume = atl1c_io_resume,
+1 -1
drivers/net/ethernet/atheros/atl1e/atl1e_main.c
··· 2489 2489 netif_device_attach(netdev); 2490 2490 } 2491 2491 2492 - static struct pci_error_handlers atl1e_err_handler = { 2492 + static const struct pci_error_handlers atl1e_err_handler = { 2493 2493 .error_detected = atl1e_io_error_detected, 2494 2494 .slot_reset = atl1e_io_slot_reset, 2495 2495 .resume = atl1e_io_resume,
+1 -1
drivers/net/ethernet/broadcom/bnx2.c
··· 8742 8742 rtnl_unlock(); 8743 8743 } 8744 8744 8745 - static struct pci_error_handlers bnx2_err_handler = { 8745 + static const struct pci_error_handlers bnx2_err_handler = { 8746 8746 .error_detected = bnx2_io_error_detected, 8747 8747 .slot_reset = bnx2_io_slot_reset, 8748 8748 .resume = bnx2_io_resume,
+5 -15
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
··· 1162 1162 1163 1163 static u8 bnx2x_is_pcie_pending(struct pci_dev *dev) 1164 1164 { 1165 - int pos; 1166 1165 u16 status; 1167 1166 1168 - pos = pci_pcie_cap(dev); 1169 - if (!pos) 1170 - return false; 1171 - 1172 - pci_read_config_word(dev, pos + PCI_EXP_DEVSTA, &status); 1167 + pcie_capability_read_word(dev, PCI_EXP_DEVSTA, &status); 1173 1168 return status & PCI_EXP_DEVSTA_TRPND; 1174 1169 } 1175 1170 ··· 6130 6135 u16 devctl; 6131 6136 int r_order, w_order; 6132 6137 6133 - pci_read_config_word(bp->pdev, 6134 - pci_pcie_cap(bp->pdev) + PCI_EXP_DEVCTL, &devctl); 6138 + pcie_capability_read_word(bp->pdev, PCI_EXP_DEVCTL, &devctl); 6135 6139 DP(NETIF_MSG_HW, "read 0x%x from devctl\n", devctl); 6136 6140 w_order = ((devctl & PCI_EXP_DEVCTL_PAYLOAD) >> 5); 6137 6141 if (bp->mrrs == -1) ··· 9374 9380 9375 9381 static int __devinit bnx2x_do_flr(struct bnx2x *bp) 9376 9382 { 9377 - int i, pos; 9383 + int i; 9378 9384 u16 status; 9379 9385 struct pci_dev *dev = bp->pdev; 9380 9386 ··· 9391 9397 return -EINVAL; 9392 9398 } 9393 9399 9394 - pos = pci_pcie_cap(dev); 9395 - if (!pos) 9396 - return -ENOTTY; 9397 - 9398 9400 /* Wait for Transaction Pending bit clean */ 9399 9401 for (i = 0; i < 4; i++) { 9400 9402 if (i) 9401 9403 msleep((1 << (i - 1)) * 100); 9402 9404 9403 - pci_read_config_word(dev, pos + PCI_EXP_DEVSTA, &status); 9405 + pcie_capability_read_word(dev, PCI_EXP_DEVSTA, &status); 9404 9406 if (!(status & PCI_EXP_DEVSTA_TRPND)) 9405 9407 goto clear; 9406 9408 } ··· 12157 12167 rtnl_unlock(); 12158 12168 } 12159 12169 12160 - static struct pci_error_handlers bnx2x_err_handler = { 12170 + static const struct pci_error_handlers bnx2x_err_handler = { 12161 12171 .error_detected = bnx2x_io_error_detected, 12162 12172 .slot_reset = bnx2x_io_slot_reset, 12163 12173 .resume = bnx2x_io_resume,
+14 -38
drivers/net/ethernet/broadcom/tg3.c
··· 3653 3653 tg3_enable_register_access(tp); 3654 3654 3655 3655 /* Restore the CLKREQ setting. */ 3656 - if (tg3_flag(tp, CLKREQ_BUG)) { 3657 - u16 lnkctl; 3658 - 3659 - pci_read_config_word(tp->pdev, 3660 - pci_pcie_cap(tp->pdev) + PCI_EXP_LNKCTL, 3661 - &lnkctl); 3662 - lnkctl |= PCI_EXP_LNKCTL_CLKREQ_EN; 3663 - pci_write_config_word(tp->pdev, 3664 - pci_pcie_cap(tp->pdev) + PCI_EXP_LNKCTL, 3665 - lnkctl); 3666 - } 3656 + if (tg3_flag(tp, CLKREQ_BUG)) 3657 + pcie_capability_set_word(tp->pdev, PCI_EXP_LNKCTL, 3658 + PCI_EXP_LNKCTL_CLKREQ_EN); 3667 3659 3668 3660 misc_host_ctrl = tr32(TG3PCI_MISC_HOST_CTRL); 3669 3661 tw32(TG3PCI_MISC_HOST_CTRL, ··· 4426 4434 4427 4435 /* Prevent send BD corruption. */ 4428 4436 if (tg3_flag(tp, CLKREQ_BUG)) { 4429 - u16 oldlnkctl, newlnkctl; 4430 - 4431 - pci_read_config_word(tp->pdev, 4432 - pci_pcie_cap(tp->pdev) + PCI_EXP_LNKCTL, 4433 - &oldlnkctl); 4434 4437 if (tp->link_config.active_speed == SPEED_100 || 4435 4438 tp->link_config.active_speed == SPEED_10) 4436 - newlnkctl = oldlnkctl & ~PCI_EXP_LNKCTL_CLKREQ_EN; 4439 + pcie_capability_clear_word(tp->pdev, PCI_EXP_LNKCTL, 4440 + PCI_EXP_LNKCTL_CLKREQ_EN); 4437 4441 else 4438 - newlnkctl = oldlnkctl | PCI_EXP_LNKCTL_CLKREQ_EN; 4439 - if (newlnkctl != oldlnkctl) 4440 - pci_write_config_word(tp->pdev, 4441 - pci_pcie_cap(tp->pdev) + 4442 - PCI_EXP_LNKCTL, newlnkctl); 4442 + pcie_capability_set_word(tp->pdev, PCI_EXP_LNKCTL, 4443 + PCI_EXP_LNKCTL_CLKREQ_EN); 4443 4444 } 4444 4445 4445 4446 if (current_link_up != netif_carrier_ok(tp->dev)) { ··· 8039 8054 8040 8055 udelay(120); 8041 8056 8042 - if (tg3_flag(tp, PCI_EXPRESS) && pci_pcie_cap(tp->pdev)) { 8057 + if (tg3_flag(tp, PCI_EXPRESS) && pci_is_pcie(tp->pdev)) { 8043 8058 u16 val16; 8044 8059 8045 8060 if (tp->pci_chip_rev_id == CHIPREV_ID_5750_A0) { ··· 8056 8071 } 8057 8072 8058 8073 /* Clear the "no snoop" and "relaxed ordering" bits. */ 8059 - pci_read_config_word(tp->pdev, 8060 - pci_pcie_cap(tp->pdev) + PCI_EXP_DEVCTL, 8061 - &val16); 8062 - val16 &= ~(PCI_EXP_DEVCTL_RELAX_EN | 8063 - PCI_EXP_DEVCTL_NOSNOOP_EN); 8074 + val16 = PCI_EXP_DEVCTL_RELAX_EN | PCI_EXP_DEVCTL_NOSNOOP_EN; 8064 8075 /* 8065 8076 * Older PCIe devices only support the 128 byte 8066 8077 * MPS setting. Enforce the restriction. 8067 8078 */ 8068 8079 if (!tg3_flag(tp, CPMU_PRESENT)) 8069 - val16 &= ~PCI_EXP_DEVCTL_PAYLOAD; 8070 - pci_write_config_word(tp->pdev, 8071 - pci_pcie_cap(tp->pdev) + PCI_EXP_DEVCTL, 8072 - val16); 8080 + val16 |= PCI_EXP_DEVCTL_PAYLOAD; 8081 + pcie_capability_clear_word(tp->pdev, PCI_EXP_DEVCTL, val16); 8073 8082 8074 8083 /* Clear error status */ 8075 - pci_write_config_word(tp->pdev, 8076 - pci_pcie_cap(tp->pdev) + PCI_EXP_DEVSTA, 8084 + pcie_capability_write_word(tp->pdev, PCI_EXP_DEVSTA, 8077 8085 PCI_EXP_DEVSTA_CED | 8078 8086 PCI_EXP_DEVSTA_NFED | 8079 8087 PCI_EXP_DEVSTA_FED | ··· 14543 14565 14544 14566 tg3_flag_set(tp, PCI_EXPRESS); 14545 14567 14546 - pci_read_config_word(tp->pdev, 14547 - pci_pcie_cap(tp->pdev) + PCI_EXP_LNKCTL, 14548 - &lnkctl); 14568 + pcie_capability_read_word(tp->pdev, PCI_EXP_LNKCTL, &lnkctl); 14549 14569 if (lnkctl & PCI_EXP_LNKCTL_CLKREQ_EN) { 14550 14570 if (GET_ASIC_REV(tp->pci_chip_rev_id) == 14551 14571 ASIC_REV_5906) { ··· 16373 16397 rtnl_unlock(); 16374 16398 } 16375 16399 16376 - static struct pci_error_handlers tg3_err_handler = { 16400 + static const struct pci_error_handlers tg3_err_handler = { 16377 16401 .error_detected = tg3_io_error_detected, 16378 16402 .slot_reset = tg3_io_slot_reset, 16379 16403 .resume = tg3_io_resume
+1 -1
drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
··· 3036 3036 t3_resume_ports(adapter); 3037 3037 } 3038 3038 3039 - static struct pci_error_handlers t3_err_handler = { 3039 + static const struct pci_error_handlers t3_err_handler = { 3040 3040 .error_detected = t3_io_error_detected, 3041 3041 .slot_reset = t3_io_slot_reset, 3042 3042 .resume = t3_io_resume,
+8 -14
drivers/net/ethernet/chelsio/cxgb3/t3_hw.c
··· 3289 3289 unsigned int log2_width, pldsize; 3290 3290 unsigned int fst_trn_rx, fst_trn_tx, acklat, rpllmt; 3291 3291 3292 - pci_read_config_word(adap->pdev, 3293 - adap->pdev->pcie_cap + PCI_EXP_DEVCTL, 3294 - &val); 3292 + pcie_capability_read_word(adap->pdev, PCI_EXP_DEVCTL, &val); 3295 3293 pldsize = (val & PCI_EXP_DEVCTL_PAYLOAD) >> 5; 3296 3294 3297 3295 pci_read_config_word(adap->pdev, 0x2, &devid); 3298 3296 if (devid == 0x37) { 3299 - pci_write_config_word(adap->pdev, 3300 - adap->pdev->pcie_cap + PCI_EXP_DEVCTL, 3301 - val & ~PCI_EXP_DEVCTL_READRQ & 3302 - ~PCI_EXP_DEVCTL_PAYLOAD); 3297 + pcie_capability_write_word(adap->pdev, PCI_EXP_DEVCTL, 3298 + val & ~PCI_EXP_DEVCTL_READRQ & 3299 + ~PCI_EXP_DEVCTL_PAYLOAD); 3303 3300 pldsize = 0; 3304 3301 } 3305 3302 3306 - pci_read_config_word(adap->pdev, adap->pdev->pcie_cap + PCI_EXP_LNKCTL, 3307 - &val); 3303 + pcie_capability_read_word(adap->pdev, PCI_EXP_LNKCTL, &val); 3308 3304 3309 3305 fst_trn_tx = G_NUMFSTTRNSEQ(t3_read_reg(adap, A_PCIE_PEX_CTRL0)); 3310 3306 fst_trn_rx = adap->params.rev == 0 ? fst_trn_tx : ··· 3421 3425 static void get_pci_mode(struct adapter *adapter, struct pci_params *p) 3422 3426 { 3423 3427 static unsigned short speed_map[] = { 33, 66, 100, 133 }; 3424 - u32 pci_mode, pcie_cap; 3428 + u32 pci_mode; 3425 3429 3426 - pcie_cap = pci_pcie_cap(adapter->pdev); 3427 - if (pcie_cap) { 3430 + if (pci_is_pcie(adapter->pdev)) { 3428 3431 u16 val; 3429 3432 3430 3433 p->variant = PCI_VARIANT_PCIE; 3431 - pci_read_config_word(adapter->pdev, pcie_cap + PCI_EXP_LNKSTA, 3432 - &val); 3434 + pcie_capability_read_word(adapter->pdev, PCI_EXP_LNKSTA, &val); 3433 3435 p->width = (val >> 4) & 0x3f; 3434 3436 return; 3435 3437 }
+2 -10
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
··· 3453 3453 rtnl_unlock(); 3454 3454 } 3455 3455 3456 - static struct pci_error_handlers cxgb4_eeh = { 3456 + static const struct pci_error_handlers cxgb4_eeh = { 3457 3457 .error_detected = eeh_err_detected, 3458 3458 .slot_reset = eeh_slot_reset, 3459 3459 .resume = eeh_resume, ··· 3694 3694 3695 3695 static void __devinit enable_pcie_relaxed_ordering(struct pci_dev *dev) 3696 3696 { 3697 - u16 v; 3698 - int pos; 3699 - 3700 - pos = pci_pcie_cap(dev); 3701 - if (pos > 0) { 3702 - pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &v); 3703 - v |= PCI_EXP_DEVCTL_RELAX_EN; 3704 - pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, v); 3705 - } 3697 + pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_RELAX_EN); 3706 3698 } 3707 3699 3708 3700 /*
+2 -4
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
··· 2741 2741 struct pci_params *p) 2742 2742 { 2743 2743 u16 val; 2744 - u32 pcie_cap = pci_pcie_cap(adapter->pdev); 2745 2744 2746 - if (pcie_cap) { 2747 - pci_read_config_word(adapter->pdev, pcie_cap + PCI_EXP_LNKSTA, 2748 - &val); 2745 + if (pci_is_pcie(adapter->pdev)) { 2746 + pcie_capability_read_word(adapter->pdev, PCI_EXP_LNKSTA, &val); 2749 2747 p->speed = val & PCI_EXP_LNKSTA_CLS; 2750 2748 p->width = (val & PCI_EXP_LNKSTA_NLW) >> 4; 2751 2749 }
+1 -1
drivers/net/ethernet/emulex/benet/be_main.c
··· 4106 4106 dev_err(&adapter->pdev->dev, "EEH resume failed\n"); 4107 4107 } 4108 4108 4109 - static struct pci_error_handlers be_eeh_handlers = { 4109 + static const struct pci_error_handlers be_eeh_handlers = { 4110 4110 .error_detected = be_eeh_err_detected, 4111 4111 .slot_reset = be_eeh_reset, 4112 4112 .resume = be_eeh_resume,
+1 -1
drivers/net/ethernet/intel/e100.c
··· 3157 3157 } 3158 3158 } 3159 3159 3160 - static struct pci_error_handlers e100_err_handler = { 3160 + static const struct pci_error_handlers e100_err_handler = { 3161 3161 .error_detected = e100_io_error_detected, 3162 3162 .slot_reset = e100_io_slot_reset, 3163 3163 .resume = e100_io_resume,
+1 -1
drivers/net/ethernet/intel/e1000/e1000_main.c
··· 192 192 static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev); 193 193 static void e1000_io_resume(struct pci_dev *pdev); 194 194 195 - static struct pci_error_handlers e1000_err_handler = { 195 + static const struct pci_error_handlers e1000_err_handler = { 196 196 .error_detected = e1000_io_error_detected, 197 197 .slot_reset = e1000_io_slot_reset, 198 198 .resume = e1000_io_resume,
+9 -20
drivers/net/ethernet/intel/e1000e/netdev.c
··· 5584 5584 */ 5585 5585 if (adapter->flags & FLAG_IS_QUAD_PORT) { 5586 5586 struct pci_dev *us_dev = pdev->bus->self; 5587 - int pos = pci_pcie_cap(us_dev); 5588 5587 u16 devctl; 5589 5588 5590 - pci_read_config_word(us_dev, pos + PCI_EXP_DEVCTL, &devctl); 5591 - pci_write_config_word(us_dev, pos + PCI_EXP_DEVCTL, 5592 - (devctl & ~PCI_EXP_DEVCTL_CERE)); 5589 + pcie_capability_read_word(us_dev, PCI_EXP_DEVCTL, &devctl); 5590 + pcie_capability_write_word(us_dev, PCI_EXP_DEVCTL, 5591 + (devctl & ~PCI_EXP_DEVCTL_CERE)); 5593 5592 5594 5593 e1000_power_off(pdev, sleep, wake); 5595 5594 5596 - pci_write_config_word(us_dev, pos + PCI_EXP_DEVCTL, devctl); 5595 + pcie_capability_write_word(us_dev, PCI_EXP_DEVCTL, devctl); 5597 5596 } else { 5598 5597 e1000_power_off(pdev, sleep, wake); 5599 5598 } ··· 5606 5607 #else 5607 5608 static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state) 5608 5609 { 5609 - int pos; 5610 - u16 reg16; 5611 - 5612 5610 /* 5613 5611 * Both device and parent should have the same ASPM setting. 5614 5612 * Disable ASPM in downstream component first and then upstream. 5615 5613 */ 5616 - pos = pci_pcie_cap(pdev); 5617 - pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &reg16); 5618 - reg16 &= ~state; 5619 - pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16); 5614 + pcie_capability_clear_word(pdev, PCI_EXP_LNKCTL, state); 5620 5615 5621 - if (!pdev->bus->self) 5622 - return; 5623 - 5624 - pos = pci_pcie_cap(pdev->bus->self); 5625 - pci_read_config_word(pdev->bus->self, pos + PCI_EXP_LNKCTL, &reg16); 5626 - reg16 &= ~state; 5627 - pci_write_config_word(pdev->bus->self, pos + PCI_EXP_LNKCTL, reg16); 5616 + if (pdev->bus->self) 5617 + pcie_capability_clear_word(pdev->bus->self, PCI_EXP_LNKCTL, 5618 + state); 5628 5619 } 5629 5620 #endif 5630 5621 static void e1000e_disable_aspm(struct pci_dev *pdev, u16 state) ··· 6475 6486 } 6476 6487 6477 6488 /* PCI Error Recovery (ERS) */ 6478 - static struct pci_error_handlers e1000_err_handler = { 6489 + static const struct pci_error_handlers e1000_err_handler = { 6479 6490 .error_detected = e1000_io_error_detected, 6480 6491 .slot_reset = e1000_io_slot_reset, 6481 6492 .resume = e1000_io_resume,
+3 -11
drivers/net/ethernet/intel/igb/igb_main.c
··· 217 217 static pci_ers_result_t igb_io_slot_reset(struct pci_dev *); 218 218 static void igb_io_resume(struct pci_dev *); 219 219 220 - static struct pci_error_handlers igb_err_handler = { 220 + static const struct pci_error_handlers igb_err_handler = { 221 221 .error_detected = igb_io_error_detected, 222 222 .slot_reset = igb_io_slot_reset, 223 223 .resume = igb_io_resume, ··· 6538 6538 s32 igb_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value) 6539 6539 { 6540 6540 struct igb_adapter *adapter = hw->back; 6541 - u16 cap_offset; 6542 6541 6543 - cap_offset = adapter->pdev->pcie_cap; 6544 - if (!cap_offset) 6542 + if (pcie_capability_read_word(adapter->pdev, reg, value)) 6545 6543 return -E1000_ERR_CONFIG; 6546 - 6547 - pci_read_config_word(adapter->pdev, cap_offset + reg, value); 6548 6544 6549 6545 return 0; 6550 6546 } ··· 6548 6552 s32 igb_write_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value) 6549 6553 { 6550 6554 struct igb_adapter *adapter = hw->back; 6551 - u16 cap_offset; 6552 6555 6553 - cap_offset = adapter->pdev->pcie_cap; 6554 - if (!cap_offset) 6556 + if (pcie_capability_write_word(adapter->pdev, reg, *value)) 6555 6557 return -E1000_ERR_CONFIG; 6556 - 6557 - pci_write_config_word(adapter->pdev, cap_offset + reg, *value); 6558 6558 6559 6559 return 0; 6560 6560 }
+1 -1
drivers/net/ethernet/intel/igbvf/netdev.c
··· 2833 2833 } 2834 2834 2835 2835 /* PCI Error Recovery (ERS) */ 2836 - static struct pci_error_handlers igbvf_err_handler = { 2836 + static const struct pci_error_handlers igbvf_err_handler = { 2837 2837 .error_detected = igbvf_io_error_detected, 2838 2838 .slot_reset = igbvf_io_slot_reset, 2839 2839 .resume = igbvf_io_resume,
+1 -1
drivers/net/ethernet/intel/ixgb/ixgb_main.c
··· 115 115 static pci_ers_result_t ixgb_io_slot_reset (struct pci_dev *pdev); 116 116 static void ixgb_io_resume (struct pci_dev *pdev); 117 117 118 - static struct pci_error_handlers ixgb_err_handler = { 118 + static const struct pci_error_handlers ixgb_err_handler = { 119 119 .error_detected = ixgb_io_error_detected, 120 120 .slot_reset = ixgb_io_slot_reset, 121 121 .resume = ixgb_io_resume,
+2 -2
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
··· 7527 7527 goto skip_bad_vf_detection; 7528 7528 7529 7529 bdev = pdev->bus->self; 7530 - while (bdev && (bdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT)) 7530 + while (bdev && (pci_pcie_type(bdev) != PCI_EXP_TYPE_ROOT_PORT)) 7531 7531 bdev = bdev->bus->self; 7532 7532 7533 7533 if (!bdev) ··· 7677 7677 netif_device_attach(netdev); 7678 7678 } 7679 7679 7680 - static struct pci_error_handlers ixgbe_err_handler = { 7680 + static const struct pci_error_handlers ixgbe_err_handler = { 7681 7681 .error_detected = ixgbe_io_error_detected, 7682 7682 .slot_reset = ixgbe_io_slot_reset, 7683 7683 .resume = ixgbe_io_resume,
+1 -1
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
··· 3256 3256 } 3257 3257 3258 3258 /* PCI Error Recovery (ERS) */ 3259 - static struct pci_error_handlers ixgbevf_err_handler = { 3259 + static const struct pci_error_handlers ixgbevf_err_handler = { 3260 3260 .error_detected = ixgbevf_io_error_detected, 3261 3261 .slot_reset = ixgbevf_io_slot_reset, 3262 3262 .resume = ixgbevf_io_resume,
+1 -1
drivers/net/ethernet/mellanox/mlx4/main.c
··· 2300 2300 return ret ? PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_RECOVERED; 2301 2301 } 2302 2302 2303 - static struct pci_error_handlers mlx4_err_handler = { 2303 + static const struct pci_error_handlers mlx4_err_handler = { 2304 2304 .error_detected = mlx4_pci_err_detected, 2305 2305 .slot_reset = mlx4_pci_slot_reset, 2306 2306 };
+4 -4
drivers/net/ethernet/mellanox/mlx4/reset.c
··· 141 141 /* Now restore the PCI headers */ 142 142 if (pcie_cap) { 143 143 devctl = hca_header[(pcie_cap + PCI_EXP_DEVCTL) / 4]; 144 - if (pci_write_config_word(dev->pdev, pcie_cap + PCI_EXP_DEVCTL, 145 - devctl)) { 144 + if (pcie_capability_write_word(dev->pdev, PCI_EXP_DEVCTL, 145 + devctl)) { 146 146 err = -ENODEV; 147 147 mlx4_err(dev, "Couldn't restore HCA PCI Express " 148 148 "Device Control register, aborting.\n"); 149 149 goto out; 150 150 } 151 151 linkctl = hca_header[(pcie_cap + PCI_EXP_LNKCTL) / 4]; 152 - if (pci_write_config_word(dev->pdev, pcie_cap + PCI_EXP_LNKCTL, 153 - linkctl)) { 152 + if (pcie_capability_write_word(dev->pdev, PCI_EXP_LNKCTL, 153 + linkctl)) { 154 154 err = -ENODEV; 155 155 mlx4_err(dev, "Couldn't restore HCA PCI Express " 156 156 "Link control register, aborting.\n");
+8 -23
drivers/net/ethernet/myricom/myri10ge/myri10ge.c
··· 1078 1078 #ifdef CONFIG_MYRI10GE_DCA 1079 1079 static int myri10ge_toggle_relaxed(struct pci_dev *pdev, int on) 1080 1080 { 1081 - int ret, cap, err; 1081 + int ret; 1082 1082 u16 ctl; 1083 1083 1084 - cap = pci_pcie_cap(pdev); 1085 - if (!cap) 1086 - return 0; 1087 - 1088 - err = pci_read_config_word(pdev, cap + PCI_EXP_DEVCTL, &ctl); 1089 - if (err) 1090 - return 0; 1084 + pcie_capability_read_word(pdev, PCI_EXP_DEVCTL, &ctl); 1091 1085 1092 1086 ret = (ctl & PCI_EXP_DEVCTL_RELAX_EN) >> 4; 1093 1087 if (ret != on) { 1094 1088 ctl &= ~PCI_EXP_DEVCTL_RELAX_EN; 1095 1089 ctl |= (on << 4); 1096 - pci_write_config_word(pdev, cap + PCI_EXP_DEVCTL, ctl); 1090 + pcie_capability_write_word(pdev, PCI_EXP_DEVCTL, ctl); 1097 1091 } 1098 1092 return ret; 1099 1093 } ··· 3186 3192 struct device *dev = &mgp->pdev->dev; 3187 3193 int cap; 3188 3194 unsigned err_cap; 3189 - u16 val; 3190 - u8 ext_type; 3191 3195 int ret; 3192 3196 3193 3197 if (!myri10ge_ecrc_enable || !bridge) 3194 3198 return; 3195 3199 3196 3200 /* check that the bridge is a root port */ 3197 - cap = pci_pcie_cap(bridge); 3198 - pci_read_config_word(bridge, cap + PCI_CAP_FLAGS, &val); 3199 - ext_type = (val & PCI_EXP_FLAGS_TYPE) >> 4; 3200 - if (ext_type != PCI_EXP_TYPE_ROOT_PORT) { 3201 + if (pci_pcie_type(bridge) != PCI_EXP_TYPE_ROOT_PORT) { 3201 3202 if (myri10ge_ecrc_enable > 1) { 3202 3203 struct pci_dev *prev_bridge, *old_bridge = bridge; 3203 3204 ··· 3207 3218 " to force ECRC\n"); 3208 3219 return; 3209 3220 } 3210 - cap = pci_pcie_cap(bridge); 3211 - pci_read_config_word(bridge, 3212 - cap + PCI_CAP_FLAGS, &val); 3213 - ext_type = (val & PCI_EXP_FLAGS_TYPE) >> 4; 3214 - } while (ext_type != PCI_EXP_TYPE_ROOT_PORT); 3221 + } while (pci_pcie_type(bridge) != 3222 + PCI_EXP_TYPE_ROOT_PORT); 3215 3223 3216 3224 dev_info(dev, 3217 3225 "Forcing ECRC on non-root port %s" ··· 3321 3335 int overridden = 0; 3322 3336 3323 3337 if (myri10ge_force_firmware == 0) { 3324 - int link_width, exp_cap; 3338 + int link_width; 3325 3339 u16 lnk; 3326 3340 3327 - exp_cap = pci_pcie_cap(mgp->pdev); 3328 - pci_read_config_word(mgp->pdev, exp_cap + PCI_EXP_LNKSTA, &lnk); 3341 + pcie_capability_read_word(mgp->pdev, PCI_EXP_LNKSTA, &lnk); 3329 3342 link_width = (lnk >> 4) & 0x3f; 3330 3343 3331 3344 /* Check to see if Link is less than 8 or if the
+1 -1
drivers/net/ethernet/neterion/s2io.c
··· 484 484 485 485 MODULE_DEVICE_TABLE(pci, s2io_tbl); 486 486 487 - static struct pci_error_handlers s2io_err_handler = { 487 + static const struct pci_error_handlers s2io_err_handler = { 488 488 .error_detected = s2io_io_error_detected, 489 489 .slot_reset = s2io_io_slot_reset, 490 490 .resume = s2io_io_resume,
+2 -2
drivers/net/ethernet/neterion/vxge/vxge-config.c
··· 757 757 u16 lnk; 758 758 759 759 /* Get the negotiated link width and speed from PCI config space */ 760 - pci_read_config_word(dev, dev->pcie_cap + PCI_EXP_LNKSTA, &lnk); 760 + pcie_capability_read_word(dev, PCI_EXP_LNKSTA, &lnk); 761 761 762 762 if ((lnk & PCI_EXP_LNKSTA_CLS) != 1) 763 763 return VXGE_HW_ERR_INVALID_PCI_INFO; ··· 1982 1982 struct pci_dev *dev = hldev->pdev; 1983 1983 u16 lnk; 1984 1984 1985 - pci_read_config_word(dev, dev->pcie_cap + PCI_EXP_LNKSTA, &lnk); 1985 + pcie_capability_read_word(dev, PCI_EXP_LNKSTA, &lnk); 1986 1986 return (lnk & VXGE_HW_PCI_EXP_LNKCAP_LNK_WIDTH) >> 4; 1987 1987 } 1988 1988
+1 -1
drivers/net/ethernet/neterion/vxge/vxge-main.c
··· 4799 4799 __LINE__); 4800 4800 } 4801 4801 4802 - static struct pci_error_handlers vxge_err_handler = { 4802 + static const struct pci_error_handlers vxge_err_handler = { 4803 4803 .error_detected = vxge_io_error_detected, 4804 4804 .slot_reset = vxge_io_slot_reset, 4805 4805 .resume = vxge_io_resume,
+1 -1
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
··· 2795 2795 }; 2796 2796 #endif 2797 2797 2798 - static struct pci_error_handlers pch_gbe_err_handler = { 2798 + static const struct pci_error_handlers pch_gbe_err_handler = { 2799 2799 .error_detected = pch_gbe_io_error_detected, 2800 2800 .slot_reset = pch_gbe_io_slot_reset, 2801 2801 .resume = pch_gbe_io_resume
+2 -2
drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
··· 1386 1386 adapter->ahw.board_type != NETXEN_BRDTYPE_P3_10G_TP) 1387 1387 return; 1388 1388 1389 - if (root->pcie_type != PCI_EXP_TYPE_ROOT_PORT) 1389 + if (pci_pcie_type(root) != PCI_EXP_TYPE_ROOT_PORT) 1390 1390 return; 1391 1391 1392 1392 aer_pos = pci_find_ext_capability(root, PCI_EXT_CAP_ID_ERR); ··· 3340 3340 { } 3341 3341 #endif 3342 3342 3343 - static struct pci_error_handlers netxen_err_handler = { 3343 + static const struct pci_error_handlers netxen_err_handler = { 3344 3344 .error_detected = netxen_io_error_detected, 3345 3345 .slot_reset = netxen_io_slot_reset, 3346 3346 .resume = netxen_io_resume,
+1 -1
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
··· 4522 4522 qlcnic_restore_indev_addr(struct net_device *dev, unsigned long event) 4523 4523 { } 4524 4524 #endif 4525 - static struct pci_error_handlers qlcnic_err_handler = { 4525 + static const struct pci_error_handlers qlcnic_err_handler = { 4526 4526 .error_detected = qlcnic_io_error_detected, 4527 4527 .slot_reset = qlcnic_io_slot_reset, 4528 4528 .resume = qlcnic_io_resume,
+1 -1
drivers/net/ethernet/qlogic/qlge/qlge_main.c
··· 4847 4847 netif_device_attach(ndev); 4848 4848 } 4849 4849 4850 - static struct pci_error_handlers qlge_err_handler = { 4850 + static const struct pci_error_handlers qlge_err_handler = { 4851 4851 .error_detected = qlge_io_error_detected, 4852 4852 .slot_reset = qlge_io_slot_reset, 4853 4853 .resume = qlge_io_resume,
+9 -35
drivers/net/ethernet/realtek/r8169.c
··· 833 833 834 834 static void rtl_tx_performance_tweak(struct pci_dev *pdev, u16 force) 835 835 { 836 - int cap = pci_pcie_cap(pdev); 837 - 838 - if (cap) { 839 - u16 ctl; 840 - 841 - pci_read_config_word(pdev, cap + PCI_EXP_DEVCTL, &ctl); 842 - ctl = (ctl & ~PCI_EXP_DEVCTL_READRQ) | force; 843 - pci_write_config_word(pdev, cap + PCI_EXP_DEVCTL, ctl); 844 - } 836 + pcie_capability_clear_and_set_word(pdev, PCI_EXP_DEVCTL, 837 + PCI_EXP_DEVCTL_READRQ, force); 845 838 } 846 839 847 840 struct rtl_cond { ··· 4732 4739 4733 4740 static void rtl_disable_clock_request(struct pci_dev *pdev) 4734 4741 { 4735 - int cap = pci_pcie_cap(pdev); 4736 - 4737 - if (cap) { 4738 - u16 ctl; 4739 - 4740 - pci_read_config_word(pdev, cap + PCI_EXP_LNKCTL, &ctl); 4741 - ctl &= ~PCI_EXP_LNKCTL_CLKREQ_EN; 4742 - pci_write_config_word(pdev, cap + PCI_EXP_LNKCTL, ctl); 4743 - } 4742 + pcie_capability_clear_word(pdev, PCI_EXP_LNKCTL, 4743 + PCI_EXP_LNKCTL_CLKREQ_EN); 4744 4744 } 4745 4745 4746 4746 static void rtl_enable_clock_request(struct pci_dev *pdev) 4747 4747 { 4748 - int cap = pci_pcie_cap(pdev); 4749 - 4750 - if (cap) { 4751 - u16 ctl; 4752 - 4753 - pci_read_config_word(pdev, cap + PCI_EXP_LNKCTL, &ctl); 4754 - ctl |= PCI_EXP_LNKCTL_CLKREQ_EN; 4755 - pci_write_config_word(pdev, cap + PCI_EXP_LNKCTL, ctl); 4756 - } 4748 + pcie_capability_set_word(pdev, PCI_EXP_LNKCTL, 4749 + PCI_EXP_LNKCTL_CLKREQ_EN); 4757 4750 } 4758 4751 4759 4752 #define R8168_CPCMD_QUIRK_MASK (\ ··· 5384 5405 tp->event_slow &= ~RxFIFOOver; 5385 5406 5386 5407 if (tp->mac_version == RTL_GIGA_MAC_VER_13 || 5387 - tp->mac_version == RTL_GIGA_MAC_VER_16) { 5388 - int cap = pci_pcie_cap(pdev); 5389 - 5390 - if (cap) { 5391 - pci_write_config_word(pdev, cap + PCI_EXP_DEVCTL, 5392 - PCI_EXP_DEVCTL_NOSNOOP_EN); 5393 - } 5394 - } 5408 + tp->mac_version == RTL_GIGA_MAC_VER_16) 5409 + pcie_capability_set_word(pdev, PCI_EXP_DEVCTL, 5410 + PCI_EXP_DEVCTL_NOSNOOP_EN); 5395 5411 5396 5412 RTL_W8(Cfg9346, Cfg9346_Unlock); 5397 5413
+7 -12
drivers/net/ethernet/sun/niu.c
··· 9762 9762 union niu_parent_id parent_id; 9763 9763 struct net_device *dev; 9764 9764 struct niu *np; 9765 - int err, pos; 9765 + int err; 9766 9766 u64 dma_mask; 9767 - u16 val16; 9768 9767 9769 9768 niu_driver_version(); 9770 9769 ··· 9786 9787 goto err_out_disable_pdev; 9787 9788 } 9788 9789 9789 - pos = pci_pcie_cap(pdev); 9790 - if (pos <= 0) { 9790 + if (!pci_is_pcie(pdev)) { 9791 9791 dev_err(&pdev->dev, "Cannot find PCI Express capability, aborting\n"); 9792 9792 goto err_out_free_res; 9793 9793 } ··· 9811 9813 goto err_out_free_dev; 9812 9814 } 9813 9815 9814 - pci_read_config_word(pdev, pos + PCI_EXP_DEVCTL, &val16); 9815 - val16 &= ~PCI_EXP_DEVCTL_NOSNOOP_EN; 9816 - val16 |= (PCI_EXP_DEVCTL_CERE | 9817 - PCI_EXP_DEVCTL_NFERE | 9818 - PCI_EXP_DEVCTL_FERE | 9819 - PCI_EXP_DEVCTL_URRE | 9820 - PCI_EXP_DEVCTL_RELAX_EN); 9821 - pci_write_config_word(pdev, pos + PCI_EXP_DEVCTL, val16); 9816 + pcie_capability_clear_and_set_word(pdev, PCI_EXP_DEVCTL, 9817 + PCI_EXP_DEVCTL_NOSNOOP_EN, 9818 + PCI_EXP_DEVCTL_CERE | PCI_EXP_DEVCTL_NFERE | 9819 + PCI_EXP_DEVCTL_FERE | PCI_EXP_DEVCTL_URRE | 9820 + PCI_EXP_DEVCTL_RELAX_EN); 9822 9821 9823 9822 dma_mask = DMA_BIT_MASK(44); 9824 9823 err = pci_set_dma_mask(pdev, dma_mask);
+6 -15
drivers/net/wireless/ath/ath9k/pci.c
··· 113 113 struct ath_hw *ah = sc->sc_ah; 114 114 struct pci_dev *pdev = to_pci_dev(sc->dev); 115 115 struct pci_dev *parent; 116 - int pos; 117 - u8 aspm; 116 + u16 aspm; 118 117 119 118 if (!ah->is_pciexpress) 120 - return; 121 - 122 - pos = pci_pcie_cap(pdev); 123 - if (!pos) 124 119 return; 125 120 126 121 parent = pdev->bus->self; ··· 124 129 125 130 if (ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) { 126 131 /* Bluetooth coexistance requires disabling ASPM. */ 127 - pci_read_config_byte(pdev, pos + PCI_EXP_LNKCTL, &aspm); 128 - aspm &= ~(PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); 129 - pci_write_config_byte(pdev, pos + PCI_EXP_LNKCTL, aspm); 132 + pcie_capability_clear_word(pdev, PCI_EXP_LNKCTL, 133 + PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); 130 134 131 135 /* 132 136 * Both upstream and downstream PCIe components should 133 137 * have the same ASPM settings. 134 138 */ 135 - pos = pci_pcie_cap(parent); 136 - pci_read_config_byte(parent, pos + PCI_EXP_LNKCTL, &aspm); 137 - aspm &= ~(PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); 138 - pci_write_config_byte(parent, pos + PCI_EXP_LNKCTL, aspm); 139 + pcie_capability_clear_word(parent, PCI_EXP_LNKCTL, 140 + PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); 139 141 140 142 ath_info(common, "Disabling ASPM since BTCOEX is enabled\n"); 141 143 return; 142 144 } 143 145 144 - pos = pci_pcie_cap(parent); 145 - pci_read_config_byte(parent, pos + PCI_EXP_LNKCTL, &aspm); 146 + pcie_capability_read_word(parent, PCI_EXP_LNKCTL, &aspm); 146 147 if (aspm & (PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1)) { 147 148 ah->aspm_enabled = true; 148 149 /* Initialize PCIe PM and SERDES registers. */
+1 -3
drivers/net/wireless/iwlegacy/common.h
··· 1832 1832 static inline u16 1833 1833 il_pcie_link_ctl(struct il_priv *il) 1834 1834 { 1835 - int pos; 1836 1835 u16 pci_lnk_ctl; 1837 - pos = pci_pcie_cap(il->pci_dev); 1838 - pci_read_config_word(il->pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl); 1836 + pcie_capability_read_word(il->pci_dev, PCI_EXP_LNKCTL, &pci_lnk_ctl); 1839 1837 return pci_lnk_ctl; 1840 1838 } 1841 1839
+2 -5
drivers/net/wireless/iwlwifi/pcie/trans.c
··· 675 675 static u16 iwl_pciexp_link_ctrl(struct iwl_trans *trans) 676 676 { 677 677 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 678 - int pos; 679 678 u16 pci_lnk_ctl; 680 679 681 - struct pci_dev *pci_dev = trans_pcie->pci_dev; 682 - 683 - pos = pci_pcie_cap(pci_dev); 684 - pci_read_config_word(pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl); 680 + pcie_capability_read_word(trans_pcie->pci_dev, PCI_EXP_LNKCTL, 681 + &pci_lnk_ctl); 685 682 return pci_lnk_ctl; 686 683 } 687 684
+3 -5
drivers/net/wireless/rtlwifi/pci.c
··· 372 372 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); 373 373 374 374 u8 tmp; 375 - int pos; 376 - u8 linkctrl_reg; 375 + u16 linkctrl_reg; 377 376 378 377 /*Link Control Register */ 379 - pos = pci_pcie_cap(pdev); 380 - pci_read_config_byte(pdev, pos + PCI_EXP_LNKCTL, &linkctrl_reg); 381 - pcipriv->ndis_adapter.linkctrl_reg = linkctrl_reg; 378 + pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &linkctrl_reg); 379 + pcipriv->ndis_adapter.linkctrl_reg = (u8)linkctrl_reg; 382 380 383 381 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Link Control Register =%x\n", 384 382 pcipriv->ndis_adapter.linkctrl_reg);
+3 -7
drivers/parisc/dino.c
··· 477 477 if (ccio_allocate_resource(dino_dev->hba.dev, res, _8MB, 478 478 F_EXTEND(0xf0000000UL) | _8MB, 479 479 F_EXTEND(0xffffffffUL) &~ _8MB, _8MB) < 0) { 480 - struct list_head *ln, *tmp_ln; 480 + struct pci_dev *dev, *tmp; 481 481 482 482 printk(KERN_ERR "Dino: cannot attach bus %s\n", 483 483 dev_name(bus->bridge)); 484 484 /* kill the bus, we can't do anything with it */ 485 - list_for_each_safe(ln, tmp_ln, &bus->devices) { 486 - struct pci_dev *dev = pci_dev_b(ln); 487 - 485 + list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) { 488 486 list_del(&dev->bus_list); 489 487 } 490 488 ··· 547 549 static void __init 548 550 dino_fixup_bus(struct pci_bus *bus) 549 551 { 550 - struct list_head *ln; 551 552 struct pci_dev *dev; 552 553 struct dino_device *dino_dev = DINO_DEV(parisc_walk_tree(bus->bridge)); 553 554 ··· 593 596 } 594 597 595 598 596 - list_for_each(ln, &bus->devices) { 597 - dev = pci_dev_b(ln); 599 + list_for_each_entry(dev, &bus->devices, bus_list) { 598 600 if (is_card_dino(&dino_dev->hba.dev->id)) 599 601 dino_card_fixup(dev); 600 602
+3 -4
drivers/parisc/lba_pci.c
··· 629 629 static void 630 630 lba_fixup_bus(struct pci_bus *bus) 631 631 { 632 - struct list_head *ln; 632 + struct pci_dev *dev; 633 633 #ifdef FBB_SUPPORT 634 634 u16 status; 635 635 #endif ··· 710 710 711 711 } 712 712 713 - list_for_each(ln, &bus->devices) { 713 + list_for_each_entry(dev, &bus->devices, bus_list) { 714 714 int i; 715 - struct pci_dev *dev = pci_dev_b(ln); 716 715 717 716 DBG("lba_fixup_bus() %s\n", pci_name(dev)); 718 717 ··· 769 770 } 770 771 771 772 /* Lastly enable FBB/PERR/SERR on all devices too */ 772 - list_for_each(ln, &bus->devices) { 773 + list_for_each_entry(dev, &bus->devices, bus_list) { 773 774 (void) pci_read_config_word(dev, PCI_COMMAND, &status); 774 775 status |= PCI_COMMAND_PARITY | PCI_COMMAND_SERR | fbb_enable; 775 776 (void) pci_write_config_word(dev, PCI_COMMAND, status);
-1
drivers/pci/Kconfig
··· 3 3 # 4 4 config ARCH_SUPPORTS_MSI 5 5 bool 6 - default n 7 6 8 7 config PCI_MSI 9 8 bool "Message Signaled Interrupts (MSI and MSI-X)"
+202
drivers/pci/access.c
··· 469 469 raw_spin_unlock_irqrestore(&pci_lock, flags); 470 470 } 471 471 EXPORT_SYMBOL_GPL(pci_cfg_access_unlock); 472 + 473 + static inline int pcie_cap_version(const struct pci_dev *dev) 474 + { 475 + return dev->pcie_flags_reg & PCI_EXP_FLAGS_VERS; 476 + } 477 + 478 + static inline bool pcie_cap_has_devctl(const struct pci_dev *dev) 479 + { 480 + return true; 481 + } 482 + 483 + static inline bool pcie_cap_has_lnkctl(const struct pci_dev *dev) 484 + { 485 + int type = pci_pcie_type(dev); 486 + 487 + return pcie_cap_version(dev) > 1 || 488 + type == PCI_EXP_TYPE_ROOT_PORT || 489 + type == PCI_EXP_TYPE_ENDPOINT || 490 + type == PCI_EXP_TYPE_LEG_END; 491 + } 492 + 493 + static inline bool pcie_cap_has_sltctl(const struct pci_dev *dev) 494 + { 495 + int type = pci_pcie_type(dev); 496 + 497 + return pcie_cap_version(dev) > 1 || 498 + type == PCI_EXP_TYPE_ROOT_PORT || 499 + (type == PCI_EXP_TYPE_DOWNSTREAM && 500 + dev->pcie_flags_reg & PCI_EXP_FLAGS_SLOT); 501 + } 502 + 503 + static inline bool pcie_cap_has_rtctl(const struct pci_dev *dev) 504 + { 505 + int type = pci_pcie_type(dev); 506 + 507 + return pcie_cap_version(dev) > 1 || 508 + type == PCI_EXP_TYPE_ROOT_PORT || 509 + type == PCI_EXP_TYPE_RC_EC; 510 + } 511 + 512 + static bool pcie_capability_reg_implemented(struct pci_dev *dev, int pos) 513 + { 514 + if (!pci_is_pcie(dev)) 515 + return false; 516 + 517 + switch (pos) { 518 + case PCI_EXP_FLAGS_TYPE: 519 + return true; 520 + case PCI_EXP_DEVCAP: 521 + case PCI_EXP_DEVCTL: 522 + case PCI_EXP_DEVSTA: 523 + return pcie_cap_has_devctl(dev); 524 + case PCI_EXP_LNKCAP: 525 + case PCI_EXP_LNKCTL: 526 + case PCI_EXP_LNKSTA: 527 + return pcie_cap_has_lnkctl(dev); 528 + case PCI_EXP_SLTCAP: 529 + case PCI_EXP_SLTCTL: 530 + case PCI_EXP_SLTSTA: 531 + return pcie_cap_has_sltctl(dev); 532 + case PCI_EXP_RTCTL: 533 + case PCI_EXP_RTCAP: 534 + case PCI_EXP_RTSTA: 535 + return pcie_cap_has_rtctl(dev); 536 + case PCI_EXP_DEVCAP2: 537 + case PCI_EXP_DEVCTL2: 538 + case PCI_EXP_LNKCAP2: 539 + case PCI_EXP_LNKCTL2: 540 + case PCI_EXP_LNKSTA2: 541 + return pcie_cap_version(dev) > 1; 542 + default: 543 + return false; 544 + } 545 + } 546 + 547 + /* 548 + * Note that these accessor functions are only for the "PCI Express 549 + * Capability" (see PCIe spec r3.0, sec 7.8). They do not apply to the 550 + * other "PCI Express Extended Capabilities" (AER, VC, ACS, MFVC, etc.) 551 + */ 552 + int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val) 553 + { 554 + int ret; 555 + 556 + *val = 0; 557 + if (pos & 1) 558 + return -EINVAL; 559 + 560 + if (pcie_capability_reg_implemented(dev, pos)) { 561 + ret = pci_read_config_word(dev, pci_pcie_cap(dev) + pos, val); 562 + /* 563 + * Reset *val to 0 if pci_read_config_word() fails, it may 564 + * have been written as 0xFFFF if hardware error happens 565 + * during pci_read_config_word(). 566 + */ 567 + if (ret) 568 + *val = 0; 569 + return ret; 570 + } 571 + 572 + /* 573 + * For Functions that do not implement the Slot Capabilities, 574 + * Slot Status, and Slot Control registers, these spaces must 575 + * be hardwired to 0b, with the exception of the Presence Detect 576 + * State bit in the Slot Status register of Downstream Ports, 577 + * which must be hardwired to 1b. (PCIe Base Spec 3.0, sec 7.8) 578 + */ 579 + if (pci_is_pcie(dev) && pos == PCI_EXP_SLTSTA && 580 + pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM) { 581 + *val = PCI_EXP_SLTSTA_PDS; 582 + } 583 + 584 + return 0; 585 + } 586 + EXPORT_SYMBOL(pcie_capability_read_word); 587 + 588 + int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val) 589 + { 590 + int ret; 591 + 592 + *val = 0; 593 + if (pos & 3) 594 + return -EINVAL; 595 + 596 + if (pcie_capability_reg_implemented(dev, pos)) { 597 + ret = pci_read_config_dword(dev, pci_pcie_cap(dev) + pos, val); 598 + /* 599 + * Reset *val to 0 if pci_read_config_dword() fails, it may 600 + * have been written as 0xFFFFFFFF if hardware error happens 601 + * during pci_read_config_dword(). 602 + */ 603 + if (ret) 604 + *val = 0; 605 + return ret; 606 + } 607 + 608 + if (pci_is_pcie(dev) && pos == PCI_EXP_SLTCTL && 609 + pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM) { 610 + *val = PCI_EXP_SLTSTA_PDS; 611 + } 612 + 613 + return 0; 614 + } 615 + EXPORT_SYMBOL(pcie_capability_read_dword); 616 + 617 + int pcie_capability_write_word(struct pci_dev *dev, int pos, u16 val) 618 + { 619 + if (pos & 1) 620 + return -EINVAL; 621 + 622 + if (!pcie_capability_reg_implemented(dev, pos)) 623 + return 0; 624 + 625 + return pci_write_config_word(dev, pci_pcie_cap(dev) + pos, val); 626 + } 627 + EXPORT_SYMBOL(pcie_capability_write_word); 628 + 629 + int pcie_capability_write_dword(struct pci_dev *dev, int pos, u32 val) 630 + { 631 + if (pos & 3) 632 + return -EINVAL; 633 + 634 + if (!pcie_capability_reg_implemented(dev, pos)) 635 + return 0; 636 + 637 + return pci_write_config_dword(dev, pci_pcie_cap(dev) + pos, val); 638 + } 639 + EXPORT_SYMBOL(pcie_capability_write_dword); 640 + 641 + int pcie_capability_clear_and_set_word(struct pci_dev *dev, int pos, 642 + u16 clear, u16 set) 643 + { 644 + int ret; 645 + u16 val; 646 + 647 + ret = pcie_capability_read_word(dev, pos, &val); 648 + if (!ret) { 649 + val &= ~clear; 650 + val |= set; 651 + ret = pcie_capability_write_word(dev, pos, val); 652 + } 653 + 654 + return ret; 655 + } 656 + EXPORT_SYMBOL(pcie_capability_clear_and_set_word); 657 + 658 + int pcie_capability_clear_and_set_dword(struct pci_dev *dev, int pos, 659 + u32 clear, u32 set) 660 + { 661 + int ret; 662 + u32 val; 663 + 664 + ret = pcie_capability_read_dword(dev, pos, &val); 665 + if (!ret) { 666 + val &= ~clear; 667 + val |= set; 668 + ret = pcie_capability_write_dword(dev, pos, val); 669 + } 670 + 671 + return ret; 672 + } 673 + EXPORT_SYMBOL(pcie_capability_clear_and_set_dword);
+5 -1
drivers/pci/bus.c
··· 87 87 void pci_bus_remove_resources(struct pci_bus *bus) 88 88 { 89 89 int i; 90 + struct pci_bus_resource *bus_res, *tmp; 90 91 91 92 for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++) 92 93 bus->resource[i] = NULL; 93 94 94 - pci_free_resource_list(&bus->resources); 95 + list_for_each_entry_safe(bus_res, tmp, &bus->resources, list) { 96 + list_del(&bus_res->list); 97 + kfree(bus_res); 98 + } 95 99 } 96 100 97 101 /**
+1 -23
drivers/pci/hotplug/Kconfig
··· 17 17 18 18 if HOTPLUG_PCI 19 19 20 - config HOTPLUG_PCI_FAKE 21 - tristate "Fake PCI Hotplug driver" 22 - help 23 - Say Y here if you want to use the fake PCI hotplug driver. It can 24 - be used to simulate PCI hotplug events if even if your system is 25 - not PCI hotplug capable. 26 - 27 - This driver will "emulate" removing PCI devices from the system. 28 - If the "power" file is written to with "0" then the specified PCI 29 - device will be completely removed from the kernel. 30 - 31 - WARNING, this does NOT turn off the power to the PCI device. 32 - This is a "logical" removal, not a physical or electrical 33 - removal. 34 - 35 - Use this module at your own risk. You have been warned! 36 - 37 - To compile this driver as a module, choose M here: the 38 - module will be called fakephp. 39 - 40 - When in doubt, say N. 41 - 42 20 config HOTPLUG_PCI_COMPAQ 43 21 tristate "Compaq PCI Hotplug driver" 44 22 depends on X86 && PCI_BIOS ··· 121 143 122 144 config HOTPLUG_PCI_RPA 123 145 tristate "RPA PCI Hotplug driver" 124 - depends on PPC_PSERIES && EEH && !HOTPLUG_PCI_FAKE 146 + depends on PPC_PSERIES && EEH 125 147 help 126 148 Say Y here if you have a RPA system that supports PCI Hotplug. 127 149
-3
drivers/pci/hotplug/Makefile
··· 23 23 24 24 obj-$(CONFIG_HOTPLUG_PCI_ACPI_IBM) += acpiphp_ibm.o 25 25 26 - # Link this last so it doesn't claim devices that have a real hotplug driver 27 - obj-$(CONFIG_HOTPLUG_PCI_FAKE) += fakephp.o 28 - 29 26 pci_hotplug-objs := pci_hotplug_core.o pcihp_slot.o 30 27 31 28 ifdef CONFIG_HOTPLUG_PCI_CPCI
+39 -60
drivers/pci/hotplug/acpiphp_glue.c
··· 115 115 .handler = handle_hotplug_event_func, 116 116 }; 117 117 118 + /* Check whether the PCI device is managed by native PCIe hotplug driver */ 119 + static bool device_is_managed_by_native_pciehp(struct pci_dev *pdev) 120 + { 121 + u32 reg32; 122 + acpi_handle tmp; 123 + struct acpi_pci_root *root; 124 + 125 + /* Check whether the PCIe port supports native PCIe hotplug */ 126 + if (pcie_capability_read_dword(pdev, PCI_EXP_SLTCAP, &reg32)) 127 + return false; 128 + if (!(reg32 & PCI_EXP_SLTCAP_HPC)) 129 + return false; 130 + 131 + /* 132 + * Check whether native PCIe hotplug has been enabled for 133 + * this PCIe hierarchy. 134 + */ 135 + tmp = acpi_find_root_bridge_handle(pdev); 136 + if (!tmp) 137 + return false; 138 + root = acpi_pci_find_root(tmp); 139 + if (!root) 140 + return false; 141 + if (!(root->osc_control_set & OSC_PCI_EXPRESS_NATIVE_HP_CONTROL)) 142 + return false; 143 + 144 + return true; 145 + } 146 + 118 147 /* callback routine to register each ACPI PCI slot object */ 119 148 static acpi_status 120 149 register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) ··· 171 142 function = adr & 0xffff; 172 143 173 144 pdev = pbus->self; 174 - if (pdev && pci_is_pcie(pdev)) { 175 - tmp = acpi_find_root_bridge_handle(pdev); 176 - if (tmp) { 177 - struct acpi_pci_root *root = acpi_pci_find_root(tmp); 178 - 179 - if (root && (root->osc_control_set & 180 - OSC_PCI_EXPRESS_NATIVE_HP_CONTROL)) 181 - return AE_OK; 182 - } 183 - } 145 + if (pdev && device_is_managed_by_native_pciehp(pdev)) 146 + return AE_OK; 184 147 185 148 newfunc = kzalloc(sizeof(struct acpiphp_func), GFP_KERNEL); 186 149 if (!newfunc) ··· 403 382 404 383 405 384 /* allocate and initialize host bridge data structure */ 406 - static void add_host_bridge(acpi_handle *handle) 385 + static void add_host_bridge(struct acpi_pci_root *root) 407 386 { 408 387 struct acpiphp_bridge *bridge; 409 - struct acpi_pci_root *root = acpi_pci_find_root(handle); 388 + acpi_handle handle = root->device->handle; 410 389 411 390 bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); 412 391 if (bridge == NULL) ··· 489 468 490 469 491 470 /* find hot-pluggable slots, and then find P2P bridge */ 492 - static int add_bridge(acpi_handle handle) 471 + static int add_bridge(struct acpi_pci_root *root) 493 472 { 494 473 acpi_status status; 495 474 unsigned long long tmp; 496 475 acpi_handle dummy_handle; 476 + acpi_handle handle = root->device->handle; 497 477 498 478 /* if the bridge doesn't have _STA, we assume it is always there */ 499 479 status = acpi_get_handle(handle, "_STA", &dummy_handle); ··· 512 490 /* check if this bridge has ejectable slots */ 513 491 if (detect_ejectable_slots(handle) > 0) { 514 492 dbg("found PCI host-bus bridge with hot-pluggable slots\n"); 515 - add_host_bridge(handle); 493 + add_host_bridge(root); 516 494 } 517 495 518 496 /* search P2P bridges under this host bridge */ ··· 610 588 return AE_OK; 611 589 } 612 590 613 - static void remove_bridge(acpi_handle handle) 591 + static void remove_bridge(struct acpi_pci_root *root) 614 592 { 615 593 struct acpiphp_bridge *bridge; 594 + acpi_handle handle = root->device->handle; 616 595 617 596 /* cleanup p2p bridges under this host bridge 618 597 in a depth-first manner */ ··· 892 869 return retval; 893 870 } 894 871 895 - static void disable_bridges(struct pci_bus *bus) 896 - { 897 - struct pci_dev *dev; 898 - list_for_each_entry(dev, &bus->devices, bus_list) { 899 - if (dev->subordinate) { 900 - disable_bridges(dev->subordinate); 901 - pci_disable_device(dev); 902 - } 903 - } 904 - } 905 - 906 872 /* return first device in slot, acquiring a reference on it */ 907 873 static struct pci_dev *dev_in_slot(struct acpiphp_slot *slot) 908 874 { ··· 943 931 * here. 944 932 */ 945 933 while ((pdev = dev_in_slot(slot))) { 946 - pci_stop_bus_device(pdev); 947 - if (pdev->subordinate) { 948 - disable_bridges(pdev->subordinate); 949 - pci_disable_device(pdev); 950 - } 951 - __pci_remove_bus_device(pdev); 934 + pci_stop_and_remove_bus_device(pdev); 952 935 pci_dev_put(pdev); 953 936 } 954 937 ··· 1482 1475 dbg("Total %d slots\n", num_slots); 1483 1476 return num_slots; 1484 1477 } 1485 - 1486 - 1487 - #if 0 1488 - /** 1489 - * acpiphp_for_each_slot - call function for each slot 1490 - * @fn: callback function 1491 - * @data: context to be passed to callback function 1492 - */ 1493 - static int acpiphp_for_each_slot(acpiphp_callback fn, void *data) 1494 - { 1495 - struct list_head *node; 1496 - struct acpiphp_bridge *bridge; 1497 - struct acpiphp_slot *slot; 1498 - int retval = 0; 1499 - 1500 - list_for_each (node, &bridge_list) { 1501 - bridge = (struct acpiphp_bridge *)node; 1502 - for (slot = bridge->slots; slot; slot = slot->next) { 1503 - retval = fn(slot, data); 1504 - if (!retval) 1505 - goto err_exit; 1506 - } 1507 - } 1508 - 1509 - err_exit: 1510 - return retval; 1511 - } 1512 - #endif 1513 1478 1514 1479 1515 1480 /**
+2 -6
drivers/pci/hotplug/cpcihp_generic.c
··· 154 154 if(!r) 155 155 return -EBUSY; 156 156 157 - bus = pci_find_bus(0, bridge_busnr); 158 - if (!bus) { 159 - err("Invalid bus number %d", bridge_busnr); 160 - return -EINVAL; 161 - } 162 - dev = pci_get_slot(bus, PCI_DEVFN(bridge_slot, 0)); 157 + dev = pci_get_domain_bus_and_slot(0, bridge_busnr, 158 + PCI_DEVFN(bridge_slot, 0)); 163 159 if(!dev || dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) { 164 160 err("Invalid bridge device %s", bridge); 165 161 pci_dev_put(dev);
+1 -20
drivers/pci/hotplug/cpqphp_ctrl.c
··· 2890 2890 func->mem_head = mem_node; 2891 2891 } else 2892 2892 return -ENOMEM; 2893 - } else if ((temp_register & 0x0BL) == 0x04) { 2894 - /* Map memory */ 2895 - base = temp_register & 0xFFFFFFF0; 2896 - base = ~base + 1; 2897 - 2898 - dbg("CND: length = 0x%x\n", base); 2899 - mem_node = get_resource(&(resources->mem_head), base); 2900 - 2901 - /* allocate the resource to the board */ 2902 - if (mem_node) { 2903 - base = mem_node->base; 2904 - 2905 - mem_node->next = func->mem_head; 2906 - func->mem_head = mem_node; 2907 - } else 2908 - return -ENOMEM; 2909 - } else if ((temp_register & 0x0BL) == 0x06) { 2910 - /* Those bits are reserved, we can't handle this */ 2911 - return 1; 2912 2893 } else { 2913 - /* Requesting space below 1M */ 2894 + /* Reserved bits or requesting space below 1M */ 2914 2895 return NOT_ENOUGH_RESOURCES; 2915 2896 } 2916 2897
-164
drivers/pci/hotplug/fakephp.c
··· 1 - /* Works like the fakephp driver used to, except a little better. 2 - * 3 - * - It's possible to remove devices with subordinate busses. 4 - * - New PCI devices that appear via any method, not just a fakephp triggered 5 - * rescan, will be noticed. 6 - * - Devices that are removed via any method, not just a fakephp triggered 7 - * removal, will also be noticed. 8 - * 9 - * Uses nothing from the pci-hotplug subsystem. 10 - * 11 - */ 12 - 13 - #include <linux/module.h> 14 - #include <linux/kernel.h> 15 - #include <linux/types.h> 16 - #include <linux/list.h> 17 - #include <linux/kobject.h> 18 - #include <linux/sysfs.h> 19 - #include <linux/init.h> 20 - #include <linux/pci.h> 21 - #include <linux/device.h> 22 - #include <linux/slab.h> 23 - #include "../pci.h" 24 - 25 - struct legacy_slot { 26 - struct kobject kobj; 27 - struct pci_dev *dev; 28 - struct list_head list; 29 - }; 30 - 31 - static LIST_HEAD(legacy_list); 32 - 33 - static ssize_t legacy_show(struct kobject *kobj, struct attribute *attr, 34 - char *buf) 35 - { 36 - struct legacy_slot *slot = container_of(kobj, typeof(*slot), kobj); 37 - strcpy(buf, "1\n"); 38 - return 2; 39 - } 40 - 41 - static void remove_callback(void *data) 42 - { 43 - pci_stop_and_remove_bus_device((struct pci_dev *)data); 44 - } 45 - 46 - static ssize_t legacy_store(struct kobject *kobj, struct attribute *attr, 47 - const char *buf, size_t len) 48 - { 49 - struct legacy_slot *slot = container_of(kobj, typeof(*slot), kobj); 50 - unsigned long val; 51 - 52 - if (strict_strtoul(buf, 0, &val) < 0) 53 - return -EINVAL; 54 - 55 - if (val) 56 - pci_rescan_bus(slot->dev->bus); 57 - else 58 - sysfs_schedule_callback(&slot->dev->dev.kobj, remove_callback, 59 - slot->dev, THIS_MODULE); 60 - return len; 61 - } 62 - 63 - static struct attribute *legacy_attrs[] = { 64 - &(struct attribute){ .name = "power", .mode = 0644 }, 65 - NULL, 66 - }; 67 - 68 - static void legacy_release(struct kobject *kobj) 69 - { 70 - struct legacy_slot *slot = container_of(kobj, typeof(*slot), kobj); 71 - 72 - pci_dev_put(slot->dev); 73 - kfree(slot); 74 - } 75 - 76 - static struct kobj_type legacy_ktype = { 77 - .sysfs_ops = &(const struct sysfs_ops){ 78 - .store = legacy_store, .show = legacy_show 79 - }, 80 - .release = &legacy_release, 81 - .default_attrs = legacy_attrs, 82 - }; 83 - 84 - static int legacy_add_slot(struct pci_dev *pdev) 85 - { 86 - struct legacy_slot *slot = kzalloc(sizeof(*slot), GFP_KERNEL); 87 - 88 - if (!slot) 89 - return -ENOMEM; 90 - 91 - if (kobject_init_and_add(&slot->kobj, &legacy_ktype, 92 - &pci_slots_kset->kobj, "%s", 93 - dev_name(&pdev->dev))) { 94 - dev_warn(&pdev->dev, "Failed to created legacy fake slot\n"); 95 - return -EINVAL; 96 - } 97 - slot->dev = pci_dev_get(pdev); 98 - 99 - list_add(&slot->list, &legacy_list); 100 - 101 - return 0; 102 - } 103 - 104 - static int legacy_notify(struct notifier_block *nb, 105 - unsigned long action, void *data) 106 - { 107 - struct pci_dev *pdev = to_pci_dev(data); 108 - 109 - if (action == BUS_NOTIFY_ADD_DEVICE) { 110 - legacy_add_slot(pdev); 111 - } else if (action == BUS_NOTIFY_DEL_DEVICE) { 112 - struct legacy_slot *slot; 113 - 114 - list_for_each_entry(slot, &legacy_list, list) 115 - if (slot->dev == pdev) 116 - goto found; 117 - 118 - dev_warn(&pdev->dev, "Missing legacy fake slot?"); 119 - return -ENODEV; 120 - found: 121 - kobject_del(&slot->kobj); 122 - list_del(&slot->list); 123 - kobject_put(&slot->kobj); 124 - } 125 - 126 - return 0; 127 - } 128 - 129 - static struct notifier_block legacy_notifier = { 130 - .notifier_call = legacy_notify 131 - }; 132 - 133 - static int __init init_legacy(void) 134 - { 135 - struct pci_dev *pdev = NULL; 136 - 137 - /* Add existing devices */ 138 - for_each_pci_dev(pdev) 139 - legacy_add_slot(pdev); 140 - 141 - /* Be alerted of any new ones */ 142 - bus_register_notifier(&pci_bus_type, &legacy_notifier); 143 - return 0; 144 - } 145 - module_init(init_legacy); 146 - 147 - static void __exit remove_legacy(void) 148 - { 149 - struct legacy_slot *slot, *tmp; 150 - 151 - bus_unregister_notifier(&pci_bus_type, &legacy_notifier); 152 - 153 - list_for_each_entry_safe(slot, tmp, &legacy_list, list) { 154 - list_del(&slot->list); 155 - kobject_del(&slot->kobj); 156 - kobject_put(&slot->kobj); 157 - } 158 - } 159 - module_exit(remove_legacy); 160 - 161 - 162 - MODULE_AUTHOR("Trent Piepho <xyzzy@speakeasy.org>"); 163 - MODULE_DESCRIPTION("Legacy version of the fakephp interface"); 164 - MODULE_LICENSE("GPL");
+1 -5
drivers/pci/hotplug/pciehp_acpi.c
··· 81 81 /* Dummy driver for dumplicate name detection */ 82 82 static int __init dummy_probe(struct pcie_device *dev) 83 83 { 84 - int pos; 85 84 u32 slot_cap; 86 85 acpi_handle handle; 87 86 struct dummy_slot *slot, *tmp; 88 87 struct pci_dev *pdev = dev->port; 89 88 90 - pos = pci_pcie_cap(pdev); 91 - if (!pos) 92 - return -ENODEV; 93 - pci_read_config_dword(pdev, pos + PCI_EXP_SLTCAP, &slot_cap); 89 + pcie_capability_read_dword(pdev, PCI_EXP_SLTCAP, &slot_cap); 94 90 slot = kzalloc(sizeof(*slot), GFP_KERNEL); 95 91 if (!slot) 96 92 return -ENOMEM;
+14 -14
drivers/pci/hotplug/pciehp_core.c
··· 300 300 301 301 static int pciehp_resume (struct pcie_device *dev) 302 302 { 303 + struct controller *ctrl; 304 + struct slot *slot; 305 + u8 status; 306 + 303 307 dev_info(&dev->device, "%s ENTRY\n", __func__); 304 - if (pciehp_force) { 305 - struct controller *ctrl = get_service_data(dev); 306 - struct slot *slot; 307 - u8 status; 308 + ctrl = get_service_data(dev); 308 309 309 - /* reinitialize the chipset's event detection logic */ 310 - pcie_enable_notification(ctrl); 310 + /* reinitialize the chipset's event detection logic */ 311 + pcie_enable_notification(ctrl); 311 312 312 - slot = ctrl->slot; 313 + slot = ctrl->slot; 313 314 314 - /* Check if slot is occupied */ 315 - pciehp_get_adapter_status(slot, &status); 316 - if (status) 317 - pciehp_enable_slot(slot); 318 - else 319 - pciehp_disable_slot(slot); 320 - } 315 + /* Check if slot is occupied */ 316 + pciehp_get_adapter_status(slot, &status); 317 + if (status) 318 + pciehp_enable_slot(slot); 319 + else 320 + pciehp_disable_slot(slot); 321 321 return 0; 322 322 } 323 323 #endif /* PM */
+4 -8
drivers/pci/hotplug/pciehp_hpc.c
··· 44 44 static inline int pciehp_readw(struct controller *ctrl, int reg, u16 *value) 45 45 { 46 46 struct pci_dev *dev = ctrl->pcie->port; 47 - return pci_read_config_word(dev, pci_pcie_cap(dev) + reg, value); 47 + return pcie_capability_read_word(dev, reg, value); 48 48 } 49 49 50 50 static inline int pciehp_readl(struct controller *ctrl, int reg, u32 *value) 51 51 { 52 52 struct pci_dev *dev = ctrl->pcie->port; 53 - return pci_read_config_dword(dev, pci_pcie_cap(dev) + reg, value); 53 + return pcie_capability_read_dword(dev, reg, value); 54 54 } 55 55 56 56 static inline int pciehp_writew(struct controller *ctrl, int reg, u16 value) 57 57 { 58 58 struct pci_dev *dev = ctrl->pcie->port; 59 - return pci_write_config_word(dev, pci_pcie_cap(dev) + reg, value); 59 + return pcie_capability_write_word(dev, reg, value); 60 60 } 61 61 62 62 static inline int pciehp_writel(struct controller *ctrl, int reg, u32 value) 63 63 { 64 64 struct pci_dev *dev = ctrl->pcie->port; 65 - return pci_write_config_dword(dev, pci_pcie_cap(dev) + reg, value); 65 + return pcie_capability_write_dword(dev, reg, value); 66 66 } 67 67 68 68 /* Power Control Command */ ··· 855 855 goto abort; 856 856 } 857 857 ctrl->pcie = dev; 858 - if (!pci_pcie_cap(pdev)) { 859 - ctrl_err(ctrl, "Cannot find PCI Express capability\n"); 860 - goto abort_ctrl; 861 - } 862 858 if (pciehp_readl(ctrl, PCI_EXP_SLTCAP, &slot_cap)) { 863 859 ctrl_err(ctrl, "Cannot read SLOTCAP register\n"); 864 860 goto abort_ctrl;
+5 -15
drivers/pci/hotplug/pcihp_slot.c
··· 96 96 static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp) 97 97 { 98 98 int pos; 99 - u16 reg16; 100 99 u32 reg32; 101 100 102 101 if (!hpp) 103 - return; 104 - 105 - /* Find PCI Express capability */ 106 - pos = pci_pcie_cap(dev); 107 - if (!pos) 108 102 return; 109 103 110 104 if (hpp->revision > 1) { ··· 108 114 } 109 115 110 116 /* Initialize Device Control Register */ 111 - pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &reg16); 112 - reg16 = (reg16 & hpp->pci_exp_devctl_and) | hpp->pci_exp_devctl_or; 113 - pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, reg16); 117 + pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL, 118 + ~hpp->pci_exp_devctl_and, hpp->pci_exp_devctl_or); 114 119 115 120 /* Initialize Link Control Register */ 116 - if (dev->subordinate) { 117 - pci_read_config_word(dev, pos + PCI_EXP_LNKCTL, &reg16); 118 - reg16 = (reg16 & hpp->pci_exp_lnkctl_and) 119 - | hpp->pci_exp_lnkctl_or; 120 - pci_write_config_word(dev, pos + PCI_EXP_LNKCTL, reg16); 121 - } 121 + if (dev->subordinate) 122 + pcie_capability_clear_and_set_word(dev, PCI_EXP_LNKCTL, 123 + ~hpp->pci_exp_lnkctl_and, hpp->pci_exp_lnkctl_or); 122 124 123 125 /* Find Advanced Error Reporting Enhanced Capability */ 124 126 pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
+3 -3
drivers/pci/iov.c
··· 433 433 struct resource *res; 434 434 struct pci_dev *pdev; 435 435 436 - if (dev->pcie_type != PCI_EXP_TYPE_RC_END && 437 - dev->pcie_type != PCI_EXP_TYPE_ENDPOINT) 436 + if (pci_pcie_type(dev) != PCI_EXP_TYPE_RC_END && 437 + pci_pcie_type(dev) != PCI_EXP_TYPE_ENDPOINT) 438 438 return -ENODEV; 439 439 440 440 pci_read_config_word(dev, pos + PCI_SRIOV_CTRL, &ctrl); ··· 503 503 iov->self = dev; 504 504 pci_read_config_dword(dev, pos + PCI_SRIOV_CAP, &iov->cap); 505 505 pci_read_config_byte(dev, pos + PCI_SRIOV_FUNC_LINK, &iov->link); 506 - if (dev->pcie_type == PCI_EXP_TYPE_RC_END) 506 + if (pci_pcie_type(dev) == PCI_EXP_TYPE_RC_END) 507 507 iov->link = PCI_DEVFN(PCI_SLOT(dev->devfn), iov->link); 508 508 509 509 if (pdev)
+10 -47
drivers/pci/pci-driver.c
··· 139 139 return retval; 140 140 return count; 141 141 } 142 - static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id); 143 142 144 143 /** 145 144 * store_remove_id - remove a PCI device ID from this driver ··· 184 185 return retval; 185 186 return count; 186 187 } 187 - static DRIVER_ATTR(remove_id, S_IWUSR, NULL, store_remove_id); 188 188 189 - static int 190 - pci_create_newid_files(struct pci_driver *drv) 191 - { 192 - int error = 0; 189 + static struct driver_attribute pci_drv_attrs[] = { 190 + __ATTR(new_id, S_IWUSR, NULL, store_new_id), 191 + __ATTR(remove_id, S_IWUSR, NULL, store_remove_id), 192 + __ATTR_NULL, 193 + }; 193 194 194 - if (drv->probe != NULL) { 195 - error = driver_create_file(&drv->driver, &driver_attr_new_id); 196 - if (error == 0) { 197 - error = driver_create_file(&drv->driver, 198 - &driver_attr_remove_id); 199 - if (error) 200 - driver_remove_file(&drv->driver, 201 - &driver_attr_new_id); 202 - } 203 - } 204 - return error; 205 - } 206 - 207 - static void pci_remove_newid_files(struct pci_driver *drv) 208 - { 209 - driver_remove_file(&drv->driver, &driver_attr_remove_id); 210 - driver_remove_file(&drv->driver, &driver_attr_new_id); 211 - } 212 - #else /* !CONFIG_HOTPLUG */ 213 - static inline int pci_create_newid_files(struct pci_driver *drv) 214 - { 215 - return 0; 216 - } 217 - static inline void pci_remove_newid_files(struct pci_driver *drv) {} 218 - #endif 195 + #else 196 + #define pci_drv_attrs NULL 197 + #endif /* CONFIG_HOTPLUG */ 219 198 220 199 /** 221 200 * pci_match_id - See if a pci device matches a given pci_id table ··· 1139 1162 int __pci_register_driver(struct pci_driver *drv, struct module *owner, 1140 1163 const char *mod_name) 1141 1164 { 1142 - int error; 1143 - 1144 1165 /* initialize common driver fields */ 1145 1166 drv->driver.name = drv->name; 1146 1167 drv->driver.bus = &pci_bus_type; ··· 1149 1174 INIT_LIST_HEAD(&drv->dynids.list); 1150 1175 1151 1176 /* register with core */ 1152 - error = driver_register(&drv->driver); 1153 - if (error) 1154 - goto out; 1155 - 1156 - error = pci_create_newid_files(drv); 1157 - if (error) 1158 - goto out_newid; 1159 - out: 1160 - return error; 1161 - 1162 - out_newid: 1163 - driver_unregister(&drv->driver); 1164 - goto out; 1177 + return driver_register(&drv->driver); 1165 1178 } 1166 1179 1167 1180 /** ··· 1165 1202 void 1166 1203 pci_unregister_driver(struct pci_driver *drv) 1167 1204 { 1168 - pci_remove_newid_files(drv); 1169 1205 driver_unregister(&drv->driver); 1170 1206 pci_free_dynids(drv); 1171 1207 } ··· 1264 1302 .shutdown = pci_device_shutdown, 1265 1303 .dev_attrs = pci_dev_attrs, 1266 1304 .bus_attrs = pci_bus_attrs, 1305 + .drv_attrs = pci_drv_attrs, 1267 1306 .pm = PCI_PM_OPS_PTR, 1268 1307 }; 1269 1308
+108 -278
drivers/pci/pci.c
··· 254 254 } 255 255 256 256 /** 257 - * pci_pcie_cap2 - query for devices' PCI_CAP_ID_EXP v2 capability structure 258 - * @dev: PCI device to check 257 + * pci_find_next_ext_capability - Find an extended capability 258 + * @dev: PCI device to query 259 + * @start: address at which to start looking (0 to start at beginning of list) 260 + * @cap: capability code 259 261 * 260 - * Like pci_pcie_cap() but also checks that the PCIe capability version is 261 - * >= 2. Note that v1 capability structures could be sparse in that not 262 - * all register fields were required. v2 requires the entire structure to 263 - * be present size wise, while still allowing for non-implemented registers 264 - * to exist but they must be hardwired to 0. 265 - * 266 - * Due to the differences in the versions of capability structures, one 267 - * must be careful not to try and access non-existant registers that may 268 - * exist in early versions - v1 - of Express devices. 269 - * 270 - * Returns the offset of the PCIe capability structure as long as the 271 - * capability version is >= 2; otherwise 0 is returned. 262 + * Returns the address of the next matching extended capability structure 263 + * within the device's PCI configuration space or 0 if the device does 264 + * not support it. Some capabilities can occur several times, e.g., the 265 + * vendor-specific capability, and this provides a way to find them all. 272 266 */ 273 - static int pci_pcie_cap2(struct pci_dev *dev) 267 + int pci_find_next_ext_capability(struct pci_dev *dev, int start, int cap) 274 268 { 275 - u16 flags; 276 - int pos; 269 + u32 header; 270 + int ttl; 271 + int pos = PCI_CFG_SPACE_SIZE; 277 272 278 - pos = pci_pcie_cap(dev); 279 - if (pos) { 280 - pci_read_config_word(dev, pos + PCI_EXP_FLAGS, &flags); 281 - if ((flags & PCI_EXP_FLAGS_VERS) < 2) 282 - pos = 0; 273 + /* minimum 8 bytes per capability */ 274 + ttl = (PCI_CFG_SPACE_EXP_SIZE - PCI_CFG_SPACE_SIZE) / 8; 275 + 276 + if (dev->cfg_size <= PCI_CFG_SPACE_SIZE) 277 + return 0; 278 + 279 + if (start) 280 + pos = start; 281 + 282 + if (pci_read_config_dword(dev, pos, &header) != PCIBIOS_SUCCESSFUL) 283 + return 0; 284 + 285 + /* 286 + * If we have no capabilities, this is indicated by cap ID, 287 + * cap version and next pointer all being 0. 288 + */ 289 + if (header == 0) 290 + return 0; 291 + 292 + while (ttl-- > 0) { 293 + if (PCI_EXT_CAP_ID(header) == cap && pos != start) 294 + return pos; 295 + 296 + pos = PCI_EXT_CAP_NEXT(header); 297 + if (pos < PCI_CFG_SPACE_SIZE) 298 + break; 299 + 300 + if (pci_read_config_dword(dev, pos, &header) != PCIBIOS_SUCCESSFUL) 301 + break; 283 302 } 284 303 285 - return pos; 304 + return 0; 286 305 } 306 + EXPORT_SYMBOL_GPL(pci_find_next_ext_capability); 287 307 288 308 /** 289 309 * pci_find_ext_capability - Find an extended capability ··· 321 301 */ 322 302 int pci_find_ext_capability(struct pci_dev *dev, int cap) 323 303 { 324 - u32 header; 325 - int ttl; 326 - int pos = PCI_CFG_SPACE_SIZE; 327 - 328 - /* minimum 8 bytes per capability */ 329 - ttl = (PCI_CFG_SPACE_EXP_SIZE - PCI_CFG_SPACE_SIZE) / 8; 330 - 331 - if (dev->cfg_size <= PCI_CFG_SPACE_SIZE) 332 - return 0; 333 - 334 - if (pci_read_config_dword(dev, pos, &header) != PCIBIOS_SUCCESSFUL) 335 - return 0; 336 - 337 - /* 338 - * If we have no capabilities, this is indicated by cap ID, 339 - * cap version and next pointer all being 0. 340 - */ 341 - if (header == 0) 342 - return 0; 343 - 344 - while (ttl-- > 0) { 345 - if (PCI_EXT_CAP_ID(header) == cap) 346 - return pos; 347 - 348 - pos = PCI_EXT_CAP_NEXT(header); 349 - if (pos < PCI_CFG_SPACE_SIZE) 350 - break; 351 - 352 - if (pci_read_config_dword(dev, pos, &header) != PCIBIOS_SUCCESSFUL) 353 - break; 354 - } 355 - 356 - return 0; 304 + return pci_find_next_ext_capability(dev, 0, cap); 357 305 } 358 306 EXPORT_SYMBOL_GPL(pci_find_ext_capability); 359 307 ··· 842 854 843 855 #define PCI_EXP_SAVE_REGS 7 844 856 845 - #define pcie_cap_has_devctl(type, flags) 1 846 - #define pcie_cap_has_lnkctl(type, flags) \ 847 - ((flags & PCI_EXP_FLAGS_VERS) > 1 || \ 848 - (type == PCI_EXP_TYPE_ROOT_PORT || \ 849 - type == PCI_EXP_TYPE_ENDPOINT || \ 850 - type == PCI_EXP_TYPE_LEG_END)) 851 - #define pcie_cap_has_sltctl(type, flags) \ 852 - ((flags & PCI_EXP_FLAGS_VERS) > 1 || \ 853 - ((type == PCI_EXP_TYPE_ROOT_PORT) || \ 854 - (type == PCI_EXP_TYPE_DOWNSTREAM && \ 855 - (flags & PCI_EXP_FLAGS_SLOT)))) 856 - #define pcie_cap_has_rtctl(type, flags) \ 857 - ((flags & PCI_EXP_FLAGS_VERS) > 1 || \ 858 - (type == PCI_EXP_TYPE_ROOT_PORT || \ 859 - type == PCI_EXP_TYPE_RC_EC)) 860 857 861 858 static struct pci_cap_saved_state *pci_find_saved_cap( 862 859 struct pci_dev *pci_dev, char cap) ··· 858 885 859 886 static int pci_save_pcie_state(struct pci_dev *dev) 860 887 { 861 - int pos, i = 0; 888 + int i = 0; 862 889 struct pci_cap_saved_state *save_state; 863 890 u16 *cap; 864 - u16 flags; 865 891 866 - pos = pci_pcie_cap(dev); 867 - if (!pos) 892 + if (!pci_is_pcie(dev)) 868 893 return 0; 869 894 870 895 save_state = pci_find_saved_cap(dev, PCI_CAP_ID_EXP); ··· 870 899 dev_err(&dev->dev, "buffer not found in %s\n", __func__); 871 900 return -ENOMEM; 872 901 } 902 + 873 903 cap = (u16 *)&save_state->cap.data[0]; 904 + pcie_capability_read_word(dev, PCI_EXP_DEVCTL, &cap[i++]); 905 + pcie_capability_read_word(dev, PCI_EXP_LNKCTL, &cap[i++]); 906 + pcie_capability_read_word(dev, PCI_EXP_SLTCTL, &cap[i++]); 907 + pcie_capability_read_word(dev, PCI_EXP_RTCTL, &cap[i++]); 908 + pcie_capability_read_word(dev, PCI_EXP_DEVCTL2, &cap[i++]); 909 + pcie_capability_read_word(dev, PCI_EXP_LNKCTL2, &cap[i++]); 910 + pcie_capability_read_word(dev, PCI_EXP_SLTCTL2, &cap[i++]); 874 911 875 - pci_read_config_word(dev, pos + PCI_EXP_FLAGS, &flags); 876 - 877 - if (pcie_cap_has_devctl(dev->pcie_type, flags)) 878 - pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &cap[i++]); 879 - if (pcie_cap_has_lnkctl(dev->pcie_type, flags)) 880 - pci_read_config_word(dev, pos + PCI_EXP_LNKCTL, &cap[i++]); 881 - if (pcie_cap_has_sltctl(dev->pcie_type, flags)) 882 - pci_read_config_word(dev, pos + PCI_EXP_SLTCTL, &cap[i++]); 883 - if (pcie_cap_has_rtctl(dev->pcie_type, flags)) 884 - pci_read_config_word(dev, pos + PCI_EXP_RTCTL, &cap[i++]); 885 - 886 - pos = pci_pcie_cap2(dev); 887 - if (!pos) 888 - return 0; 889 - 890 - pci_read_config_word(dev, pos + PCI_EXP_DEVCTL2, &cap[i++]); 891 - pci_read_config_word(dev, pos + PCI_EXP_LNKCTL2, &cap[i++]); 892 - pci_read_config_word(dev, pos + PCI_EXP_SLTCTL2, &cap[i++]); 893 912 return 0; 894 913 } 895 914 896 915 static void pci_restore_pcie_state(struct pci_dev *dev) 897 916 { 898 - int i = 0, pos; 917 + int i = 0; 899 918 struct pci_cap_saved_state *save_state; 900 919 u16 *cap; 901 - u16 flags; 902 920 903 921 save_state = pci_find_saved_cap(dev, PCI_CAP_ID_EXP); 904 - pos = pci_find_capability(dev, PCI_CAP_ID_EXP); 905 - if (!save_state || pos <= 0) 922 + if (!save_state) 906 923 return; 924 + 907 925 cap = (u16 *)&save_state->cap.data[0]; 908 - 909 - pci_read_config_word(dev, pos + PCI_EXP_FLAGS, &flags); 910 - 911 - if (pcie_cap_has_devctl(dev->pcie_type, flags)) 912 - pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, cap[i++]); 913 - if (pcie_cap_has_lnkctl(dev->pcie_type, flags)) 914 - pci_write_config_word(dev, pos + PCI_EXP_LNKCTL, cap[i++]); 915 - if (pcie_cap_has_sltctl(dev->pcie_type, flags)) 916 - pci_write_config_word(dev, pos + PCI_EXP_SLTCTL, cap[i++]); 917 - if (pcie_cap_has_rtctl(dev->pcie_type, flags)) 918 - pci_write_config_word(dev, pos + PCI_EXP_RTCTL, cap[i++]); 919 - 920 - pos = pci_pcie_cap2(dev); 921 - if (!pos) 922 - return; 923 - 924 - pci_write_config_word(dev, pos + PCI_EXP_DEVCTL2, cap[i++]); 925 - pci_write_config_word(dev, pos + PCI_EXP_LNKCTL2, cap[i++]); 926 - pci_write_config_word(dev, pos + PCI_EXP_SLTCTL2, cap[i++]); 926 + pcie_capability_write_word(dev, PCI_EXP_DEVCTL, cap[i++]); 927 + pcie_capability_write_word(dev, PCI_EXP_LNKCTL, cap[i++]); 928 + pcie_capability_write_word(dev, PCI_EXP_SLTCTL, cap[i++]); 929 + pcie_capability_write_word(dev, PCI_EXP_RTCTL, cap[i++]); 930 + pcie_capability_write_word(dev, PCI_EXP_DEVCTL2, cap[i++]); 931 + pcie_capability_write_word(dev, PCI_EXP_LNKCTL2, cap[i++]); 932 + pcie_capability_write_word(dev, PCI_EXP_SLTCTL2, cap[i++]); 927 933 } 928 934 929 935 ··· 1491 1543 1492 1544 /** 1493 1545 * pci_wakeup - Wake up a PCI device 1494 - * @dev: Device to handle. 1546 + * @pci_dev: Device to handle. 1495 1547 * @ign: ignored parameter 1496 1548 */ 1497 1549 static int pci_wakeup(struct pci_dev *pci_dev, void *ign) ··· 2015 2067 */ 2016 2068 void pci_enable_ari(struct pci_dev *dev) 2017 2069 { 2018 - int pos; 2019 2070 u32 cap; 2020 - u16 ctrl; 2021 2071 struct pci_dev *bridge; 2022 2072 2023 2073 if (pcie_ari_disabled || !pci_is_pcie(dev) || dev->devfn) 2024 2074 return; 2025 2075 2026 - pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ARI); 2027 - if (!pos) 2076 + if (!pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ARI)) 2028 2077 return; 2029 2078 2030 2079 bridge = dev->bus->self; 2031 2080 if (!bridge) 2032 2081 return; 2033 2082 2034 - /* ARI is a PCIe cap v2 feature */ 2035 - pos = pci_pcie_cap2(bridge); 2036 - if (!pos) 2037 - return; 2038 - 2039 - pci_read_config_dword(bridge, pos + PCI_EXP_DEVCAP2, &cap); 2083 + pcie_capability_read_dword(bridge, PCI_EXP_DEVCAP2, &cap); 2040 2084 if (!(cap & PCI_EXP_DEVCAP2_ARI)) 2041 2085 return; 2042 2086 2043 - pci_read_config_word(bridge, pos + PCI_EXP_DEVCTL2, &ctrl); 2044 - ctrl |= PCI_EXP_DEVCTL2_ARI; 2045 - pci_write_config_word(bridge, pos + PCI_EXP_DEVCTL2, ctrl); 2046 - 2087 + pcie_capability_set_word(bridge, PCI_EXP_DEVCTL2, PCI_EXP_DEVCTL2_ARI); 2047 2088 bridge->ari_enabled = 1; 2048 2089 } 2049 2090 ··· 2047 2110 */ 2048 2111 void pci_enable_ido(struct pci_dev *dev, unsigned long type) 2049 2112 { 2050 - int pos; 2051 - u16 ctrl; 2113 + u16 ctrl = 0; 2052 2114 2053 - /* ID-based Ordering is a PCIe cap v2 feature */ 2054 - pos = pci_pcie_cap2(dev); 2055 - if (!pos) 2056 - return; 2057 - 2058 - pci_read_config_word(dev, pos + PCI_EXP_DEVCTL2, &ctrl); 2059 2115 if (type & PCI_EXP_IDO_REQUEST) 2060 2116 ctrl |= PCI_EXP_IDO_REQ_EN; 2061 2117 if (type & PCI_EXP_IDO_COMPLETION) 2062 2118 ctrl |= PCI_EXP_IDO_CMP_EN; 2063 - pci_write_config_word(dev, pos + PCI_EXP_DEVCTL2, ctrl); 2119 + if (ctrl) 2120 + pcie_capability_set_word(dev, PCI_EXP_DEVCTL2, ctrl); 2064 2121 } 2065 2122 EXPORT_SYMBOL(pci_enable_ido); 2066 2123 ··· 2065 2134 */ 2066 2135 void pci_disable_ido(struct pci_dev *dev, unsigned long type) 2067 2136 { 2068 - int pos; 2069 - u16 ctrl; 2137 + u16 ctrl = 0; 2070 2138 2071 - /* ID-based Ordering is a PCIe cap v2 feature */ 2072 - pos = pci_pcie_cap2(dev); 2073 - if (!pos) 2074 - return; 2075 - 2076 - pci_read_config_word(dev, pos + PCI_EXP_DEVCTL2, &ctrl); 2077 2139 if (type & PCI_EXP_IDO_REQUEST) 2078 - ctrl &= ~PCI_EXP_IDO_REQ_EN; 2140 + ctrl |= PCI_EXP_IDO_REQ_EN; 2079 2141 if (type & PCI_EXP_IDO_COMPLETION) 2080 - ctrl &= ~PCI_EXP_IDO_CMP_EN; 2081 - pci_write_config_word(dev, pos + PCI_EXP_DEVCTL2, ctrl); 2142 + ctrl |= PCI_EXP_IDO_CMP_EN; 2143 + if (ctrl) 2144 + pcie_capability_clear_word(dev, PCI_EXP_DEVCTL2, ctrl); 2082 2145 } 2083 2146 EXPORT_SYMBOL(pci_disable_ido); 2084 2147 ··· 2097 2172 */ 2098 2173 int pci_enable_obff(struct pci_dev *dev, enum pci_obff_signal_type type) 2099 2174 { 2100 - int pos; 2101 2175 u32 cap; 2102 2176 u16 ctrl; 2103 2177 int ret; 2104 2178 2105 - /* OBFF is a PCIe cap v2 feature */ 2106 - pos = pci_pcie_cap2(dev); 2107 - if (!pos) 2108 - return -ENOTSUPP; 2109 - 2110 - pci_read_config_dword(dev, pos + PCI_EXP_DEVCAP2, &cap); 2179 + pcie_capability_read_dword(dev, PCI_EXP_DEVCAP2, &cap); 2111 2180 if (!(cap & PCI_EXP_OBFF_MASK)) 2112 2181 return -ENOTSUPP; /* no OBFF support at all */ 2113 2182 ··· 2112 2193 return ret; 2113 2194 } 2114 2195 2115 - pci_read_config_word(dev, pos + PCI_EXP_DEVCTL2, &ctrl); 2196 + pcie_capability_read_word(dev, PCI_EXP_DEVCTL2, &ctrl); 2116 2197 if (cap & PCI_EXP_OBFF_WAKE) 2117 2198 ctrl |= PCI_EXP_OBFF_WAKE_EN; 2118 2199 else { ··· 2130 2211 return -ENOTSUPP; 2131 2212 } 2132 2213 } 2133 - pci_write_config_word(dev, pos + PCI_EXP_DEVCTL2, ctrl); 2214 + pcie_capability_write_word(dev, PCI_EXP_DEVCTL2, ctrl); 2134 2215 2135 2216 return 0; 2136 2217 } ··· 2144 2225 */ 2145 2226 void pci_disable_obff(struct pci_dev *dev) 2146 2227 { 2147 - int pos; 2148 - u16 ctrl; 2149 - 2150 - /* OBFF is a PCIe cap v2 feature */ 2151 - pos = pci_pcie_cap2(dev); 2152 - if (!pos) 2153 - return; 2154 - 2155 - pci_read_config_word(dev, pos + PCI_EXP_DEVCTL2, &ctrl); 2156 - ctrl &= ~PCI_EXP_OBFF_WAKE_EN; 2157 - pci_write_config_word(dev, pos + PCI_EXP_DEVCTL2, ctrl); 2228 + pcie_capability_clear_word(dev, PCI_EXP_DEVCTL2, PCI_EXP_OBFF_WAKE_EN); 2158 2229 } 2159 2230 EXPORT_SYMBOL(pci_disable_obff); 2160 2231 ··· 2157 2248 */ 2158 2249 static bool pci_ltr_supported(struct pci_dev *dev) 2159 2250 { 2160 - int pos; 2161 2251 u32 cap; 2162 2252 2163 - /* LTR is a PCIe cap v2 feature */ 2164 - pos = pci_pcie_cap2(dev); 2165 - if (!pos) 2166 - return false; 2167 - 2168 - pci_read_config_dword(dev, pos + PCI_EXP_DEVCAP2, &cap); 2253 + pcie_capability_read_dword(dev, PCI_EXP_DEVCAP2, &cap); 2169 2254 2170 2255 return cap & PCI_EXP_DEVCAP2_LTR; 2171 2256 } ··· 2176 2273 */ 2177 2274 int pci_enable_ltr(struct pci_dev *dev) 2178 2275 { 2179 - int pos; 2180 - u16 ctrl; 2181 2276 int ret; 2182 - 2183 - if (!pci_ltr_supported(dev)) 2184 - return -ENOTSUPP; 2185 - 2186 - /* LTR is a PCIe cap v2 feature */ 2187 - pos = pci_pcie_cap2(dev); 2188 - if (!pos) 2189 - return -ENOTSUPP; 2190 2277 2191 2278 /* Only primary function can enable/disable LTR */ 2192 2279 if (PCI_FUNC(dev->devfn) != 0) 2193 2280 return -EINVAL; 2281 + 2282 + if (!pci_ltr_supported(dev)) 2283 + return -ENOTSUPP; 2194 2284 2195 2285 /* Enable upstream ports first */ 2196 2286 if (dev->bus->self) { ··· 2192 2296 return ret; 2193 2297 } 2194 2298 2195 - pci_read_config_word(dev, pos + PCI_EXP_DEVCTL2, &ctrl); 2196 - ctrl |= PCI_EXP_LTR_EN; 2197 - pci_write_config_word(dev, pos + PCI_EXP_DEVCTL2, ctrl); 2198 - 2199 - return 0; 2299 + return pcie_capability_set_word(dev, PCI_EXP_DEVCTL2, PCI_EXP_LTR_EN); 2200 2300 } 2201 2301 EXPORT_SYMBOL(pci_enable_ltr); 2202 2302 ··· 2202 2310 */ 2203 2311 void pci_disable_ltr(struct pci_dev *dev) 2204 2312 { 2205 - int pos; 2206 - u16 ctrl; 2207 - 2208 - if (!pci_ltr_supported(dev)) 2209 - return; 2210 - 2211 - /* LTR is a PCIe cap v2 feature */ 2212 - pos = pci_pcie_cap2(dev); 2213 - if (!pos) 2214 - return; 2215 - 2216 2313 /* Only primary function can enable/disable LTR */ 2217 2314 if (PCI_FUNC(dev->devfn) != 0) 2218 2315 return; 2219 2316 2220 - pci_read_config_word(dev, pos + PCI_EXP_DEVCTL2, &ctrl); 2221 - ctrl &= ~PCI_EXP_LTR_EN; 2222 - pci_write_config_word(dev, pos + PCI_EXP_DEVCTL2, ctrl); 2317 + if (!pci_ltr_supported(dev)) 2318 + return; 2319 + 2320 + pcie_capability_clear_word(dev, PCI_EXP_DEVCTL2, PCI_EXP_LTR_EN); 2223 2321 } 2224 2322 EXPORT_SYMBOL(pci_disable_ltr); 2225 2323 ··· 2292 2410 if (!pci_acs_enable) 2293 2411 return; 2294 2412 2295 - if (!pci_is_pcie(dev)) 2296 - return; 2297 - 2298 2413 pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ACS); 2299 2414 if (!pos) 2300 2415 return; ··· 2339 2460 acs_flags &= (PCI_ACS_RR | PCI_ACS_CR | 2340 2461 PCI_ACS_EC | PCI_ACS_DT); 2341 2462 2342 - if (pdev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM || 2343 - pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT || 2463 + if (pci_pcie_type(pdev) == PCI_EXP_TYPE_DOWNSTREAM || 2464 + pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT || 2344 2465 pdev->multifunction) { 2345 2466 pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ACS); 2346 2467 if (!pos) ··· 3056 3177 static int pcie_flr(struct pci_dev *dev, int probe) 3057 3178 { 3058 3179 int i; 3059 - int pos; 3060 3180 u32 cap; 3061 - u16 status, control; 3181 + u16 status; 3062 3182 3063 - pos = pci_pcie_cap(dev); 3064 - if (!pos) 3065 - return -ENOTTY; 3066 - 3067 - pci_read_config_dword(dev, pos + PCI_EXP_DEVCAP, &cap); 3183 + pcie_capability_read_dword(dev, PCI_EXP_DEVCAP, &cap); 3068 3184 if (!(cap & PCI_EXP_DEVCAP_FLR)) 3069 3185 return -ENOTTY; 3070 3186 ··· 3071 3197 if (i) 3072 3198 msleep((1 << (i - 1)) * 100); 3073 3199 3074 - pci_read_config_word(dev, pos + PCI_EXP_DEVSTA, &status); 3200 + pcie_capability_read_word(dev, PCI_EXP_DEVSTA, &status); 3075 3201 if (!(status & PCI_EXP_DEVSTA_TRPND)) 3076 3202 goto clear; 3077 3203 } ··· 3080 3206 "proceeding with reset anyway\n"); 3081 3207 3082 3208 clear: 3083 - pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &control); 3084 - control |= PCI_EXP_DEVCTL_BCR_FLR; 3085 - pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, control); 3209 + pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR); 3086 3210 3087 3211 msleep(100); 3088 3212 ··· 3448 3576 */ 3449 3577 int pcie_get_readrq(struct pci_dev *dev) 3450 3578 { 3451 - int ret, cap; 3452 3579 u16 ctl; 3453 3580 3454 - cap = pci_pcie_cap(dev); 3455 - if (!cap) 3456 - return -EINVAL; 3581 + pcie_capability_read_word(dev, PCI_EXP_DEVCTL, &ctl); 3457 3582 3458 - ret = pci_read_config_word(dev, cap + PCI_EXP_DEVCTL, &ctl); 3459 - if (!ret) 3460 - ret = 128 << ((ctl & PCI_EXP_DEVCTL_READRQ) >> 12); 3461 - 3462 - return ret; 3583 + return 128 << ((ctl & PCI_EXP_DEVCTL_READRQ) >> 12); 3463 3584 } 3464 3585 EXPORT_SYMBOL(pcie_get_readrq); 3465 3586 ··· 3466 3601 */ 3467 3602 int pcie_set_readrq(struct pci_dev *dev, int rq) 3468 3603 { 3469 - int cap, err = -EINVAL; 3470 - u16 ctl, v; 3604 + u16 v; 3471 3605 3472 3606 if (rq < 128 || rq > 4096 || !is_power_of_2(rq)) 3473 - goto out; 3607 + return -EINVAL; 3474 3608 3475 - cap = pci_pcie_cap(dev); 3476 - if (!cap) 3477 - goto out; 3478 - 3479 - err = pci_read_config_word(dev, cap + PCI_EXP_DEVCTL, &ctl); 3480 - if (err) 3481 - goto out; 3482 3609 /* 3483 3610 * If using the "performance" PCIe config, we clamp the 3484 3611 * read rq size to the max packet size to prevent the ··· 3488 3631 3489 3632 v = (ffs(rq) - 8) << 12; 3490 3633 3491 - if ((ctl & PCI_EXP_DEVCTL_READRQ) != v) { 3492 - ctl &= ~PCI_EXP_DEVCTL_READRQ; 3493 - ctl |= v; 3494 - err = pci_write_config_word(dev, cap + PCI_EXP_DEVCTL, ctl); 3495 - } 3496 - 3497 - out: 3498 - return err; 3634 + return pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL, 3635 + PCI_EXP_DEVCTL_READRQ, v); 3499 3636 } 3500 3637 EXPORT_SYMBOL(pcie_set_readrq); 3501 3638 ··· 3502 3651 */ 3503 3652 int pcie_get_mps(struct pci_dev *dev) 3504 3653 { 3505 - int ret, cap; 3506 3654 u16 ctl; 3507 3655 3508 - cap = pci_pcie_cap(dev); 3509 - if (!cap) 3510 - return -EINVAL; 3656 + pcie_capability_read_word(dev, PCI_EXP_DEVCTL, &ctl); 3511 3657 3512 - ret = pci_read_config_word(dev, cap + PCI_EXP_DEVCTL, &ctl); 3513 - if (!ret) 3514 - ret = 128 << ((ctl & PCI_EXP_DEVCTL_PAYLOAD) >> 5); 3515 - 3516 - return ret; 3658 + return 128 << ((ctl & PCI_EXP_DEVCTL_PAYLOAD) >> 5); 3517 3659 } 3518 3660 3519 3661 /** ··· 3519 3675 */ 3520 3676 int pcie_set_mps(struct pci_dev *dev, int mps) 3521 3677 { 3522 - int cap, err = -EINVAL; 3523 - u16 ctl, v; 3678 + u16 v; 3524 3679 3525 3680 if (mps < 128 || mps > 4096 || !is_power_of_2(mps)) 3526 - goto out; 3681 + return -EINVAL; 3527 3682 3528 3683 v = ffs(mps) - 8; 3529 3684 if (v > dev->pcie_mpss) 3530 - goto out; 3685 + return -EINVAL; 3531 3686 v <<= 5; 3532 3687 3533 - cap = pci_pcie_cap(dev); 3534 - if (!cap) 3535 - goto out; 3536 - 3537 - err = pci_read_config_word(dev, cap + PCI_EXP_DEVCTL, &ctl); 3538 - if (err) 3539 - goto out; 3540 - 3541 - if ((ctl & PCI_EXP_DEVCTL_PAYLOAD) != v) { 3542 - ctl &= ~PCI_EXP_DEVCTL_PAYLOAD; 3543 - ctl |= v; 3544 - err = pci_write_config_word(dev, cap + PCI_EXP_DEVCTL, ctl); 3545 - } 3546 - out: 3547 - return err; 3688 + return pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL, 3689 + PCI_EXP_DEVCTL_PAYLOAD, v); 3548 3690 } 3549 3691 3550 3692 /**
+1 -1
drivers/pci/pcie/aer/aer_inject.c
··· 288 288 while (1) { 289 289 if (!pci_is_pcie(dev)) 290 290 break; 291 - if (dev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) 291 + if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) 292 292 return dev; 293 293 if (!dev->bus->self) 294 294 break;
+12 -14
drivers/pci/pcie/aer/aerdrv.c
··· 48 48 static void aer_error_resume(struct pci_dev *dev); 49 49 static pci_ers_result_t aer_root_reset(struct pci_dev *dev); 50 50 51 - static struct pci_error_handlers aer_error_handlers = { 51 + static const struct pci_error_handlers aer_error_handlers = { 52 52 .error_detected = aer_error_detected, 53 53 .resume = aer_error_resume, 54 54 }; ··· 81 81 static int set_device_error_reporting(struct pci_dev *dev, void *data) 82 82 { 83 83 bool enable = *((bool *)data); 84 + int type = pci_pcie_type(dev); 84 85 85 - if ((dev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) || 86 - (dev->pcie_type == PCI_EXP_TYPE_UPSTREAM) || 87 - (dev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM)) { 86 + if ((type == PCI_EXP_TYPE_ROOT_PORT) || 87 + (type == PCI_EXP_TYPE_UPSTREAM) || 88 + (type == PCI_EXP_TYPE_DOWNSTREAM)) { 88 89 if (enable) 89 90 pci_enable_pcie_error_reporting(dev); 90 91 else ··· 122 121 static void aer_enable_rootport(struct aer_rpc *rpc) 123 122 { 124 123 struct pci_dev *pdev = rpc->rpd->port; 125 - int pos, aer_pos; 124 + int aer_pos; 126 125 u16 reg16; 127 126 u32 reg32; 128 127 129 - pos = pci_pcie_cap(pdev); 130 128 /* Clear PCIe Capability's Device Status */ 131 - pci_read_config_word(pdev, pos+PCI_EXP_DEVSTA, &reg16); 132 - pci_write_config_word(pdev, pos+PCI_EXP_DEVSTA, reg16); 129 + pcie_capability_read_word(pdev, PCI_EXP_DEVSTA, &reg16); 130 + pcie_capability_write_word(pdev, PCI_EXP_DEVSTA, reg16); 133 131 134 132 /* Disable system error generation in response to error messages */ 135 - pci_read_config_word(pdev, pos + PCI_EXP_RTCTL, &reg16); 136 - reg16 &= ~(SYSTEM_ERROR_INTR_ON_MESG_MASK); 137 - pci_write_config_word(pdev, pos + PCI_EXP_RTCTL, reg16); 133 + pcie_capability_clear_word(pdev, PCI_EXP_RTCTL, 134 + SYSTEM_ERROR_INTR_ON_MESG_MASK); 138 135 139 136 aer_pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ERR); 140 137 /* Clear error status */ ··· 394 395 u16 reg16; 395 396 396 397 /* Clean up Root device status */ 397 - pos = pci_pcie_cap(dev); 398 - pci_read_config_word(dev, pos + PCI_EXP_DEVSTA, &reg16); 399 - pci_write_config_word(dev, pos + PCI_EXP_DEVSTA, reg16); 398 + pcie_capability_read_word(dev, PCI_EXP_DEVSTA, &reg16); 399 + pcie_capability_write_word(dev, PCI_EXP_DEVSTA, reg16); 400 400 401 401 /* Clean AER Root Error Status */ 402 402 pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
+1 -1
drivers/pci/pcie/aer/aerdrv_acpi.c
··· 60 60 p = (struct acpi_hest_aer_common *)(hest_hdr + 1); 61 61 if (p->flags & ACPI_HEST_GLOBAL) { 62 62 if ((pci_is_pcie(info->pci_dev) && 63 - info->pci_dev->pcie_type == pcie_type) || bridge) 63 + pci_pcie_type(info->pci_dev) == pcie_type) || bridge) 64 64 ff = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST); 65 65 } else 66 66 if (hest_match_pci(p, info->pci_dev))
+17 -50
drivers/pci/pcie/aer/aerdrv_core.c
··· 32 32 module_param(forceload, bool, 0); 33 33 module_param(nosourceid, bool, 0); 34 34 35 + #define PCI_EXP_AER_FLAGS (PCI_EXP_DEVCTL_CERE | PCI_EXP_DEVCTL_NFERE | \ 36 + PCI_EXP_DEVCTL_FERE | PCI_EXP_DEVCTL_URRE) 37 + 35 38 int pci_enable_pcie_error_reporting(struct pci_dev *dev) 36 39 { 37 - u16 reg16 = 0; 38 - int pos; 39 - 40 40 if (pcie_aer_get_firmware_first(dev)) 41 41 return -EIO; 42 42 43 - pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); 44 - if (!pos) 43 + if (!pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR)) 45 44 return -EIO; 46 45 47 - pos = pci_pcie_cap(dev); 48 - if (!pos) 49 - return -EIO; 50 - 51 - pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &reg16); 52 - reg16 |= (PCI_EXP_DEVCTL_CERE | 53 - PCI_EXP_DEVCTL_NFERE | 54 - PCI_EXP_DEVCTL_FERE | 55 - PCI_EXP_DEVCTL_URRE); 56 - pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, reg16); 57 - 58 - return 0; 46 + return pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_AER_FLAGS); 59 47 } 60 48 EXPORT_SYMBOL_GPL(pci_enable_pcie_error_reporting); 61 49 62 50 int pci_disable_pcie_error_reporting(struct pci_dev *dev) 63 51 { 64 - u16 reg16 = 0; 65 - int pos; 66 - 67 52 if (pcie_aer_get_firmware_first(dev)) 68 53 return -EIO; 69 54 70 - pos = pci_pcie_cap(dev); 71 - if (!pos) 72 - return -EIO; 73 - 74 - pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &reg16); 75 - reg16 &= ~(PCI_EXP_DEVCTL_CERE | 76 - PCI_EXP_DEVCTL_NFERE | 77 - PCI_EXP_DEVCTL_FERE | 78 - PCI_EXP_DEVCTL_URRE); 79 - pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, reg16); 80 - 81 - return 0; 55 + return pcie_capability_clear_word(dev, PCI_EXP_DEVCTL, 56 + PCI_EXP_AER_FLAGS); 82 57 } 83 58 EXPORT_SYMBOL_GPL(pci_disable_pcie_error_reporting); 84 59 ··· 126 151 */ 127 152 if (atomic_read(&dev->enable_cnt) == 0) 128 153 return false; 129 - pos = pci_pcie_cap(dev); 130 - if (!pos) 131 - return false; 132 154 133 155 /* Check if AER is enabled */ 134 - pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &reg16); 135 - if (!(reg16 & ( 136 - PCI_EXP_DEVCTL_CERE | 137 - PCI_EXP_DEVCTL_NFERE | 138 - PCI_EXP_DEVCTL_FERE | 139 - PCI_EXP_DEVCTL_URRE))) 156 + pcie_capability_read_word(dev, PCI_EXP_DEVCTL, &reg16); 157 + if (!(reg16 & PCI_EXP_AER_FLAGS)) 140 158 return false; 159 + 141 160 pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); 142 161 if (!pos) 143 162 return false; ··· 209 240 static int report_error_detected(struct pci_dev *dev, void *data) 210 241 { 211 242 pci_ers_result_t vote; 212 - struct pci_error_handlers *err_handler; 243 + const struct pci_error_handlers *err_handler; 213 244 struct aer_broadcast_data *result_data; 214 245 result_data = (struct aer_broadcast_data *) data; 215 246 ··· 243 274 static int report_mmio_enabled(struct pci_dev *dev, void *data) 244 275 { 245 276 pci_ers_result_t vote; 246 - struct pci_error_handlers *err_handler; 277 + const struct pci_error_handlers *err_handler; 247 278 struct aer_broadcast_data *result_data; 248 279 result_data = (struct aer_broadcast_data *) data; 249 280 ··· 261 292 static int report_slot_reset(struct pci_dev *dev, void *data) 262 293 { 263 294 pci_ers_result_t vote; 264 - struct pci_error_handlers *err_handler; 295 + const struct pci_error_handlers *err_handler; 265 296 struct aer_broadcast_data *result_data; 266 297 result_data = (struct aer_broadcast_data *) data; 267 298 ··· 278 309 279 310 static int report_resume(struct pci_dev *dev, void *data) 280 311 { 281 - struct pci_error_handlers *err_handler; 312 + const struct pci_error_handlers *err_handler; 282 313 283 314 dev->error_state = pci_channel_io_normal; 284 315 ··· 434 465 435 466 if (driver && driver->reset_link) { 436 467 status = driver->reset_link(udev); 437 - } else if (udev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM) { 468 + } else if (pci_pcie_type(udev) == PCI_EXP_TYPE_DOWNSTREAM) { 438 469 status = default_downstream_reset_link(udev); 439 470 } else { 440 471 dev_printk(KERN_DEBUG, &dev->dev, ··· 509 540 "resume", 510 541 report_resume); 511 542 512 - dev_printk(KERN_DEBUG, &dev->dev, 513 - "AER driver successfully recovered\n"); 543 + dev_info(&dev->dev, "AER: Device recovery successful\n"); 514 544 return; 515 545 516 546 failed: 517 547 /* TODO: Should kernel panic here? */ 518 - dev_printk(KERN_DEBUG, &dev->dev, 519 - "AER driver didn't recover\n"); 548 + dev_info(&dev->dev, "AER: Device recovery failed\n"); 520 549 } 521 550 522 551 /**
+47 -72
drivers/pci/pcie/aspm.c
··· 125 125 126 126 static void pcie_set_clkpm_nocheck(struct pcie_link_state *link, int enable) 127 127 { 128 - int pos; 129 - u16 reg16; 130 128 struct pci_dev *child; 131 129 struct pci_bus *linkbus = link->pdev->subordinate; 132 130 133 131 list_for_each_entry(child, &linkbus->devices, bus_list) { 134 - pos = pci_pcie_cap(child); 135 - if (!pos) 136 - return; 137 - pci_read_config_word(child, pos + PCI_EXP_LNKCTL, &reg16); 138 132 if (enable) 139 - reg16 |= PCI_EXP_LNKCTL_CLKREQ_EN; 133 + pcie_capability_set_word(child, PCI_EXP_LNKCTL, 134 + PCI_EXP_LNKCTL_CLKREQ_EN); 140 135 else 141 - reg16 &= ~PCI_EXP_LNKCTL_CLKREQ_EN; 142 - pci_write_config_word(child, pos + PCI_EXP_LNKCTL, reg16); 136 + pcie_capability_clear_word(child, PCI_EXP_LNKCTL, 137 + PCI_EXP_LNKCTL_CLKREQ_EN); 143 138 } 144 139 link->clkpm_enabled = !!enable; 145 140 } ··· 152 157 153 158 static void pcie_clkpm_cap_init(struct pcie_link_state *link, int blacklist) 154 159 { 155 - int pos, capable = 1, enabled = 1; 160 + int capable = 1, enabled = 1; 156 161 u32 reg32; 157 162 u16 reg16; 158 163 struct pci_dev *child; ··· 160 165 161 166 /* All functions should have the same cap and state, take the worst */ 162 167 list_for_each_entry(child, &linkbus->devices, bus_list) { 163 - pos = pci_pcie_cap(child); 164 - if (!pos) 165 - return; 166 - pci_read_config_dword(child, pos + PCI_EXP_LNKCAP, &reg32); 168 + pcie_capability_read_dword(child, PCI_EXP_LNKCAP, &reg32); 167 169 if (!(reg32 & PCI_EXP_LNKCAP_CLKPM)) { 168 170 capable = 0; 169 171 enabled = 0; 170 172 break; 171 173 } 172 - pci_read_config_word(child, pos + PCI_EXP_LNKCTL, &reg16); 174 + pcie_capability_read_word(child, PCI_EXP_LNKCTL, &reg16); 173 175 if (!(reg16 & PCI_EXP_LNKCTL_CLKREQ_EN)) 174 176 enabled = 0; 175 177 } ··· 182 190 */ 183 191 static void pcie_aspm_configure_common_clock(struct pcie_link_state *link) 184 192 { 185 - int ppos, cpos, same_clock = 1; 193 + int same_clock = 1; 186 194 u16 reg16, parent_reg, child_reg[8]; 187 195 unsigned long start_jiffies; 188 196 struct pci_dev *child, *parent = link->pdev; ··· 195 203 BUG_ON(!pci_is_pcie(child)); 196 204 197 205 /* Check downstream component if bit Slot Clock Configuration is 1 */ 198 - cpos = pci_pcie_cap(child); 199 - pci_read_config_word(child, cpos + PCI_EXP_LNKSTA, &reg16); 206 + pcie_capability_read_word(child, PCI_EXP_LNKSTA, &reg16); 200 207 if (!(reg16 & PCI_EXP_LNKSTA_SLC)) 201 208 same_clock = 0; 202 209 203 210 /* Check upstream component if bit Slot Clock Configuration is 1 */ 204 - ppos = pci_pcie_cap(parent); 205 - pci_read_config_word(parent, ppos + PCI_EXP_LNKSTA, &reg16); 211 + pcie_capability_read_word(parent, PCI_EXP_LNKSTA, &reg16); 206 212 if (!(reg16 & PCI_EXP_LNKSTA_SLC)) 207 213 same_clock = 0; 208 214 209 215 /* Configure downstream component, all functions */ 210 216 list_for_each_entry(child, &linkbus->devices, bus_list) { 211 - cpos = pci_pcie_cap(child); 212 - pci_read_config_word(child, cpos + PCI_EXP_LNKCTL, &reg16); 217 + pcie_capability_read_word(child, PCI_EXP_LNKCTL, &reg16); 213 218 child_reg[PCI_FUNC(child->devfn)] = reg16; 214 219 if (same_clock) 215 220 reg16 |= PCI_EXP_LNKCTL_CCC; 216 221 else 217 222 reg16 &= ~PCI_EXP_LNKCTL_CCC; 218 - pci_write_config_word(child, cpos + PCI_EXP_LNKCTL, reg16); 223 + pcie_capability_write_word(child, PCI_EXP_LNKCTL, reg16); 219 224 } 220 225 221 226 /* Configure upstream component */ 222 - pci_read_config_word(parent, ppos + PCI_EXP_LNKCTL, &reg16); 227 + pcie_capability_read_word(parent, PCI_EXP_LNKCTL, &reg16); 223 228 parent_reg = reg16; 224 229 if (same_clock) 225 230 reg16 |= PCI_EXP_LNKCTL_CCC; 226 231 else 227 232 reg16 &= ~PCI_EXP_LNKCTL_CCC; 228 - pci_write_config_word(parent, ppos + PCI_EXP_LNKCTL, reg16); 233 + pcie_capability_write_word(parent, PCI_EXP_LNKCTL, reg16); 229 234 230 235 /* Retrain link */ 231 236 reg16 |= PCI_EXP_LNKCTL_RL; 232 - pci_write_config_word(parent, ppos + PCI_EXP_LNKCTL, reg16); 237 + pcie_capability_write_word(parent, PCI_EXP_LNKCTL, reg16); 233 238 234 239 /* Wait for link training end. Break out after waiting for timeout */ 235 240 start_jiffies = jiffies; 236 241 for (;;) { 237 - pci_read_config_word(parent, ppos + PCI_EXP_LNKSTA, &reg16); 242 + pcie_capability_read_word(parent, PCI_EXP_LNKSTA, &reg16); 238 243 if (!(reg16 & PCI_EXP_LNKSTA_LT)) 239 244 break; 240 245 if (time_after(jiffies, start_jiffies + LINK_RETRAIN_TIMEOUT)) ··· 244 255 /* Training failed. Restore common clock configurations */ 245 256 dev_printk(KERN_ERR, &parent->dev, 246 257 "ASPM: Could not configure common clock\n"); 247 - list_for_each_entry(child, &linkbus->devices, bus_list) { 248 - cpos = pci_pcie_cap(child); 249 - pci_write_config_word(child, cpos + PCI_EXP_LNKCTL, 250 - child_reg[PCI_FUNC(child->devfn)]); 251 - } 252 - pci_write_config_word(parent, ppos + PCI_EXP_LNKCTL, parent_reg); 258 + list_for_each_entry(child, &linkbus->devices, bus_list) 259 + pcie_capability_write_word(child, PCI_EXP_LNKCTL, 260 + child_reg[PCI_FUNC(child->devfn)]); 261 + pcie_capability_write_word(parent, PCI_EXP_LNKCTL, parent_reg); 253 262 } 254 263 255 264 /* Convert L0s latency encoding to ns */ ··· 292 305 static void pcie_get_aspm_reg(struct pci_dev *pdev, 293 306 struct aspm_register_info *info) 294 307 { 295 - int pos; 296 308 u16 reg16; 297 309 u32 reg32; 298 310 299 - pos = pci_pcie_cap(pdev); 300 - pci_read_config_dword(pdev, pos + PCI_EXP_LNKCAP, &reg32); 311 + pcie_capability_read_dword(pdev, PCI_EXP_LNKCAP, &reg32); 301 312 info->support = (reg32 & PCI_EXP_LNKCAP_ASPMS) >> 10; 302 313 info->latency_encoding_l0s = (reg32 & PCI_EXP_LNKCAP_L0SEL) >> 12; 303 314 info->latency_encoding_l1 = (reg32 & PCI_EXP_LNKCAP_L1EL) >> 15; 304 - pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &reg16); 315 + pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &reg16); 305 316 info->enabled = reg16 & PCI_EXP_LNKCTL_ASPMC; 306 317 } 307 318 ··· 397 412 * do ASPM for now. 398 413 */ 399 414 list_for_each_entry(child, &linkbus->devices, bus_list) { 400 - if (child->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) { 415 + if (pci_pcie_type(child) == PCI_EXP_TYPE_PCI_BRIDGE) { 401 416 link->aspm_disable = ASPM_STATE_ALL; 402 417 break; 403 418 } ··· 405 420 406 421 /* Get and check endpoint acceptable latencies */ 407 422 list_for_each_entry(child, &linkbus->devices, bus_list) { 408 - int pos; 409 423 u32 reg32, encoding; 410 424 struct aspm_latency *acceptable = 411 425 &link->acceptable[PCI_FUNC(child->devfn)]; 412 426 413 - if (child->pcie_type != PCI_EXP_TYPE_ENDPOINT && 414 - child->pcie_type != PCI_EXP_TYPE_LEG_END) 427 + if (pci_pcie_type(child) != PCI_EXP_TYPE_ENDPOINT && 428 + pci_pcie_type(child) != PCI_EXP_TYPE_LEG_END) 415 429 continue; 416 430 417 - pos = pci_pcie_cap(child); 418 - pci_read_config_dword(child, pos + PCI_EXP_DEVCAP, &reg32); 431 + pcie_capability_read_dword(child, PCI_EXP_DEVCAP, &reg32); 419 432 /* Calculate endpoint L0s acceptable latency */ 420 433 encoding = (reg32 & PCI_EXP_DEVCAP_L0S) >> 6; 421 434 acceptable->l0s = calc_l0s_acceptable(encoding); ··· 427 444 428 445 static void pcie_config_aspm_dev(struct pci_dev *pdev, u32 val) 429 446 { 430 - u16 reg16; 431 - int pos = pci_pcie_cap(pdev); 432 - 433 - pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &reg16); 434 - reg16 &= ~0x3; 435 - reg16 |= val; 436 - pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16); 447 + pcie_capability_clear_and_set_word(pdev, PCI_EXP_LNKCTL, 0x3, val); 437 448 } 438 449 439 450 static void pcie_config_aspm_link(struct pcie_link_state *link, u32 state) ··· 482 505 static int pcie_aspm_sanity_check(struct pci_dev *pdev) 483 506 { 484 507 struct pci_dev *child; 485 - int pos; 486 508 u32 reg32; 487 509 488 510 /* ··· 489 513 * very strange. Disable ASPM for the whole slot 490 514 */ 491 515 list_for_each_entry(child, &pdev->subordinate->devices, bus_list) { 492 - pos = pci_pcie_cap(child); 493 - if (!pos) 516 + if (!pci_is_pcie(child)) 494 517 return -EINVAL; 495 518 496 519 /* ··· 505 530 * Disable ASPM for pre-1.1 PCIe device, we follow MS to use 506 531 * RBER bit to determine if a function is 1.1 version device 507 532 */ 508 - pci_read_config_dword(child, pos + PCI_EXP_DEVCAP, &reg32); 533 + pcie_capability_read_dword(child, PCI_EXP_DEVCAP, &reg32); 509 534 if (!(reg32 & PCI_EXP_DEVCAP_RBER) && !aspm_force) { 510 535 dev_printk(KERN_INFO, &child->dev, "disabling ASPM" 511 536 " on pre-1.1 PCIe device. You can enable it" ··· 527 552 INIT_LIST_HEAD(&link->children); 528 553 INIT_LIST_HEAD(&link->link); 529 554 link->pdev = pdev; 530 - if (pdev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM) { 555 + if (pci_pcie_type(pdev) == PCI_EXP_TYPE_DOWNSTREAM) { 531 556 struct pcie_link_state *parent; 532 557 parent = pdev->bus->parent->self->link_state; 533 558 if (!parent) { ··· 560 585 561 586 if (!pci_is_pcie(pdev) || pdev->link_state) 562 587 return; 563 - if (pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT && 564 - pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM) 588 + if (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT && 589 + pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM) 565 590 return; 566 591 567 592 /* VIA has a strange chipset, root port is under a bridge */ 568 - if (pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT && 593 + if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT && 569 594 pdev->bus->self) 570 595 return; 571 596 ··· 622 647 if (link->root != root) 623 648 continue; 624 649 list_for_each_entry(child, &linkbus->devices, bus_list) { 625 - if ((child->pcie_type != PCI_EXP_TYPE_ENDPOINT) && 626 - (child->pcie_type != PCI_EXP_TYPE_LEG_END)) 650 + if ((pci_pcie_type(child) != PCI_EXP_TYPE_ENDPOINT) && 651 + (pci_pcie_type(child) != PCI_EXP_TYPE_LEG_END)) 627 652 continue; 628 653 pcie_aspm_check_latency(child); 629 654 } ··· 638 663 639 664 if (!pci_is_pcie(pdev) || !parent || !parent->link_state) 640 665 return; 641 - if ((parent->pcie_type != PCI_EXP_TYPE_ROOT_PORT) && 642 - (parent->pcie_type != PCI_EXP_TYPE_DOWNSTREAM)) 666 + if ((pci_pcie_type(parent) != PCI_EXP_TYPE_ROOT_PORT) && 667 + (pci_pcie_type(parent) != PCI_EXP_TYPE_DOWNSTREAM)) 643 668 return; 644 669 645 670 down_read(&pci_bus_sem); ··· 679 704 680 705 if (aspm_disabled || !pci_is_pcie(pdev) || !link) 681 706 return; 682 - if ((pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT) && 683 - (pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM)) 707 + if ((pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT) && 708 + (pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM)) 684 709 return; 685 710 /* 686 711 * Devices changed PM state, we should recheck if latency ··· 704 729 if (aspm_policy != POLICY_POWERSAVE) 705 730 return; 706 731 707 - if ((pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT) && 708 - (pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM)) 732 + if ((pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT) && 733 + (pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM)) 709 734 return; 710 735 711 736 down_read(&pci_bus_sem); ··· 732 757 if (!pci_is_pcie(pdev)) 733 758 return; 734 759 735 - if (pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT || 736 - pdev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM) 760 + if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT || 761 + pci_pcie_type(pdev) == PCI_EXP_TYPE_DOWNSTREAM) 737 762 parent = pdev; 738 763 if (!parent || !parent->link_state) 739 764 return; ··· 908 933 struct pcie_link_state *link_state = pdev->link_state; 909 934 910 935 if (!pci_is_pcie(pdev) || 911 - (pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT && 912 - pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM) || !link_state) 936 + (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT && 937 + pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM) || !link_state) 913 938 return; 914 939 915 940 if (link_state->aspm_support) ··· 925 950 struct pcie_link_state *link_state = pdev->link_state; 926 951 927 952 if (!pci_is_pcie(pdev) || 928 - (pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT && 929 - pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM) || !link_state) 953 + (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT && 954 + pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM) || !link_state) 930 955 return; 931 956 932 957 if (link_state->aspm_support)
+9 -20
drivers/pci/pcie/pme.c
··· 57 57 */ 58 58 void pcie_pme_interrupt_enable(struct pci_dev *dev, bool enable) 59 59 { 60 - int rtctl_pos; 61 - u16 rtctl; 62 - 63 - rtctl_pos = pci_pcie_cap(dev) + PCI_EXP_RTCTL; 64 - 65 - pci_read_config_word(dev, rtctl_pos, &rtctl); 66 60 if (enable) 67 - rtctl |= PCI_EXP_RTCTL_PMEIE; 61 + pcie_capability_set_word(dev, PCI_EXP_RTCTL, 62 + PCI_EXP_RTCTL_PMEIE); 68 63 else 69 - rtctl &= ~PCI_EXP_RTCTL_PMEIE; 70 - pci_write_config_word(dev, rtctl_pos, rtctl); 64 + pcie_capability_clear_word(dev, PCI_EXP_RTCTL, 65 + PCI_EXP_RTCTL_PMEIE); 71 66 } 72 67 73 68 /** ··· 115 120 if (!dev) 116 121 return false; 117 122 118 - if (pci_is_pcie(dev) && dev->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) { 123 + if (pci_is_pcie(dev) && pci_pcie_type(dev) == PCI_EXP_TYPE_PCI_BRIDGE) { 119 124 down_read(&pci_bus_sem); 120 125 if (pcie_pme_walk_bus(bus)) 121 126 found = true; ··· 221 226 struct pcie_pme_service_data *data = 222 227 container_of(work, struct pcie_pme_service_data, work); 223 228 struct pci_dev *port = data->srv->port; 224 - int rtsta_pos; 225 229 u32 rtsta; 226 - 227 - rtsta_pos = pci_pcie_cap(port) + PCI_EXP_RTSTA; 228 230 229 231 spin_lock_irq(&data->lock); 230 232 ··· 229 237 if (data->noirq) 230 238 break; 231 239 232 - pci_read_config_dword(port, rtsta_pos, &rtsta); 240 + pcie_capability_read_dword(port, PCI_EXP_RTSTA, &rtsta); 233 241 if (rtsta & PCI_EXP_RTSTA_PME) { 234 242 /* 235 243 * Clear PME status of the port. If there are other ··· 268 276 { 269 277 struct pci_dev *port; 270 278 struct pcie_pme_service_data *data; 271 - int rtsta_pos; 272 279 u32 rtsta; 273 280 unsigned long flags; 274 281 275 282 port = ((struct pcie_device *)context)->port; 276 283 data = get_service_data((struct pcie_device *)context); 277 284 278 - rtsta_pos = pci_pcie_cap(port) + PCI_EXP_RTSTA; 279 - 280 285 spin_lock_irqsave(&data->lock, flags); 281 - pci_read_config_dword(port, rtsta_pos, &rtsta); 286 + pcie_capability_read_dword(port, PCI_EXP_RTSTA, &rtsta); 282 287 283 288 if (!(rtsta & PCI_EXP_RTSTA_PME)) { 284 289 spin_unlock_irqrestore(&data->lock, flags); ··· 324 335 struct pci_dev *dev; 325 336 326 337 /* Check if this is a root port event collector. */ 327 - if (port->pcie_type != PCI_EXP_TYPE_RC_EC || !bus) 338 + if (pci_pcie_type(port) != PCI_EXP_TYPE_RC_EC || !bus) 328 339 return; 329 340 330 341 down_read(&pci_bus_sem); 331 342 list_for_each_entry(dev, &bus->devices, bus_list) 332 343 if (pci_is_pcie(dev) 333 - && dev->pcie_type == PCI_EXP_TYPE_RC_END) 344 + && pci_pcie_type(dev) == PCI_EXP_TYPE_RC_END) 334 345 pcie_pme_set_native(dev, NULL); 335 346 up_read(&pci_bus_sem); 336 347 }
+1 -1
drivers/pci/pcie/portdrv_bus.c
··· 38 38 return 0; 39 39 40 40 if ((driver->port_type != PCIE_ANY_PORT) && 41 - (driver->port_type != pciedev->port->pcie_type)) 41 + (driver->port_type != pci_pcie_type(pciedev->port))) 42 42 return 0; 43 43 44 44 return 1;
+18 -16
drivers/pci/pcie/portdrv_core.c
··· 200 200 { 201 201 int i, irq = -1; 202 202 203 - /* We have to use INTx if MSI cannot be used for PCIe PME or pciehp. */ 203 + /* 204 + * If MSI cannot be used for PCIe PME or hotplug, we have to use 205 + * INTx or other interrupts, e.g. system shared interrupt. 206 + */ 204 207 if (((mask & PCIE_PORT_SERVICE_PME) && pcie_pme_no_msi()) || 205 208 ((mask & PCIE_PORT_SERVICE_HP) && pciehp_no_msi())) { 206 - if (dev->pin) 209 + if (dev->irq) 207 210 irq = dev->irq; 208 211 goto no_msi; 209 212 } ··· 215 212 if (!pcie_port_enable_msix(dev, irqs, mask)) 216 213 return 0; 217 214 218 - /* We're not going to use MSI-X, so try MSI and fall back to INTx */ 219 - if (!pci_enable_msi(dev) || dev->pin) 215 + /* 216 + * We're not going to use MSI-X, so try MSI and fall back to INTx. 217 + * If neither MSI/MSI-X nor INTx available, try other interrupt. On 218 + * some platforms, root port doesn't support MSI/MSI-X/INTx in RC mode. 219 + */ 220 + if (!pci_enable_msi(dev) || dev->irq) 220 221 irq = dev->irq; 221 222 222 223 no_msi: ··· 253 246 */ 254 247 static int get_port_device_capability(struct pci_dev *dev) 255 248 { 256 - int services = 0, pos; 257 - u16 reg16; 249 + int services = 0; 258 250 u32 reg32; 259 251 int cap_mask = 0; 260 252 int err; ··· 271 265 return 0; 272 266 } 273 267 274 - pos = pci_pcie_cap(dev); 275 - pci_read_config_word(dev, pos + PCI_EXP_FLAGS, &reg16); 276 268 /* Hot-Plug Capable */ 277 - if ((cap_mask & PCIE_PORT_SERVICE_HP) && (reg16 & PCI_EXP_FLAGS_SLOT)) { 278 - pci_read_config_dword(dev, pos + PCI_EXP_SLTCAP, &reg32); 269 + if (cap_mask & PCIE_PORT_SERVICE_HP) { 270 + pcie_capability_read_dword(dev, PCI_EXP_SLTCAP, &reg32); 279 271 if (reg32 & PCI_EXP_SLTCAP_HPC) { 280 272 services |= PCIE_PORT_SERVICE_HP; 281 273 /* ··· 281 277 * enabled by the BIOS and the hot-plug service driver 282 278 * is not loaded. 283 279 */ 284 - pos += PCI_EXP_SLTCTL; 285 - pci_read_config_word(dev, pos, &reg16); 286 - reg16 &= ~(PCI_EXP_SLTCTL_CCIE | PCI_EXP_SLTCTL_HPIE); 287 - pci_write_config_word(dev, pos, reg16); 280 + pcie_capability_clear_word(dev, PCI_EXP_SLTCTL, 281 + PCI_EXP_SLTCTL_CCIE | PCI_EXP_SLTCTL_HPIE); 288 282 } 289 283 } 290 284 /* AER capable */ ··· 300 298 services |= PCIE_PORT_SERVICE_VC; 301 299 /* Root ports are capable of generating PME too */ 302 300 if ((cap_mask & PCIE_PORT_SERVICE_PME) 303 - && dev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) { 301 + && pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) { 304 302 services |= PCIE_PORT_SERVICE_PME; 305 303 /* 306 304 * Disable PME interrupt on this port in case it's been enabled ··· 338 336 device->release = release_pcie_device; /* callback to free pcie dev */ 339 337 dev_set_name(device, "%s:pcie%02x", 340 338 pci_name(pdev), 341 - get_descriptor_id(pdev->pcie_type, service)); 339 + get_descriptor_id(pci_pcie_type(pdev), service)); 342 340 device->parent = &pdev->dev; 343 341 device_enable_async_suspend(device); 344 342
+10 -17
drivers/pci/pcie/portdrv_pci.c
··· 64 64 */ 65 65 void pcie_clear_root_pme_status(struct pci_dev *dev) 66 66 { 67 - int rtsta_pos; 68 - u32 rtsta; 69 - 70 - rtsta_pos = pci_pcie_cap(dev) + PCI_EXP_RTSTA; 71 - 72 - pci_read_config_dword(dev, rtsta_pos, &rtsta); 73 - rtsta |= PCI_EXP_RTSTA_PME; 74 - pci_write_config_dword(dev, rtsta_pos, rtsta); 67 + pcie_capability_set_dword(dev, PCI_EXP_RTSTA, PCI_EXP_RTSTA_PME); 75 68 } 76 69 77 70 static int pcie_portdrv_restore_config(struct pci_dev *dev) ··· 88 95 * which breaks ACPI-based runtime wakeup on PCI Express, so clear those 89 96 * bits now just in case (shouldn't hurt). 90 97 */ 91 - if(pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) 98 + if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT) 92 99 pcie_clear_root_pme_status(pdev); 93 100 return 0; 94 101 } ··· 188 195 int status; 189 196 190 197 if (!pci_is_pcie(dev) || 191 - ((dev->pcie_type != PCI_EXP_TYPE_ROOT_PORT) && 192 - (dev->pcie_type != PCI_EXP_TYPE_UPSTREAM) && 193 - (dev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM))) 198 + ((pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT) && 199 + (pci_pcie_type(dev) != PCI_EXP_TYPE_UPSTREAM) && 200 + (pci_pcie_type(dev) != PCI_EXP_TYPE_DOWNSTREAM))) 194 201 return -ENODEV; 195 202 196 203 if (!dev->irq && dev->pin) { ··· 378 385 }; 379 386 MODULE_DEVICE_TABLE(pci, port_pci_ids); 380 387 381 - static struct pci_error_handlers pcie_portdrv_err_handler = { 382 - .error_detected = pcie_portdrv_error_detected, 383 - .mmio_enabled = pcie_portdrv_mmio_enabled, 384 - .slot_reset = pcie_portdrv_slot_reset, 385 - .resume = pcie_portdrv_err_resume, 388 + static const struct pci_error_handlers pcie_portdrv_err_handler = { 389 + .error_detected = pcie_portdrv_error_detected, 390 + .mmio_enabled = pcie_portdrv_mmio_enabled, 391 + .slot_reset = pcie_portdrv_slot_reset, 392 + .resume = pcie_portdrv_err_resume, 386 393 }; 387 394 388 395 static struct pci_driver pcie_portdriver = {
+14 -25
drivers/pci/probe.c
··· 606 606 u32 linkcap; 607 607 u16 linksta; 608 608 609 - pci_read_config_dword(bridge, pos + PCI_EXP_LNKCAP, &linkcap); 609 + pcie_capability_read_dword(bridge, PCI_EXP_LNKCAP, &linkcap); 610 610 bus->max_bus_speed = pcie_link_speed[linkcap & 0xf]; 611 611 612 - pci_read_config_word(bridge, pos + PCI_EXP_LNKSTA, &linksta); 612 + pcie_capability_read_word(bridge, PCI_EXP_LNKSTA, &linksta); 613 613 pcie_update_link_speed(bus, linksta); 614 614 } 615 615 } ··· 729 729 730 730 /* Check if setup is sensible at all */ 731 731 if (!pass && 732 - (primary != bus->number || secondary <= bus->number)) { 733 - dev_dbg(&dev->dev, "bus configuration invalid, reconfiguring\n"); 732 + (primary != bus->number || secondary <= bus->number || 733 + secondary > subordinate)) { 734 + dev_info(&dev->dev, "bridge configuration invalid ([bus %02x-%02x]), reconfiguring\n", 735 + secondary, subordinate); 734 736 broken = 1; 735 737 } 736 738 ··· 934 932 pdev->is_pcie = 1; 935 933 pdev->pcie_cap = pos; 936 934 pci_read_config_word(pdev, pos + PCI_EXP_FLAGS, &reg16); 937 - pdev->pcie_type = (reg16 & PCI_EXP_FLAGS_TYPE) >> 4; 935 + pdev->pcie_flags_reg = reg16; 938 936 pci_read_config_word(pdev, pos + PCI_EXP_DEVCAP, &reg16); 939 937 pdev->pcie_mpss = reg16 & PCI_EXP_DEVCAP_PAYLOAD; 940 938 } 941 939 942 940 void set_pcie_hotplug_bridge(struct pci_dev *pdev) 943 941 { 944 - int pos; 945 - u16 reg16; 946 942 u32 reg32; 947 943 948 - pos = pci_pcie_cap(pdev); 949 - if (!pos) 950 - return; 951 - pci_read_config_word(pdev, pos + PCI_EXP_FLAGS, &reg16); 952 - if (!(reg16 & PCI_EXP_FLAGS_SLOT)) 953 - return; 954 - pci_read_config_dword(pdev, pos + PCI_EXP_SLTCAP, &reg32); 944 + pcie_capability_read_dword(pdev, PCI_EXP_SLTCAP, &reg32); 955 945 if (reg32 & PCI_EXP_SLTCAP_HPC) 956 946 pdev->is_hotplug_bridge = 1; 957 947 } ··· 1157 1163 if (class == PCI_CLASS_BRIDGE_HOST) 1158 1164 return pci_cfg_space_size_ext(dev); 1159 1165 1160 - pos = pci_pcie_cap(dev); 1161 - if (!pos) { 1166 + if (!pci_is_pcie(dev)) { 1162 1167 pos = pci_find_capability(dev, PCI_CAP_ID_PCIX); 1163 1168 if (!pos) 1164 1169 goto fail; ··· 1379 1386 1380 1387 if (!parent || !pci_is_pcie(parent)) 1381 1388 return 0; 1382 - if (parent->pcie_type == PCI_EXP_TYPE_ROOT_PORT) 1389 + if (pci_pcie_type(parent) == PCI_EXP_TYPE_ROOT_PORT) 1383 1390 return 1; 1384 - if (parent->pcie_type == PCI_EXP_TYPE_DOWNSTREAM && 1391 + if (pci_pcie_type(parent) == PCI_EXP_TYPE_DOWNSTREAM && 1385 1392 !pci_has_flag(PCI_SCAN_ALL_PCIE_DEVS)) 1386 1393 return 1; 1387 1394 return 0; ··· 1458 1465 */ 1459 1466 if (dev->is_hotplug_bridge && (!list_is_singular(&dev->bus->devices) || 1460 1467 (dev->bus->self && 1461 - dev->bus->self->pcie_type != PCI_EXP_TYPE_ROOT_PORT))) 1468 + pci_pcie_type(dev->bus->self) != PCI_EXP_TYPE_ROOT_PORT))) 1462 1469 *smpss = 0; 1463 1470 1464 1471 if (*smpss > dev->pcie_mpss) ··· 1474 1481 if (pcie_bus_config == PCIE_BUS_PERFORMANCE) { 1475 1482 mps = 128 << dev->pcie_mpss; 1476 1483 1477 - if (dev->pcie_type != PCI_EXP_TYPE_ROOT_PORT && dev->bus->self) 1484 + if (pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT && 1485 + dev->bus->self) 1478 1486 /* For "Performance", the assumption is made that 1479 1487 * downstream communication will never be larger than 1480 1488 * the MRRS. So, the MPS only needs to be configured ··· 1750 1756 "busn_res: can not insert %pR under %s%pR (conflicts with %s %pR)\n", 1751 1757 res, pci_is_root_bus(b) ? "domain " : "", 1752 1758 parent_res, conflict->name, conflict); 1753 - else 1754 - dev_printk(KERN_DEBUG, &b->dev, 1755 - "busn_res: %pR is inserted under %s%pR\n", 1756 - res, pci_is_root_bus(b) ? "domain " : "", 1757 - parent_res); 1758 1759 1759 1760 return conflict == NULL; 1760 1761 }
-19
drivers/pci/proc.c
··· 434 434 return 0; 435 435 } 436 436 437 - #if 0 438 - int pci_proc_attach_bus(struct pci_bus* bus) 439 - { 440 - struct proc_dir_entry *de = bus->procdir; 441 - 442 - if (!proc_initialized) 443 - return -EACCES; 444 - 445 - if (!de) { 446 - char name[16]; 447 - sprintf(name, "%02x", bus->number); 448 - de = bus->procdir = proc_mkdir(name, proc_bus_pci_dir); 449 - if (!de) 450 - return -ENOMEM; 451 - } 452 - return 0; 453 - } 454 - #endif /* 0 */ 455 - 456 437 int pci_proc_detach_bus(struct pci_bus* bus) 457 438 { 458 439 struct proc_dir_entry *de = bus->procdir;
+25 -6
drivers/pci/quirks.c
··· 3081 3081 3082 3082 static int reset_intel_82599_sfp_virtfn(struct pci_dev *dev, int probe) 3083 3083 { 3084 - int pos; 3084 + int i; 3085 + u16 status; 3085 3086 3086 - pos = pci_find_capability(dev, PCI_CAP_ID_EXP); 3087 - if (!pos) 3088 - return -ENOTTY; 3087 + /* 3088 + * http://www.intel.com/content/dam/doc/datasheet/82599-10-gbe-controller-datasheet.pdf 3089 + * 3090 + * The 82599 supports FLR on VFs, but FLR support is reported only 3091 + * in the PF DEVCAP (sec 9.3.10.4), not in the VF DEVCAP (sec 9.5). 3092 + * Therefore, we can't use pcie_flr(), which checks the VF DEVCAP. 3093 + */ 3089 3094 3090 3095 if (probe) 3091 3096 return 0; 3092 3097 3093 - pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, 3094 - PCI_EXP_DEVCTL_BCR_FLR); 3098 + /* Wait for Transaction Pending bit clean */ 3099 + for (i = 0; i < 4; i++) { 3100 + if (i) 3101 + msleep((1 << (i - 1)) * 100); 3102 + 3103 + pcie_capability_read_word(dev, PCI_EXP_DEVSTA, &status); 3104 + if (!(status & PCI_EXP_DEVSTA_TRPND)) 3105 + goto clear; 3106 + } 3107 + 3108 + dev_err(&dev->dev, "transaction is not cleared; " 3109 + "proceeding with reset anyway\n"); 3110 + 3111 + clear: 3112 + pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR); 3113 + 3095 3114 msleep(100); 3096 3115 3097 3116 return 0;
+45 -115
drivers/pci/remove.c
··· 32 32 33 33 static void pci_destroy_dev(struct pci_dev *dev) 34 34 { 35 - /* Remove the device from the device lists, and prevent any further 36 - * list accesses from this device */ 37 35 down_write(&pci_bus_sem); 38 36 list_del(&dev->bus_list); 39 - dev->bus_list.next = dev->bus_list.prev = NULL; 40 37 up_write(&pci_bus_sem); 41 38 42 39 pci_free_resources(dev); 43 40 pci_dev_put(dev); 44 41 } 45 42 46 - /** 47 - * pci_remove_device_safe - remove an unused hotplug device 48 - * @dev: the device to remove 49 - * 50 - * Delete the device structure from the device lists and 51 - * notify userspace (/sbin/hotplug), but only if the device 52 - * in question is not being used by a driver. 53 - * Returns 0 on success. 54 - */ 55 - #if 0 56 - int pci_remove_device_safe(struct pci_dev *dev) 43 + void pci_remove_bus(struct pci_bus *bus) 57 44 { 58 - if (pci_dev_driver(dev)) 59 - return -EBUSY; 60 - pci_destroy_dev(dev); 61 - return 0; 62 - } 63 - #endif /* 0 */ 64 - 65 - void pci_remove_bus(struct pci_bus *pci_bus) 66 - { 67 - pci_proc_detach_bus(pci_bus); 45 + pci_proc_detach_bus(bus); 68 46 69 47 down_write(&pci_bus_sem); 70 - list_del(&pci_bus->node); 71 - pci_bus_release_busn_res(pci_bus); 48 + list_del(&bus->node); 49 + pci_bus_release_busn_res(bus); 72 50 up_write(&pci_bus_sem); 73 - if (!pci_bus->is_added) 51 + if (!bus->is_added) 74 52 return; 75 53 76 - pci_remove_legacy_files(pci_bus); 77 - device_unregister(&pci_bus->dev); 54 + pci_remove_legacy_files(bus); 55 + device_unregister(&bus->dev); 78 56 } 79 57 EXPORT_SYMBOL(pci_remove_bus); 80 58 81 - static void __pci_remove_behind_bridge(struct pci_dev *dev); 59 + static void pci_stop_bus_device(struct pci_dev *dev) 60 + { 61 + struct pci_bus *bus = dev->subordinate; 62 + struct pci_dev *child, *tmp; 63 + 64 + /* 65 + * Stopping an SR-IOV PF device removes all the associated VFs, 66 + * which will update the bus->devices list and confuse the 67 + * iterator. Therefore, iterate in reverse so we remove the VFs 68 + * first, then the PF. 69 + */ 70 + if (bus) { 71 + list_for_each_entry_safe_reverse(child, tmp, 72 + &bus->devices, bus_list) 73 + pci_stop_bus_device(child); 74 + } 75 + 76 + pci_stop_dev(dev); 77 + } 78 + 79 + static void pci_remove_bus_device(struct pci_dev *dev) 80 + { 81 + struct pci_bus *bus = dev->subordinate; 82 + struct pci_dev *child, *tmp; 83 + 84 + if (bus) { 85 + list_for_each_entry_safe(child, tmp, 86 + &bus->devices, bus_list) 87 + pci_remove_bus_device(child); 88 + 89 + pci_remove_bus(bus); 90 + dev->subordinate = NULL; 91 + } 92 + 93 + pci_destroy_dev(dev); 94 + } 95 + 82 96 /** 83 97 * pci_stop_and_remove_bus_device - remove a PCI device and any children 84 98 * @dev: the device to remove ··· 105 91 * device lists, remove the /proc entry, and notify userspace 106 92 * (/sbin/hotplug). 107 93 */ 108 - void __pci_remove_bus_device(struct pci_dev *dev) 109 - { 110 - if (dev->subordinate) { 111 - struct pci_bus *b = dev->subordinate; 112 - 113 - __pci_remove_behind_bridge(dev); 114 - pci_remove_bus(b); 115 - dev->subordinate = NULL; 116 - } 117 - 118 - pci_destroy_dev(dev); 119 - } 120 - EXPORT_SYMBOL(__pci_remove_bus_device); 121 - 122 94 void pci_stop_and_remove_bus_device(struct pci_dev *dev) 123 95 { 124 96 pci_stop_bus_device(dev); 125 - __pci_remove_bus_device(dev); 97 + pci_remove_bus_device(dev); 126 98 } 127 - 128 - static void __pci_remove_behind_bridge(struct pci_dev *dev) 129 - { 130 - struct list_head *l, *n; 131 - 132 - if (dev->subordinate) 133 - list_for_each_safe(l, n, &dev->subordinate->devices) 134 - __pci_remove_bus_device(pci_dev_b(l)); 135 - } 136 - 137 - static void pci_stop_behind_bridge(struct pci_dev *dev) 138 - { 139 - struct list_head *l, *n; 140 - 141 - if (dev->subordinate) 142 - list_for_each_safe(l, n, &dev->subordinate->devices) 143 - pci_stop_bus_device(pci_dev_b(l)); 144 - } 145 - 146 - /** 147 - * pci_stop_and_remove_behind_bridge - stop and remove all devices behind 148 - * a PCI bridge 149 - * @dev: PCI bridge device 150 - * 151 - * Remove all devices on the bus, except for the parent bridge. 152 - * This also removes any child buses, and any devices they may 153 - * contain in a depth-first manner. 154 - */ 155 - void pci_stop_and_remove_behind_bridge(struct pci_dev *dev) 156 - { 157 - pci_stop_behind_bridge(dev); 158 - __pci_remove_behind_bridge(dev); 159 - } 160 - 161 - static void pci_stop_bus_devices(struct pci_bus *bus) 162 - { 163 - struct list_head *l, *n; 164 - 165 - /* 166 - * VFs could be removed by pci_stop_and_remove_bus_device() in the 167 - * pci_stop_bus_devices() code path for PF. 168 - * aka, bus->devices get updated in the process. 169 - * but VFs are inserted after PFs when SRIOV is enabled for PF, 170 - * We can iterate the list backwards to get prev valid PF instead 171 - * of removed VF. 172 - */ 173 - list_for_each_prev_safe(l, n, &bus->devices) { 174 - struct pci_dev *dev = pci_dev_b(l); 175 - pci_stop_bus_device(dev); 176 - } 177 - } 178 - 179 - /** 180 - * pci_stop_bus_device - stop a PCI device and any children 181 - * @dev: the device to stop 182 - * 183 - * Stop a PCI device (detach the driver, remove from the global list 184 - * and so on). This also stop any subordinate buses and children in a 185 - * depth-first manner. 186 - */ 187 - void pci_stop_bus_device(struct pci_dev *dev) 188 - { 189 - if (dev->subordinate) 190 - pci_stop_bus_devices(dev->subordinate); 191 - 192 - pci_stop_dev(dev); 193 - } 194 - 195 99 EXPORT_SYMBOL(pci_stop_and_remove_bus_device); 196 - EXPORT_SYMBOL(pci_stop_and_remove_behind_bridge); 197 - EXPORT_SYMBOL_GPL(pci_stop_bus_device);
-59
drivers/pci/rom.c
··· 167 167 return rom; 168 168 } 169 169 170 - #if 0 171 - /** 172 - * pci_map_rom_copy - map a PCI ROM to kernel space, create a copy 173 - * @pdev: pointer to pci device struct 174 - * @size: pointer to receive size of pci window over ROM 175 - * 176 - * Return: kernel virtual pointer to image of ROM 177 - * 178 - * Map a PCI ROM into kernel space. If ROM is boot video ROM, 179 - * the shadow BIOS copy will be returned instead of the 180 - * actual ROM. 181 - */ 182 - void __iomem *pci_map_rom_copy(struct pci_dev *pdev, size_t *size) 183 - { 184 - struct resource *res = &pdev->resource[PCI_ROM_RESOURCE]; 185 - void __iomem *rom; 186 - 187 - rom = pci_map_rom(pdev, size); 188 - if (!rom) 189 - return NULL; 190 - 191 - if (res->flags & (IORESOURCE_ROM_COPY | IORESOURCE_ROM_SHADOW | 192 - IORESOURCE_ROM_BIOS_COPY)) 193 - return rom; 194 - 195 - res->start = (unsigned long)kmalloc(*size, GFP_KERNEL); 196 - if (!res->start) 197 - return rom; 198 - 199 - res->end = res->start + *size; 200 - memcpy_fromio((void*)(unsigned long)res->start, rom, *size); 201 - pci_unmap_rom(pdev, rom); 202 - res->flags |= IORESOURCE_ROM_COPY; 203 - 204 - return (void __iomem *)(unsigned long)res->start; 205 - } 206 - #endif /* 0 */ 207 - 208 170 /** 209 171 * pci_unmap_rom - unmap the ROM from kernel space 210 172 * @pdev: pointer to pci device struct ··· 187 225 if (!(res->flags & (IORESOURCE_ROM_ENABLE | IORESOURCE_ROM_SHADOW))) 188 226 pci_disable_rom(pdev); 189 227 } 190 - 191 - #if 0 192 - /** 193 - * pci_remove_rom - disable the ROM and remove its sysfs attribute 194 - * @pdev: pointer to pci device struct 195 - * 196 - * Remove the rom file in sysfs and disable ROM decoding. 197 - */ 198 - void pci_remove_rom(struct pci_dev *pdev) 199 - { 200 - struct resource *res = &pdev->resource[PCI_ROM_RESOURCE]; 201 - 202 - if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) 203 - sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr); 204 - if (!(res->flags & (IORESOURCE_ROM_ENABLE | 205 - IORESOURCE_ROM_SHADOW | 206 - IORESOURCE_ROM_BIOS_COPY | 207 - IORESOURCE_ROM_COPY))) 208 - pci_disable_rom(pdev); 209 - } 210 - #endif /* 0 */ 211 228 212 229 /** 213 230 * pci_cleanup_rom - free the ROM copy created by pci_map_rom_copy
+19 -40
drivers/pci/search.c
··· 41 41 continue; 42 42 } 43 43 /* PCI device should connect to a PCIe bridge */ 44 - if (pdev->pcie_type != PCI_EXP_TYPE_PCI_BRIDGE) { 44 + if (pci_pcie_type(pdev) != PCI_EXP_TYPE_PCI_BRIDGE) { 45 45 /* Busted hardware? */ 46 46 WARN_ON_ONCE(1); 47 47 return NULL; ··· 130 130 * decrement the reference count by calling pci_dev_put(). 131 131 * If no device is found, %NULL is returned. 132 132 */ 133 - struct pci_dev * pci_get_slot(struct pci_bus *bus, unsigned int devfn) 133 + struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn) 134 134 { 135 - struct list_head *tmp; 136 135 struct pci_dev *dev; 137 136 138 137 WARN_ON(in_interrupt()); 139 138 down_read(&pci_bus_sem); 140 139 141 - list_for_each(tmp, &bus->devices) { 142 - dev = pci_dev_b(tmp); 140 + list_for_each_entry(dev, &bus->devices, bus_list) { 143 141 if (dev->devfn == devfn) 144 142 goto out; 145 143 } ··· 243 245 unsigned int ss_vendor, unsigned int ss_device, 244 246 struct pci_dev *from) 245 247 { 246 - struct pci_dev *pdev; 247 - struct pci_device_id *id; 248 + struct pci_device_id id = { 249 + .vendor = vendor, 250 + .device = device, 251 + .subvendor = ss_vendor, 252 + .subdevice = ss_device, 253 + }; 248 254 249 - /* 250 - * pci_find_subsys() can be called on the ide_setup() path, 251 - * super-early in boot. But the down_read() will enable local 252 - * interrupts, which can cause some machines to crash. So here we 253 - * detect and flag that situation and bail out early. 254 - */ 255 - if (unlikely(no_pci_devices())) 256 - return NULL; 257 - 258 - id = kzalloc(sizeof(*id), GFP_KERNEL); 259 - if (!id) 260 - return NULL; 261 - id->vendor = vendor; 262 - id->device = device; 263 - id->subvendor = ss_vendor; 264 - id->subdevice = ss_device; 265 - 266 - pdev = pci_get_dev_by_id(id, from); 267 - kfree(id); 268 - 269 - return pdev; 255 + return pci_get_dev_by_id(&id, from); 270 256 } 271 257 272 258 /** ··· 289 307 */ 290 308 struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from) 291 309 { 292 - struct pci_dev *dev; 293 - struct pci_device_id *id; 310 + struct pci_device_id id = { 311 + .vendor = PCI_ANY_ID, 312 + .device = PCI_ANY_ID, 313 + .subvendor = PCI_ANY_ID, 314 + .subdevice = PCI_ANY_ID, 315 + .class_mask = PCI_ANY_ID, 316 + .class = class, 317 + }; 294 318 295 - id = kzalloc(sizeof(*id), GFP_KERNEL); 296 - if (!id) 297 - return NULL; 298 - id->vendor = id->device = id->subvendor = id->subdevice = PCI_ANY_ID; 299 - id->class_mask = PCI_ANY_ID; 300 - id->class = class; 301 - 302 - dev = pci_get_dev_by_id(id, from); 303 - kfree(id); 304 - return dev; 319 + return pci_get_dev_by_id(&id, from); 305 320 } 306 321 307 322 /**
+60 -21
drivers/pci/setup-bus.c
··· 697 697 return size; 698 698 } 699 699 700 + resource_size_t __weak pcibios_window_alignment(struct pci_bus *bus, 701 + unsigned long type) 702 + { 703 + return 1; 704 + } 705 + 706 + #define PCI_P2P_DEFAULT_MEM_ALIGN 0x100000 /* 1MiB */ 707 + #define PCI_P2P_DEFAULT_IO_ALIGN 0x1000 /* 4KiB */ 708 + #define PCI_P2P_DEFAULT_IO_ALIGN_1K 0x400 /* 1KiB */ 709 + 710 + static resource_size_t window_alignment(struct pci_bus *bus, 711 + unsigned long type) 712 + { 713 + resource_size_t align = 1, arch_align; 714 + 715 + if (type & IORESOURCE_MEM) 716 + align = PCI_P2P_DEFAULT_MEM_ALIGN; 717 + else if (type & IORESOURCE_IO) { 718 + /* 719 + * Per spec, I/O windows are 4K-aligned, but some 720 + * bridges have an extension to support 1K alignment. 721 + */ 722 + if (bus->self->io_window_1k) 723 + align = PCI_P2P_DEFAULT_IO_ALIGN_1K; 724 + else 725 + align = PCI_P2P_DEFAULT_IO_ALIGN; 726 + } 727 + 728 + arch_align = pcibios_window_alignment(bus, type); 729 + return max(align, arch_align); 730 + } 731 + 700 732 /** 701 733 * pbus_size_io() - size the io window of a given bus 702 734 * ··· 749 717 struct resource *b_res = find_free_bus_resource(bus, IORESOURCE_IO); 750 718 unsigned long size = 0, size0 = 0, size1 = 0; 751 719 resource_size_t children_add_size = 0; 752 - resource_size_t min_align = 4096, align; 720 + resource_size_t min_align, io_align, align; 753 721 754 722 if (!b_res) 755 723 return; 756 724 757 - /* 758 - * Per spec, I/O windows are 4K-aligned, but some bridges have an 759 - * extension to support 1K alignment. 760 - */ 761 - if (bus->self->io_window_1k) 762 - min_align = 1024; 725 + io_align = min_align = window_alignment(bus, IORESOURCE_IO); 763 726 list_for_each_entry(dev, &bus->devices, bus_list) { 764 727 int i; 765 728 ··· 781 754 } 782 755 } 783 756 784 - if (min_align > 4096) 785 - min_align = 4096; 757 + if (min_align > io_align) 758 + min_align = io_align; 786 759 787 760 size0 = calculate_iosize(size, min_size, size1, 788 761 resource_size(b_res), min_align); ··· 810 783 "%pR to %pR add_size %lx\n", b_res, 811 784 &bus->busn_res, size1-size0); 812 785 } 786 + } 787 + 788 + static inline resource_size_t calculate_mem_align(resource_size_t *aligns, 789 + int max_order) 790 + { 791 + resource_size_t align = 0; 792 + resource_size_t min_align = 0; 793 + int order; 794 + 795 + for (order = 0; order <= max_order; order++) { 796 + resource_size_t align1 = 1; 797 + 798 + align1 <<= (order + 20); 799 + 800 + if (!align) 801 + min_align = align1; 802 + else if (ALIGN(align + min_align, min_align) < align1) 803 + min_align = align1 >> 1; 804 + align += aligns[order]; 805 + } 806 + 807 + return min_align; 813 808 } 814 809 815 810 /** ··· 913 864 children_add_size += get_res_add_size(realloc_head, r); 914 865 } 915 866 } 916 - align = 0; 917 - min_align = 0; 918 - for (order = 0; order <= max_order; order++) { 919 - resource_size_t align1 = 1; 920 867 921 - align1 <<= (order + 20); 922 - 923 - if (!align) 924 - min_align = align1; 925 - else if (ALIGN(align + min_align, min_align) < align1) 926 - min_align = align1 >> 1; 927 - align += aligns[order]; 928 - } 868 + min_align = calculate_mem_align(aligns, max_order); 869 + min_align = max(min_align, window_alignment(bus, b_res->flags & mask)); 929 870 size0 = calculate_memsize(size, min_size, 0, resource_size(b_res), min_align); 930 871 if (children_add_size > add_size) 931 872 add_size = children_add_size;
+7 -2
drivers/pci/setup-irq.c
··· 17 17 #include <linux/ioport.h> 18 18 #include <linux/cache.h> 19 19 20 + void __weak pcibios_update_irq(struct pci_dev *dev, int irq) 21 + { 22 + dev_dbg(&dev->dev, "assigning IRQ %02d\n", irq); 23 + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); 24 + } 20 25 21 - static void __init 26 + static void 22 27 pdev_fixup_irq(struct pci_dev *dev, 23 28 u8 (*swizzle)(struct pci_dev *, u8 *), 24 29 int (*map_irq)(const struct pci_dev *, u8, u8)) ··· 59 54 pcibios_update_irq(dev, irq); 60 55 } 61 56 62 - void __init 57 + void 63 58 pci_fixup_irqs(u8 (*swizzle)(struct pci_dev *, u8 *), 64 59 int (*map_irq)(const struct pci_dev *, u8, u8)) 65 60 {
+2 -8
drivers/pci/xen-pcifront.c
··· 982 982 int err = 0; 983 983 int i, num_devs; 984 984 unsigned int domain, bus, slot, func; 985 - struct pci_bus *pci_bus; 986 985 struct pci_dev *pci_dev; 987 986 char str[64]; 988 987 ··· 1031 1032 goto out; 1032 1033 } 1033 1034 1034 - pci_bus = pci_find_bus(domain, bus); 1035 - if (!pci_bus) { 1036 - dev_dbg(&pdev->xdev->dev, "Cannot get bus %04x:%02x\n", 1037 - domain, bus); 1038 - continue; 1039 - } 1040 - pci_dev = pci_get_slot(pci_bus, PCI_DEVFN(slot, func)); 1035 + pci_dev = pci_get_domain_bus_and_slot(domain, bus, 1036 + PCI_DEVFN(slot, func)); 1041 1037 if (!pci_dev) { 1042 1038 dev_dbg(&pdev->xdev->dev, 1043 1039 "Cannot get PCI device %04x:%02x:%02x.%d\n",
+12 -3
drivers/pcmcia/cardbus.c
··· 105 105 */ 106 106 void cb_free(struct pcmcia_socket *s) 107 107 { 108 - struct pci_dev *bridge = s->cb_dev; 108 + struct pci_dev *bridge, *dev, *tmp; 109 + struct pci_bus *bus; 109 110 110 - if (bridge) 111 - pci_stop_and_remove_behind_bridge(bridge); 111 + bridge = s->cb_dev; 112 + if (!bridge) 113 + return; 114 + 115 + bus = bridge->subordinate; 116 + if (!bus) 117 + return; 118 + 119 + list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) 120 + pci_stop_and_remove_bus_device(dev); 112 121 }
+6 -12
drivers/rapidio/devices/tsi721.c
··· 2219 2219 const struct pci_device_id *id) 2220 2220 { 2221 2221 struct tsi721_device *priv; 2222 - int cap; 2223 2222 int err; 2224 - u32 regval; 2225 2223 2226 2224 priv = kzalloc(sizeof(struct tsi721_device), GFP_KERNEL); 2227 2225 if (priv == NULL) { ··· 2328 2330 dev_info(&pdev->dev, "Unable to set consistent DMA mask\n"); 2329 2331 } 2330 2332 2331 - cap = pci_pcie_cap(pdev); 2332 - BUG_ON(cap == 0); 2333 + BUG_ON(!pci_is_pcie(pdev)); 2333 2334 2334 2335 /* Clear "no snoop" and "relaxed ordering" bits, use default MRRS. */ 2335 - pci_read_config_dword(pdev, cap + PCI_EXP_DEVCTL, &regval); 2336 - regval &= ~(PCI_EXP_DEVCTL_READRQ | PCI_EXP_DEVCTL_RELAX_EN | 2337 - PCI_EXP_DEVCTL_NOSNOOP_EN); 2338 - regval |= 0x2 << MAX_READ_REQUEST_SZ_SHIFT; 2339 - pci_write_config_dword(pdev, cap + PCI_EXP_DEVCTL, regval); 2336 + pcie_capability_clear_and_set_word(pdev, PCI_EXP_DEVCTL, 2337 + PCI_EXP_DEVCTL_READRQ | PCI_EXP_DEVCTL_RELAX_EN | 2338 + PCI_EXP_DEVCTL_NOSNOOP_EN, 2339 + 0x2 << MAX_READ_REQUEST_SZ_SHIFT); 2340 2340 2341 2341 /* Adjust PCIe completion timeout. */ 2342 - pci_read_config_dword(pdev, cap + PCI_EXP_DEVCTL2, &regval); 2343 - regval &= ~(0x0f); 2344 - pci_write_config_dword(pdev, cap + PCI_EXP_DEVCTL2, regval | 0x2); 2342 + pcie_capability_clear_and_set_word(pdev, PCI_EXP_DEVCTL2, 0xf, 0x2); 2345 2343 2346 2344 /* 2347 2345 * FIXUP: correct offsets of MSI-X tables in the MSI-X Capability Block
+1 -1
drivers/scsi/ipr.c
··· 9228 9228 }; 9229 9229 MODULE_DEVICE_TABLE(pci, ipr_pci_table); 9230 9230 9231 - static struct pci_error_handlers ipr_err_handler = { 9231 + static const struct pci_error_handlers ipr_err_handler = { 9232 9232 .error_detected = ipr_pci_error_detected, 9233 9233 .slot_reset = ipr_pci_slot_reset, 9234 9234 };
+1 -1
drivers/scsi/lpfc/lpfc_init.c
··· 10425 10425 10426 10426 MODULE_DEVICE_TABLE(pci, lpfc_id_table); 10427 10427 10428 - static struct pci_error_handlers lpfc_err_handler = { 10428 + static const struct pci_error_handlers lpfc_err_handler = { 10429 10429 .error_detected = lpfc_io_error_detected, 10430 10430 .slot_reset = lpfc_io_slot_reset, 10431 10431 .resume = lpfc_io_resume,
+1 -1
drivers/scsi/mpt2sas/mpt2sas_scsih.c
··· 8306 8306 return PCI_ERS_RESULT_NEED_RESET; 8307 8307 } 8308 8308 8309 - static struct pci_error_handlers _scsih_err_handler = { 8309 + static const struct pci_error_handlers _scsih_err_handler = { 8310 8310 .error_detected = _scsih_pci_error_detected, 8311 8311 .mmio_enabled = _scsih_pci_mmio_enabled, 8312 8312 .slot_reset = _scsih_pci_slot_reset,
+2 -6
drivers/scsi/qla2xxx/qla_nx.c
··· 1615 1615 char * 1616 1616 qla82xx_pci_info_str(struct scsi_qla_host *vha, char *str) 1617 1617 { 1618 - int pcie_reg; 1619 1618 struct qla_hw_data *ha = vha->hw; 1620 1619 char lwstr[6]; 1621 1620 uint16_t lnk; 1622 1621 1623 - pcie_reg = pci_pcie_cap(ha->pdev); 1624 - pci_read_config_word(ha->pdev, pcie_reg + PCI_EXP_LNKSTA, &lnk); 1622 + pcie_capability_read_word(ha->pdev, PCI_EXP_LNKSTA, &lnk); 1625 1623 ha->link_width = (lnk >> 4) & 0x3f; 1626 1624 1627 1625 strcpy(str, "PCIe ("); ··· 2495 2497 int 2496 2498 qla82xx_start_firmware(scsi_qla_host_t *vha) 2497 2499 { 2498 - int pcie_cap; 2499 2500 uint16_t lnk; 2500 2501 struct qla_hw_data *ha = vha->hw; 2501 2502 ··· 2525 2528 } 2526 2529 2527 2530 /* Negotiated Link width */ 2528 - pcie_cap = pci_pcie_cap(ha->pdev); 2529 - pci_read_config_word(ha->pdev, pcie_cap + PCI_EXP_LNKSTA, &lnk); 2531 + pcie_capability_read_word(ha->pdev, PCI_EXP_LNKSTA, &lnk); 2530 2532 ha->link_width = (lnk >> 4) & 0x3f; 2531 2533 2532 2534 /* Synchronize with Receive peg */
+1 -1
drivers/scsi/qla2xxx/qla_os.c
··· 4471 4471 ha->flags.eeh_busy = 0; 4472 4472 } 4473 4473 4474 - static struct pci_error_handlers qla2xxx_err_handler = { 4474 + static const struct pci_error_handlers qla2xxx_err_handler = { 4475 4475 .error_detected = qla2xxx_pci_error_detected, 4476 4476 .mmio_enabled = qla2xxx_pci_mmio_enabled, 4477 4477 .slot_reset = qla2xxx_pci_slot_reset,
+1 -3
drivers/scsi/qla4xxx/ql4_nx.c
··· 1566 1566 static int 1567 1567 qla4_8xxx_start_firmware(struct scsi_qla_host *ha, uint32_t image_start) 1568 1568 { 1569 - int pcie_cap; 1570 1569 uint16_t lnk; 1571 1570 1572 1571 /* scrub dma mask expansion register */ ··· 1589 1590 } 1590 1591 1591 1592 /* Negotiated Link width */ 1592 - pcie_cap = pci_pcie_cap(ha->pdev); 1593 - pci_read_config_word(ha->pdev, pcie_cap + PCI_EXP_LNKSTA, &lnk); 1593 + pcie_capability_read_word(ha->pdev, PCI_EXP_LNKSTA, &lnk); 1594 1594 ha->link_width = (lnk >> 4) & 0x3f; 1595 1595 1596 1596 /* Synchronize with Receive peg */
+1 -1
drivers/scsi/qla4xxx/ql4_os.c
··· 6148 6148 clear_bit(AF_EEH_BUSY, &ha->flags); 6149 6149 } 6150 6150 6151 - static struct pci_error_handlers qla4xxx_err_handler = { 6151 + static const struct pci_error_handlers qla4xxx_err_handler = { 6152 6152 .error_detected = qla4xxx_pci_error_detected, 6153 6153 .mmio_enabled = qla4xxx_pci_mmio_enabled, 6154 6154 .slot_reset = qla4xxx_pci_slot_reset,
+1 -1
drivers/scsi/sym53c8xx_2/sym_glue.c
··· 2117 2117 2118 2118 MODULE_DEVICE_TABLE(pci, sym2_id_table); 2119 2119 2120 - static struct pci_error_handlers sym2_err_handler = { 2120 + static const struct pci_error_handlers sym2_err_handler = { 2121 2121 .error_detected = sym2_io_error_detected, 2122 2122 .mmio_enabled = sym2_io_slot_dump, 2123 2123 .slot_reset = sym2_io_slot_reset,
+5 -14
drivers/staging/et131x/et131x.c
··· 3995 3995 static int et131x_pci_init(struct et131x_adapter *adapter, 3996 3996 struct pci_dev *pdev) 3997 3997 { 3998 - int cap = pci_pcie_cap(pdev); 3999 3998 u16 max_payload; 4000 - u16 ctl; 4001 3999 int i, rc; 4002 4000 4003 4001 rc = et131x_init_eeprom(adapter); 4004 4002 if (rc < 0) 4005 4003 goto out; 4006 4004 4007 - if (!cap) { 4005 + if (!pci_is_pcie(pdev)) { 4008 4006 dev_err(&pdev->dev, "Missing PCIe capabilities\n"); 4009 4007 goto err_out; 4010 4008 } ··· 4010 4012 /* Let's set up the PORT LOGIC Register. First we need to know what 4011 4013 * the max_payload_size is 4012 4014 */ 4013 - if (pci_read_config_word(pdev, cap + PCI_EXP_DEVCAP, &max_payload)) { 4015 + if (pcie_capability_read_word(pdev, PCI_EXP_DEVCAP, &max_payload)) { 4014 4016 dev_err(&pdev->dev, 4015 4017 "Could not read PCI config space for Max Payload Size\n"); 4016 4018 goto err_out; ··· 4047 4049 } 4048 4050 4049 4051 /* Change the max read size to 2k */ 4050 - if (pci_read_config_word(pdev, cap + PCI_EXP_DEVCTL, &ctl)) { 4052 + if (pcie_capability_clear_and_set_word(pdev, PCI_EXP_DEVCTL, 4053 + PCI_EXP_DEVCTL_READRQ, 0x4 << 12)) { 4051 4054 dev_err(&pdev->dev, 4052 - "Could not read PCI config space for Max read size\n"); 4053 - goto err_out; 4054 - } 4055 - 4056 - ctl = (ctl & ~PCI_EXP_DEVCTL_READRQ) | (0x04 << 12); 4057 - 4058 - if (pci_write_config_word(pdev, cap + PCI_EXP_DEVCTL, ctl)) { 4059 - dev_err(&pdev->dev, 4060 - "Could not write PCI config space for Max read size\n"); 4055 + "Couldn't change PCI config space for Max read size\n"); 4061 4056 goto err_out; 4062 4057 } 4063 4058
+3 -5
drivers/staging/rtl8192e/rtl8192e/rtl_pci.c
··· 31 31 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); 32 32 33 33 u8 tmp; 34 - int pos; 35 - u8 LinkCtrlReg; 34 + u16 LinkCtrlReg; 36 35 37 - pos = pci_find_capability(priv->pdev, PCI_CAP_ID_EXP); 38 - pci_read_config_byte(priv->pdev, pos + PCI_EXP_LNKCTL, &LinkCtrlReg); 39 - priv->NdisAdapter.LinkCtrlReg = LinkCtrlReg; 36 + pcie_capability_read_word(priv->pdev, PCI_EXP_LNKCTL, &LinkCtrlReg); 37 + priv->NdisAdapter.LinkCtrlReg = (u8)LinkCtrlReg; 40 38 41 39 RT_TRACE(COMP_INIT, "Link Control Register =%x\n", 42 40 priv->NdisAdapter.LinkCtrlReg);
+1 -1
drivers/tty/serial/8250/8250_pci.c
··· 4236 4236 pciserial_resume_ports(priv); 4237 4237 } 4238 4238 4239 - static struct pci_error_handlers serial8250_err_handler = { 4239 + static const struct pci_error_handlers serial8250_err_handler = { 4240 4240 .error_detected = serial8250_io_error_detected, 4241 4241 .slot_reset = serial8250_io_slot_reset, 4242 4242 .resume = serial8250_io_resume,
+1 -1
drivers/tty/serial/jsm/jsm_driver.c
··· 54 54 static pci_ers_result_t jsm_io_slot_reset(struct pci_dev *pdev); 55 55 static void jsm_io_resume(struct pci_dev *pdev); 56 56 57 - static struct pci_error_handlers jsm_err_handler = { 57 + static const struct pci_error_handlers jsm_err_handler = { 58 58 .error_detected = jsm_io_error_detected, 59 59 .slot_reset = jsm_io_slot_reset, 60 60 .resume = jsm_io_resume,
+1 -1
drivers/xen/xen-pciback/pci_stub.c
··· 871 871 } 872 872 873 873 /*add xen_pcibk AER handling*/ 874 - static struct pci_error_handlers xen_pcibk_error_handler = { 874 + static const struct pci_error_handlers xen_pcibk_error_handler = { 875 875 .error_detected = xen_pcibk_error_detected, 876 876 .mmio_enabled = xen_pcibk_mmio_enabled, 877 877 .slot_reset = xen_pcibk_slot_reset,
+3 -3
include/linux/acpi.h
··· 138 138 void acpi_pci_irq_disable (struct pci_dev *dev); 139 139 140 140 struct acpi_pci_driver { 141 - struct acpi_pci_driver *next; 142 - int (*add)(acpi_handle handle); 143 - void (*remove)(acpi_handle handle); 141 + struct list_head node; 142 + int (*add)(struct acpi_pci_root *root); 143 + void (*remove)(struct acpi_pci_root *root); 144 144 }; 145 145 146 146 int acpi_pci_register_driver(struct acpi_pci_driver *driver);
+11 -6
include/linux/pci-acpi.h
··· 22 22 static inline acpi_handle acpi_find_root_bridge_handle(struct pci_dev *pdev) 23 23 { 24 24 struct pci_bus *pbus = pdev->bus; 25 + 25 26 /* Find a PCI root bus */ 26 27 while (!pci_is_root_bus(pbus)) 27 28 pbus = pbus->parent; 28 - return acpi_get_pci_rootbridge_handle(pci_domain_nr(pbus), 29 - pbus->number); 29 + 30 + return DEVICE_ACPI_HANDLE(pbus->bridge); 30 31 } 31 32 32 33 static inline acpi_handle acpi_pci_get_bridge_handle(struct pci_bus *pbus) 33 34 { 34 - if (!pci_is_root_bus(pbus)) 35 - return DEVICE_ACPI_HANDLE(&(pbus->self->dev)); 36 - return acpi_get_pci_rootbridge_handle(pci_domain_nr(pbus), 37 - pbus->number); 35 + struct device *dev; 36 + 37 + if (pci_is_root_bus(pbus)) 38 + dev = pbus->bridge; 39 + else 40 + dev = &pbus->self->dev; 41 + 42 + return DEVICE_ACPI_HANDLE(dev); 38 43 } 39 44 #endif 40 45
+48 -7
include/linux/pci.h
··· 254 254 u8 revision; /* PCI revision, low byte of class word */ 255 255 u8 hdr_type; /* PCI header type (`multi' flag masked out) */ 256 256 u8 pcie_cap; /* PCI-E capability offset */ 257 - u8 pcie_type:4; /* PCI-E device/port type */ 258 257 u8 pcie_mpss:3; /* PCI-E Max Payload Size Supported */ 259 258 u8 rom_base_reg; /* which config register controls the ROM */ 260 259 u8 pin; /* which interrupt pin this device uses */ 260 + u16 pcie_flags_reg; /* cached PCI-E Capabilities Register */ 261 261 262 262 struct pci_driver *driver; /* which driver has allocated this device */ 263 263 u64 dma_mask; /* Mask of the bits of bus address this ··· 369 369 370 370 extern struct pci_dev *alloc_pci_dev(void); 371 371 372 - #define pci_dev_b(n) list_entry(n, struct pci_dev, bus_list) 373 372 #define to_pci_dev(n) container_of(n, struct pci_dev, dev) 374 373 #define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL) 375 374 ··· 595 596 int (*resume_early) (struct pci_dev *dev); 596 597 int (*resume) (struct pci_dev *dev); /* Device woken up */ 597 598 void (*shutdown) (struct pci_dev *dev); 598 - struct pci_error_handlers *err_handler; 599 + const struct pci_error_handlers *err_handler; 599 600 struct device_driver driver; 600 601 struct pci_dynids dynids; 601 602 }; ··· 733 734 extern struct pci_dev *pci_dev_get(struct pci_dev *dev); 734 735 extern void pci_dev_put(struct pci_dev *dev); 735 736 extern void pci_remove_bus(struct pci_bus *b); 736 - extern void __pci_remove_bus_device(struct pci_dev *dev); 737 737 extern void pci_stop_and_remove_bus_device(struct pci_dev *dev); 738 - extern void pci_stop_bus_device(struct pci_dev *dev); 739 738 void pci_setup_cardbus(struct pci_bus *bus); 740 739 extern void pci_sort_breadthfirst(void); 741 740 #define dev_is_pci(d) ((d)->bus == &pci_bus_type) ··· 752 755 int pci_find_capability(struct pci_dev *dev, int cap); 753 756 int pci_find_next_capability(struct pci_dev *dev, u8 pos, int cap); 754 757 int pci_find_ext_capability(struct pci_dev *dev, int cap); 758 + int pci_find_next_ext_capability(struct pci_dev *dev, int pos, int cap); 755 759 int pci_find_ht_capability(struct pci_dev *dev, int ht_cap); 756 760 int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap); 757 761 struct pci_bus *pci_find_next_bus(const struct pci_bus *from); ··· 812 814 u32 val) 813 815 { 814 816 return pci_bus_write_config_dword(dev->bus, dev->devfn, where, val); 817 + } 818 + 819 + int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val); 820 + int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val); 821 + int pcie_capability_write_word(struct pci_dev *dev, int pos, u16 val); 822 + int pcie_capability_write_dword(struct pci_dev *dev, int pos, u32 val); 823 + int pcie_capability_clear_and_set_word(struct pci_dev *dev, int pos, 824 + u16 clear, u16 set); 825 + int pcie_capability_clear_and_set_dword(struct pci_dev *dev, int pos, 826 + u32 clear, u32 set); 827 + 828 + static inline int pcie_capability_set_word(struct pci_dev *dev, int pos, 829 + u16 set) 830 + { 831 + return pcie_capability_clear_and_set_word(dev, pos, 0, set); 832 + } 833 + 834 + static inline int pcie_capability_set_dword(struct pci_dev *dev, int pos, 835 + u32 set) 836 + { 837 + return pcie_capability_clear_and_set_dword(dev, pos, 0, set); 838 + } 839 + 840 + static inline int pcie_capability_clear_word(struct pci_dev *dev, int pos, 841 + u16 clear) 842 + { 843 + return pcie_capability_clear_and_set_word(dev, pos, clear, 0); 844 + } 845 + 846 + static inline int pcie_capability_clear_dword(struct pci_dev *dev, int pos, 847 + u32 clear) 848 + { 849 + return pcie_capability_clear_and_set_dword(dev, pos, clear, 0); 815 850 } 816 851 817 852 /* user-space driven config access */ ··· 1044 1013 module_driver(__pci_driver, pci_register_driver, \ 1045 1014 pci_unregister_driver) 1046 1015 1047 - void pci_stop_and_remove_behind_bridge(struct pci_dev *dev); 1048 1016 struct pci_driver *pci_dev_driver(const struct pci_dev *dev); 1049 1017 int pci_add_dynid(struct pci_driver *drv, 1050 1018 unsigned int vendor, unsigned int device, ··· 1061 1031 int pci_cfg_space_size(struct pci_dev *dev); 1062 1032 unsigned char pci_bus_max_busnr(struct pci_bus *bus); 1063 1033 void pci_setup_bridge(struct pci_bus *bus); 1034 + resource_size_t pcibios_window_alignment(struct pci_bus *bus, 1035 + unsigned long type); 1064 1036 1065 1037 #define PCI_VGA_STATE_CHANGE_BRIDGE (1 << 0) 1066 1038 #define PCI_VGA_STATE_CHANGE_DECODES (1 << 1) ··· 1504 1472 /* Anonymous variables would be nice... */ 1505 1473 #define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, class, \ 1506 1474 class_shift, hook) \ 1507 - static const struct pci_fixup const __pci_fixup_##name __used \ 1475 + static const struct pci_fixup __pci_fixup_##name __used \ 1508 1476 __attribute__((__section__(#section), aligned((sizeof(void *))))) \ 1509 1477 = { vendor, device, class, class_shift, hook }; 1510 1478 ··· 1680 1648 static inline bool pci_is_pcie(struct pci_dev *dev) 1681 1649 { 1682 1650 return !!pci_pcie_cap(dev); 1651 + } 1652 + 1653 + /** 1654 + * pci_pcie_type - get the PCIe device/port type 1655 + * @dev: PCI device 1656 + */ 1657 + static inline int pci_pcie_type(const struct pci_dev *dev) 1658 + { 1659 + return (dev->pcie_flags_reg & PCI_EXP_FLAGS_TYPE) >> 4; 1683 1660 } 1684 1661 1685 1662 void pci_request_acs(void);
+7
include/linux/pci_regs.h
··· 549 549 #define PCI_EXP_LNKCAP2_SLS_8_0GB 0x04 /* Current Link Speed 8.0GT/s */ 550 550 #define PCI_EXP_LNKCAP2_CROSSLINK 0x100 /* Crosslink supported */ 551 551 #define PCI_EXP_LNKCTL2 48 /* Link Control 2 */ 552 + #define PCI_EXP_LNKSTA2 50 /* Link Status 2 */ 552 553 #define PCI_EXP_SLTCTL2 56 /* Slot Control 2 */ 553 554 554 555 /* Extended Capabilities (PCI-X 2.0 and Express) */ ··· 677 676 #define PCI_PWR_CAP 12 /* Capability */ 678 677 #define PCI_PWR_CAP_BUDGET(x) ((x) & 1) /* Included in system budget */ 679 678 #define PCI_EXT_CAP_PWR_SIZEOF 16 679 + 680 + /* Vendor-Specific (VSEC, PCI_EXT_CAP_ID_VNDR) */ 681 + #define PCI_VNDR_HEADER 4 /* Vendor-Specific Header */ 682 + #define PCI_VNDR_HEADER_ID(x) ((x) & 0xffff) 683 + #define PCI_VNDR_HEADER_REV(x) (((x) >> 16) & 0xf) 684 + #define PCI_VNDR_HEADER_LEN(x) (((x) >> 20) & 0xfff) 680 685 681 686 /* 682 687 * Hypertransport sub capability types
+1 -1
include/linux/pcieport_if.h
··· 49 49 int (*resume) (struct pcie_device *dev); 50 50 51 51 /* Service Error Recovery Handler */ 52 - struct pci_error_handlers *err_handler; 52 + const struct pci_error_handlers *err_handler; 53 53 54 54 /* Link Reset Capability - AER service driver specific */ 55 55 pci_ers_result_t (*reset_link) (struct pci_dev *dev);