Re: [PATCH RFC 2/3] PCI: Allow quirks to extend the link-up wait after reset
From: Lukas Wunner
Date: Thu Dec 03 2026 - 03:34:49 EST
On Wed, Dec 02, 2026 at 04:43:27PM -0800, Brett Creeley wrote:
> +++ b/drivers/pci/pci.c
> @@ -4614,12 +4614,14 @@ static int pci_pm_reset(struct pci_dev *dev, bool probe)
> * @pdev: Device whose link to wait for.
> * @use_lt: Use the LT bit if TRUE, or the DLLLA bit if FALSE.
> * @active: Waiting for active or inactive?
> + * @timeout_ms: How long to wait for the status change (in ms)
> *
> * Return 0 if successful, or -ETIMEDOUT if status has not changed within
> - * PCIE_LINK_RETRAIN_TIMEOUT_MS milliseconds.
> + * @timeout_ms milliseconds.
> */
> static int pcie_wait_for_link_status(struct pci_dev *pdev,
> - bool use_lt, bool active)
> + bool use_lt, bool active,
> + unsigned int timeout_ms)
> {
Can you make it so that pcie_wait_for_link_status() doesn't take
an extra parameter, but uses pdev->link_up_timeout in lieu of
PCIE_LINK_RETRAIN_TIMEOUT_MS if it is non-zero?
That would simplify the patch considerably. Patches that deal
with non-conforming hardware should be minimally intrusive.
> @@ -4833,7 +4875,9 @@ int pci_bridge_wait_for_secondary_bus(struct pci_dev *dev, char *reset_type)
>
> /* Take d3cold_delay requirements into account */
> delay = pci_bus_max_d3cold_delay(dev->subordinate);
> - if (!delay) {
> + link_up_timeout = pci_bus_max_link_up_timeout(dev->subordinate);
> + extended = pcie_link_up_timeout_extended(dev, link_up_timeout);
> + if (!delay && !extended) {
> up_read(&pci_bus_sem);
> return 0;
> }
Why is this needed? I'd expect the control flow to just fall through
to the !pcie_wait_for_link_delay() at the end of
pci_bridge_wait_for_secondary_bus()?
> +++ b/include/linux/pci.h
> @@ -434,6 +434,7 @@ struct pci_dev {
> unsigned int no_bw_notif:1; /* BW notifications may cause issues */
> unsigned int d3hot_delay; /* D3hot->D0 transition time in ms */
> unsigned int d3cold_delay; /* D3cold->D0 transition time in ms */
> + unsigned int link_up_timeout; /* Link-up wait (ms), >5 GT/s ports */
>
I'd preer link_up_delay for consistency with the other fields
in the struct. I'm not sure the >5 GT/s limitation needs to
be mentioned.
Thanks,
Lukas