From d6b58cc171f4d03b10ddc3c5acb32e6f15cc239c Mon Sep 17 00:00:00 2001 From: Sajid Dalvi Date: Tue, 20 Feb 2024 13:20:17 -0600 Subject: [PATCH] ANDROID: PCI: dwc: Wait for the link only if it has been 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. The patch submitted to the upstream kernel (see link below) was not accepted due to no upstream user. The change here is a simplified version of that patch, which will wait for a link only if start_link ops has been defined. Bug: 315052790 Link: https://lore.kernel.org/all/20240112093006.2832105-1-ajayagarwal@google.com/ Change-Id: I4e8d00f6195062728417e41ddd51072880676920 Signed-off-by: Sajid Dalvi --- drivers/pci/controller/dwc/pcie-designware-host.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index 6241d3f4e9d5..759a14389dd9 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -483,10 +483,12 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp) 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) { + /* Ignore errors, the link may come up later */ + dw_pcie_wait_for_link(pci); + } + } bridge->sysdata = pp;