From: Denis Benato <benato.denis96@gmail.com>
To: Raag Jadav <raag.jadav@intel.com>,
rafael@kernel.org, mahesh@linux.ibm.com, oohall@gmail.com,
bhelgaas@google.com, Mario Limonciello <superm1@kernel.org>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
ilpo.jarvinen@linux.intel.com, lukas@wunner.de,
aravind.iddamsetty@linux.intel.com
Subject: Re: [PATCH v3] PCI: Prevent power state transition of erroneous device
Date: Wed, 14 May 2025 18:29:26 +0200 [thread overview]
Message-ID: <7dbb64ee-3683-4b47-b17d-288447da746e@gmail.com> (raw)
In-Reply-To: <20250504090444.3347952-1-raag.jadav@intel.com>
Hello,
Lately I am experiencing a few problems related to either (one of or both) PCI and/or thunderbolt and Mario Limonciello pointed me to this patch.
you can follow an example of my problems in this [1] bug report.
I tested this patch on top of 6.14.6 and this patch comes with a nasty regression: s2idle resume breaks all my three GPUs, while for example the sound of a YT video resumes fine.
You can see the dmesg here: https://pastebin.com/Um7bmdWi
I will also say that, on the bright side, this patch makes my laptop behave better on boot as the amdgpu plugged on the thunderbolt port is always enabled on power on, while without this patch it is random if it will be active immediately after laptop has been turned on.
[1] https://lore.kernel.org/all/965c9753-f14b-4a87-9f6d-8798e09ad6f5@gmail.com/
On 5/4/25 11:04, Raag Jadav wrote:
> If error flags are set on an AER capable device, most likely either the
> device recovery is in progress or has already failed. Neither of the
> cases are well suited for power state transition of the device, since
> this can lead to unpredictable consequences like resume failure, or in
> worst case the device is lost because of it. Leave the device in its
> existing power state to avoid such issues.
>
> Signed-off-by: Raag Jadav <raag.jadav@intel.com>
> ---
>
> v2: Synchronize AER handling with PCI PM (Rafael)
> v3: Move pci_aer_in_progress() to pci_set_low_power_state() (Rafael)
> Elaborate "why" (Bjorn)
>
> More discussion on [1].
> [1] https://lore.kernel.org/all/CAJZ5v0g-aJXfVH+Uc=9eRPuW08t-6PwzdyMXsC6FZRKYJtY03Q@mail.gmail.com/
>
> drivers/pci/pci.c | 12 ++++++++++++
> drivers/pci/pcie/aer.c | 11 +++++++++++
> include/linux/aer.h | 2 ++
> 3 files changed, 25 insertions(+)
>
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 4d7c9f64ea24..25b2df34336c 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -9,6 +9,7 @@
> */
>
> #include <linux/acpi.h>
> +#include <linux/aer.h>
> #include <linux/kernel.h>
> #include <linux/delay.h>
> #include <linux/dmi.h>
> @@ -1539,6 +1540,17 @@ static int pci_set_low_power_state(struct pci_dev *dev, pci_power_t state, bool
> || (state == PCI_D2 && !dev->d2_support))
> return -EIO;
>
> + /*
> + * If error flags are set on an AER capable device, most likely either
> + * the device recovery is in progress or has already failed. Neither of
> + * the cases are well suited for power state transition of the device,
> + * since this can lead to unpredictable consequences like resume
> + * failure, or in worst case the device is lost because of it. Leave the
> + * device in its existing power state to avoid such issues.
> + */
> + if (pci_aer_in_progress(dev))
> + 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 %s, device inaccessible\n",
> diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
> index a1cf8c7ef628..4040770df4f0 100644
> --- a/drivers/pci/pcie/aer.c
> +++ b/drivers/pci/pcie/aer.c
> @@ -237,6 +237,17 @@ int pcie_aer_is_native(struct pci_dev *dev)
> }
> EXPORT_SYMBOL_NS_GPL(pcie_aer_is_native, "CXL");
>
> +bool pci_aer_in_progress(struct pci_dev *dev)
> +{
> + u16 reg16;
> +
> + if (!pcie_aer_is_native(dev))
> + return false;
> +
> + pcie_capability_read_word(dev, PCI_EXP_DEVSTA, ®16);
> + return !!(reg16 & PCI_EXP_AER_FLAGS);
> +}
> +
> static int pci_enable_pcie_error_reporting(struct pci_dev *dev)
> {
> int rc;
> diff --git a/include/linux/aer.h b/include/linux/aer.h
> index 02940be66324..e6a380bb2e68 100644
> --- a/include/linux/aer.h
> +++ b/include/linux/aer.h
> @@ -56,12 +56,14 @@ struct aer_capability_regs {
> #if defined(CONFIG_PCIEAER)
> int pci_aer_clear_nonfatal_status(struct pci_dev *dev);
> int pcie_aer_is_native(struct pci_dev *dev);
> +bool pci_aer_in_progress(struct pci_dev *dev);
> #else
> static inline int pci_aer_clear_nonfatal_status(struct pci_dev *dev)
> {
> return -EINVAL;
> }
> static inline int pcie_aer_is_native(struct pci_dev *dev) { return 0; }
> +static inline bool pci_aer_in_progress(struct pci_dev *dev) { return false; }
> #endif
>
> void pci_print_aer(struct pci_dev *dev, int aer_severity,
next prev parent reply other threads:[~2025-05-14 16:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-04 9:04 [PATCH v3] PCI: Prevent power state transition of erroneous device Raag Jadav
2025-05-12 10:23 ` Raag Jadav
2025-05-12 11:56 ` Rafael J. Wysocki
2025-05-12 16:52 ` Raag Jadav
2025-05-13 4:41 ` Lukas Wunner
2025-05-13 15:17 ` Raag Jadav
2025-05-14 16:29 ` Denis Benato [this message]
2025-05-14 19:53 ` Mario Limonciello
2025-05-14 21:25 ` Denis Benato
2025-05-15 11:58 ` Raag Jadav
2025-05-15 12:26 ` Lukas Wunner
2025-05-15 14:11 ` Denis Benato
2025-05-15 14:41 ` Mario Limonciello
2025-05-21 13:33 ` Lukas Wunner
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=7dbb64ee-3683-4b47-b17d-288447da746e@gmail.com \
--to=benato.denis96@gmail.com \
--cc=aravind.iddamsetty@linux.intel.com \
--cc=bhelgaas@google.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=mahesh@linux.ibm.com \
--cc=oohall@gmail.com \
--cc=raag.jadav@intel.com \
--cc=rafael@kernel.org \
--cc=superm1@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).