* [PATCH] PCI/AER: Block runtime suspend when handling errors
@ 2024-02-09 14:08 Stanislaw Gruszka
2024-02-09 14:16 ` Rafael J. Wysocki
2024-02-09 15:45 ` Kuppuswamy Sathyanarayanan
0 siblings, 2 replies; 4+ messages in thread
From: Stanislaw Gruszka @ 2024-02-09 14:08 UTC (permalink / raw)
To: Bjorn Helgaas, Rafael J. Wysocki
Cc: linux-pci, linux-pm, Mahesh J Salgaonkar, Oliver O'Halloran,
Kuppuswamy Sathyanarayanan, Stanislaw Gruszka
PM runtime can be done simultaneously with AER error handling.
Avoid that by using pm_runtime_get_sync() before and pm_runtime_put()
after reset in pcie_do_recovery() for all recovering devices.
pm_runtime_get_sync() will increase dev->power.usage_count counter
to prevent any possible future request to runtime suspend a device,
as well as resume device is was in D3hot state.
I tested with igc device by doing simultaneous aer_inject and
rpm suspend/resume via /sys/bus/pci/devices/PCI_ID/power/control
and can reproduce:
igc 0000:02:00.0: not ready 65535ms after bus reset; giving up
pcieport 0000:00:1c.2: AER: Root Port link has been reset (-25)
pcieport 0000:00:1c.2: AER: subordinate device reset failed
pcieport 0000:00:1c.2: AER: device recovery failed
igc 0000:02:00.0: Unable to change power state from D3hot to D0, device inaccessible
The problem disappears when applied this patch.
Signed-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
---
RFC -> v1:
add runtime callbacks to pcie_do_recovery(), this covers DPC case
as well as case of recovering multiple devices under same port.
drivers/pci/pcie/err.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
index 59c90d04a609..705893b5f7b0 100644
--- a/drivers/pci/pcie/err.c
+++ b/drivers/pci/pcie/err.c
@@ -13,6 +13,7 @@
#define dev_fmt(fmt) "AER: " fmt
#include <linux/pci.h>
+#include <linux/pm_runtime.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/errno.h>
@@ -85,6 +86,18 @@ static int report_error_detected(struct pci_dev *dev,
return 0;
}
+static int pci_pm_runtime_get_sync(struct pci_dev *pdev, void *data)
+{
+ pm_runtime_get_sync(&pdev->dev);
+ return 0;
+}
+
+static int pci_pm_runtime_put(struct pci_dev *pdev, void *data)
+{
+ pm_runtime_put(&pdev->dev);
+ return 0;
+}
+
static int report_frozen_detected(struct pci_dev *dev, void *data)
{
return report_error_detected(dev, pci_channel_io_frozen, data);
@@ -207,6 +220,8 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
else
bridge = pci_upstream_bridge(dev);
+ pci_walk_bridge(bridge, pci_pm_runtime_get_sync, NULL);
+
pci_dbg(bridge, "broadcast error_detected message\n");
if (state == pci_channel_io_frozen) {
pci_walk_bridge(bridge, report_frozen_detected, &status);
@@ -251,10 +266,15 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
pcie_clear_device_status(dev);
pci_aer_clear_nonfatal_status(dev);
}
+
+ pci_walk_bridge(bridge, pci_pm_runtime_put, NULL);
+
pci_info(bridge, "device recovery successful\n");
return status;
failed:
+ pci_walk_bridge(bridge, pci_pm_runtime_put, NULL);
+
pci_uevent_ers(bridge, PCI_ERS_RESULT_DISCONNECT);
/* TODO: Should kernel panic here? */
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] PCI/AER: Block runtime suspend when handling errors
2024-02-09 14:08 [PATCH] PCI/AER: Block runtime suspend when handling errors Stanislaw Gruszka
@ 2024-02-09 14:16 ` Rafael J. Wysocki
2024-02-09 15:45 ` Kuppuswamy Sathyanarayanan
1 sibling, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2024-02-09 14:16 UTC (permalink / raw)
To: Stanislaw Gruszka
Cc: Bjorn Helgaas, Rafael J. Wysocki, linux-pci, linux-pm,
Mahesh J Salgaonkar, Oliver O'Halloran,
Kuppuswamy Sathyanarayanan
On Fri, Feb 9, 2024 at 3:09 PM Stanislaw Gruszka
<stanislaw.gruszka@linux.intel.com> wrote:
>
> PM runtime can be done simultaneously with AER error handling.
> Avoid that by using pm_runtime_get_sync() before and pm_runtime_put()
> after reset in pcie_do_recovery() for all recovering devices.
>
> pm_runtime_get_sync() will increase dev->power.usage_count counter
> to prevent any possible future request to runtime suspend a device,
> as well as resume device is was in D3hot state.
>
> I tested with igc device by doing simultaneous aer_inject and
> rpm suspend/resume via /sys/bus/pci/devices/PCI_ID/power/control
> and can reproduce:
>
> igc 0000:02:00.0: not ready 65535ms after bus reset; giving up
> pcieport 0000:00:1c.2: AER: Root Port link has been reset (-25)
> pcieport 0000:00:1c.2: AER: subordinate device reset failed
> pcieport 0000:00:1c.2: AER: device recovery failed
> igc 0000:02:00.0: Unable to change power state from D3hot to D0, device inaccessible
>
> The problem disappears when applied this patch.
>
> Signed-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
Looks reasonable to me:
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
> ---
> RFC -> v1:
> add runtime callbacks to pcie_do_recovery(), this covers DPC case
> as well as case of recovering multiple devices under same port.
>
> drivers/pci/pcie/err.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
> index 59c90d04a609..705893b5f7b0 100644
> --- a/drivers/pci/pcie/err.c
> +++ b/drivers/pci/pcie/err.c
> @@ -13,6 +13,7 @@
> #define dev_fmt(fmt) "AER: " fmt
>
> #include <linux/pci.h>
> +#include <linux/pm_runtime.h>
> #include <linux/module.h>
> #include <linux/kernel.h>
> #include <linux/errno.h>
> @@ -85,6 +86,18 @@ static int report_error_detected(struct pci_dev *dev,
> return 0;
> }
>
> +static int pci_pm_runtime_get_sync(struct pci_dev *pdev, void *data)
> +{
> + pm_runtime_get_sync(&pdev->dev);
> + return 0;
> +}
> +
> +static int pci_pm_runtime_put(struct pci_dev *pdev, void *data)
> +{
> + pm_runtime_put(&pdev->dev);
> + return 0;
> +}
> +
> static int report_frozen_detected(struct pci_dev *dev, void *data)
> {
> return report_error_detected(dev, pci_channel_io_frozen, data);
> @@ -207,6 +220,8 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
> else
> bridge = pci_upstream_bridge(dev);
>
> + pci_walk_bridge(bridge, pci_pm_runtime_get_sync, NULL);
> +
> pci_dbg(bridge, "broadcast error_detected message\n");
> if (state == pci_channel_io_frozen) {
> pci_walk_bridge(bridge, report_frozen_detected, &status);
> @@ -251,10 +266,15 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
> pcie_clear_device_status(dev);
> pci_aer_clear_nonfatal_status(dev);
> }
> +
> + pci_walk_bridge(bridge, pci_pm_runtime_put, NULL);
> +
> pci_info(bridge, "device recovery successful\n");
> return status;
>
> failed:
> + pci_walk_bridge(bridge, pci_pm_runtime_put, NULL);
> +
> pci_uevent_ers(bridge, PCI_ERS_RESULT_DISCONNECT);
>
> /* TODO: Should kernel panic here? */
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] PCI/AER: Block runtime suspend when handling errors
2024-02-09 14:08 [PATCH] PCI/AER: Block runtime suspend when handling errors Stanislaw Gruszka
2024-02-09 14:16 ` Rafael J. Wysocki
@ 2024-02-09 15:45 ` Kuppuswamy Sathyanarayanan
2024-02-12 8:13 ` Stanislaw Gruszka
1 sibling, 1 reply; 4+ messages in thread
From: Kuppuswamy Sathyanarayanan @ 2024-02-09 15:45 UTC (permalink / raw)
To: Stanislaw Gruszka, Bjorn Helgaas, Rafael J. Wysocki
Cc: linux-pci, linux-pm, Mahesh J Salgaonkar, Oliver O'Halloran
On 2/9/24 6:08 AM, Stanislaw Gruszka wrote:
> PM runtime can be done simultaneously with AER error handling.
> Avoid that by using pm_runtime_get_sync() before and pm_runtime_put()
> after reset in pcie_do_recovery() for all recovering devices.
>
> pm_runtime_get_sync() will increase dev->power.usage_count counter
> to prevent any possible future request to runtime suspend a device,
> as well as resume device is was in D3hot state.
runtime suspend a device or resume a device that was in D3hot state.
>
> I tested with igc device by doing simultaneous aer_inject and
> rpm suspend/resume via /sys/bus/pci/devices/PCI_ID/power/control
> and can reproduce:
>
> igc 0000:02:00.0: not ready 65535ms after bus reset; giving up
> pcieport 0000:00:1c.2: AER: Root Port link has been reset (-25)
> pcieport 0000:00:1c.2: AER: subordinate device reset failed
> pcieport 0000:00:1c.2: AER: device recovery failed
> igc 0000:02:00.0: Unable to change power state from D3hot to D0, device inaccessible
>
> The problem disappears when applied this patch.
>
> Signed-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
> ---
since it is a bug fix, may be Cc: stable@vger.kernel.org
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
> RFC -> v1:
> add runtime callbacks to pcie_do_recovery(), this covers DPC case
> as well as case of recovering multiple devices under same port.
>
> drivers/pci/pcie/err.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
> index 59c90d04a609..705893b5f7b0 100644
> --- a/drivers/pci/pcie/err.c
> +++ b/drivers/pci/pcie/err.c
> @@ -13,6 +13,7 @@
> #define dev_fmt(fmt) "AER: " fmt
>
> #include <linux/pci.h>
> +#include <linux/pm_runtime.h>
> #include <linux/module.h>
> #include <linux/kernel.h>
> #include <linux/errno.h>
> @@ -85,6 +86,18 @@ static int report_error_detected(struct pci_dev *dev,
> return 0;
> }
>
> +static int pci_pm_runtime_get_sync(struct pci_dev *pdev, void *data)
> +{
> + pm_runtime_get_sync(&pdev->dev);
> + return 0;
> +}
> +
> +static int pci_pm_runtime_put(struct pci_dev *pdev, void *data)
> +{
> + pm_runtime_put(&pdev->dev);
> + return 0;
> +}
> +
> static int report_frozen_detected(struct pci_dev *dev, void *data)
> {
> return report_error_detected(dev, pci_channel_io_frozen, data);
> @@ -207,6 +220,8 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
> else
> bridge = pci_upstream_bridge(dev);
>
> + pci_walk_bridge(bridge, pci_pm_runtime_get_sync, NULL);
> +
> pci_dbg(bridge, "broadcast error_detected message\n");
> if (state == pci_channel_io_frozen) {
> pci_walk_bridge(bridge, report_frozen_detected, &status);
> @@ -251,10 +266,15 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
> pcie_clear_device_status(dev);
> pci_aer_clear_nonfatal_status(dev);
> }
> +
> + pci_walk_bridge(bridge, pci_pm_runtime_put, NULL);
> +
> pci_info(bridge, "device recovery successful\n");
> return status;
>
> failed:
> + pci_walk_bridge(bridge, pci_pm_runtime_put, NULL);
> +
> pci_uevent_ers(bridge, PCI_ERS_RESULT_DISCONNECT);
>
> /* TODO: Should kernel panic here? */
--
Sathyanarayanan Kuppuswamy
Linux Kernel Developer
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] PCI/AER: Block runtime suspend when handling errors
2024-02-09 15:45 ` Kuppuswamy Sathyanarayanan
@ 2024-02-12 8:13 ` Stanislaw Gruszka
0 siblings, 0 replies; 4+ messages in thread
From: Stanislaw Gruszka @ 2024-02-12 8:13 UTC (permalink / raw)
To: Kuppuswamy Sathyanarayanan
Cc: Bjorn Helgaas, Rafael J. Wysocki, linux-pci, linux-pm,
Mahesh J Salgaonkar, Oliver O'Halloran
On Fri, Feb 09, 2024 at 07:45:05AM -0800, Kuppuswamy Sathyanarayanan wrote:
>
> On 2/9/24 6:08 AM, Stanislaw Gruszka wrote:
> > PM runtime can be done simultaneously with AER error handling.
> > Avoid that by using pm_runtime_get_sync() before and pm_runtime_put()
> > after reset in pcie_do_recovery() for all recovering devices.
> >
> > pm_runtime_get_sync() will increase dev->power.usage_count counter
> > to prevent any possible future request to runtime suspend a device,
> > as well as resume device is was in D3hot state.
> runtime suspend a device or resume a device that was in D3hot state.
I think "or" is not proper here, since both: resume and prevention
of suspend are done. I'll reword this way:
pm_runtime_get_sync() will increase dev->power.usage_count counter
to prevent any possible future request to runtime suspend a device
It will also resume a device, if it was previously in D3hot state.
Hope that's clearer.
Thanks
Stanislaw
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-02-12 8:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-09 14:08 [PATCH] PCI/AER: Block runtime suspend when handling errors Stanislaw Gruszka
2024-02-09 14:16 ` Rafael J. Wysocki
2024-02-09 15:45 ` Kuppuswamy Sathyanarayanan
2024-02-12 8:13 ` Stanislaw Gruszka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox