Skip to contentSkip to conversation

PCI/AER: Avoid power state transition during system suspend

PATCH In review Raag Jadav 3 participants 6 messages Apr 3, 2025 – Apr 4, 2025

Subsystems (2)
lore
Share & tools
lore

Raag Jadav

author
#0 lore raw

PATCH 1/1 PCI/AER: Avoid power state transition during system suspend

If an error is triggered while system suspend is in progress, any bus level power state transition will result in unpredictable error handling. Mark skip_bus_pm flag as true to avoid this.

---

Ideally we'd want to defer recovery until system resume, but this is good enough to prevent device suspend.

More discussion at [1].
[1] https://lore.kernel.org/r/[email protected]

 drivers/pci/pcie/aer.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/pci/pcie/aer.c +6 -0
index 508474e17183..5acf4efc2df3 100644
@@ -1108,6 +1108,12 @@ static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info)
 
 static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info)
 {
+	/*
+	 * Avoid any power state transition if an error is triggered during
+	 * system suspend.
+	 */
+	dev->skip_bus_pm = true;
+
 	cxl_rch_handle_error(dev, info);
 	pci_aer_handle_error(dev, info);
 	pci_dev_put(dev);
Signature · 1 line
2.34.1
author
#1 lore raw
Quoted 4 lines · Raag Jadav

If an error is triggered while system suspend is in progress, any bus level power state transition will result in unpredictable error handling. Mark skip_bus_pm flag as true to avoid this.

Quoted 8 lines

---

Ideally we'd want to defer recovery until system resume, but this is good enough to prevent device suspend.

More discussion at [1].
[1] https://lore.kernel.org/r/[email protected]

I just realized I messed up the link, please use [2] instead. Apologies for the inconvenience.

[2] https://lore.kernel.org/all/CAJZ5v0g-aJXfVH+Uc=9eRPuW08t-6PwzdyMXsC6FZRKYJtY03Q@mail.gmail.com

Quoted 23 lines
 drivers/pci/pcie/aer.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/pci/pcie/aer.c +6 -0
index 508474e17183..5acf4efc2df3 100644
@@ -1108,6 +1108,12 @@ static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info)
 
 static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info)
 {
+	/*
+	 * Avoid any power state transition if an error is triggered during
+	 * system suspend.
+	 */
+	dev->skip_bus_pm = true;
+
 	cxl_rch_handle_error(dev, info);
 	pci_aer_handle_error(dev, info);
 	pci_dev_put(dev);
Signature · 1 line
2.34.1
#2 lore raw
In reply to Raag Jadav
Quoted 4 lines · Raag Jadav

If an error is triggered while system suspend is in progress, any bus level power state transition will result in unpredictable error handling. Mark skip_bus_pm flag as true to avoid this.

This needs to be synchronized with the skip_bus_pm clearing in pci_pm_suspend().

Also, skip_bus_pm is only used in the _noirq phases, so if a driver calls pci_set_power_state() from its ->suspend() callback, this change won't help.

I think that you're aware of it, but the changelog should mention this limitation.

Quoted 30 lines

---

Ideally we'd want to defer recovery until system resume, but this is good enough to prevent device suspend.

More discussion at [1].
[1] https://lore.kernel.org/r/[email protected]

 drivers/pci/pcie/aer.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/pci/pcie/aer.c +6 -1
index 508474e17183..5acf4efc2df3 100644
@@ -1108,6 +1108,12 @@ static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info)
 
 static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info)
 {
+       /*
+        * Avoid any power state transition if an error is triggered during
+        * system suspend.
+        */
+       dev->skip_bus_pm = true;
+
        cxl_rch_handle_error(dev, info);
        pci_aer_handle_error(dev, info);
        pci_dev_put(dev);
--
author
#3 lore raw
Quoted 7 lines · Rafael J. Wysocki
Quoted 4 lines · Raag Jadav

If an error is triggered while system suspend is in progress, any bus level power state transition will result in unpredictable error handling. Mark skip_bus_pm flag as true to avoid this.

This needs to be synchronized with the skip_bus_pm clearing in pci_pm_suspend().

I'm wondering if we can have something like aer_in_progress flag that we can use in PCI PM for this? ...

Quoted 3 lines

Also, skip_bus_pm is only used in the _noirq phases, so if a driver calls pci_set_power_state() from its ->suspend() callback, this change won't help.

... and perhaps skip these if it is set?

Raag

#4 lore raw
In reply to Raag Jadav
Quoted 3 lines · Raag Jadav

If an error is triggered while system suspend is in progress, any bus level power state transition will result in unpredictable error handling. Mark skip_bus_pm flag as true to avoid this.

[...]

Quoted 2 lines

Ideally we'd want to defer recovery until system resume, but this is good enough to prevent device suspend.

if (system_state == SYSTEM_SUSPEND)

... tells you whether the system is suspending, so you could catch that in the error recovery code.

Suspend to ACPI state S3 or S4 shouldn't need error recovery through reset upon resume because devices are generally reset by BIOS on resume anyway.

Thanks,

Lukas

author
#5 lore raw
Quoted 4 lines · Lukas Wunner
Quoted 3 lines · Raag Jadav

If an error is triggered while system suspend is in progress, any bus level power state transition will result in unpredictable error handling. Mark skip_bus_pm flag as true to avoid this.

Quoted 8 lines

[...]

Quoted 2 lines

Ideally we'd want to defer recovery until system resume, but this is good enough to prevent device suspend.

if (system_state == SYSTEM_SUSPEND)

... tells you whether the system is suspending, so you could catch that in the error recovery code.

Even if we catch it, what'd be the expectation with it? Do we can simply ignore the error because of system state?

I'm assuming deferring will require a fair bit of revamp (and I'm not sure if I'm qualified for it).

Quoted 2 lines

Suspend to ACPI state S3 or S4 shouldn't need error recovery through reset upon resume because devices are generally reset by BIOS on resume anyway.

Thanks for your input. We have s2idle usecase as well.

So the question here is whether we should allow suspending the device with errors at all (atleast until successful recovery). Wouldn't the device resume be unpredictable because of it?

Raag