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

Merge branch 'pci/controller/linkup-fix'

- Rename PCIE_RESET_CONFIG_DEVICE_WAIT_MS to PCIE_RESET_CONFIG_WAIT_MS (the
required delay before sending config requests after a reset) (Niklas
Cassel)

- PCIE_T_RRS_READY_MS and PCIE_RESET_CONFIG_WAIT_MS were two names for the
same delay; replace PCIE_T_RRS_READY_MS with PCIE_RESET_CONFIG_WAIT_MS
and remove PCIE_T_RRS_READY_MS (Niklas Cassel)

- Add required PCIE_RESET_CONFIG_WAIT_MS delay after Link up IRQ to
dw-rockchip, qcom (Niklas Cassel)

- Add required PCIE_RESET_CONFIG_WAIT_MS after waiting for Link up on
Ports that support > 5.0 GT/s in dwc core (Niklas Cassel)

- Move LINK_WAIT_SLEEP_MS and LINK_WAIT_MAX_RETRIES to pci.h and prefix
with 'PCIE_' for potential sharing across drivers (Niklas Cassel)

* pci/controller/linkup-fix:
PCI: Move link up wait time and max retries macros to pci.h
PCI: dwc: Ensure that dw_pcie_wait_for_link() waits 100 ms after link up
PCI: qcom: Wait PCIE_RESET_CONFIG_WAIT_MS after link-up IRQ
PCI: dw-rockchip: Wait PCIE_RESET_CONFIG_WAIT_MS after link-up IRQ
PCI: rockchip-host: Use macro PCIE_RESET_CONFIG_WAIT_MS
PCI: Rename PCIE_RESET_CONFIG_DEVICE_WAIT_MS to PCIE_RESET_CONFIG_WAIT_MS

+20 -17
+11 -3
drivers/pci/controller/dwc/pcie-designware.c
··· 702 702 int retries; 703 703 704 704 /* Check if the link is up or not */ 705 - for (retries = 0; retries < LINK_WAIT_MAX_RETRIES; retries++) { 705 + for (retries = 0; retries < PCIE_LINK_WAIT_MAX_RETRIES; retries++) { 706 706 if (dw_pcie_link_up(pci)) 707 707 break; 708 708 709 - msleep(LINK_WAIT_SLEEP_MS); 709 + msleep(PCIE_LINK_WAIT_SLEEP_MS); 710 710 } 711 711 712 - if (retries >= LINK_WAIT_MAX_RETRIES) { 712 + if (retries >= PCIE_LINK_WAIT_MAX_RETRIES) { 713 713 dev_info(pci->dev, "Phy link never came up\n"); 714 714 return -ETIMEDOUT; 715 715 } 716 + 717 + /* 718 + * As per PCIe r6.0, sec 6.6.1, a Downstream Port that supports Link 719 + * speeds greater than 5.0 GT/s, software must wait a minimum of 100 ms 720 + * after Link training completes before sending a Configuration Request. 721 + */ 722 + if (pci->max_link_speed > 2) 723 + msleep(PCIE_RESET_CONFIG_WAIT_MS); 716 724 717 725 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP); 718 726 val = dw_pcie_readw_dbi(pci, offset + PCI_EXP_LNKSTA);
-4
drivers/pci/controller/dwc/pcie-designware.h
··· 62 62 #define dw_pcie_cap_set(_pci, _cap) \ 63 63 set_bit(DW_PCIE_CAP_ ## _cap, &(_pci)->caps) 64 64 65 - /* Parameters for the waiting for link up routine */ 66 - #define LINK_WAIT_MAX_RETRIES 10 67 - #define LINK_WAIT_SLEEP_MS 90 68 - 69 65 /* Parameters for the waiting for iATU enabled routine */ 70 66 #define LINK_WAIT_MAX_IATU_RETRIES 5 71 67 #define LINK_WAIT_IATU 9
+1
drivers/pci/controller/dwc/pcie-dw-rockchip.c
··· 458 458 459 459 if (reg & PCIE_RDLH_LINK_UP_CHGED) { 460 460 if (rockchip_pcie_link_up(pci)) { 461 + msleep(PCIE_RESET_CONFIG_WAIT_MS); 461 462 dev_dbg(dev, "Received Link up event. Starting enumeration!\n"); 462 463 /* Rescan the bus to enumerate endpoint devices */ 463 464 pci_lock_rescan_remove();
+1
drivers/pci/controller/dwc/pcie-qcom.c
··· 1564 1564 writel_relaxed(status, pcie->parf + PARF_INT_ALL_CLEAR); 1565 1565 1566 1566 if (FIELD_GET(PARF_INT_ALL_LINK_UP, status)) { 1567 + msleep(PCIE_RESET_CONFIG_WAIT_MS); 1567 1568 dev_dbg(dev, "Received Link up event. Starting enumeration!\n"); 1568 1569 /* Rescan the bus to enumerate endpoint devices */ 1569 1570 pci_lock_rescan_remove();
+1 -1
drivers/pci/controller/pcie-rockchip-host.c
··· 325 325 msleep(PCIE_T_PVPERL_MS); 326 326 gpiod_set_value_cansleep(rockchip->perst_gpio, 1); 327 327 328 - msleep(PCIE_T_RRS_READY_MS); 328 + msleep(PCIE_RESET_CONFIG_WAIT_MS); 329 329 330 330 /* 500ms timeout value should be enough for Gen1/2 training */ 331 331 err = readl_poll_timeout(rockchip->apb_base + PCIE_CLIENT_BASIC_STATUS1,
+1 -1
drivers/pci/controller/plda/pcie-starfive.c
··· 368 368 * of 100ms following exit from a conventional reset before 369 369 * sending a configuration request to the device. 370 370 */ 371 - msleep(PCIE_RESET_CONFIG_DEVICE_WAIT_MS); 371 + msleep(PCIE_RESET_CONFIG_WAIT_MS); 372 372 373 373 if (starfive_pcie_host_wait_for_link(pcie)) 374 374 dev_info(dev, "port link down\n");
+5 -8
drivers/pci/pci.h
··· 36 36 #define PCIE_T_PERST_CLK_US 100 37 37 38 38 /* 39 - * End of conventional reset (PERST# de-asserted) to first configuration 40 - * request (device able to respond with a "Request Retry Status" completion), 41 - * from PCIe r6.0, sec 6.6.1. 42 - */ 43 - #define PCIE_T_RRS_READY_MS 100 44 - 45 - /* 46 39 * PCIe r6.0, sec 5.3.3.2.1 <PME Synchronization> 47 40 * Recommends 1ms to 10ms timeout to check L2 ready. 48 41 */ ··· 54 61 * completes before sending a Configuration Request to the device 55 62 * immediately below that Port." 56 63 */ 57 - #define PCIE_RESET_CONFIG_DEVICE_WAIT_MS 100 64 + #define PCIE_RESET_CONFIG_WAIT_MS 100 65 + 66 + /* Parameters for the waiting for link up routine */ 67 + #define PCIE_LINK_WAIT_MAX_RETRIES 10 68 + #define PCIE_LINK_WAIT_SLEEP_MS 90 58 69 59 70 /* Message Routing (r[2:0]); PCIe r6.0, sec 2.2.8 */ 60 71 #define PCIE_MSG_TYPE_R_RC 0