Re: diagnosing resume failures after disconnected USB4 drives (Was: Re: PCI/ASPM: Fix L1SS saving (linus/master commit 7507eb3e7bfac))

Kenneth Crudup
2025-03-06T16:56:47Z

Is this a separate commit on top of master, or along with your previous fix?

-Kenny

On 3/6/25 08:45, Lukas Wunner wrote:
> On Tue, Mar 04, 2025 at 10:23:14AM +0200, Mika Westerberg wrote:
>> Unfortunately I still see the same hang. I double checked, with revert the
>> problem goes a way and with this patch I still see it.
>>
>> Steps:
>>
>> 1. Boot the system, nothing connected.
>> 2. Connect TBT 4 dock to the host.
>> 3. Connect TBT 3 NVMe to the TBT4 doc.
>> 4. Authorize both PCIe tunnels, verify devices are there.
>> 5. Enter s2idle.
>> 6. Unplug the TBT 4 dock from the host.
>> 7. Exit s2idle.
>
> Thanks for testing. Would you mind giving the below a spin?
>
> I've realized this can likely be solved in a much easier way:
>
> The ->resume_noirq callback is invoked while traversing down
> the hierarchy and the topmost slot which detects device replacement
> already marks everything below as disconnected. Hence any nested
> hotplug ports can just skip the replacement check because they're
> disconnected as well.
>
> -- >8 --
>
> diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
> index ff458e6..997841c 100644
> --- a/drivers/pci/hotplug/pciehp_core.c
> +++ b/drivers/pci/hotplug/pciehp_core.c
> @@ -286,9 +286,12 @@ static int pciehp_suspend(struct pcie_device *dev)
>
> static bool pciehp_device_replaced(struct controller *ctrl)
> {
> - struct pci_dev *pdev __free(pci_dev_put);
> + struct pci_dev *pdev __free(pci_dev_put) = NULL;
> u32 reg;
>
> + if (pci_dev_is_disconnected(ctrl->pcie->port))
> + return false;
> +
> pdev = pci_get_slot(ctrl->pcie->port->subordinate, PCI_DEVFN(0, 0));
> if (!pdev)
> return true;