Re: [PATCH v4] PCI/PM: Skip resuming to D0 if disconnected

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 24 Jun 2025, Mario Limonciello wrote:

> On 6/24/25 5:24 AM, Rafael J. Wysocki wrote:
> > On Tue, Jun 24, 2025 at 9:22 AM Lukas Wunner <lukas@xxxxxxxxx> wrote:
> > > 
> > > [cc += Rafael, Mika]
> > > 
> > > On Mon, Jun 23, 2025 at 02:13:34PM -0500, Mario Limonciello wrote:
> > > > From: Mario Limonciello <mario.limonciello@xxxxxxx>
> > > > 
> > > > When a USB4 dock is unplugged the PCIe bridge it's connected to will
> > > > issue a "Link Down" and "Card not detected event". The PCI core will
> > > > treat this as a surprise hotplug event and unconfigure all downstream
> > > > devices. This involves setting the device error state to
> > > > `pci_channel_io_perm_failure` which pci_dev_is_disconnected() will
> > > > check.
> > > > 
> > > > It doesn't make sense to runtime resume disconnected devices to D0 and
> > > > report the (expected) error, so bail early.
> > > > 
> > > > Suggested-by: Lukas Wunner <lukas@xxxxxxxxx>
> > > > Signed-off-by: Mario Limonciello <mario.limonciello@xxxxxxx>
> > > 
> > > Reviewed-by: Lukas Wunner <lukas@xxxxxxxxx>
> > > 
> > > > ---
> > > > v4:
> > > >   * no info message
> > > > v3:
> > > >   * Adjust text and subject
> > > >   * Add an info message instead
> > > > v2:
> > > >   * Use pci_dev_is_disconnected()
> > > > v1:
> > > > https://lore.kernel.org/linux-usb/20250609020223.269407-1-superm1@xxxxxxxxxx/T/#mf95c947990d016fbfccfd11afe60b8ae08aafa0b
> > > > ---
> > > >   drivers/pci/pci.c | 5 +++++
> > > >   1 file changed, 5 insertions(+)
> > > > 
> > > > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> > > > index 9e42090fb1089..160a9a482c732 100644
> > > > --- a/drivers/pci/pci.c
> > > > +++ b/drivers/pci/pci.c
> > > > @@ -1374,6 +1374,11 @@ int pci_power_up(struct pci_dev *dev)
> > > >                return -EIO;
> > > >        }
> > > > 
> > > > +     if (pci_dev_is_disconnected(dev)) {
> > > > +             dev->current_state = PCI_D3cold;
> > 
> > Why not PCI_UNKNOWN?
> 
> It was following what other situations of failure did:
> * existing error in pci_power_up()
> * error in pci_update_current_state()
> * error in pci_set_low_power_state()
> 
> I view all of these cases as unrecoverable failures.
> 
> So perhaps if changing this one to PCI_UNKNOWN those three should those also
> be PCI_UNKNOWN?
> 
> Bjorn, Lukas, thoughts?
> 
> > 
> > > > +             return -EIO;
> > > > +     }
> > > > +
> > > >        pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
> > > >        if (PCI_POSSIBLE_ERROR(pmcsr)) {
> > > >                pci_err(dev, "Unable to change power state from %s to D0,
> > > > device inaccessible\n",

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx>

(I've no opinion on PCI_UNKNOWN or not.)

-- 
 i.

[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux