[PATCH] PCI: cadence: skip the link polling when endpoint not connected
Aksh Garg
a-garg7 at ti.com
Mon Jun 22 22:23:48 PDT 2026
On 22/06/26 20:22, Manivannan Sadhasivam wrote:
> On Fri, Jun 05, 2026 at 12:49:22PM +0530, Aksh Garg wrote:
>> cdns_pcie_host_wait_for_link() polls on link-up for 10 retries with a
>> delay of 90-100ms each (~1 second). A call to cdns_pcie_host_link_setup()
>> during the resume operation blocks the resume operation unnecessarily for
>> ~1s even when no endpoint device is connected.
>>
>> Add skip_link_polling flag to track link state across suspend/resume
>> cycles. If link was down before suspend, skip the expensive polling
>> in resume since no endpoint was present.
>>
>
> Won't you need the delay if a device gets plugged while the host was suspended?
> We had this same concern with the DWC drivers and we left the delay as-is as
> nothing prevents an user to connect a device when the host was suspended.
Yes, that is true. However, the platforms that do not support hot-plug
can skip the delay during resume since no device could have been
connected while suspended (only those platform's driver would be
expected to set 'rc->skip_link_polling) just like what Tegra264 PCIe
driver tries to do at [1], where the driver sets "pcie->link_up = false"
if the link is down during the probe and if the controller doesn't
support hot-plug.
Even if a user connects a device (when the host was suspended) to a
platform which doesn't support hotplug, the user is expected to run a
bus rescan, which doesn't call cdns_pcie_host_link_setup() anyway, hence
the flag 'skip_link_polling' is not taken into account in that case.
[1]:
https://lore.kernel.org/all/20260617-tegra264-pcie-v7-3-eae7ae964629@nvidia.com/
>
> - Mani
>
>> Signed-off-by: Aksh Garg <a-garg7 at ti.com>
>> ---
>> drivers/pci/controller/cadence/pci-j721e.c | 5 +++++
>> drivers/pci/controller/cadence/pcie-cadence-host-hpa.c | 3 +++
>> drivers/pci/controller/cadence/pcie-cadence-host.c | 3 +++
>> drivers/pci/controller/cadence/pcie-cadence.h | 3 +++
>> 4 files changed, 14 insertions(+)
>>
>> diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c
>> index bfdfe98d5aba..849eb8bb9e45 100644
>> --- a/drivers/pci/controller/cadence/pci-j721e.c
>> +++ b/drivers/pci/controller/cadence/pci-j721e.c
>> @@ -686,6 +686,11 @@ static int j721e_pcie_suspend_noirq(struct device *dev)
>> struct j721e_pcie *pcie = dev_get_drvdata(dev);
>>
>> if (pcie->mode == PCI_MODE_RC) {
>> + struct cdns_pcie_rc *rc = cdns_pcie_to_rc(pcie->cdns_pcie);
>> +
>> + /* If link is down before suspend, skip polling in resume */
>> + rc->skip_link_polling = !j721e_pcie_link_up(pcie->cdns_pcie);
>> +
>> gpiod_set_value_cansleep(pcie->reset_gpio, 0);
>> clk_disable_unprepare(pcie->refclk);
>> }
>> diff --git a/drivers/pci/controller/cadence/pcie-cadence-host-hpa.c b/drivers/pci/controller/cadence/pcie-cadence-host-hpa.c
>> index 0f540bed58e8..d78c1282a5ee 100644
>> --- a/drivers/pci/controller/cadence/pcie-cadence-host-hpa.c
>> +++ b/drivers/pci/controller/cadence/pcie-cadence-host-hpa.c
>> @@ -301,6 +301,9 @@ int cdns_pcie_hpa_host_link_setup(struct cdns_pcie_rc *rc)
>> return ret;
>> }
>>
>> + if (rc->skip_link_polling)
>> + return 0;
>> +
>> ret = cdns_pcie_host_wait_for_link(pcie, cdns_pcie_hpa_link_up);
>> if (ret)
>> dev_dbg(dev, "PCIe link never came up\n");
>> diff --git a/drivers/pci/controller/cadence/pcie-cadence-host.c b/drivers/pci/controller/cadence/pcie-cadence-host.c
>> index 0bc9e6e90e0e..026414c21ee1 100644
>> --- a/drivers/pci/controller/cadence/pcie-cadence-host.c
>> +++ b/drivers/pci/controller/cadence/pcie-cadence-host.c
>> @@ -352,6 +352,9 @@ int cdns_pcie_host_link_setup(struct cdns_pcie_rc *rc)
>> return ret;
>> }
>>
>> + if (rc->skip_link_polling)
>> + return 0;
>> +
>> ret = cdns_pcie_host_start_link(rc, cdns_pcie_link_up);
>> if (ret)
>> dev_dbg(dev, "PCIe link never came up\n");
>> diff --git a/drivers/pci/controller/cadence/pcie-cadence.h b/drivers/pci/controller/cadence/pcie-cadence.h
>> index 574e9cf4d003..01e49ecccc7b 100644
>> --- a/drivers/pci/controller/cadence/pcie-cadence.h
>> +++ b/drivers/pci/controller/cadence/pcie-cadence.h
>> @@ -117,6 +117,8 @@ struct cdns_pcie {
>> * @no_inbound_map: Whether inbound mapping is supported
>> * @quirk_broken_aspm_l0s: Disable ASPM L0s support as quirk
>> * @quirk_broken_aspm_l1: Disable ASPM L1 support as quirk
>> + * @skip_link_polling: Skip link polling in resume if link was down before
>> + * suspend, to avoid long delay in resume
>> */
>> struct cdns_pcie_rc {
>> struct cdns_pcie pcie;
>> @@ -131,6 +133,7 @@ struct cdns_pcie_rc {
>> unsigned int no_inbound_map:1;
>> unsigned int quirk_broken_aspm_l0s:1;
>> unsigned int quirk_broken_aspm_l1:1;
>> + unsigned int skip_link_polling:1;
>> };
>>
>> /**
>> --
>> 2.34.1
>>
>
More information about the linux-arm-kernel
mailing list