mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 10:31:46 +09:00
BACKPORT: FROMGIT: 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.
Bug: 270085637
Link: https://lore.kernel.org/r/20230412093425.3659088-1-ajayagarwal@google.com
Tested-by: Will McVicker <willmcvicker@google.com>
Signed-off-by: Sajid Dalvi <sdalvi@google.com>
Signed-off-by: Ajay Agarwal <ajayagarwal@google.com>
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
(cherry picked from commit da56a1bfba
https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git controller/dwc)
[willmcvicker: fixed trivial merge conflicts]
Signed-off-by: Will McVicker <willmcvicker@google.com>
Change-Id: Ia4d9b41b2a15cb077025f6250d8fa07c495a17a9
This commit is contained in:
committed by
Treehugger Robot
parent
4439750641
commit
80d7019423
@@ -479,14 +479,19 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp)
|
||||
if (ret)
|
||||
goto err_free_msi;
|
||||
|
||||
if (!dw_pcie_link_up(pci)) {
|
||||
if (dw_pcie_link_up(pci)) {
|
||||
dw_pcie_print_link_status(pci);
|
||||
} else {
|
||||
ret = dw_pcie_start_link(pci);
|
||||
if (ret)
|
||||
goto err_free_msi;
|
||||
}
|
||||
|
||||
/* Ignore errors, the link may come up later */
|
||||
dw_pcie_wait_for_link(pci);
|
||||
if (pci->ops && pci->ops->start_link) {
|
||||
ret = dw_pcie_wait_for_link(pci);
|
||||
if (ret)
|
||||
goto err_stop_link;
|
||||
}
|
||||
}
|
||||
|
||||
bridge->sysdata = pp;
|
||||
|
||||
|
||||
@@ -434,9 +434,20 @@ void dw_pcie_disable_atu(struct dw_pcie *pci, u32 dir, int index)
|
||||
dw_pcie_writel_atu(pci, dir, index, PCIE_ATU_REGION_CTRL2, 0);
|
||||
}
|
||||
|
||||
int dw_pcie_wait_for_link(struct dw_pcie *pci)
|
||||
void dw_pcie_print_link_status(struct dw_pcie *pci)
|
||||
{
|
||||
u32 offset, val;
|
||||
|
||||
offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
|
||||
val = dw_pcie_readw_dbi(pci, offset + PCI_EXP_LNKSTA);
|
||||
|
||||
dev_info(pci->dev, "PCIe Gen.%u x%u link up\n",
|
||||
FIELD_GET(PCI_EXP_LNKSTA_CLS, val),
|
||||
FIELD_GET(PCI_EXP_LNKSTA_NLW, val));
|
||||
}
|
||||
|
||||
int dw_pcie_wait_for_link(struct dw_pcie *pci)
|
||||
{
|
||||
int retries;
|
||||
|
||||
/* Check if the link is up or not */
|
||||
@@ -452,12 +463,7 @@ int dw_pcie_wait_for_link(struct dw_pcie *pci)
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
|
||||
val = dw_pcie_readw_dbi(pci, offset + PCI_EXP_LNKSTA);
|
||||
|
||||
dev_info(pci->dev, "PCIe Gen.%u x%u link up\n",
|
||||
FIELD_GET(PCI_EXP_LNKSTA_CLS, val),
|
||||
FIELD_GET(PCI_EXP_LNKSTA_NLW, val));
|
||||
dw_pcie_print_link_status(pci);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -351,6 +351,7 @@ int dw_pcie_prog_inbound_atu(struct dw_pcie *pci, u8 func_no, int index,
|
||||
void dw_pcie_disable_atu(struct dw_pcie *pci, u32 dir, int index);
|
||||
void dw_pcie_setup(struct dw_pcie *pci);
|
||||
void dw_pcie_iatu_detect(struct dw_pcie *pci);
|
||||
void dw_pcie_print_link_status(struct dw_pcie *pci);
|
||||
|
||||
static inline void dw_pcie_writel_dbi(struct dw_pcie *pci, u32 reg, u32 val)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user