diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-13 15:14:47 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-13 15:14:47 -0500 |
commit | 193c0d682525987db59ac3a24531a77e4947aa95 (patch) | |
tree | 7b58346171c4d07e2c2ee6c3c469c325495149a4 /drivers | |
parent | 8b0cab14951fbf8126795ab301835a8f8126a988 (diff) | |
parent | 1cb73f8c479e66541fefd3f7fa547b1fa56cdc54 (diff) |
Merge tag 'for-3.8' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci
Pull PCI update from Bjorn Helgaas:
"Host bridge hotplug:
- Untangle _PRT from struct pci_bus (Bjorn Helgaas)
- Request _OSC control before scanning root bus (Taku Izumi)
- Assign resources when adding host bridge (Yinghai Lu)
- Remove root bus when removing host bridge (Yinghai Lu)
- Remove _PRT during hot remove (Yinghai Lu)
SRIOV
- Add sysfs knobs to control numVFs (Don Dutile)
Power management
- Notify devices when power resource turned on (Huang Ying)
Bug fixes
- Work around broken _SEG on HP xw9300 (Bjorn Helgaas)
- Keep runtime PM enabled for unbound PCI devices (Huang Ying)
- Fix Optimus dual-GPU runtime D3 suspend issue (Dave Airlie)
- Fix xen frontend shutdown issue (David Vrabel)
- Work around PLX PCI 9050 BAR alignment erratum (Ian Abbott)
Miscellaneous
- Add GPL license for drivers/pci/ioapic (Andrew Cooks)
- Add standard PCI-X, PCIe ASPM register #defines (Bjorn Helgaas)
- NumaChip remote PCI support (Daniel Blueman)
- Fix PCIe Link Capabilities Supported Link Speed definition (Jingoo
Han)
- Convert dev_printk() to dev_info(), etc (Joe Perches)
- Add support for non PCI BAR ROM data (Matthew Garrett)
- Add x86 support for host bridge translation offset (Mike Yoknis)
- Report success only when every driver supports AER (Vijay
Pandarathil)"
Fix up trivial conflicts.
* tag 'for-3.8' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (48 commits)
PCI: Use phys_addr_t for physical ROM address
x86/PCI: Add NumaChip remote PCI support
ath9k: Use standard #defines for PCIe Capability ASPM fields
iwlwifi: Use standard #defines for PCIe Capability ASPM fields
iwlwifi: collapse wrapper for pcie_capability_read_word()
iwlegacy: Use standard #defines for PCIe Capability ASPM fields
iwlegacy: collapse wrapper for pcie_capability_read_word()
cxgb3: Use standard #defines for PCIe Capability ASPM fields
PCI: Add standard PCIe Capability Link ASPM field names
PCI/portdrv: Use PCI Express Capability accessors
PCI: Use standard PCIe Capability Link register field names
x86: Use PCI setup data
PCI: Add support for non-BAR ROMs
PCI: Add pcibios_add_device
EFI: Stash ROMs if they're not in the PCI BAR
PCI: Add and use standard PCI-X Capability register names
PCI/PM: Keep runtime PM enabled for unbound PCI devices
xen-pcifront: Handle backend CLOSED without CLOSING
PCI: SRIOV control and status via sysfs (documentation)
PCI/AER: Report success only when every device has AER-aware driver
...
Diffstat (limited to 'drivers')
28 files changed, 601 insertions, 247 deletions
diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c index 2ef04098cc1d..a1dee29beed3 100644 --- a/drivers/acpi/pci_bind.c +++ b/drivers/acpi/pci_bind.c | |||
@@ -45,11 +45,12 @@ static int acpi_pci_unbind(struct acpi_device *device) | |||
45 | 45 | ||
46 | device_set_run_wake(&dev->dev, false); | 46 | device_set_run_wake(&dev->dev, false); |
47 | pci_acpi_remove_pm_notifier(device); | 47 | pci_acpi_remove_pm_notifier(device); |
48 | acpi_power_resource_unregister_device(&dev->dev, device->handle); | ||
48 | 49 | ||
49 | if (!dev->subordinate) | 50 | if (!dev->subordinate) |
50 | goto out; | 51 | goto out; |
51 | 52 | ||
52 | acpi_pci_irq_del_prt(dev->subordinate); | 53 | acpi_pci_irq_del_prt(pci_domain_nr(dev->bus), dev->subordinate->number); |
53 | 54 | ||
54 | device->ops.bind = NULL; | 55 | device->ops.bind = NULL; |
55 | device->ops.unbind = NULL; | 56 | device->ops.unbind = NULL; |
@@ -63,7 +64,7 @@ static int acpi_pci_bind(struct acpi_device *device) | |||
63 | { | 64 | { |
64 | acpi_status status; | 65 | acpi_status status; |
65 | acpi_handle handle; | 66 | acpi_handle handle; |
66 | struct pci_bus *bus; | 67 | unsigned char bus; |
67 | struct pci_dev *dev; | 68 | struct pci_dev *dev; |
68 | 69 | ||
69 | dev = acpi_get_pci_dev(device->handle); | 70 | dev = acpi_get_pci_dev(device->handle); |
@@ -71,6 +72,7 @@ static int acpi_pci_bind(struct acpi_device *device) | |||
71 | return 0; | 72 | return 0; |
72 | 73 | ||
73 | pci_acpi_add_pm_notifier(device, dev); | 74 | pci_acpi_add_pm_notifier(device, dev); |
75 | acpi_power_resource_register_device(&dev->dev, device->handle); | ||
74 | if (device->wakeup.flags.run_wake) | 76 | if (device->wakeup.flags.run_wake) |
75 | device_set_run_wake(&dev->dev, true); | 77 | device_set_run_wake(&dev->dev, true); |
76 | 78 | ||
@@ -100,11 +102,11 @@ static int acpi_pci_bind(struct acpi_device *device) | |||
100 | goto out; | 102 | goto out; |
101 | 103 | ||
102 | if (dev->subordinate) | 104 | if (dev->subordinate) |
103 | bus = dev->subordinate; | 105 | bus = dev->subordinate->number; |
104 | else | 106 | else |
105 | bus = dev->bus; | 107 | bus = dev->bus->number; |
106 | 108 | ||
107 | acpi_pci_irq_add_prt(device->handle, bus); | 109 | acpi_pci_irq_add_prt(device->handle, pci_domain_nr(dev->bus), bus); |
108 | 110 | ||
109 | out: | 111 | out: |
110 | pci_dev_put(dev); | 112 | pci_dev_put(dev); |
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c index 23a032490130..68a921d03247 100644 --- a/drivers/acpi/pci_irq.c +++ b/drivers/acpi/pci_irq.c | |||
@@ -184,7 +184,7 @@ static void do_prt_fixups(struct acpi_prt_entry *entry, | |||
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | static int acpi_pci_irq_add_entry(acpi_handle handle, struct pci_bus *bus, | 187 | static int acpi_pci_irq_add_entry(acpi_handle handle, int segment, int bus, |
188 | struct acpi_pci_routing_table *prt) | 188 | struct acpi_pci_routing_table *prt) |
189 | { | 189 | { |
190 | struct acpi_prt_entry *entry; | 190 | struct acpi_prt_entry *entry; |
@@ -198,8 +198,8 @@ static int acpi_pci_irq_add_entry(acpi_handle handle, struct pci_bus *bus, | |||
198 | * 1=INTA, 2=INTB. We use the PCI encoding throughout, so convert | 198 | * 1=INTA, 2=INTB. We use the PCI encoding throughout, so convert |
199 | * it here. | 199 | * it here. |
200 | */ | 200 | */ |
201 | entry->id.segment = pci_domain_nr(bus); | 201 | entry->id.segment = segment; |
202 | entry->id.bus = bus->number; | 202 | entry->id.bus = bus; |
203 | entry->id.device = (prt->address >> 16) & 0xFFFF; | 203 | entry->id.device = (prt->address >> 16) & 0xFFFF; |
204 | entry->pin = prt->pin + 1; | 204 | entry->pin = prt->pin + 1; |
205 | 205 | ||
@@ -244,7 +244,7 @@ static int acpi_pci_irq_add_entry(acpi_handle handle, struct pci_bus *bus, | |||
244 | return 0; | 244 | return 0; |
245 | } | 245 | } |
246 | 246 | ||
247 | int acpi_pci_irq_add_prt(acpi_handle handle, struct pci_bus *bus) | 247 | int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus) |
248 | { | 248 | { |
249 | acpi_status status; | 249 | acpi_status status; |
250 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | 250 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
@@ -273,7 +273,7 @@ int acpi_pci_irq_add_prt(acpi_handle handle, struct pci_bus *bus) | |||
273 | 273 | ||
274 | entry = buffer.pointer; | 274 | entry = buffer.pointer; |
275 | while (entry && (entry->length > 0)) { | 275 | while (entry && (entry->length > 0)) { |
276 | acpi_pci_irq_add_entry(handle, bus, entry); | 276 | acpi_pci_irq_add_entry(handle, segment, bus, entry); |
277 | entry = (struct acpi_pci_routing_table *) | 277 | entry = (struct acpi_pci_routing_table *) |
278 | ((unsigned long)entry + entry->length); | 278 | ((unsigned long)entry + entry->length); |
279 | } | 279 | } |
@@ -282,17 +282,16 @@ int acpi_pci_irq_add_prt(acpi_handle handle, struct pci_bus *bus) | |||
282 | return 0; | 282 | return 0; |
283 | } | 283 | } |
284 | 284 | ||
285 | void acpi_pci_irq_del_prt(struct pci_bus *bus) | 285 | void acpi_pci_irq_del_prt(int segment, int bus) |
286 | { | 286 | { |
287 | struct acpi_prt_entry *entry, *tmp; | 287 | struct acpi_prt_entry *entry, *tmp; |
288 | 288 | ||
289 | printk(KERN_DEBUG | 289 | printk(KERN_DEBUG |
290 | "ACPI: Delete PCI Interrupt Routing Table for %04x:%02x\n", | 290 | "ACPI: Delete PCI Interrupt Routing Table for %04x:%02x\n", |
291 | pci_domain_nr(bus), bus->number); | 291 | segment, bus); |
292 | spin_lock(&acpi_prt_lock); | 292 | spin_lock(&acpi_prt_lock); |
293 | list_for_each_entry_safe(entry, tmp, &acpi_prt_list, list) { | 293 | list_for_each_entry_safe(entry, tmp, &acpi_prt_list, list) { |
294 | if (pci_domain_nr(bus) == entry->id.segment | 294 | if (segment == entry->id.segment && bus == entry->id.bus) { |
295 | && bus->number == entry->id.bus) { | ||
296 | list_del(&entry->list); | 295 | list_del(&entry->list); |
297 | kfree(entry); | 296 | kfree(entry); |
298 | } | 297 | } |
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index f70b9e5fc1b5..7928d4dc7056 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c | |||
@@ -454,6 +454,7 @@ static int acpi_pci_root_add(struct acpi_device *device) | |||
454 | acpi_handle handle; | 454 | acpi_handle handle; |
455 | struct acpi_device *child; | 455 | struct acpi_device *child; |
456 | u32 flags, base_flags; | 456 | u32 flags, base_flags; |
457 | bool is_osc_granted = false; | ||
457 | 458 | ||
458 | root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); | 459 | root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); |
459 | if (!root) | 460 | if (!root) |
@@ -501,85 +502,47 @@ static int acpi_pci_root_add(struct acpi_device *device) | |||
501 | strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS); | 502 | strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS); |
502 | device->driver_data = root; | 503 | device->driver_data = root; |
503 | 504 | ||
504 | root->mcfg_addr = acpi_pci_root_get_mcfg_addr(device->handle); | ||
505 | |||
506 | /* | ||
507 | * All supported architectures that use ACPI have support for | ||
508 | * PCI domains, so we indicate this in _OSC support capabilities. | ||
509 | */ | ||
510 | flags = base_flags = OSC_PCI_SEGMENT_GROUPS_SUPPORT; | ||
511 | acpi_pci_osc_support(root, flags); | ||
512 | |||
513 | /* | ||
514 | * TBD: Need PCI interface for enumeration/configuration of roots. | ||
515 | */ | ||
516 | |||
517 | mutex_lock(&acpi_pci_root_lock); | ||
518 | list_add_tail(&root->node, &acpi_pci_roots); | ||
519 | mutex_unlock(&acpi_pci_root_lock); | ||
520 | |||
521 | printk(KERN_INFO PREFIX "%s [%s] (domain %04x %pR)\n", | 505 | printk(KERN_INFO PREFIX "%s [%s] (domain %04x %pR)\n", |
522 | acpi_device_name(device), acpi_device_bid(device), | 506 | acpi_device_name(device), acpi_device_bid(device), |
523 | root->segment, &root->secondary); | 507 | root->segment, &root->secondary); |
524 | 508 | ||
525 | /* | 509 | /* |
526 | * Scan the Root Bridge | ||
527 | * -------------------- | ||
528 | * Must do this prior to any attempt to bind the root device, as the | ||
529 | * PCI namespace does not get created until this call is made (and | ||
530 | * thus the root bridge's pci_dev does not exist). | ||
531 | */ | ||
532 | root->bus = pci_acpi_scan_root(root); | ||
533 | if (!root->bus) { | ||
534 | printk(KERN_ERR PREFIX | ||
535 | "Bus %04x:%02x not present in PCI namespace\n", | ||
536 | root->segment, (unsigned int)root->secondary.start); | ||
537 | result = -ENODEV; | ||
538 | goto out_del_root; | ||
539 | } | ||
540 | |||
541 | /* | ||
542 | * Attach ACPI-PCI Context | ||
543 | * ----------------------- | ||
544 | * Thus binding the ACPI and PCI devices. | ||
545 | */ | ||
546 | result = acpi_pci_bind_root(device); | ||
547 | if (result) | ||
548 | goto out_del_root; | ||
549 | |||
550 | /* | ||
551 | * PCI Routing Table | 510 | * PCI Routing Table |
552 | * ----------------- | 511 | * ----------------- |
553 | * Evaluate and parse _PRT, if exists. | 512 | * Evaluate and parse _PRT, if exists. |
554 | */ | 513 | */ |
555 | status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle); | 514 | status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle); |
556 | if (ACPI_SUCCESS(status)) | 515 | if (ACPI_SUCCESS(status)) |
557 | result = acpi_pci_irq_add_prt(device->handle, root->bus); | 516 | result = acpi_pci_irq_add_prt(device->handle, root->segment, |
517 | root->secondary.start); | ||
518 | |||
519 | root->mcfg_addr = acpi_pci_root_get_mcfg_addr(device->handle); | ||
558 | 520 | ||
559 | /* | 521 | /* |
560 | * Scan and bind all _ADR-Based Devices | 522 | * All supported architectures that use ACPI have support for |
523 | * PCI domains, so we indicate this in _OSC support capabilities. | ||
561 | */ | 524 | */ |
562 | list_for_each_entry(child, &device->children, node) | 525 | flags = base_flags = OSC_PCI_SEGMENT_GROUPS_SUPPORT; |
563 | acpi_pci_bridge_scan(child); | 526 | acpi_pci_osc_support(root, flags); |
564 | 527 | ||
565 | /* Indicate support for various _OSC capabilities. */ | 528 | /* Indicate support for various _OSC capabilities. */ |
566 | if (pci_ext_cfg_avail(root->bus->self)) | 529 | if (pci_ext_cfg_avail()) |
567 | flags |= OSC_EXT_PCI_CONFIG_SUPPORT; | 530 | flags |= OSC_EXT_PCI_CONFIG_SUPPORT; |
568 | if (pcie_aspm_support_enabled()) | 531 | if (pcie_aspm_support_enabled()) { |
569 | flags |= OSC_ACTIVE_STATE_PWR_SUPPORT | | 532 | flags |= OSC_ACTIVE_STATE_PWR_SUPPORT | |
570 | OSC_CLOCK_PWR_CAPABILITY_SUPPORT; | 533 | OSC_CLOCK_PWR_CAPABILITY_SUPPORT; |
534 | } | ||
571 | if (pci_msi_enabled()) | 535 | if (pci_msi_enabled()) |
572 | flags |= OSC_MSI_SUPPORT; | 536 | flags |= OSC_MSI_SUPPORT; |
573 | if (flags != base_flags) { | 537 | if (flags != base_flags) { |
574 | status = acpi_pci_osc_support(root, flags); | 538 | status = acpi_pci_osc_support(root, flags); |
575 | if (ACPI_FAILURE(status)) { | 539 | if (ACPI_FAILURE(status)) { |
576 | dev_info(root->bus->bridge, "ACPI _OSC support " | 540 | dev_info(&device->dev, "ACPI _OSC support " |
577 | "notification failed, disabling PCIe ASPM\n"); | 541 | "notification failed, disabling PCIe ASPM\n"); |
578 | pcie_no_aspm(); | 542 | pcie_no_aspm(); |
579 | flags = base_flags; | 543 | flags = base_flags; |
580 | } | 544 | } |
581 | } | 545 | } |
582 | |||
583 | if (!pcie_ports_disabled | 546 | if (!pcie_ports_disabled |
584 | && (flags & ACPI_PCIE_REQ_SUPPORT) == ACPI_PCIE_REQ_SUPPORT) { | 547 | && (flags & ACPI_PCIE_REQ_SUPPORT) == ACPI_PCIE_REQ_SUPPORT) { |
585 | flags = OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL | 548 | flags = OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL |
@@ -588,40 +551,81 @@ static int acpi_pci_root_add(struct acpi_device *device) | |||
588 | 551 | ||
589 | if (pci_aer_available()) { | 552 | if (pci_aer_available()) { |
590 | if (aer_acpi_firmware_first()) | 553 | if (aer_acpi_firmware_first()) |
591 | dev_dbg(root->bus->bridge, | 554 | dev_dbg(&device->dev, |
592 | "PCIe errors handled by BIOS.\n"); | 555 | "PCIe errors handled by BIOS.\n"); |
593 | else | 556 | else |
594 | flags |= OSC_PCI_EXPRESS_AER_CONTROL; | 557 | flags |= OSC_PCI_EXPRESS_AER_CONTROL; |
595 | } | 558 | } |
596 | 559 | ||
597 | dev_info(root->bus->bridge, | 560 | dev_info(&device->dev, |
598 | "Requesting ACPI _OSC control (0x%02x)\n", flags); | 561 | "Requesting ACPI _OSC control (0x%02x)\n", flags); |
599 | 562 | ||
600 | status = acpi_pci_osc_control_set(device->handle, &flags, | 563 | status = acpi_pci_osc_control_set(device->handle, &flags, |
601 | OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL); | 564 | OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL); |
602 | if (ACPI_SUCCESS(status)) { | 565 | if (ACPI_SUCCESS(status)) { |
603 | dev_info(root->bus->bridge, | 566 | is_osc_granted = true; |
567 | dev_info(&device->dev, | ||
604 | "ACPI _OSC control (0x%02x) granted\n", flags); | 568 | "ACPI _OSC control (0x%02x) granted\n", flags); |
605 | if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) { | ||
606 | /* | ||
607 | * We have ASPM control, but the FADT indicates | ||
608 | * that it's unsupported. Clear it. | ||
609 | */ | ||
610 | pcie_clear_aspm(root->bus); | ||
611 | } | ||
612 | } else { | 569 | } else { |
613 | dev_info(root->bus->bridge, | 570 | is_osc_granted = false; |
571 | dev_info(&device->dev, | ||
614 | "ACPI _OSC request failed (%s), " | 572 | "ACPI _OSC request failed (%s), " |
615 | "returned control mask: 0x%02x\n", | 573 | "returned control mask: 0x%02x\n", |
616 | acpi_format_exception(status), flags); | 574 | acpi_format_exception(status), flags); |
617 | pr_info("ACPI _OSC control for PCIe not granted, " | ||
618 | "disabling ASPM\n"); | ||
619 | pcie_no_aspm(); | ||
620 | } | 575 | } |
621 | } else { | 576 | } else { |
622 | dev_info(root->bus->bridge, | 577 | dev_info(&device->dev, |
623 | "Unable to request _OSC control " | 578 | "Unable to request _OSC control " |
624 | "(_OSC support mask: 0x%02x)\n", flags); | 579 | "(_OSC support mask: 0x%02x)\n", flags); |
580 | } | ||
581 | |||
582 | /* | ||
583 | * TBD: Need PCI interface for enumeration/configuration of roots. | ||
584 | */ | ||
585 | |||
586 | mutex_lock(&acpi_pci_root_lock); | ||
587 | list_add_tail(&root->node, &acpi_pci_roots); | ||
588 | mutex_unlock(&acpi_pci_root_lock); | ||
589 | |||
590 | /* | ||
591 | * Scan the Root Bridge | ||
592 | * -------------------- | ||
593 | * Must do this prior to any attempt to bind the root device, as the | ||
594 | * PCI namespace does not get created until this call is made (and | ||
595 | * thus the root bridge's pci_dev does not exist). | ||
596 | */ | ||
597 | root->bus = pci_acpi_scan_root(root); | ||
598 | if (!root->bus) { | ||
599 | printk(KERN_ERR PREFIX | ||
600 | "Bus %04x:%02x not present in PCI namespace\n", | ||
601 | root->segment, (unsigned int)root->secondary.start); | ||
602 | result = -ENODEV; | ||
603 | goto out_del_root; | ||
604 | } | ||
605 | |||
606 | /* | ||
607 | * Attach ACPI-PCI Context | ||
608 | * ----------------------- | ||
609 | * Thus binding the ACPI and PCI devices. | ||
610 | */ | ||
611 | result = acpi_pci_bind_root(device); | ||
612 | if (result) | ||
613 | goto out_del_root; | ||
614 | |||
615 | /* | ||
616 | * Scan and bind all _ADR-Based Devices | ||
617 | */ | ||
618 | list_for_each_entry(child, &device->children, node) | ||
619 | acpi_pci_bridge_scan(child); | ||
620 | |||
621 | /* ASPM setting */ | ||
622 | if (is_osc_granted) { | ||
623 | if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) | ||
624 | pcie_clear_aspm(root->bus); | ||
625 | } else { | ||
626 | pr_info("ACPI _OSC control for PCIe not granted, " | ||
627 | "disabling ASPM\n"); | ||
628 | pcie_no_aspm(); | ||
625 | } | 629 | } |
626 | 630 | ||
627 | pci_acpi_add_bus_pm_notifier(device, root->bus); | 631 | pci_acpi_add_bus_pm_notifier(device, root->bus); |
@@ -634,6 +638,8 @@ out_del_root: | |||
634 | mutex_lock(&acpi_pci_root_lock); | 638 | mutex_lock(&acpi_pci_root_lock); |
635 | list_del(&root->node); | 639 | list_del(&root->node); |
636 | mutex_unlock(&acpi_pci_root_lock); | 640 | mutex_unlock(&acpi_pci_root_lock); |
641 | |||
642 | acpi_pci_irq_del_prt(root->segment, root->secondary.start); | ||
637 | end: | 643 | end: |
638 | kfree(root); | 644 | kfree(root); |
639 | return result; | 645 | return result; |
@@ -644,12 +650,19 @@ static int acpi_pci_root_start(struct acpi_device *device) | |||
644 | struct acpi_pci_root *root = acpi_driver_data(device); | 650 | struct acpi_pci_root *root = acpi_driver_data(device); |
645 | struct acpi_pci_driver *driver; | 651 | struct acpi_pci_driver *driver; |
646 | 652 | ||
653 | if (system_state != SYSTEM_BOOTING) | ||
654 | pci_assign_unassigned_bus_resources(root->bus); | ||
655 | |||
647 | mutex_lock(&acpi_pci_root_lock); | 656 | mutex_lock(&acpi_pci_root_lock); |
648 | list_for_each_entry(driver, &acpi_pci_drivers, node) | 657 | list_for_each_entry(driver, &acpi_pci_drivers, node) |
649 | if (driver->add) | 658 | if (driver->add) |
650 | driver->add(root); | 659 | driver->add(root); |
651 | mutex_unlock(&acpi_pci_root_lock); | 660 | mutex_unlock(&acpi_pci_root_lock); |
652 | 661 | ||
662 | /* need to after hot-added ioapic is registered */ | ||
663 | if (system_state != SYSTEM_BOOTING) | ||
664 | pci_enable_bridges(root->bus); | ||
665 | |||
653 | pci_bus_add_devices(root->bus); | 666 | pci_bus_add_devices(root->bus); |
654 | 667 | ||
655 | return 0; | 668 | return 0; |
@@ -657,17 +670,29 @@ static int acpi_pci_root_start(struct acpi_device *device) | |||
657 | 670 | ||
658 | static int acpi_pci_root_remove(struct acpi_device *device, int type) | 671 | static int acpi_pci_root_remove(struct acpi_device *device, int type) |
659 | { | 672 | { |
673 | acpi_status status; | ||
674 | acpi_handle handle; | ||
660 | struct acpi_pci_root *root = acpi_driver_data(device); | 675 | struct acpi_pci_root *root = acpi_driver_data(device); |
661 | struct acpi_pci_driver *driver; | 676 | struct acpi_pci_driver *driver; |
662 | 677 | ||
678 | pci_stop_root_bus(root->bus); | ||
679 | |||
663 | mutex_lock(&acpi_pci_root_lock); | 680 | mutex_lock(&acpi_pci_root_lock); |
664 | list_for_each_entry(driver, &acpi_pci_drivers, node) | 681 | list_for_each_entry_reverse(driver, &acpi_pci_drivers, node) |
665 | if (driver->remove) | 682 | if (driver->remove) |
666 | driver->remove(root); | 683 | driver->remove(root); |
684 | mutex_unlock(&acpi_pci_root_lock); | ||
667 | 685 | ||
668 | device_set_run_wake(root->bus->bridge, false); | 686 | device_set_run_wake(root->bus->bridge, false); |
669 | pci_acpi_remove_bus_pm_notifier(device); | 687 | pci_acpi_remove_bus_pm_notifier(device); |
670 | 688 | ||
689 | status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle); | ||
690 | if (ACPI_SUCCESS(status)) | ||
691 | acpi_pci_irq_del_prt(root->segment, root->secondary.start); | ||
692 | |||
693 | pci_remove_root_bus(root->bus); | ||
694 | |||
695 | mutex_lock(&acpi_pci_root_lock); | ||
671 | list_del(&root->node); | 696 | list_del(&root->node); |
672 | mutex_unlock(&acpi_pci_root_lock); | 697 | mutex_unlock(&acpi_pci_root_lock); |
673 | kfree(root); | 698 | kfree(root); |
diff --git a/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c b/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c index aef45d3113ba..3dee68612c9e 100644 --- a/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c +++ b/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c | |||
@@ -3307,7 +3307,7 @@ static void config_pcie(struct adapter *adap) | |||
3307 | G_NUMFSTTRNSEQRX(t3_read_reg(adap, A_PCIE_MODE)); | 3307 | G_NUMFSTTRNSEQRX(t3_read_reg(adap, A_PCIE_MODE)); |
3308 | log2_width = fls(adap->params.pci.width) - 1; | 3308 | log2_width = fls(adap->params.pci.width) - 1; |
3309 | acklat = ack_lat[log2_width][pldsize]; | 3309 | acklat = ack_lat[log2_width][pldsize]; |
3310 | if (val & 1) /* check LOsEnable */ | 3310 | if (val & PCI_EXP_LNKCTL_ASPM_L0S) /* check LOsEnable */ |
3311 | acklat += fst_trn_tx * 4; | 3311 | acklat += fst_trn_tx * 4; |
3312 | rpllmt = rpl_tmr[log2_width][pldsize] + fst_trn_rx * 4; | 3312 | rpllmt = rpl_tmr[log2_width][pldsize] + fst_trn_rx * 4; |
3313 | 3313 | ||
diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c index 8e9b826f878b..7ae73fbd9136 100644 --- a/drivers/net/wireless/ath/ath9k/pci.c +++ b/drivers/net/wireless/ath/ath9k/pci.c | |||
@@ -114,23 +114,23 @@ static void ath_pci_aspm_init(struct ath_common *common) | |||
114 | 114 | ||
115 | if ((ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) && | 115 | if ((ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) && |
116 | (AR_SREV_9285(ah))) { | 116 | (AR_SREV_9285(ah))) { |
117 | /* Bluetooth coexistance requires disabling ASPM. */ | 117 | /* Bluetooth coexistence requires disabling ASPM. */ |
118 | pcie_capability_clear_word(pdev, PCI_EXP_LNKCTL, | 118 | pcie_capability_clear_word(pdev, PCI_EXP_LNKCTL, |
119 | PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); | 119 | PCI_EXP_LNKCTL_ASPM_L0S | PCI_EXP_LNKCTL_ASPM_L1); |
120 | 120 | ||
121 | /* | 121 | /* |
122 | * Both upstream and downstream PCIe components should | 122 | * Both upstream and downstream PCIe components should |
123 | * have the same ASPM settings. | 123 | * have the same ASPM settings. |
124 | */ | 124 | */ |
125 | pcie_capability_clear_word(parent, PCI_EXP_LNKCTL, | 125 | pcie_capability_clear_word(parent, PCI_EXP_LNKCTL, |
126 | PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); | 126 | PCI_EXP_LNKCTL_ASPM_L0S | PCI_EXP_LNKCTL_ASPM_L1); |
127 | 127 | ||
128 | ath_info(common, "Disabling ASPM since BTCOEX is enabled\n"); | 128 | ath_info(common, "Disabling ASPM since BTCOEX is enabled\n"); |
129 | return; | 129 | return; |
130 | } | 130 | } |
131 | 131 | ||
132 | pcie_capability_read_word(parent, PCI_EXP_LNKCTL, &aspm); | 132 | pcie_capability_read_word(parent, PCI_EXP_LNKCTL, &aspm); |
133 | if (aspm & (PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1)) { | 133 | if (aspm & (PCI_EXP_LNKCTL_ASPM_L0S | PCI_EXP_LNKCTL_ASPM_L1)) { |
134 | ah->aspm_enabled = true; | 134 | ah->aspm_enabled = true; |
135 | /* Initialize PCIe PM and SERDES registers. */ | 135 | /* Initialize PCIe PM and SERDES registers. */ |
136 | ath9k_hw_configpcipowersave(ah, false); | 136 | ath9k_hw_configpcipowersave(ah, false); |
diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h index 2d092f328547..1b15b0b2292b 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h | |||
@@ -917,10 +917,6 @@ struct il4965_scd_bc_tbl { | |||
917 | /* PCI registers */ | 917 | /* PCI registers */ |
918 | #define PCI_CFG_RETRY_TIMEOUT 0x041 | 918 | #define PCI_CFG_RETRY_TIMEOUT 0x041 |
919 | 919 | ||
920 | /* PCI register values */ | ||
921 | #define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01 | ||
922 | #define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02 | ||
923 | |||
924 | #define IL4965_DEFAULT_TX_RETRY 15 | 920 | #define IL4965_DEFAULT_TX_RETRY 15 |
925 | 921 | ||
926 | /* EEPROM */ | 922 | /* EEPROM */ |
diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 318ed3c9fe74..7e16d10a7f14 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c | |||
@@ -1183,9 +1183,10 @@ EXPORT_SYMBOL(il_power_update_mode); | |||
1183 | void | 1183 | void |
1184 | il_power_initialize(struct il_priv *il) | 1184 | il_power_initialize(struct il_priv *il) |
1185 | { | 1185 | { |
1186 | u16 lctl = il_pcie_link_ctl(il); | 1186 | u16 lctl; |
1187 | 1187 | ||
1188 | il->power_data.pci_pm = !(lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN); | 1188 | pcie_capability_read_word(il->pci_dev, PCI_EXP_LNKCTL, &lctl); |
1189 | il->power_data.pci_pm = !(lctl & PCI_EXP_LNKCTL_ASPM_L0S); | ||
1189 | 1190 | ||
1190 | il->power_data.debug_sleep_level_override = -1; | 1191 | il->power_data.debug_sleep_level_override = -1; |
1191 | 1192 | ||
@@ -4233,9 +4234,8 @@ il_apm_init(struct il_priv *il) | |||
4233 | * power savings, even without L1. | 4234 | * power savings, even without L1. |
4234 | */ | 4235 | */ |
4235 | if (il->cfg->set_l0s) { | 4236 | if (il->cfg->set_l0s) { |
4236 | lctl = il_pcie_link_ctl(il); | 4237 | pcie_capability_read_word(il->pci_dev, PCI_EXP_LNKCTL, &lctl); |
4237 | if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) == | 4238 | if (lctl & PCI_EXP_LNKCTL_ASPM_L1) { |
4238 | PCI_CFG_LINK_CTRL_VAL_L1_EN) { | ||
4239 | /* L1-ASPM enabled; disable(!) L0S */ | 4239 | /* L1-ASPM enabled; disable(!) L0S */ |
4240 | il_set_bit(il, CSR_GIO_REG, | 4240 | il_set_bit(il, CSR_GIO_REG, |
4241 | CSR_GIO_REG_VAL_L0S_ENABLED); | 4241 | CSR_GIO_REG_VAL_L0S_ENABLED); |
diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index e254cba4557a..a9a569f432fb 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h | |||
@@ -1829,14 +1829,6 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd); | |||
1829 | * PCI * | 1829 | * PCI * |
1830 | *****************************************************/ | 1830 | *****************************************************/ |
1831 | 1831 | ||
1832 | static inline u16 | ||
1833 | il_pcie_link_ctl(struct il_priv *il) | ||
1834 | { | ||
1835 | u16 pci_lnk_ctl; | ||
1836 | pcie_capability_read_word(il->pci_dev, PCI_EXP_LNKCTL, &pci_lnk_ctl); | ||
1837 | return pci_lnk_ctl; | ||
1838 | } | ||
1839 | |||
1840 | void il_bg_watchdog(unsigned long data); | 1832 | void il_bg_watchdog(unsigned long data); |
1841 | u32 il_usecs_to_beacons(struct il_priv *il, u32 usec, u32 beacon_interval); | 1833 | u32 il_usecs_to_beacons(struct il_priv *il, u32 usec, u32 beacon_interval); |
1842 | __le32 il_add_beacon_time(struct il_priv *il, u32 base, u32 addon, | 1834 | __le32 il_add_beacon_time(struct il_priv *il, u32 base, u32 addon, |
@@ -2434,10 +2426,6 @@ struct il_tfd { | |||
2434 | /* PCI registers */ | 2426 | /* PCI registers */ |
2435 | #define PCI_CFG_RETRY_TIMEOUT 0x041 | 2427 | #define PCI_CFG_RETRY_TIMEOUT 0x041 |
2436 | 2428 | ||
2437 | /* PCI register values */ | ||
2438 | #define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01 | ||
2439 | #define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02 | ||
2440 | |||
2441 | struct il_rate_info { | 2429 | struct il_rate_info { |
2442 | u8 plcp; /* uCode API: RATE_6M_PLCP, etc. */ | 2430 | u8 plcp; /* uCode API: RATE_6M_PLCP, etc. */ |
2443 | u8 plcp_siso; /* uCode API: RATE_SISO_6M_PLCP, etc. */ | 2431 | u8 plcp_siso; /* uCode API: RATE_SISO_6M_PLCP, etc. */ |
diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c index d66cad4a7d6a..35708b959ad6 100644 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c | |||
@@ -94,8 +94,6 @@ static void iwl_pcie_set_pwr_vmain(struct iwl_trans *trans) | |||
94 | 94 | ||
95 | /* PCI registers */ | 95 | /* PCI registers */ |
96 | #define PCI_CFG_RETRY_TIMEOUT 0x041 | 96 | #define PCI_CFG_RETRY_TIMEOUT 0x041 |
97 | #define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01 | ||
98 | #define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02 | ||
99 | 97 | ||
100 | static void iwl_pcie_apm_config(struct iwl_trans *trans) | 98 | static void iwl_pcie_apm_config(struct iwl_trans *trans) |
101 | { | 99 | { |
@@ -111,9 +109,7 @@ static void iwl_pcie_apm_config(struct iwl_trans *trans) | |||
111 | * power savings, even without L1. | 109 | * power savings, even without L1. |
112 | */ | 110 | */ |
113 | pcie_capability_read_word(trans_pcie->pci_dev, PCI_EXP_LNKCTL, &lctl); | 111 | pcie_capability_read_word(trans_pcie->pci_dev, PCI_EXP_LNKCTL, &lctl); |
114 | 112 | if (lctl & PCI_EXP_LNKCTL_ASPM_L1) { | |
115 | if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) == | ||
116 | PCI_CFG_LINK_CTRL_VAL_L1_EN) { | ||
117 | /* L1-ASPM enabled; disable(!) L0S */ | 113 | /* L1-ASPM enabled; disable(!) L0S */ |
118 | iwl_set_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); | 114 | iwl_set_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); |
119 | dev_info(trans->dev, "L1 Enabled; Disabling L0S\n"); | 115 | dev_info(trans->dev, "L1 Enabled; Disabling L0S\n"); |
@@ -122,7 +118,7 @@ static void iwl_pcie_apm_config(struct iwl_trans *trans) | |||
122 | iwl_clear_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); | 118 | iwl_clear_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); |
123 | dev_info(trans->dev, "L1 Disabled; Enabling L0S\n"); | 119 | dev_info(trans->dev, "L1 Disabled; Enabling L0S\n"); |
124 | } | 120 | } |
125 | trans->pm_support = !(lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN); | 121 | trans->pm_support = !(lctl & PCI_EXP_LNKCTL_ASPM_L0S); |
126 | } | 122 | } |
127 | 123 | ||
128 | /* | 124 | /* |
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index a543746fb354..ad6a8b635692 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c | |||
@@ -170,6 +170,11 @@ int pci_bus_add_device(struct pci_dev *dev) | |||
170 | int retval; | 170 | int retval; |
171 | 171 | ||
172 | pci_fixup_device(pci_fixup_final, dev); | 172 | pci_fixup_device(pci_fixup_final, dev); |
173 | |||
174 | retval = pcibios_add_device(dev); | ||
175 | if (retval) | ||
176 | return retval; | ||
177 | |||
173 | retval = device_add(&dev->dev); | 178 | retval = device_add(&dev->dev); |
174 | if (retval) | 179 | if (retval) |
175 | return retval; | 180 | return retval; |
diff --git a/drivers/pci/ioapic.c b/drivers/pci/ioapic.c index 2eca902a4283..3c6bbdd059a4 100644 --- a/drivers/pci/ioapic.c +++ b/drivers/pci/ioapic.c | |||
@@ -125,3 +125,5 @@ static void __exit ioapic_exit(void) | |||
125 | 125 | ||
126 | module_init(ioapic_init); | 126 | module_init(ioapic_init); |
127 | module_exit(ioapic_exit); | 127 | module_exit(ioapic_exit); |
128 | |||
129 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index aeccc911abb8..bafd2bbcaf65 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c | |||
@@ -106,7 +106,7 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset) | |||
106 | virtfn->resource[i].name = pci_name(virtfn); | 106 | virtfn->resource[i].name = pci_name(virtfn); |
107 | virtfn->resource[i].flags = res->flags; | 107 | virtfn->resource[i].flags = res->flags; |
108 | size = resource_size(res); | 108 | size = resource_size(res); |
109 | do_div(size, iov->total); | 109 | do_div(size, iov->total_VFs); |
110 | virtfn->resource[i].start = res->start + size * id; | 110 | virtfn->resource[i].start = res->start + size * id; |
111 | virtfn->resource[i].end = virtfn->resource[i].start + size - 1; | 111 | virtfn->resource[i].end = virtfn->resource[i].start + size - 1; |
112 | rc = request_resource(res, &virtfn->resource[i]); | 112 | rc = request_resource(res, &virtfn->resource[i]); |
@@ -194,7 +194,7 @@ static int sriov_migration(struct pci_dev *dev) | |||
194 | u16 status; | 194 | u16 status; |
195 | struct pci_sriov *iov = dev->sriov; | 195 | struct pci_sriov *iov = dev->sriov; |
196 | 196 | ||
197 | if (!iov->nr_virtfn) | 197 | if (!iov->num_VFs) |
198 | return 0; | 198 | return 0; |
199 | 199 | ||
200 | if (!(iov->cap & PCI_SRIOV_CAP_VFM)) | 200 | if (!(iov->cap & PCI_SRIOV_CAP_VFM)) |
@@ -216,7 +216,7 @@ static void sriov_migration_task(struct work_struct *work) | |||
216 | u16 status; | 216 | u16 status; |
217 | struct pci_sriov *iov = container_of(work, struct pci_sriov, mtask); | 217 | struct pci_sriov *iov = container_of(work, struct pci_sriov, mtask); |
218 | 218 | ||
219 | for (i = iov->initial; i < iov->nr_virtfn; i++) { | 219 | for (i = iov->initial_VFs; i < iov->num_VFs; i++) { |
220 | state = readb(iov->mstate + i); | 220 | state = readb(iov->mstate + i); |
221 | if (state == PCI_SRIOV_VFM_MI) { | 221 | if (state == PCI_SRIOV_VFM_MI) { |
222 | writeb(PCI_SRIOV_VFM_AV, iov->mstate + i); | 222 | writeb(PCI_SRIOV_VFM_AV, iov->mstate + i); |
@@ -244,7 +244,7 @@ static int sriov_enable_migration(struct pci_dev *dev, int nr_virtfn) | |||
244 | resource_size_t pa; | 244 | resource_size_t pa; |
245 | struct pci_sriov *iov = dev->sriov; | 245 | struct pci_sriov *iov = dev->sriov; |
246 | 246 | ||
247 | if (nr_virtfn <= iov->initial) | 247 | if (nr_virtfn <= iov->initial_VFs) |
248 | return 0; | 248 | return 0; |
249 | 249 | ||
250 | pci_read_config_dword(dev, iov->pos + PCI_SRIOV_VFM, &table); | 250 | pci_read_config_dword(dev, iov->pos + PCI_SRIOV_VFM, &table); |
@@ -294,15 +294,15 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) | |||
294 | if (!nr_virtfn) | 294 | if (!nr_virtfn) |
295 | return 0; | 295 | return 0; |
296 | 296 | ||
297 | if (iov->nr_virtfn) | 297 | if (iov->num_VFs) |
298 | return -EINVAL; | 298 | return -EINVAL; |
299 | 299 | ||
300 | pci_read_config_word(dev, iov->pos + PCI_SRIOV_INITIAL_VF, &initial); | 300 | pci_read_config_word(dev, iov->pos + PCI_SRIOV_INITIAL_VF, &initial); |
301 | if (initial > iov->total || | 301 | if (initial > iov->total_VFs || |
302 | (!(iov->cap & PCI_SRIOV_CAP_VFM) && (initial != iov->total))) | 302 | (!(iov->cap & PCI_SRIOV_CAP_VFM) && (initial != iov->total_VFs))) |
303 | return -EIO; | 303 | return -EIO; |
304 | 304 | ||
305 | if (nr_virtfn < 0 || nr_virtfn > iov->total || | 305 | if (nr_virtfn < 0 || nr_virtfn > iov->total_VFs || |
306 | (!(iov->cap & PCI_SRIOV_CAP_VFM) && (nr_virtfn > initial))) | 306 | (!(iov->cap & PCI_SRIOV_CAP_VFM) && (nr_virtfn > initial))) |
307 | return -EINVAL; | 307 | return -EINVAL; |
308 | 308 | ||
@@ -359,7 +359,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) | |||
359 | msleep(100); | 359 | msleep(100); |
360 | pci_cfg_access_unlock(dev); | 360 | pci_cfg_access_unlock(dev); |
361 | 361 | ||
362 | iov->initial = initial; | 362 | iov->initial_VFs = initial; |
363 | if (nr_virtfn < initial) | 363 | if (nr_virtfn < initial) |
364 | initial = nr_virtfn; | 364 | initial = nr_virtfn; |
365 | 365 | ||
@@ -376,7 +376,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) | |||
376 | } | 376 | } |
377 | 377 | ||
378 | kobject_uevent(&dev->dev.kobj, KOBJ_CHANGE); | 378 | kobject_uevent(&dev->dev.kobj, KOBJ_CHANGE); |
379 | iov->nr_virtfn = nr_virtfn; | 379 | iov->num_VFs = nr_virtfn; |
380 | 380 | ||
381 | return 0; | 381 | return 0; |
382 | 382 | ||
@@ -401,13 +401,13 @@ static void sriov_disable(struct pci_dev *dev) | |||
401 | int i; | 401 | int i; |
402 | struct pci_sriov *iov = dev->sriov; | 402 | struct pci_sriov *iov = dev->sriov; |
403 | 403 | ||
404 | if (!iov->nr_virtfn) | 404 | if (!iov->num_VFs) |
405 | return; | 405 | return; |
406 | 406 | ||
407 | if (iov->cap & PCI_SRIOV_CAP_VFM) | 407 | if (iov->cap & PCI_SRIOV_CAP_VFM) |
408 | sriov_disable_migration(dev); | 408 | sriov_disable_migration(dev); |
409 | 409 | ||
410 | for (i = 0; i < iov->nr_virtfn; i++) | 410 | for (i = 0; i < iov->num_VFs; i++) |
411 | virtfn_remove(dev, i, 0); | 411 | virtfn_remove(dev, i, 0); |
412 | 412 | ||
413 | iov->ctrl &= ~(PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE); | 413 | iov->ctrl &= ~(PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE); |
@@ -419,7 +419,7 @@ static void sriov_disable(struct pci_dev *dev) | |||
419 | if (iov->link != dev->devfn) | 419 | if (iov->link != dev->devfn) |
420 | sysfs_remove_link(&dev->dev.kobj, "dep_link"); | 420 | sysfs_remove_link(&dev->dev.kobj, "dep_link"); |
421 | 421 | ||
422 | iov->nr_virtfn = 0; | 422 | iov->num_VFs = 0; |
423 | } | 423 | } |
424 | 424 | ||
425 | static int sriov_init(struct pci_dev *dev, int pos) | 425 | static int sriov_init(struct pci_dev *dev, int pos) |
@@ -496,7 +496,7 @@ found: | |||
496 | iov->pos = pos; | 496 | iov->pos = pos; |
497 | iov->nres = nres; | 497 | iov->nres = nres; |
498 | iov->ctrl = ctrl; | 498 | iov->ctrl = ctrl; |
499 | iov->total = total; | 499 | iov->total_VFs = total; |
500 | iov->offset = offset; | 500 | iov->offset = offset; |
501 | iov->stride = stride; | 501 | iov->stride = stride; |
502 | iov->pgsz = pgsz; | 502 | iov->pgsz = pgsz; |
@@ -529,7 +529,7 @@ failed: | |||
529 | 529 | ||
530 | static void sriov_release(struct pci_dev *dev) | 530 | static void sriov_release(struct pci_dev *dev) |
531 | { | 531 | { |
532 | BUG_ON(dev->sriov->nr_virtfn); | 532 | BUG_ON(dev->sriov->num_VFs); |
533 | 533 | ||
534 | if (dev != dev->sriov->dev) | 534 | if (dev != dev->sriov->dev) |
535 | pci_dev_put(dev->sriov->dev); | 535 | pci_dev_put(dev->sriov->dev); |
@@ -554,7 +554,7 @@ static void sriov_restore_state(struct pci_dev *dev) | |||
554 | pci_update_resource(dev, i); | 554 | pci_update_resource(dev, i); |
555 | 555 | ||
556 | pci_write_config_dword(dev, iov->pos + PCI_SRIOV_SYS_PGSIZE, iov->pgsz); | 556 | pci_write_config_dword(dev, iov->pos + PCI_SRIOV_SYS_PGSIZE, iov->pgsz); |
557 | pci_write_config_word(dev, iov->pos + PCI_SRIOV_NUM_VF, iov->nr_virtfn); | 557 | pci_write_config_word(dev, iov->pos + PCI_SRIOV_NUM_VF, iov->num_VFs); |
558 | pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl); | 558 | pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl); |
559 | if (iov->ctrl & PCI_SRIOV_CTRL_VFE) | 559 | if (iov->ctrl & PCI_SRIOV_CTRL_VFE) |
560 | msleep(100); | 560 | msleep(100); |
@@ -661,7 +661,7 @@ int pci_iov_bus_range(struct pci_bus *bus) | |||
661 | list_for_each_entry(dev, &bus->devices, bus_list) { | 661 | list_for_each_entry(dev, &bus->devices, bus_list) { |
662 | if (!dev->is_physfn) | 662 | if (!dev->is_physfn) |
663 | continue; | 663 | continue; |
664 | busnr = virtfn_bus(dev, dev->sriov->total - 1); | 664 | busnr = virtfn_bus(dev, dev->sriov->total_VFs - 1); |
665 | if (busnr > max) | 665 | if (busnr > max) |
666 | max = busnr; | 666 | max = busnr; |
667 | } | 667 | } |
@@ -729,9 +729,56 @@ EXPORT_SYMBOL_GPL(pci_sriov_migration); | |||
729 | */ | 729 | */ |
730 | int pci_num_vf(struct pci_dev *dev) | 730 | int pci_num_vf(struct pci_dev *dev) |
731 | { | 731 | { |
732 | if (!dev || !dev->is_physfn) | 732 | if (!dev->is_physfn) |
733 | return 0; | 733 | return 0; |
734 | else | 734 | |
735 | return dev->sriov->nr_virtfn; | 735 | return dev->sriov->num_VFs; |
736 | } | 736 | } |
737 | EXPORT_SYMBOL_GPL(pci_num_vf); | 737 | EXPORT_SYMBOL_GPL(pci_num_vf); |
738 | |||
739 | /** | ||
740 | * pci_sriov_set_totalvfs -- reduce the TotalVFs available | ||
741 | * @dev: the PCI PF device | ||
742 | * numvfs: number that should be used for TotalVFs supported | ||
743 | * | ||
744 | * Should be called from PF driver's probe routine with | ||
745 | * device's mutex held. | ||
746 | * | ||
747 | * Returns 0 if PF is an SRIOV-capable device and | ||
748 | * value of numvfs valid. If not a PF with VFS, return -EINVAL; | ||
749 | * if VFs already enabled, return -EBUSY. | ||
750 | */ | ||
751 | int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs) | ||
752 | { | ||
753 | if (!dev->is_physfn || (numvfs > dev->sriov->total_VFs)) | ||
754 | return -EINVAL; | ||
755 | |||
756 | /* Shouldn't change if VFs already enabled */ | ||
757 | if (dev->sriov->ctrl & PCI_SRIOV_CTRL_VFE) | ||
758 | return -EBUSY; | ||
759 | else | ||
760 | dev->sriov->driver_max_VFs = numvfs; | ||
761 | |||
762 | return 0; | ||
763 | } | ||
764 | EXPORT_SYMBOL_GPL(pci_sriov_set_totalvfs); | ||
765 | |||
766 | /** | ||
767 | * pci_sriov_get_totalvfs -- get total VFs supported on this devic3 | ||
768 | * @dev: the PCI PF device | ||
769 | * | ||
770 | * For a PCIe device with SRIOV support, return the PCIe | ||
771 | * SRIOV capability value of TotalVFs or the value of driver_max_VFs | ||
772 | * if the driver reduced it. Otherwise, -EINVAL. | ||
773 | */ | ||
774 | int pci_sriov_get_totalvfs(struct pci_dev *dev) | ||
775 | { | ||
776 | if (!dev->is_physfn) | ||
777 | return -EINVAL; | ||
778 | |||
779 | if (dev->sriov->driver_max_VFs) | ||
780 | return dev->sriov->driver_max_VFs; | ||
781 | |||
782 | return dev->sriov->total_VFs; | ||
783 | } | ||
784 | EXPORT_SYMBOL_GPL(pci_sriov_get_totalvfs); | ||
diff --git a/drivers/pci/irq.c b/drivers/pci/irq.c index e5f69a43b1b1..b008cf86b9c3 100644 --- a/drivers/pci/irq.c +++ b/drivers/pci/irq.c | |||
@@ -14,11 +14,11 @@ static void pci_note_irq_problem(struct pci_dev *pdev, const char *reason) | |||
14 | { | 14 | { |
15 | struct pci_dev *parent = to_pci_dev(pdev->dev.parent); | 15 | struct pci_dev *parent = to_pci_dev(pdev->dev.parent); |
16 | 16 | ||
17 | dev_printk(KERN_ERR, &pdev->dev, | 17 | dev_err(&pdev->dev, |
18 | "Potentially misrouted IRQ (Bridge %s %04x:%04x)\n", | 18 | "Potentially misrouted IRQ (Bridge %s %04x:%04x)\n", |
19 | dev_name(&parent->dev), parent->vendor, parent->device); | 19 | dev_name(&parent->dev), parent->vendor, parent->device); |
20 | dev_printk(KERN_ERR, &pdev->dev, "%s\n", reason); | 20 | dev_err(&pdev->dev, "%s\n", reason); |
21 | dev_printk(KERN_ERR, &pdev->dev, "Please report to linux-kernel@vger.kernel.org\n"); | 21 | dev_err(&pdev->dev, "Please report to linux-kernel@vger.kernel.org\n"); |
22 | WARN_ON(1); | 22 | WARN_ON(1); |
23 | } | 23 | } |
24 | 24 | ||
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 1dc78c5cabf8..f79cbcd3944b 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c | |||
@@ -248,31 +248,26 @@ struct drv_dev_and_id { | |||
248 | static long local_pci_probe(void *_ddi) | 248 | static long local_pci_probe(void *_ddi) |
249 | { | 249 | { |
250 | struct drv_dev_and_id *ddi = _ddi; | 250 | struct drv_dev_and_id *ddi = _ddi; |
251 | struct device *dev = &ddi->dev->dev; | 251 | struct pci_dev *pci_dev = ddi->dev; |
252 | struct device *parent = dev->parent; | 252 | struct pci_driver *pci_drv = ddi->drv; |
253 | struct device *dev = &pci_dev->dev; | ||
253 | int rc; | 254 | int rc; |
254 | 255 | ||
255 | /* The parent bridge must be in active state when probing */ | 256 | /* |
256 | if (parent) | 257 | * Unbound PCI devices are always put in D0, regardless of |
257 | pm_runtime_get_sync(parent); | 258 | * runtime PM status. During probe, the device is set to |
258 | /* Unbound PCI devices are always set to disabled and suspended. | 259 | * active and the usage count is incremented. If the driver |
259 | * During probe, the device is set to enabled and active and the | 260 | * supports runtime PM, it should call pm_runtime_put_noidle() |
260 | * usage count is incremented. If the driver supports runtime PM, | 261 | * in its probe routine and pm_runtime_get_noresume() in its |
261 | * it should call pm_runtime_put_noidle() in its probe routine and | 262 | * remove routine. |
262 | * pm_runtime_get_noresume() in its remove routine. | ||
263 | */ | 263 | */ |
264 | pm_runtime_get_noresume(dev); | 264 | pm_runtime_get_sync(dev); |
265 | pm_runtime_set_active(dev); | 265 | pci_dev->driver = pci_drv; |
266 | pm_runtime_enable(dev); | 266 | rc = pci_drv->probe(pci_dev, ddi->id); |
267 | |||
268 | rc = ddi->drv->probe(ddi->dev, ddi->id); | ||
269 | if (rc) { | 267 | if (rc) { |
270 | pm_runtime_disable(dev); | 268 | pci_dev->driver = NULL; |
271 | pm_runtime_set_suspended(dev); | 269 | pm_runtime_put_sync(dev); |
272 | pm_runtime_put_noidle(dev); | ||
273 | } | 270 | } |
274 | if (parent) | ||
275 | pm_runtime_put(parent); | ||
276 | return rc; | 271 | return rc; |
277 | } | 272 | } |
278 | 273 | ||
@@ -322,10 +317,8 @@ __pci_device_probe(struct pci_driver *drv, struct pci_dev *pci_dev) | |||
322 | id = pci_match_device(drv, pci_dev); | 317 | id = pci_match_device(drv, pci_dev); |
323 | if (id) | 318 | if (id) |
324 | error = pci_call_probe(drv, pci_dev, id); | 319 | error = pci_call_probe(drv, pci_dev, id); |
325 | if (error >= 0) { | 320 | if (error >= 0) |
326 | pci_dev->driver = drv; | ||
327 | error = 0; | 321 | error = 0; |
328 | } | ||
329 | } | 322 | } |
330 | return error; | 323 | return error; |
331 | } | 324 | } |
@@ -361,9 +354,7 @@ static int pci_device_remove(struct device * dev) | |||
361 | } | 354 | } |
362 | 355 | ||
363 | /* Undo the runtime PM settings in local_pci_probe() */ | 356 | /* Undo the runtime PM settings in local_pci_probe() */ |
364 | pm_runtime_disable(dev); | 357 | pm_runtime_put_sync(dev); |
365 | pm_runtime_set_suspended(dev); | ||
366 | pm_runtime_put_noidle(dev); | ||
367 | 358 | ||
368 | /* | 359 | /* |
369 | * If the device is still on, set the power state as "unknown", | 360 | * If the device is still on, set the power state as "unknown", |
@@ -986,6 +977,13 @@ static int pci_pm_runtime_suspend(struct device *dev) | |||
986 | pci_power_t prev = pci_dev->current_state; | 977 | pci_power_t prev = pci_dev->current_state; |
987 | int error; | 978 | int error; |
988 | 979 | ||
980 | /* | ||
981 | * If pci_dev->driver is not set (unbound), the device should | ||
982 | * always remain in D0 regardless of the runtime PM status | ||
983 | */ | ||
984 | if (!pci_dev->driver) | ||
985 | return 0; | ||
986 | |||
989 | if (!pm || !pm->runtime_suspend) | 987 | if (!pm || !pm->runtime_suspend) |
990 | return -ENOSYS; | 988 | return -ENOSYS; |
991 | 989 | ||
@@ -1007,10 +1005,10 @@ static int pci_pm_runtime_suspend(struct device *dev) | |||
1007 | return 0; | 1005 | return 0; |
1008 | } | 1006 | } |
1009 | 1007 | ||
1010 | if (!pci_dev->state_saved) | 1008 | if (!pci_dev->state_saved) { |
1011 | pci_save_state(pci_dev); | 1009 | pci_save_state(pci_dev); |
1012 | 1010 | pci_finish_runtime_suspend(pci_dev); | |
1013 | pci_finish_runtime_suspend(pci_dev); | 1011 | } |
1014 | 1012 | ||
1015 | return 0; | 1013 | return 0; |
1016 | } | 1014 | } |
@@ -1021,6 +1019,13 @@ static int pci_pm_runtime_resume(struct device *dev) | |||
1021 | struct pci_dev *pci_dev = to_pci_dev(dev); | 1019 | struct pci_dev *pci_dev = to_pci_dev(dev); |
1022 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; | 1020 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; |
1023 | 1021 | ||
1022 | /* | ||
1023 | * If pci_dev->driver is not set (unbound), the device should | ||
1024 | * always remain in D0 regardless of the runtime PM status | ||
1025 | */ | ||
1026 | if (!pci_dev->driver) | ||
1027 | return 0; | ||
1028 | |||
1024 | if (!pm || !pm->runtime_resume) | 1029 | if (!pm || !pm->runtime_resume) |
1025 | return -ENOSYS; | 1030 | return -ENOSYS; |
1026 | 1031 | ||
@@ -1038,8 +1043,16 @@ static int pci_pm_runtime_resume(struct device *dev) | |||
1038 | 1043 | ||
1039 | static int pci_pm_runtime_idle(struct device *dev) | 1044 | static int pci_pm_runtime_idle(struct device *dev) |
1040 | { | 1045 | { |
1046 | struct pci_dev *pci_dev = to_pci_dev(dev); | ||
1041 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; | 1047 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; |
1042 | 1048 | ||
1049 | /* | ||
1050 | * If pci_dev->driver is not set (unbound), the device should | ||
1051 | * always remain in D0 regardless of the runtime PM status | ||
1052 | */ | ||
1053 | if (!pci_dev->driver) | ||
1054 | goto out; | ||
1055 | |||
1043 | if (!pm) | 1056 | if (!pm) |
1044 | return -ENOSYS; | 1057 | return -ENOSYS; |
1045 | 1058 | ||
@@ -1049,8 +1062,8 @@ static int pci_pm_runtime_idle(struct device *dev) | |||
1049 | return ret; | 1062 | return ret; |
1050 | } | 1063 | } |
1051 | 1064 | ||
1065 | out: | ||
1052 | pm_runtime_suspend(dev); | 1066 | pm_runtime_suspend(dev); |
1053 | |||
1054 | return 0; | 1067 | return 0; |
1055 | } | 1068 | } |
1056 | 1069 | ||
diff --git a/drivers/pci/pci-stub.c b/drivers/pci/pci-stub.c index 775e933c2225..6e47c519c510 100644 --- a/drivers/pci/pci-stub.c +++ b/drivers/pci/pci-stub.c | |||
@@ -28,7 +28,7 @@ MODULE_PARM_DESC(ids, "Initial PCI IDs to add to the stub driver, format is " | |||
28 | 28 | ||
29 | static int pci_stub_probe(struct pci_dev *dev, const struct pci_device_id *id) | 29 | static int pci_stub_probe(struct pci_dev *dev, const struct pci_device_id *id) |
30 | { | 30 | { |
31 | dev_printk(KERN_INFO, &dev->dev, "claimed by stub\n"); | 31 | dev_info(&dev->dev, "claimed by stub\n"); |
32 | return 0; | 32 | return 0; |
33 | } | 33 | } |
34 | 34 | ||
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 68d56f02e721..05b78b16d20b 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -401,6 +401,106 @@ static ssize_t d3cold_allowed_show(struct device *dev, | |||
401 | } | 401 | } |
402 | #endif | 402 | #endif |
403 | 403 | ||
404 | #ifdef CONFIG_PCI_IOV | ||
405 | static ssize_t sriov_totalvfs_show(struct device *dev, | ||
406 | struct device_attribute *attr, | ||
407 | char *buf) | ||
408 | { | ||
409 | struct pci_dev *pdev = to_pci_dev(dev); | ||
410 | |||
411 | return sprintf(buf, "%u\n", pci_sriov_get_totalvfs(pdev)); | ||
412 | } | ||
413 | |||
414 | |||
415 | static ssize_t sriov_numvfs_show(struct device *dev, | ||
416 | struct device_attribute *attr, | ||
417 | char *buf) | ||
418 | { | ||
419 | struct pci_dev *pdev = to_pci_dev(dev); | ||
420 | |||
421 | return sprintf(buf, "%u\n", pdev->sriov->num_VFs); | ||
422 | } | ||
423 | |||
424 | /* | ||
425 | * num_vfs > 0; number of vfs to enable | ||
426 | * num_vfs = 0; disable all vfs | ||
427 | * | ||
428 | * Note: SRIOV spec doesn't allow partial VF | ||
429 | * disable, so its all or none. | ||
430 | */ | ||
431 | static ssize_t sriov_numvfs_store(struct device *dev, | ||
432 | struct device_attribute *attr, | ||
433 | const char *buf, size_t count) | ||
434 | { | ||
435 | struct pci_dev *pdev = to_pci_dev(dev); | ||
436 | int num_vfs_enabled = 0; | ||
437 | int num_vfs; | ||
438 | int ret = 0; | ||
439 | u16 total; | ||
440 | |||
441 | if (kstrtoint(buf, 0, &num_vfs) < 0) | ||
442 | return -EINVAL; | ||
443 | |||
444 | /* is PF driver loaded w/callback */ | ||
445 | if (!pdev->driver || !pdev->driver->sriov_configure) { | ||
446 | dev_info(&pdev->dev, | ||
447 | "Driver doesn't support SRIOV configuration via sysfs\n"); | ||
448 | return -ENOSYS; | ||
449 | } | ||
450 | |||
451 | /* if enabling vf's ... */ | ||
452 | total = pci_sriov_get_totalvfs(pdev); | ||
453 | /* Requested VFs to enable < totalvfs and none enabled already */ | ||
454 | if ((num_vfs > 0) && (num_vfs <= total)) { | ||
455 | if (pdev->sriov->num_VFs == 0) { | ||
456 | num_vfs_enabled = | ||
457 | pdev->driver->sriov_configure(pdev, num_vfs); | ||
458 | if ((num_vfs_enabled >= 0) && | ||
459 | (num_vfs_enabled != num_vfs)) { | ||
460 | dev_warn(&pdev->dev, | ||
461 | "Only %d VFs enabled\n", | ||
462 | num_vfs_enabled); | ||
463 | return count; | ||
464 | } else if (num_vfs_enabled < 0) | ||
465 | /* error code from driver callback */ | ||
466 | return num_vfs_enabled; | ||
467 | } else if (num_vfs == pdev->sriov->num_VFs) { | ||
468 | dev_warn(&pdev->dev, | ||
469 | "%d VFs already enabled; no enable action taken\n", | ||
470 | num_vfs); | ||
471 | return count; | ||
472 | } else { | ||
473 | dev_warn(&pdev->dev, | ||
474 | "%d VFs already enabled. Disable before enabling %d VFs\n", | ||
475 | pdev->sriov->num_VFs, num_vfs); | ||
476 | return -EINVAL; | ||
477 | } | ||
478 | } | ||
479 | |||
480 | /* disable vfs */ | ||
481 | if (num_vfs == 0) { | ||
482 | if (pdev->sriov->num_VFs != 0) { | ||
483 | ret = pdev->driver->sriov_configure(pdev, 0); | ||
484 | return ret ? ret : count; | ||
485 | } else { | ||
486 | dev_warn(&pdev->dev, | ||
487 | "All VFs disabled; no disable action taken\n"); | ||
488 | return count; | ||
489 | } | ||
490 | } | ||
491 | |||
492 | dev_err(&pdev->dev, | ||
493 | "Invalid value for number of VFs to enable: %d\n", num_vfs); | ||
494 | |||
495 | return -EINVAL; | ||
496 | } | ||
497 | |||
498 | static struct device_attribute sriov_totalvfs_attr = __ATTR_RO(sriov_totalvfs); | ||
499 | static struct device_attribute sriov_numvfs_attr = | ||
500 | __ATTR(sriov_numvfs, (S_IRUGO|S_IWUSR|S_IWGRP), | ||
501 | sriov_numvfs_show, sriov_numvfs_store); | ||
502 | #endif /* CONFIG_PCI_IOV */ | ||
503 | |||
404 | struct device_attribute pci_dev_attrs[] = { | 504 | struct device_attribute pci_dev_attrs[] = { |
405 | __ATTR_RO(resource), | 505 | __ATTR_RO(resource), |
406 | __ATTR_RO(vendor), | 506 | __ATTR_RO(vendor), |
@@ -1262,29 +1362,20 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev) | |||
1262 | pdev->rom_attr = attr; | 1362 | pdev->rom_attr = attr; |
1263 | } | 1363 | } |
1264 | 1364 | ||
1265 | if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA) { | ||
1266 | retval = device_create_file(&pdev->dev, &vga_attr); | ||
1267 | if (retval) | ||
1268 | goto err_rom_file; | ||
1269 | } | ||
1270 | |||
1271 | /* add platform-specific attributes */ | 1365 | /* add platform-specific attributes */ |
1272 | retval = pcibios_add_platform_entries(pdev); | 1366 | retval = pcibios_add_platform_entries(pdev); |
1273 | if (retval) | 1367 | if (retval) |
1274 | goto err_vga_file; | 1368 | goto err_rom_file; |
1275 | 1369 | ||
1276 | /* add sysfs entries for various capabilities */ | 1370 | /* add sysfs entries for various capabilities */ |
1277 | retval = pci_create_capabilities_sysfs(pdev); | 1371 | retval = pci_create_capabilities_sysfs(pdev); |
1278 | if (retval) | 1372 | if (retval) |
1279 | goto err_vga_file; | 1373 | goto err_rom_file; |
1280 | 1374 | ||
1281 | pci_create_firmware_label_files(pdev); | 1375 | pci_create_firmware_label_files(pdev); |
1282 | 1376 | ||
1283 | return 0; | 1377 | return 0; |
1284 | 1378 | ||
1285 | err_vga_file: | ||
1286 | if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA) | ||
1287 | device_remove_file(&pdev->dev, &vga_attr); | ||
1288 | err_rom_file: | 1379 | err_rom_file: |
1289 | if (rom_size) { | 1380 | if (rom_size) { |
1290 | sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr); | 1381 | sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr); |
@@ -1370,3 +1461,62 @@ static int __init pci_sysfs_init(void) | |||
1370 | } | 1461 | } |
1371 | 1462 | ||
1372 | late_initcall(pci_sysfs_init); | 1463 | late_initcall(pci_sysfs_init); |
1464 | |||
1465 | static struct attribute *pci_dev_dev_attrs[] = { | ||
1466 | &vga_attr.attr, | ||
1467 | NULL, | ||
1468 | }; | ||
1469 | |||
1470 | static umode_t pci_dev_attrs_are_visible(struct kobject *kobj, | ||
1471 | struct attribute *a, int n) | ||
1472 | { | ||
1473 | struct device *dev = container_of(kobj, struct device, kobj); | ||
1474 | struct pci_dev *pdev = to_pci_dev(dev); | ||
1475 | |||
1476 | if (a == &vga_attr.attr) | ||
1477 | if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA) | ||
1478 | return 0; | ||
1479 | |||
1480 | return a->mode; | ||
1481 | } | ||
1482 | |||
1483 | #ifdef CONFIG_PCI_IOV | ||
1484 | static struct attribute *sriov_dev_attrs[] = { | ||
1485 | &sriov_totalvfs_attr.attr, | ||
1486 | &sriov_numvfs_attr.attr, | ||
1487 | NULL, | ||
1488 | }; | ||
1489 | |||
1490 | static umode_t sriov_attrs_are_visible(struct kobject *kobj, | ||
1491 | struct attribute *a, int n) | ||
1492 | { | ||
1493 | struct device *dev = container_of(kobj, struct device, kobj); | ||
1494 | |||
1495 | if (!dev_is_pf(dev)) | ||
1496 | return 0; | ||
1497 | |||
1498 | return a->mode; | ||
1499 | } | ||
1500 | |||
1501 | static struct attribute_group sriov_dev_attr_group = { | ||
1502 | .attrs = sriov_dev_attrs, | ||
1503 | .is_visible = sriov_attrs_are_visible, | ||
1504 | }; | ||
1505 | #endif /* CONFIG_PCI_IOV */ | ||
1506 | |||
1507 | static struct attribute_group pci_dev_attr_group = { | ||
1508 | .attrs = pci_dev_dev_attrs, | ||
1509 | .is_visible = pci_dev_attrs_are_visible, | ||
1510 | }; | ||
1511 | |||
1512 | static const struct attribute_group *pci_dev_attr_groups[] = { | ||
1513 | &pci_dev_attr_group, | ||
1514 | #ifdef CONFIG_PCI_IOV | ||
1515 | &sriov_dev_attr_group, | ||
1516 | #endif | ||
1517 | NULL, | ||
1518 | }; | ||
1519 | |||
1520 | struct device_type pci_dev_type = { | ||
1521 | .groups = pci_dev_attr_groups, | ||
1522 | }; | ||
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index bdf66b500f22..5cb5820fae40 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -1333,6 +1333,19 @@ void pcim_pin_device(struct pci_dev *pdev) | |||
1333 | dr->pinned = 1; | 1333 | dr->pinned = 1; |
1334 | } | 1334 | } |
1335 | 1335 | ||
1336 | /* | ||
1337 | * pcibios_add_device - provide arch specific hooks when adding device dev | ||
1338 | * @dev: the PCI device being added | ||
1339 | * | ||
1340 | * Permits the platform to provide architecture specific functionality when | ||
1341 | * devices are added. This is the default implementation. Architecture | ||
1342 | * implementations can override this. | ||
1343 | */ | ||
1344 | int __weak pcibios_add_device (struct pci_dev *dev) | ||
1345 | { | ||
1346 | return 0; | ||
1347 | } | ||
1348 | |||
1336 | /** | 1349 | /** |
1337 | * pcibios_disable_device - disable arch specific PCI resources for device dev | 1350 | * pcibios_disable_device - disable arch specific PCI resources for device dev |
1338 | * @dev: the PCI device to disable | 1351 | * @dev: the PCI device to disable |
@@ -1578,15 +1591,25 @@ void pci_pme_active(struct pci_dev *dev, bool enable) | |||
1578 | 1591 | ||
1579 | pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, pmcsr); | 1592 | pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, pmcsr); |
1580 | 1593 | ||
1581 | /* PCI (as opposed to PCIe) PME requires that the device have | 1594 | /* |
1582 | its PME# line hooked up correctly. Not all hardware vendors | 1595 | * PCI (as opposed to PCIe) PME requires that the device have |
1583 | do this, so the PME never gets delivered and the device | 1596 | * its PME# line hooked up correctly. Not all hardware vendors |
1584 | remains asleep. The easiest way around this is to | 1597 | * do this, so the PME never gets delivered and the device |
1585 | periodically walk the list of suspended devices and check | 1598 | * remains asleep. The easiest way around this is to |
1586 | whether any have their PME flag set. The assumption is that | 1599 | * periodically walk the list of suspended devices and check |
1587 | we'll wake up often enough anyway that this won't be a huge | 1600 | * whether any have their PME flag set. The assumption is that |
1588 | hit, and the power savings from the devices will still be a | 1601 | * we'll wake up often enough anyway that this won't be a huge |
1589 | win. */ | 1602 | * hit, and the power savings from the devices will still be a |
1603 | * win. | ||
1604 | * | ||
1605 | * Although PCIe uses in-band PME message instead of PME# line | ||
1606 | * to report PME, PME does not work for some PCIe devices in | ||
1607 | * reality. For example, there are devices that set their PME | ||
1608 | * status bits, but don't really bother to send a PME message; | ||
1609 | * there are PCI Express Root Ports that don't bother to | ||
1610 | * trigger interrupts when they receive PME messages from the | ||
1611 | * devices below. So PME poll is used for PCIe devices too. | ||
1612 | */ | ||
1590 | 1613 | ||
1591 | if (dev->pme_poll) { | 1614 | if (dev->pme_poll) { |
1592 | struct pci_pme_device *pme_dev; | 1615 | struct pci_pme_device *pme_dev; |
@@ -1900,6 +1923,8 @@ void pci_pm_init(struct pci_dev *dev) | |||
1900 | u16 pmc; | 1923 | u16 pmc; |
1901 | 1924 | ||
1902 | pm_runtime_forbid(&dev->dev); | 1925 | pm_runtime_forbid(&dev->dev); |
1926 | pm_runtime_set_active(&dev->dev); | ||
1927 | pm_runtime_enable(&dev->dev); | ||
1903 | device_enable_async_suspend(&dev->dev); | 1928 | device_enable_async_suspend(&dev->dev); |
1904 | dev->wakeup_prepared = false; | 1929 | dev->wakeup_prepared = false; |
1905 | 1930 | ||
@@ -3865,14 +3890,13 @@ static void pci_no_domains(void) | |||
3865 | } | 3890 | } |
3866 | 3891 | ||
3867 | /** | 3892 | /** |
3868 | * pci_ext_cfg_enabled - can we access extended PCI config space? | 3893 | * pci_ext_cfg_avail - can we access extended PCI config space? |
3869 | * @dev: The PCI device of the root bridge. | ||
3870 | * | 3894 | * |
3871 | * Returns 1 if we can access PCI extended config space (offsets | 3895 | * Returns 1 if we can access PCI extended config space (offsets |
3872 | * greater than 0xff). This is the default implementation. Architecture | 3896 | * greater than 0xff). This is the default implementation. Architecture |
3873 | * implementations can override this. | 3897 | * implementations can override this. |
3874 | */ | 3898 | */ |
3875 | int __weak pci_ext_cfg_avail(struct pci_dev *dev) | 3899 | int __weak pci_ext_cfg_avail(void) |
3876 | { | 3900 | { |
3877 | return 1; | 3901 | return 1; |
3878 | } | 3902 | } |
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index e253881c4275..e8518292826f 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h | |||
@@ -158,6 +158,7 @@ static inline int pci_no_d1d2(struct pci_dev *dev) | |||
158 | } | 158 | } |
159 | extern struct device_attribute pci_dev_attrs[]; | 159 | extern struct device_attribute pci_dev_attrs[]; |
160 | extern struct device_attribute pcibus_dev_attrs[]; | 160 | extern struct device_attribute pcibus_dev_attrs[]; |
161 | extern struct device_type pci_dev_type; | ||
161 | extern struct bus_attribute pci_bus_attrs[]; | 162 | extern struct bus_attribute pci_bus_attrs[]; |
162 | 163 | ||
163 | 164 | ||
@@ -229,13 +230,14 @@ struct pci_sriov { | |||
229 | int nres; /* number of resources */ | 230 | int nres; /* number of resources */ |
230 | u32 cap; /* SR-IOV Capabilities */ | 231 | u32 cap; /* SR-IOV Capabilities */ |
231 | u16 ctrl; /* SR-IOV Control */ | 232 | u16 ctrl; /* SR-IOV Control */ |
232 | u16 total; /* total VFs associated with the PF */ | 233 | u16 total_VFs; /* total VFs associated with the PF */ |
233 | u16 initial; /* initial VFs associated with the PF */ | 234 | u16 initial_VFs; /* initial VFs associated with the PF */ |
234 | u16 nr_virtfn; /* number of VFs available */ | 235 | u16 num_VFs; /* number of VFs available */ |
235 | u16 offset; /* first VF Routing ID offset */ | 236 | u16 offset; /* first VF Routing ID offset */ |
236 | u16 stride; /* following VF stride */ | 237 | u16 stride; /* following VF stride */ |
237 | u32 pgsz; /* page size for BAR alignment */ | 238 | u32 pgsz; /* page size for BAR alignment */ |
238 | u8 link; /* Function Dependency Link */ | 239 | u8 link; /* Function Dependency Link */ |
240 | u16 driver_max_VFs; /* max num VFs driver supports */ | ||
239 | struct pci_dev *dev; /* lowest numbered PF */ | 241 | struct pci_dev *dev; /* lowest numbered PF */ |
240 | struct pci_dev *self; /* this PF */ | 242 | struct pci_dev *self; /* this PF */ |
241 | struct mutex lock; /* lock for VF bus */ | 243 | struct mutex lock; /* lock for VF bus */ |
diff --git a/drivers/pci/pcie/aer/aerdrv.h b/drivers/pci/pcie/aer/aerdrv.h index 94a7598eb262..22f840f4dda1 100644 --- a/drivers/pci/pcie/aer/aerdrv.h +++ b/drivers/pci/pcie/aer/aerdrv.h | |||
@@ -87,6 +87,9 @@ struct aer_broadcast_data { | |||
87 | static inline pci_ers_result_t merge_result(enum pci_ers_result orig, | 87 | static inline pci_ers_result_t merge_result(enum pci_ers_result orig, |
88 | enum pci_ers_result new) | 88 | enum pci_ers_result new) |
89 | { | 89 | { |
90 | if (new == PCI_ERS_RESULT_NO_AER_DRIVER) | ||
91 | return PCI_ERS_RESULT_NO_AER_DRIVER; | ||
92 | |||
90 | if (new == PCI_ERS_RESULT_NONE) | 93 | if (new == PCI_ERS_RESULT_NONE) |
91 | return orig; | 94 | return orig; |
92 | 95 | ||
@@ -97,7 +100,7 @@ static inline pci_ers_result_t merge_result(enum pci_ers_result orig, | |||
97 | break; | 100 | break; |
98 | case PCI_ERS_RESULT_DISCONNECT: | 101 | case PCI_ERS_RESULT_DISCONNECT: |
99 | if (new == PCI_ERS_RESULT_NEED_RESET) | 102 | if (new == PCI_ERS_RESULT_NEED_RESET) |
100 | orig = new; | 103 | orig = PCI_ERS_RESULT_NEED_RESET; |
101 | break; | 104 | break; |
102 | default: | 105 | default: |
103 | break; | 106 | break; |
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c index af4e31cd3a3b..421bbc5fee32 100644 --- a/drivers/pci/pcie/aer/aerdrv_core.c +++ b/drivers/pci/pcie/aer/aerdrv_core.c | |||
@@ -232,13 +232,27 @@ static int report_error_detected(struct pci_dev *dev, void *data) | |||
232 | dev->driver ? | 232 | dev->driver ? |
233 | "no AER-aware driver" : "no driver"); | 233 | "no AER-aware driver" : "no driver"); |
234 | } | 234 | } |
235 | goto out; | 235 | |
236 | /* | ||
237 | * If there's any device in the subtree that does not | ||
238 | * have an error_detected callback, returning | ||
239 | * PCI_ERS_RESULT_NO_AER_DRIVER prevents calling of | ||
240 | * the subsequent mmio_enabled/slot_reset/resume | ||
241 | * callbacks of "any" device in the subtree. All the | ||
242 | * devices in the subtree are left in the error state | ||
243 | * without recovery. | ||
244 | */ | ||
245 | |||
246 | if (!(dev->hdr_type & PCI_HEADER_TYPE_BRIDGE)) | ||
247 | vote = PCI_ERS_RESULT_NO_AER_DRIVER; | ||
248 | else | ||
249 | vote = PCI_ERS_RESULT_NONE; | ||
250 | } else { | ||
251 | err_handler = dev->driver->err_handler; | ||
252 | vote = err_handler->error_detected(dev, result_data->state); | ||
236 | } | 253 | } |
237 | 254 | ||
238 | err_handler = dev->driver->err_handler; | ||
239 | vote = err_handler->error_detected(dev, result_data->state); | ||
240 | result_data->result = merge_result(result_data->result, vote); | 255 | result_data->result = merge_result(result_data->result, vote); |
241 | out: | ||
242 | device_unlock(&dev->dev); | 256 | device_unlock(&dev->dev); |
243 | return 0; | 257 | return 0; |
244 | } | 258 | } |
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 213753b283a6..b52630b8eada 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c | |||
@@ -242,8 +242,7 @@ static void pcie_aspm_configure_common_clock(struct pcie_link_state *link) | |||
242 | return; | 242 | return; |
243 | 243 | ||
244 | /* Training failed. Restore common clock configurations */ | 244 | /* Training failed. Restore common clock configurations */ |
245 | dev_printk(KERN_ERR, &parent->dev, | 245 | dev_err(&parent->dev, "ASPM: Could not configure common clock\n"); |
246 | "ASPM: Could not configure common clock\n"); | ||
247 | list_for_each_entry(child, &linkbus->devices, bus_list) | 246 | list_for_each_entry(child, &linkbus->devices, bus_list) |
248 | pcie_capability_write_word(child, PCI_EXP_LNKCTL, | 247 | pcie_capability_write_word(child, PCI_EXP_LNKCTL, |
249 | child_reg[PCI_FUNC(child->devfn)]); | 248 | child_reg[PCI_FUNC(child->devfn)]); |
@@ -427,7 +426,8 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) | |||
427 | 426 | ||
428 | static void pcie_config_aspm_dev(struct pci_dev *pdev, u32 val) | 427 | static void pcie_config_aspm_dev(struct pci_dev *pdev, u32 val) |
429 | { | 428 | { |
430 | pcie_capability_clear_and_set_word(pdev, PCI_EXP_LNKCTL, 0x3, val); | 429 | pcie_capability_clear_and_set_word(pdev, PCI_EXP_LNKCTL, |
430 | PCI_EXP_LNKCTL_ASPMC, val); | ||
431 | } | 431 | } |
432 | 432 | ||
433 | static void pcie_config_aspm_link(struct pcie_link_state *link, u32 state) | 433 | static void pcie_config_aspm_link(struct pcie_link_state *link, u32 state) |
@@ -442,12 +442,12 @@ static void pcie_config_aspm_link(struct pcie_link_state *link, u32 state) | |||
442 | return; | 442 | return; |
443 | /* Convert ASPM state to upstream/downstream ASPM register state */ | 443 | /* Convert ASPM state to upstream/downstream ASPM register state */ |
444 | if (state & ASPM_STATE_L0S_UP) | 444 | if (state & ASPM_STATE_L0S_UP) |
445 | dwstream |= PCIE_LINK_STATE_L0S; | 445 | dwstream |= PCI_EXP_LNKCTL_ASPM_L0S; |
446 | if (state & ASPM_STATE_L0S_DW) | 446 | if (state & ASPM_STATE_L0S_DW) |
447 | upstream |= PCIE_LINK_STATE_L0S; | 447 | upstream |= PCI_EXP_LNKCTL_ASPM_L0S; |
448 | if (state & ASPM_STATE_L1) { | 448 | if (state & ASPM_STATE_L1) { |
449 | upstream |= PCIE_LINK_STATE_L1; | 449 | upstream |= PCI_EXP_LNKCTL_ASPM_L1; |
450 | dwstream |= PCIE_LINK_STATE_L1; | 450 | dwstream |= PCI_EXP_LNKCTL_ASPM_L1; |
451 | } | 451 | } |
452 | /* | 452 | /* |
453 | * Spec 2.0 suggests all functions should be configured the | 453 | * Spec 2.0 suggests all functions should be configured the |
@@ -507,9 +507,7 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev) | |||
507 | */ | 507 | */ |
508 | pcie_capability_read_dword(child, PCI_EXP_DEVCAP, ®32); | 508 | pcie_capability_read_dword(child, PCI_EXP_DEVCAP, ®32); |
509 | if (!(reg32 & PCI_EXP_DEVCAP_RBER) && !aspm_force) { | 509 | if (!(reg32 & PCI_EXP_DEVCAP_RBER) && !aspm_force) { |
510 | dev_printk(KERN_INFO, &child->dev, "disabling ASPM" | 510 | dev_info(&child->dev, "disabling ASPM on pre-1.1 PCIe device. You can enable it with 'pcie_aspm=force'\n"); |
511 | " on pre-1.1 PCIe device. You can enable it" | ||
512 | " with 'pcie_aspm=force'\n"); | ||
513 | return -EINVAL; | 511 | return -EINVAL; |
514 | } | 512 | } |
515 | } | 513 | } |
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c index ed129b414624..b42133afca98 100644 --- a/drivers/pci/pcie/portdrv_core.c +++ b/drivers/pci/pcie/portdrv_core.c | |||
@@ -120,8 +120,7 @@ static int pcie_port_enable_msix(struct pci_dev *dev, int *vectors, int mask) | |||
120 | * the value in this field indicates which MSI-X Table entry is | 120 | * the value in this field indicates which MSI-X Table entry is |
121 | * used to generate the interrupt message." | 121 | * used to generate the interrupt message." |
122 | */ | 122 | */ |
123 | pos = pci_pcie_cap(dev); | 123 | pcie_capability_read_word(dev, PCI_EXP_FLAGS, ®16); |
124 | pci_read_config_word(dev, pos + PCI_EXP_FLAGS, ®16); | ||
125 | entry = (reg16 & PCI_EXP_FLAGS_IRQ) >> 9; | 124 | entry = (reg16 & PCI_EXP_FLAGS_IRQ) >> 9; |
126 | if (entry >= nr_entries) | 125 | if (entry >= nr_entries) |
127 | goto Error; | 126 | goto Error; |
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 3683f6094e3f..6186f03d84f3 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
@@ -521,7 +521,7 @@ static unsigned char pcie_link_speed[] = { | |||
521 | 521 | ||
522 | void pcie_update_link_speed(struct pci_bus *bus, u16 linksta) | 522 | void pcie_update_link_speed(struct pci_bus *bus, u16 linksta) |
523 | { | 523 | { |
524 | bus->cur_bus_speed = pcie_link_speed[linksta & 0xf]; | 524 | bus->cur_bus_speed = pcie_link_speed[linksta & PCI_EXP_LNKSTA_CLS]; |
525 | } | 525 | } |
526 | EXPORT_SYMBOL_GPL(pcie_update_link_speed); | 526 | EXPORT_SYMBOL_GPL(pcie_update_link_speed); |
527 | 527 | ||
@@ -579,14 +579,16 @@ static void pci_set_bus_speed(struct pci_bus *bus) | |||
579 | if (pos) { | 579 | if (pos) { |
580 | u16 status; | 580 | u16 status; |
581 | enum pci_bus_speed max; | 581 | enum pci_bus_speed max; |
582 | pci_read_config_word(bridge, pos + 2, &status); | ||
583 | 582 | ||
584 | if (status & 0x8000) { | 583 | pci_read_config_word(bridge, pos + PCI_X_BRIDGE_SSTATUS, |
584 | &status); | ||
585 | |||
586 | if (status & PCI_X_SSTATUS_533MHZ) { | ||
585 | max = PCI_SPEED_133MHz_PCIX_533; | 587 | max = PCI_SPEED_133MHz_PCIX_533; |
586 | } else if (status & 0x4000) { | 588 | } else if (status & PCI_X_SSTATUS_266MHZ) { |
587 | max = PCI_SPEED_133MHz_PCIX_266; | 589 | max = PCI_SPEED_133MHz_PCIX_266; |
588 | } else if (status & 0x0002) { | 590 | } else if (status & PCI_X_SSTATUS_133MHZ) { |
589 | if (((status >> 12) & 0x3) == 2) { | 591 | if ((status & PCI_X_SSTATUS_VERS) == PCI_X_SSTATUS_V2) { |
590 | max = PCI_SPEED_133MHz_PCIX_ECC; | 592 | max = PCI_SPEED_133MHz_PCIX_ECC; |
591 | } else { | 593 | } else { |
592 | max = PCI_SPEED_133MHz_PCIX; | 594 | max = PCI_SPEED_133MHz_PCIX; |
@@ -596,7 +598,8 @@ static void pci_set_bus_speed(struct pci_bus *bus) | |||
596 | } | 598 | } |
597 | 599 | ||
598 | bus->max_bus_speed = max; | 600 | bus->max_bus_speed = max; |
599 | bus->cur_bus_speed = pcix_bus_speed[(status >> 6) & 0xf]; | 601 | bus->cur_bus_speed = pcix_bus_speed[ |
602 | (status & PCI_X_SSTATUS_FREQ) >> 6]; | ||
600 | 603 | ||
601 | return; | 604 | return; |
602 | } | 605 | } |
@@ -607,7 +610,7 @@ static void pci_set_bus_speed(struct pci_bus *bus) | |||
607 | u16 linksta; | 610 | u16 linksta; |
608 | 611 | ||
609 | pcie_capability_read_dword(bridge, PCI_EXP_LNKCAP, &linkcap); | 612 | pcie_capability_read_dword(bridge, PCI_EXP_LNKCAP, &linkcap); |
610 | bus->max_bus_speed = pcie_link_speed[linkcap & 0xf]; | 613 | bus->max_bus_speed = pcie_link_speed[linkcap & PCI_EXP_LNKCAP_SLS]; |
611 | 614 | ||
612 | pcie_capability_read_word(bridge, PCI_EXP_LNKSTA, &linksta); | 615 | pcie_capability_read_word(bridge, PCI_EXP_LNKSTA, &linksta); |
613 | pcie_update_link_speed(bus, linksta); | 616 | pcie_update_link_speed(bus, linksta); |
@@ -975,6 +978,7 @@ int pci_setup_device(struct pci_dev *dev) | |||
975 | dev->sysdata = dev->bus->sysdata; | 978 | dev->sysdata = dev->bus->sysdata; |
976 | dev->dev.parent = dev->bus->bridge; | 979 | dev->dev.parent = dev->bus->bridge; |
977 | dev->dev.bus = &pci_bus_type; | 980 | dev->dev.bus = &pci_bus_type; |
981 | dev->dev.type = &pci_dev_type; | ||
978 | dev->hdr_type = hdr_type & 0x7f; | 982 | dev->hdr_type = hdr_type & 0x7f; |
979 | dev->multifunction = !!(hdr_type & 0x80); | 983 | dev->multifunction = !!(hdr_type & 0x80); |
980 | dev->error_state = pci_channel_io_normal; | 984 | dev->error_state = pci_channel_io_normal; |
@@ -1889,6 +1893,28 @@ unsigned int __ref pci_rescan_bus_bridge_resize(struct pci_dev *bridge) | |||
1889 | return max; | 1893 | return max; |
1890 | } | 1894 | } |
1891 | 1895 | ||
1896 | /** | ||
1897 | * pci_rescan_bus - scan a PCI bus for devices. | ||
1898 | * @bus: PCI bus to scan | ||
1899 | * | ||
1900 | * Scan a PCI bus and child buses for new devices, adds them, | ||
1901 | * and enables them. | ||
1902 | * | ||
1903 | * Returns the max number of subordinate bus discovered. | ||
1904 | */ | ||
1905 | unsigned int __ref pci_rescan_bus(struct pci_bus *bus) | ||
1906 | { | ||
1907 | unsigned int max; | ||
1908 | |||
1909 | max = pci_scan_child_bus(bus); | ||
1910 | pci_assign_unassigned_bus_resources(bus); | ||
1911 | pci_enable_bridges(bus); | ||
1912 | pci_bus_add_devices(bus); | ||
1913 | |||
1914 | return max; | ||
1915 | } | ||
1916 | EXPORT_SYMBOL_GPL(pci_rescan_bus); | ||
1917 | |||
1892 | EXPORT_SYMBOL(pci_add_new_bus); | 1918 | EXPORT_SYMBOL(pci_add_new_bus); |
1893 | EXPORT_SYMBOL(pci_scan_slot); | 1919 | EXPORT_SYMBOL(pci_scan_slot); |
1894 | EXPORT_SYMBOL(pci_scan_bridge); | 1920 | EXPORT_SYMBOL(pci_scan_bridge); |
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 22ad3ee0cf0b..8f7a6344e79e 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -1790,6 +1790,45 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TOSHIBA_2, | |||
1790 | PCI_DEVICE_ID_TOSHIBA_TC86C001_IDE, | 1790 | PCI_DEVICE_ID_TOSHIBA_TC86C001_IDE, |
1791 | quirk_tc86c001_ide); | 1791 | quirk_tc86c001_ide); |
1792 | 1792 | ||
1793 | /* | ||
1794 | * PLX PCI 9050 PCI Target bridge controller has an errata that prevents the | ||
1795 | * local configuration registers accessible via BAR0 (memory) or BAR1 (i/o) | ||
1796 | * being read correctly if bit 7 of the base address is set. | ||
1797 | * The BAR0 or BAR1 region may be disabled (size 0) or enabled (size 128). | ||
1798 | * Re-allocate the regions to a 256-byte boundary if necessary. | ||
1799 | */ | ||
1800 | static void quirk_plx_pci9050(struct pci_dev *dev) | ||
1801 | { | ||
1802 | unsigned int bar; | ||
1803 | |||
1804 | /* Fixed in revision 2 (PCI 9052). */ | ||
1805 | if (dev->revision >= 2) | ||
1806 | return; | ||
1807 | for (bar = 0; bar <= 1; bar++) | ||
1808 | if (pci_resource_len(dev, bar) == 0x80 && | ||
1809 | (pci_resource_start(dev, bar) & 0x80)) { | ||
1810 | struct resource *r = &dev->resource[bar]; | ||
1811 | dev_info(&dev->dev, | ||
1812 | "Re-allocating PLX PCI 9050 BAR %u to length 256 to avoid bit 7 bug\n", | ||
1813 | bar); | ||
1814 | r->start = 0; | ||
1815 | r->end = 0xff; | ||
1816 | } | ||
1817 | } | ||
1818 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050, | ||
1819 | quirk_plx_pci9050); | ||
1820 | /* | ||
1821 | * The following Meilhaus (vendor ID 0x1402) device IDs (amongst others) | ||
1822 | * may be using the PLX PCI 9050: 0x0630, 0x0940, 0x0950, 0x0960, 0x100b, | ||
1823 | * 0x1400, 0x140a, 0x140b, 0x14e0, 0x14ea, 0x14eb, 0x1604, 0x1608, 0x160c, | ||
1824 | * 0x168f, 0x2000, 0x2600, 0x3000, 0x810a, 0x810b. | ||
1825 | * | ||
1826 | * Currently, device IDs 0x2000 and 0x2600 are used by the Comedi "me_daq" | ||
1827 | * driver. | ||
1828 | */ | ||
1829 | DECLARE_PCI_FIXUP_HEADER(0x1402, 0x2000, quirk_plx_pci9050); | ||
1830 | DECLARE_PCI_FIXUP_HEADER(0x1402, 0x2600, quirk_plx_pci9050); | ||
1831 | |||
1793 | static void quirk_netmos(struct pci_dev *dev) | 1832 | static void quirk_netmos(struct pci_dev *dev) |
1794 | { | 1833 | { |
1795 | unsigned int num_parallel = (dev->subsystem_device & 0xf0) >> 4; | 1834 | unsigned int num_parallel = (dev->subsystem_device & 0xf0) >> 4; |
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index 513972f3ed13..7c0fd9252e6f 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c | |||
@@ -111,3 +111,39 @@ void pci_stop_and_remove_bus_device(struct pci_dev *dev) | |||
111 | pci_remove_bus_device(dev); | 111 | pci_remove_bus_device(dev); |
112 | } | 112 | } |
113 | EXPORT_SYMBOL(pci_stop_and_remove_bus_device); | 113 | EXPORT_SYMBOL(pci_stop_and_remove_bus_device); |
114 | |||
115 | void pci_stop_root_bus(struct pci_bus *bus) | ||
116 | { | ||
117 | struct pci_dev *child, *tmp; | ||
118 | struct pci_host_bridge *host_bridge; | ||
119 | |||
120 | if (!pci_is_root_bus(bus)) | ||
121 | return; | ||
122 | |||
123 | host_bridge = to_pci_host_bridge(bus->bridge); | ||
124 | list_for_each_entry_safe_reverse(child, tmp, | ||
125 | &bus->devices, bus_list) | ||
126 | pci_stop_bus_device(child); | ||
127 | |||
128 | /* stop the host bridge */ | ||
129 | device_del(&host_bridge->dev); | ||
130 | } | ||
131 | |||
132 | void pci_remove_root_bus(struct pci_bus *bus) | ||
133 | { | ||
134 | struct pci_dev *child, *tmp; | ||
135 | struct pci_host_bridge *host_bridge; | ||
136 | |||
137 | if (!pci_is_root_bus(bus)) | ||
138 | return; | ||
139 | |||
140 | host_bridge = to_pci_host_bridge(bus->bridge); | ||
141 | list_for_each_entry_safe(child, tmp, | ||
142 | &bus->devices, bus_list) | ||
143 | pci_remove_bus_device(child); | ||
144 | pci_remove_bus(bus); | ||
145 | host_bridge->bus = NULL; | ||
146 | |||
147 | /* remove the host bridge */ | ||
148 | put_device(&host_bridge->dev); | ||
149 | } | ||
diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c index 0b3037ab8b93..ab886b7ee327 100644 --- a/drivers/pci/rom.c +++ b/drivers/pci/rom.c | |||
@@ -118,11 +118,17 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size) | |||
118 | void __iomem *rom; | 118 | void __iomem *rom; |
119 | 119 | ||
120 | /* | 120 | /* |
121 | * Some devices may provide ROMs via a source other than the BAR | ||
122 | */ | ||
123 | if (pdev->rom && pdev->romlen) { | ||
124 | *size = pdev->romlen; | ||
125 | return phys_to_virt(pdev->rom); | ||
126 | /* | ||
121 | * IORESOURCE_ROM_SHADOW set on x86, x86_64 and IA64 supports legacy | 127 | * IORESOURCE_ROM_SHADOW set on x86, x86_64 and IA64 supports legacy |
122 | * memory map if the VGA enable bit of the Bridge Control register is | 128 | * memory map if the VGA enable bit of the Bridge Control register is |
123 | * set for embedded VGA. | 129 | * set for embedded VGA. |
124 | */ | 130 | */ |
125 | if (res->flags & IORESOURCE_ROM_SHADOW) { | 131 | } else if (res->flags & IORESOURCE_ROM_SHADOW) { |
126 | /* primary video rom always starts here */ | 132 | /* primary video rom always starts here */ |
127 | start = (loff_t)0xC0000; | 133 | start = (loff_t)0xC0000; |
128 | *size = 0x20000; /* cover C000:0 through E000:0 */ | 134 | *size = 0x20000; /* cover C000:0 through E000:0 */ |
@@ -181,7 +187,8 @@ void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom) | |||
181 | if (res->flags & (IORESOURCE_ROM_COPY | IORESOURCE_ROM_BIOS_COPY)) | 187 | if (res->flags & (IORESOURCE_ROM_COPY | IORESOURCE_ROM_BIOS_COPY)) |
182 | return; | 188 | return; |
183 | 189 | ||
184 | iounmap(rom); | 190 | if (!pdev->rom || !pdev->romlen) |
191 | iounmap(rom); | ||
185 | 192 | ||
186 | /* Disable again before continuing, leave enabled if pci=rom */ | 193 | /* Disable again before continuing, leave enabled if pci=rom */ |
187 | if (!(res->flags & (IORESOURCE_ROM_ENABLE | IORESOURCE_ROM_SHADOW))) | 194 | if (!(res->flags & (IORESOURCE_ROM_ENABLE | IORESOURCE_ROM_SHADOW))) |
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 1e808ca338f8..6d3591d57ea0 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c | |||
@@ -1550,25 +1550,12 @@ enable_all: | |||
1550 | } | 1550 | } |
1551 | EXPORT_SYMBOL_GPL(pci_assign_unassigned_bridge_resources); | 1551 | EXPORT_SYMBOL_GPL(pci_assign_unassigned_bridge_resources); |
1552 | 1552 | ||
1553 | #ifdef CONFIG_HOTPLUG | 1553 | void pci_assign_unassigned_bus_resources(struct pci_bus *bus) |
1554 | /** | ||
1555 | * pci_rescan_bus - scan a PCI bus for devices. | ||
1556 | * @bus: PCI bus to scan | ||
1557 | * | ||
1558 | * Scan a PCI bus and child buses for new devices, adds them, | ||
1559 | * and enables them. | ||
1560 | * | ||
1561 | * Returns the max number of subordinate bus discovered. | ||
1562 | */ | ||
1563 | unsigned int __ref pci_rescan_bus(struct pci_bus *bus) | ||
1564 | { | 1554 | { |
1565 | unsigned int max; | ||
1566 | struct pci_dev *dev; | 1555 | struct pci_dev *dev; |
1567 | LIST_HEAD(add_list); /* list of resources that | 1556 | LIST_HEAD(add_list); /* list of resources that |
1568 | want additional resources */ | 1557 | want additional resources */ |
1569 | 1558 | ||
1570 | max = pci_scan_child_bus(bus); | ||
1571 | |||
1572 | down_read(&pci_bus_sem); | 1559 | down_read(&pci_bus_sem); |
1573 | list_for_each_entry(dev, &bus->devices, bus_list) | 1560 | list_for_each_entry(dev, &bus->devices, bus_list) |
1574 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || | 1561 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || |
@@ -1579,11 +1566,4 @@ unsigned int __ref pci_rescan_bus(struct pci_bus *bus) | |||
1579 | up_read(&pci_bus_sem); | 1566 | up_read(&pci_bus_sem); |
1580 | __pci_bus_assign_resources(bus, &add_list, NULL); | 1567 | __pci_bus_assign_resources(bus, &add_list, NULL); |
1581 | BUG_ON(!list_empty(&add_list)); | 1568 | BUG_ON(!list_empty(&add_list)); |
1582 | |||
1583 | pci_enable_bridges(bus); | ||
1584 | pci_bus_add_devices(bus); | ||
1585 | |||
1586 | return max; | ||
1587 | } | 1569 | } |
1588 | EXPORT_SYMBOL_GPL(pci_rescan_bus); | ||
1589 | #endif | ||
diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c index db542f4196a4..966abc6054d7 100644 --- a/drivers/pci/xen-pcifront.c +++ b/drivers/pci/xen-pcifront.c | |||
@@ -1068,13 +1068,16 @@ static void __init_refok pcifront_backend_changed(struct xenbus_device *xdev, | |||
1068 | case XenbusStateInitialising: | 1068 | case XenbusStateInitialising: |
1069 | case XenbusStateInitWait: | 1069 | case XenbusStateInitWait: |
1070 | case XenbusStateInitialised: | 1070 | case XenbusStateInitialised: |
1071 | case XenbusStateClosed: | ||
1072 | break; | 1071 | break; |
1073 | 1072 | ||
1074 | case XenbusStateConnected: | 1073 | case XenbusStateConnected: |
1075 | pcifront_try_connect(pdev); | 1074 | pcifront_try_connect(pdev); |
1076 | break; | 1075 | break; |
1077 | 1076 | ||
1077 | case XenbusStateClosed: | ||
1078 | if (xdev->state == XenbusStateClosed) | ||
1079 | break; | ||
1080 | /* Missed the backend's CLOSING state -- fallthrough */ | ||
1078 | case XenbusStateClosing: | 1081 | case XenbusStateClosing: |
1079 | dev_warn(&xdev->dev, "backend going away!\n"); | 1082 | dev_warn(&xdev->dev, "backend going away!\n"); |
1080 | pcifront_try_disconnect(pdev); | 1083 | pcifront_try_disconnect(pdev); |