Skip to content

Commit 480b315

Browse files
committed
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
2 parents 769ce53 + d7467bc commit 480b315

File tree

7 files changed

+20
-17
lines changed

7 files changed

+20
-17
lines changed

drivers/pci/controller/dwc/pcie-designware.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -702,18 +702,26 @@ int dw_pcie_wait_for_link(struct dw_pcie *pci)
702702
int retries;
703703

704704
/* 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++) {
706706
if (dw_pcie_link_up(pci))
707707
break;
708708

709-
msleep(LINK_WAIT_SLEEP_MS);
709+
msleep(PCIE_LINK_WAIT_SLEEP_MS);
710710
}
711711

712-
if (retries >= LINK_WAIT_MAX_RETRIES) {
712+
if (retries >= PCIE_LINK_WAIT_MAX_RETRIES) {
713713
dev_info(pci->dev, "Phy link never came up\n");
714714
return -ETIMEDOUT;
715715
}
716716

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);
724+
717725
offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
718726
val = dw_pcie_readw_dbi(pci, offset + PCI_EXP_LNKSTA);
719727

drivers/pci/controller/dwc/pcie-designware.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@
6262
#define dw_pcie_cap_set(_pci, _cap) \
6363
set_bit(DW_PCIE_CAP_ ## _cap, &(_pci)->caps)
6464

65-
/* Parameters for the waiting for link up routine */
66-
#define LINK_WAIT_MAX_RETRIES 10
67-
#define LINK_WAIT_SLEEP_MS 90
68-
6965
/* Parameters for the waiting for iATU enabled routine */
7066
#define LINK_WAIT_MAX_IATU_RETRIES 5
7167
#define LINK_WAIT_IATU 9

drivers/pci/controller/dwc/pcie-dw-rockchip.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ static irqreturn_t rockchip_pcie_rc_sys_irq_thread(int irq, void *arg)
458458

459459
if (reg & PCIE_RDLH_LINK_UP_CHGED) {
460460
if (rockchip_pcie_link_up(pci)) {
461+
msleep(PCIE_RESET_CONFIG_WAIT_MS);
461462
dev_dbg(dev, "Received Link up event. Starting enumeration!\n");
462463
/* Rescan the bus to enumerate endpoint devices */
463464
pci_lock_rescan_remove();

drivers/pci/controller/dwc/pcie-qcom.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,6 +1564,7 @@ static irqreturn_t qcom_pcie_global_irq_thread(int irq, void *data)
15641564
writel_relaxed(status, pcie->parf + PARF_INT_ALL_CLEAR);
15651565

15661566
if (FIELD_GET(PARF_INT_ALL_LINK_UP, status)) {
1567+
msleep(PCIE_RESET_CONFIG_WAIT_MS);
15671568
dev_dbg(dev, "Received Link up event. Starting enumeration!\n");
15681569
/* Rescan the bus to enumerate endpoint devices */
15691570
pci_lock_rescan_remove();

drivers/pci/controller/pcie-rockchip-host.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ static int rockchip_pcie_host_init_port(struct rockchip_pcie *rockchip)
325325
msleep(PCIE_T_PVPERL_MS);
326326
gpiod_set_value_cansleep(rockchip->perst_gpio, 1);
327327

328-
msleep(PCIE_T_RRS_READY_MS);
328+
msleep(PCIE_RESET_CONFIG_WAIT_MS);
329329

330330
/* 500ms timeout value should be enough for Gen1/2 training */
331331
err = readl_poll_timeout(rockchip->apb_base + PCIE_CLIENT_BASIC_STATUS1,

drivers/pci/controller/plda/pcie-starfive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ static int starfive_pcie_host_init(struct plda_pcie_rp *plda)
368368
* of 100ms following exit from a conventional reset before
369369
* sending a configuration request to the device.
370370
*/
371-
msleep(PCIE_RESET_CONFIG_DEVICE_WAIT_MS);
371+
msleep(PCIE_RESET_CONFIG_WAIT_MS);
372372

373373
if (starfive_pcie_host_wait_for_link(pcie))
374374
dev_info(dev, "port link down\n");

drivers/pci/pci.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,6 @@ struct pcie_tlp_log;
3535
*/
3636
#define PCIE_T_PERST_CLK_US 100
3737

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-
4538
/*
4639
* PCIe r6.0, sec 5.3.3.2.1 <PME Synchronization>
4740
* Recommends 1ms to 10ms timeout to check L2 ready.
@@ -61,7 +54,11 @@ struct pcie_tlp_log;
6154
* completes before sending a Configuration Request to the device
6255
* immediately below that Port."
6356
*/
64-
#define PCIE_RESET_CONFIG_DEVICE_WAIT_MS 100
57+
#define PCIE_RESET_CONFIG_WAIT_MS 100
58+
59+
/* Parameters for the waiting for link up routine */
60+
#define PCIE_LINK_WAIT_MAX_RETRIES 10
61+
#define PCIE_LINK_WAIT_SLEEP_MS 90
6562

6663
/* Message Routing (r[2:0]); PCIe r6.0, sec 2.2.8 */
6764
#define PCIE_MSG_TYPE_R_RC 0

0 commit comments

Comments
 (0)