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

Merge branch 'pci/misc' into next

* pci/misc:
PCI: Read capability list as dwords, not bytes
PCI: Don't clear ASPM bits when the FADT declares it's unsupported
PCI: Clarify policy for vendor IDs in pci.txt
PCI/ACPI: Optimize device state transition delays
PCI: Export pci_find_host_bridge() for use inside PCI core
PCI: Make a shareable UUID for PCI firmware ACPI _DSM
PCI: Fix typo in Thunderbolt kernel message

+118 -56
+6 -6
Documentation/PCI/pci.txt
··· 564 564 8. Vendor and device identifications 565 565 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 566 566 567 - One is not required to add new device ids to include/linux/pci_ids.h. 568 - Please add PCI_VENDOR_ID_xxx for vendors and a hex constant for device ids. 567 + Do not add new device or vendor IDs to include/linux/pci_ids.h unless they 568 + are shared across multiple drivers. You can add private definitions in 569 + your driver if they're helpful, or just use plain hex constants. 569 570 570 - PCI_VENDOR_ID_xxx constants are re-used. The device ids are arbitrary 571 - hex numbers (vendor controlled) and normally used only in a single 572 - location, the pci_device_id table. 571 + The device IDs are arbitrary hex numbers (vendor controlled) and normally used 572 + only in a single location, the pci_device_id table. 573 573 574 - Please DO submit new vendor/device ids to pciids.sourceforge.net project. 574 + Please DO submit new vendor/device IDs to http://pciids.sourceforge.net/. 575 575 576 576 577 577
+8 -11
drivers/acpi/pci_root.c
··· 423 423 } 424 424 EXPORT_SYMBOL(acpi_pci_osc_control_set); 425 425 426 - static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm, 427 - int *clear_aspm) 426 + static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm) 428 427 { 429 428 u32 support, control, requested; 430 429 acpi_status status; ··· 494 495 decode_osc_control(root, "OS now controls", control); 495 496 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) { 496 497 /* 497 - * We have ASPM control, but the FADT indicates 498 - * that it's unsupported. Clear it. 498 + * We have ASPM control, but the FADT indicates that 499 + * it's unsupported. Leave existing configuration 500 + * intact and prevent the OS from touching it. 499 501 */ 500 - *clear_aspm = 1; 502 + dev_info(&device->dev, "FADT indicates ASPM is unsupported, using BIOS configuration\n"); 503 + *no_aspm = 1; 501 504 } 502 505 } else { 503 506 decode_osc_control(root, "OS requested", requested); ··· 526 525 int result; 527 526 struct acpi_pci_root *root; 528 527 acpi_handle handle = device->handle; 529 - int no_aspm = 0, clear_aspm = 0; 528 + int no_aspm = 0; 530 529 bool hotadd = system_state != SYSTEM_BOOTING; 531 530 532 531 root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); ··· 585 584 586 585 root->mcfg_addr = acpi_pci_root_get_mcfg_addr(handle); 587 586 588 - negotiate_os_control(root, &no_aspm, &clear_aspm); 587 + negotiate_os_control(root, &no_aspm); 589 588 590 589 /* 591 590 * TBD: Need PCI interface for enumeration/configuration of roots. ··· 608 607 goto remove_dmar; 609 608 } 610 609 611 - if (clear_aspm) { 612 - dev_info(&device->dev, "Disabling ASPM (FADT indicates it is unsupported)\n"); 613 - pcie_clear_aspm(root->bus); 614 - } 615 610 if (no_aspm) 616 611 pcie_no_aspm(); 617 612
+3 -3
drivers/pci/host-bridge.c
··· 16 16 return bus; 17 17 } 18 18 19 - static struct pci_host_bridge *find_pci_host_bridge(struct pci_bus *bus) 19 + struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus) 20 20 { 21 21 struct pci_bus *root_bus = find_pci_root_bus(bus); 22 22 ··· 48 48 void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region, 49 49 struct resource *res) 50 50 { 51 - struct pci_host_bridge *bridge = find_pci_host_bridge(bus); 51 + struct pci_host_bridge *bridge = pci_find_host_bridge(bus); 52 52 struct resource_entry *window; 53 53 resource_size_t offset = 0; 54 54 ··· 73 73 void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res, 74 74 struct pci_bus_region *region) 75 75 { 76 - struct pci_host_bridge *bridge = find_pci_host_bridge(bus); 76 + struct pci_host_bridge *bridge = pci_find_host_bridge(bus); 77 77 struct resource_entry *window; 78 78 resource_size_t offset = 0; 79 79
+83
drivers/pci/pci-acpi.c
··· 18 18 #include <linux/pm_qos.h> 19 19 #include "pci.h" 20 20 21 + /* 22 + * The UUID is defined in the PCI Firmware Specification available here: 23 + * https://www.pcisig.com/members/downloads/pcifw_r3_1_13Dec10.pdf 24 + */ 25 + const u8 pci_acpi_dsm_uuid[] = { 26 + 0xd0, 0x37, 0xc9, 0xe5, 0x53, 0x35, 0x7a, 0x4d, 27 + 0x91, 0x17, 0xea, 0x4d, 0x19, 0xc3, 0x43, 0x4d 28 + }; 29 + 21 30 phys_addr_t acpi_pci_root_get_mcfg_addr(acpi_handle handle) 22 31 { 23 32 acpi_status status = AE_NOT_EXIST; ··· 537 528 538 529 void acpi_pci_add_bus(struct pci_bus *bus) 539 530 { 531 + union acpi_object *obj; 532 + struct pci_host_bridge *bridge; 533 + 540 534 if (acpi_pci_disabled || !bus->bridge) 541 535 return; 542 536 543 537 acpi_pci_slot_enumerate(bus); 544 538 acpiphp_enumerate_slots(bus); 539 + 540 + /* 541 + * For a host bridge, check its _DSM for function 8 and if 542 + * that is available, mark it in pci_host_bridge. 543 + */ 544 + if (!pci_is_root_bus(bus)) 545 + return; 546 + 547 + obj = acpi_evaluate_dsm(ACPI_HANDLE(bus->bridge), pci_acpi_dsm_uuid, 3, 548 + RESET_DELAY_DSM, NULL); 549 + if (!obj) 550 + return; 551 + 552 + if (obj->type == ACPI_TYPE_INTEGER && obj->integer.value == 1) { 553 + bridge = pci_find_host_bridge(bus); 554 + bridge->ignore_reset_delay = 1; 555 + } 556 + ACPI_FREE(obj); 545 557 } 546 558 547 559 void acpi_pci_remove_bus(struct pci_bus *bus) ··· 588 558 check_children); 589 559 } 590 560 561 + /** 562 + * pci_acpi_optimize_delay - optimize PCI D3 and D3cold delay from ACPI 563 + * @pdev: the PCI device whose delay is to be updated 564 + * @adev: the companion ACPI device of this PCI device 565 + * 566 + * Update the d3_delay and d3cold_delay of a PCI device from the ACPI _DSM 567 + * control method of either the device itself or the PCI host bridge. 568 + * 569 + * Function 8, "Reset Delay," applies to the entire hierarchy below a PCI 570 + * host bridge. If it returns one, the OS may assume that all devices in 571 + * the hierarchy have already completed power-on reset delays. 572 + * 573 + * Function 9, "Device Readiness Durations," applies only to the object 574 + * where it is located. It returns delay durations required after various 575 + * events if the device requires less time than the spec requires. Delays 576 + * from this function take precedence over the Reset Delay function. 577 + * 578 + * These _DSM functions are defined by the draft ECN of January 28, 2014, 579 + * titled "ACPI additions for FW latency optimizations." 580 + */ 581 + static void pci_acpi_optimize_delay(struct pci_dev *pdev, 582 + acpi_handle handle) 583 + { 584 + struct pci_host_bridge *bridge = pci_find_host_bridge(pdev->bus); 585 + int value; 586 + union acpi_object *obj, *elements; 587 + 588 + if (bridge->ignore_reset_delay) 589 + pdev->d3cold_delay = 0; 590 + 591 + obj = acpi_evaluate_dsm(handle, pci_acpi_dsm_uuid, 3, 592 + FUNCTION_DELAY_DSM, NULL); 593 + if (!obj) 594 + return; 595 + 596 + if (obj->type == ACPI_TYPE_PACKAGE && obj->package.count == 5) { 597 + elements = obj->package.elements; 598 + if (elements[0].type == ACPI_TYPE_INTEGER) { 599 + value = (int)elements[0].integer.value / 1000; 600 + if (value < PCI_PM_D3COLD_WAIT) 601 + pdev->d3cold_delay = value; 602 + } 603 + if (elements[3].type == ACPI_TYPE_INTEGER) { 604 + value = (int)elements[3].integer.value / 1000; 605 + if (value < PCI_PM_D3_WAIT) 606 + pdev->d3_delay = value; 607 + } 608 + } 609 + ACPI_FREE(obj); 610 + } 611 + 591 612 static void pci_acpi_setup(struct device *dev) 592 613 { 593 614 struct pci_dev *pci_dev = to_pci_dev(dev); ··· 646 565 647 566 if (!adev) 648 567 return; 568 + 569 + pci_acpi_optimize_delay(pci_dev, adev->handle); 649 570 650 571 pci_acpi_add_pm_notifier(adev, pci_dev); 651 572 if (!adev->wakeup.flags.valid)
+2 -9
drivers/pci/pci-label.c
··· 31 31 #include <linux/pci-acpi.h> 32 32 #include "pci.h" 33 33 34 - #define DEVICE_LABEL_DSM 0x07 35 - 36 34 #ifdef CONFIG_DMI 37 35 enum smbios_attr_enum { 38 36 SMBIOS_ATTR_NONE = 0, ··· 146 148 #endif 147 149 148 150 #ifdef CONFIG_ACPI 149 - static const char device_label_dsm_uuid[] = { 150 - 0xD0, 0x37, 0xC9, 0xE5, 0x53, 0x35, 0x7A, 0x4D, 151 - 0x91, 0x17, 0xEA, 0x4D, 0x19, 0xC3, 0x43, 0x4D 152 - }; 153 - 154 151 enum acpi_attr_enum { 155 152 ACPI_ATTR_LABEL_SHOW, 156 153 ACPI_ATTR_INDEX_SHOW, ··· 172 179 if (!handle) 173 180 return -1; 174 181 175 - obj = acpi_evaluate_dsm(handle, device_label_dsm_uuid, 0x2, 182 + obj = acpi_evaluate_dsm(handle, pci_acpi_dsm_uuid, 0x2, 176 183 DEVICE_LABEL_DSM, NULL); 177 184 if (!obj) 178 185 return -1; ··· 212 219 if (!handle) 213 220 return false; 214 221 215 - return !!acpi_check_dsm(handle, device_label_dsm_uuid, 0x2, 222 + return !!acpi_check_dsm(handle, pci_acpi_dsm_uuid, 0x2, 216 223 1 << DEVICE_LABEL_DSM); 217 224 } 218 225
+7 -4
drivers/pci/pci.c
··· 146 146 u8 pos, int cap, int *ttl) 147 147 { 148 148 u8 id; 149 + u16 ent; 150 + 151 + pci_bus_read_config_byte(bus, devfn, pos, &pos); 149 152 150 153 while ((*ttl)--) { 151 - pci_bus_read_config_byte(bus, devfn, pos, &pos); 152 154 if (pos < 0x40) 153 155 break; 154 156 pos &= ~3; 155 - pci_bus_read_config_byte(bus, devfn, pos + PCI_CAP_LIST_ID, 156 - &id); 157 + pci_bus_read_config_word(bus, devfn, pos, &ent); 158 + 159 + id = ent & 0xff; 157 160 if (id == 0xff) 158 161 break; 159 162 if (id == cap) 160 163 return pos; 161 - pos += PCI_CAP_LIST_NEXT; 164 + pos = (ent >> 8); 162 165 } 163 166 return 0; 164 167 }
+2
drivers/pci/pci.h
··· 321 321 } 322 322 #endif 323 323 324 + struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus); 325 + 324 326 #endif /* DRIVERS_PCI_H */
-18
drivers/pci/pcie/aspm.c
··· 782 782 } 783 783 EXPORT_SYMBOL(pci_disable_link_state); 784 784 785 - void pcie_clear_aspm(struct pci_bus *bus) 786 - { 787 - struct pci_dev *child; 788 - 789 - if (aspm_force) 790 - return; 791 - 792 - /* 793 - * Clear any ASPM setup that the firmware has carried out on this bus 794 - */ 795 - list_for_each_entry(child, &bus->devices, bus_list) { 796 - __pci_disable_link_state(child, PCIE_LINK_STATE_L0S | 797 - PCIE_LINK_STATE_L1 | 798 - PCIE_LINK_STATE_CLKPM, 799 - false, true); 800 - } 801 - } 802 - 803 785 static int pcie_aspm_set_policy(const char *val, struct kernel_param *kp) 804 786 { 805 787 int i;
+1 -1
drivers/pci/quirks.c
··· 3182 3182 || nhi->subsystem_vendor != 0x2222 3183 3183 || nhi->subsystem_device != 0x1111) 3184 3184 goto out; 3185 - dev_info(&dev->dev, "quirk: wating for thunderbolt to reestablish pci tunnels...\n"); 3185 + dev_info(&dev->dev, "quirk: waiting for thunderbolt to reestablish PCI tunnels...\n"); 3186 3186 device_pm_wait_for_dev(&dev->dev, &nhi->dev); 3187 3187 out: 3188 3188 pci_dev_put(nhi);
+5
include/linux/pci-acpi.h
··· 77 77 static inline void acpiphp_check_host_bridge(struct acpi_device *adev) { } 78 78 #endif 79 79 80 + extern const u8 pci_acpi_dsm_uuid[]; 81 + #define DEVICE_LABEL_DSM 0x07 82 + #define RESET_DELAY_DSM 0x08 83 + #define FUNCTION_DELAY_DSM 0x09 84 + 80 85 #else /* CONFIG_ACPI */ 81 86 static inline void acpi_pci_add_bus(struct pci_bus *bus) { } 82 87 static inline void acpi_pci_remove_bus(struct pci_bus *bus) { }
-4
include/linux/pci-aspm.h
··· 29 29 void pcie_aspm_powersave_config_link(struct pci_dev *pdev); 30 30 void pci_disable_link_state(struct pci_dev *pdev, int state); 31 31 void pci_disable_link_state_locked(struct pci_dev *pdev, int state); 32 - void pcie_clear_aspm(struct pci_bus *bus); 33 32 void pcie_no_aspm(void); 34 33 #else 35 34 static inline void pcie_aspm_init_link_state(struct pci_dev *pdev) ··· 44 45 { 45 46 } 46 47 static inline void pci_disable_link_state(struct pci_dev *pdev, int state) 47 - { 48 - } 49 - static inline void pcie_clear_aspm(struct pci_bus *bus) 50 48 { 51 49 } 52 50 static inline void pcie_no_aspm(void)
+1
include/linux/pci.h
··· 406 406 struct list_head windows; /* resource_entry */ 407 407 void (*release_fn)(struct pci_host_bridge *); 408 408 void *release_data; 409 + unsigned int ignore_reset_delay:1; /* for entire hierarchy */ 409 410 }; 410 411 411 412 #define to_pci_host_bridge(n) container_of(n, struct pci_host_bridge, dev)