From: Lukas Wunner <lukas@wunner.de>
To: Mario Limonciello <superm1@kernel.org>
Cc: mario.limonciello@amd.com, bhelgaas@google.com,
linux-pci@vger.kernel.org,
"Rafael J. Wysocki" <rafael@kernel.org>,
Mika Westerberg <westeri@kernel.org>
Subject: Re: [PATCH v4] PCI/PM: Skip resuming to D0 if disconnected
Date: Tue, 24 Jun 2025 09:22:53 +0200 [thread overview]
Message-ID: <aFpSTT_UHakY91_q@wunner.de> (raw)
In-Reply-To: <20250623191335.3780832-1-superm1@kernel.org>
[cc += Rafael, Mika]
On Mon, Jun 23, 2025 at 02:13:34PM -0500, Mario Limonciello wrote:
> From: Mario Limonciello <mario.limonciello@amd.com>
>
> 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@wunner.de>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Reviewed-by: Lukas Wunner <lukas@wunner.de>
> ---
> 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@kernel.org/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;
> + 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",
> --
> 2.43.0
next prev parent reply other threads:[~2025-06-24 7:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-23 19:13 [PATCH v4] PCI/PM: Skip resuming to D0 if disconnected Mario Limonciello
2025-06-24 7:22 ` Lukas Wunner [this message]
2025-06-24 10:24 ` Rafael J. Wysocki
2025-06-24 15:08 ` Mario Limonciello
2025-06-26 12:09 ` Ilpo Järvinen
2025-06-26 12:31 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aFpSTT_UHakY91_q@wunner.de \
--to=lukas@wunner.de \
--cc=bhelgaas@google.com \
--cc=linux-pci@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=rafael@kernel.org \
--cc=superm1@kernel.org \
--cc=westeri@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.