Skip to content

Commit da56a1b

Browse files
Ajay AgarwalLorenzo Pieralisi
authored andcommitted
PCI: dwc: Wait for link up only if link is started
In dw_pcie_host_init() regardless of whether the link has been started or not, the code waits for the link to come up. Even in cases where start_link() is not defined the code ends up spinning in a loop for 1 second. Since in some systems dw_pcie_host_init() gets called during probe, this one second loop for each pcie interface instance ends up extending the boot time. Wait for the link up in only if the start_link() is defined. Link: https://lore.kernel.org/r/[email protected] Tested-by: Will McVicker <[email protected]> Signed-off-by: Sajid Dalvi <[email protected]> Signed-off-by: Ajay Agarwal <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]>
1 parent ac9a786 commit da56a1b

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,14 +485,19 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp)
485485
if (ret)
486486
goto err_remove_edma;
487487

488-
if (!dw_pcie_link_up(pci)) {
488+
if (dw_pcie_link_up(pci)) {
489+
dw_pcie_print_link_status(pci);
490+
} else {
489491
ret = dw_pcie_start_link(pci);
490492
if (ret)
491493
goto err_remove_edma;
492-
}
493494

494-
/* Ignore errors, the link may come up later */
495-
dw_pcie_wait_for_link(pci);
495+
if (pci->ops && pci->ops->start_link) {
496+
ret = dw_pcie_wait_for_link(pci);
497+
if (ret)
498+
goto err_stop_link;
499+
}
500+
}
496501

497502
bridge->sysdata = pp;
498503

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -644,9 +644,20 @@ void dw_pcie_disable_atu(struct dw_pcie *pci, u32 dir, int index)
644644
dw_pcie_writel_atu(pci, dir, index, PCIE_ATU_REGION_CTRL2, 0);
645645
}
646646

647-
int dw_pcie_wait_for_link(struct dw_pcie *pci)
647+
void dw_pcie_print_link_status(struct dw_pcie *pci)
648648
{
649649
u32 offset, val;
650+
651+
offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
652+
val = dw_pcie_readw_dbi(pci, offset + PCI_EXP_LNKSTA);
653+
654+
dev_info(pci->dev, "PCIe Gen.%u x%u link up\n",
655+
FIELD_GET(PCI_EXP_LNKSTA_CLS, val),
656+
FIELD_GET(PCI_EXP_LNKSTA_NLW, val));
657+
}
658+
659+
int dw_pcie_wait_for_link(struct dw_pcie *pci)
660+
{
650661
int retries;
651662

652663
/* Check if the link is up or not */
@@ -662,12 +673,7 @@ int dw_pcie_wait_for_link(struct dw_pcie *pci)
662673
return -ETIMEDOUT;
663674
}
664675

665-
offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
666-
val = dw_pcie_readw_dbi(pci, offset + PCI_EXP_LNKSTA);
667-
668-
dev_info(pci->dev, "PCIe Gen.%u x%u link up\n",
669-
FIELD_GET(PCI_EXP_LNKSTA_CLS, val),
670-
FIELD_GET(PCI_EXP_LNKSTA_NLW, val));
676+
dw_pcie_print_link_status(pci);
671677

672678
return 0;
673679
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ void dw_pcie_setup(struct dw_pcie *pci);
429429
void dw_pcie_iatu_detect(struct dw_pcie *pci);
430430
int dw_pcie_edma_detect(struct dw_pcie *pci);
431431
void dw_pcie_edma_remove(struct dw_pcie *pci);
432+
void dw_pcie_print_link_status(struct dw_pcie *pci);
432433

433434
static inline void dw_pcie_writel_dbi(struct dw_pcie *pci, u32 reg, u32 val)
434435
{

0 commit comments

Comments
 (0)