PCI / ACPI / PM: Resume bridges w/o drivers on suspend-to-RAM
PATCH 1/1 PCI / ACPI / PM: Resume bridges w/o drivers on suspend-to-RAM
From: Rafael J. Wysocki <[email protected]>
It is reported that commit c62ec4610c40 (PM / core: Fix direct_complete handling for devices with no callbacks) introduced a system suspend regression on Samsung 305V4A by allowing a PCI bridge (not a PCIe port) to stay in D3 over suspend-to-RAM, which is a side effect of setting power.direct_complete for the children of that bridge that have no PM callbacks.
On the majority of systems PCI bridges are not allowed to be runtime-suspended (the power/control sysfs attribute is set to "on" for them by default), but user space can change that setting and if it does so and a given bridge has no children with PM callbacks, the direct_complete optimization will be applied to it and it will stay in suspend over system suspend. Apparently, that confuses the platform firmware on the affected machine and that may very well happen elsewhere, so avoid the direct_complete optimization for PCI bridges with no drivers (if there is a driver, it should take care of the PM handling) on suspend-to-RAM altogether (that should not matter for suspend-to-idle as platform firmware is not involved in it).
--- drivers/pci/pci-acpi.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/pci/pci-acpi.c +8 -0
@@ -638,6 +638,14 @@ static bool acpi_pci_need_resume(structif (acpi_target_system_state () ==ACPI_STATE_S0 )return false; +/* +* In some cases (eg. Samsung 305V4A) leaving a bridge in suspend +* confuses the platform firmware, so avoid doing that, unless the +* bridge has a driver that should take care of PM handling. +*/ +if (pci_is_bridge (dev) && !dev->driver) +return true; +return !!adev->power.flags.dsw_present; }
Quoted 22 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
It is reported that commit
c62ec4610c40(PM / core: Fixdirect_completehandling for devices with no callbacks) introduced a system suspend regression on Samsung 305V4A by allowing a PCI bridge (not a PCIe port) to stay in D3 over suspend-to-RAM, which is a side effect of setting power.direct_complete for the children of that bridge that have no PM callbacks.On the majority of systems PCI bridges are not allowed to be runtime-suspended (the power/control sysfs attribute is set to "on" for them by default), but user space can change that setting and if it does so and a given bridge has no children with PM callbacks, the
direct_completeoptimization will be applied to it and it will stay in suspend over system suspend. Apparently, that confuses the platform firmware on the affected machine and that may very well happen elsewhere, so avoid thedirect_completeoptimization for PCI bridges with no drivers (if there is a driver, it should take care of the PM handling) on suspend-to-RAM altogether (that should not matter for suspend-to-idle as platform firmware is not involved in it).
Quoted 5 lines
Fixes c62ec4610c40 (PM / core: Fix direct_complete handling for devices with no callbacks)Reported-by [email protected]Tested-by [email protected]Signed-off-by Rafael J. Wysocki <[email protected]>
Quoted 9 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
It is reported that commit
c62ec4610c40(PM / core: Fixdirect_completehandling for devices with no callbacks) introduced a system suspend regression on Samsung 305V4A by allowing a PCI bridge (not a PCIe port) to stay in D3 over suspend-to-RAM, which is a side effect of setting power.direct_complete for the children of that bridge that have no PM callbacks.
Quoted 6 lines
On the majority of systems PCI bridges are not allowed to be runtime-suspended (the power/control sysfs attribute is set to "on" for them by default), but user space can change that setting and if it does so and a given bridge has no children with PM callbacks, the
direct_completeoptimization will be applied to it and it will stay in suspend over system suspend. Apparently, that confuses the
"stay in D3 over system suspend"? (just to be explicit about what "in suspend" means)
Quoted 21 lines
platform firmware on the affected machine and that may very well happen elsewhere, so avoid the
direct_completeoptimization for PCI bridges with no drivers (if there is a driver, it should take care of the PM handling) on suspend-to-RAM altogether (that should not matter for suspend-to-idle as platform firmware is not involved in it).Fixes c62ec4610c40 (PM / core: Fix direct_complete handling for devices with no callbacks)Reported-by [email protected]Tested-by [email protected]Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/pci/pci-acpi.c | 8 ++++++++ 1 file changed, 8 insertions(+)Index:
linux-pm/drivers/pci/pci-acpi.c
===================================================================
drivers/pci/pci-acpi.c static bool acpi_pci_need_resume(struct · line 647
Quoted 10 lines
drivers/pci/pci-acpi.c +7
-0@@ -638,6 +638,14 @@ static bool acpi_pci_need_resume(structif (acpi_target_system_state () ==ACPI_STATE_S0 )return false; +/* +* In some cases (eg. Samsung 305V4A) leaving a bridge in suspend +* confuses the platform firmware, so avoid doing that, unless the +* bridge has a driver that should take care of PM handling. +*/ +if (pci_is_bridge (dev) && !dev->driver) +return true;
It sounds like the question of whether leaving a bridge in D3 confuses the firmware has a platform-specific answer. How does the driver PM handling know how to do the right thing? Does it need to know whether it's safe to put the device in D3? Or maybe a device is never put in D3 for system suspend if it has a driver?
But I'm just kibbitzing; since you merged c62ec4610c40, I'm happy if you also merge this:
Quoted 8 lines
drivers/pci/pci-acpi.c +0
-1return !!adev->power.flags.dsw_present; } --To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Rafael J. Wysocki
maintainerQuoted 17 lines · Bjorn Helgaas
Quoted 9 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
It is reported that commit
c62ec4610c40(PM / core: Fixdirect_completehandling for devices with no callbacks) introduced a system suspend regression on Samsung 305V4A by allowing a PCI bridge (not a PCIe port) to stay in D3 over suspend-to-RAM, which is a side effect of setting power.direct_complete for the children of that bridge that have no PM callbacks.Quoted 6 lines
On the majority of systems PCI bridges are not allowed to be runtime-suspended (the power/control sysfs attribute is set to "on" for them by default), but user space can change that setting and if it does so and a given bridge has no children with PM callbacks, the
direct_completeoptimization will be applied to it and it will stay in suspend over system suspend. Apparently, that confuses the
Quoted 2 lines
"stay in D3 over system suspend"? (just to be explicit about what "in suspend" means)
OK
Quoted 24 lines
Quoted 24 lines
platform firmware on the affected machine and that may very well happen elsewhere, so avoid the
direct_completeoptimization for PCI bridges with no drivers (if there is a driver, it should take care of the PM handling) on suspend-to-RAM altogether (that should not matter for suspend-to-idle as platform firmware is not involved in it).Fixes c62ec4610c40 (PM / core: Fix direct_complete handling for devices with no callbacks)Reported-by [email protected]Tested-by [email protected]Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/pci/pci-acpi.c | 8 ++++++++ 1 file changed, 8 insertions(+)Index:
linux-pm/drivers/pci/pci-acpi.c
===================================================================drivers/pci/pci-acpi.c +0
-0@@ -638,6 +638,14 @@ static bool acpi_pci_need_resume(structif (acpi_target_system_state () ==ACPI_STATE_S0 )return false;
Quoted 10 lines
drivers/pci/pci-acpi.c static bool acpi_pci_need_resume(struct · line 647
Quoted 7 lines
drivers/pci/pci-acpi.c +7
-0+/* +* In some cases (eg. Samsung 305V4A) leaving a bridge in suspend +* confuses the platform firmware, so avoid doing that, unless the +* bridge has a driver that should take care of PM handling. +*/ +if (pci_is_bridge (dev) && !dev->driver) +return true;It sounds like the question of whether leaving a bridge in D3 confuses the firmware has a platform-specific answer.
Well, it may confuse the platform firmware in general.
Quoted 1 line
How does the driver PM handling know how to do the right thing?
For endpoints this is not an issue as they always have been expected to be in D3 before passing control to the platform firmware on S3 entry, but we've never done that for bridges by default, except for PCIe ports with PM enabled (in which case the driver decides whether or not to enable it).
Quoted 3 lines
Does it need to know whether
it's safe to put the device in D3? Or maybe a device is never put in D3 for system suspend if it has a driver?
As per the above, endpoints should be OK (or they are quirky if not), but bridges are sort of a gray area. PCIe ports for which we enable PM should be fine, for the rest it's better to be conservative and resume them IMO.
Quoted 7 lines
But I'm just kibbitzing; since you merged
c62ec4610c40, I'm happy if you also merge this:Acked-by Bjorn Helgaas <[email protected]>Quoted 2 lines
drivers/pci/pci-acpi.c +0
-0return !!adev->power.flags.dsw_present; }
Thanks!
Quoted 17 lines · Rafael J. Wysocki
Quoted 11 lines · Bjorn Helgaas
drivers/pci/pci-acpi.c static bool acpi_pci_need_resume(struct · line 647
Quoted 9 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
drivers/pci/pci-acpi.c +7
-0+/* +* In some cases (eg. Samsung 305V4A) leaving a bridge in suspend +* confuses the platform firmware, so avoid doing that, unless the +* bridge has a driver that should take care of PM handling. +*/ +if (pci_is_bridge (dev) && !dev->driver) +return true;Quoted 2 lines
It sounds like the question of whether leaving a bridge in D3 confuses the firmware has a platform-specific answer.
Well, it may confuse the platform firmware in general.
Quoted 7 lines
Quoted 1 line
How does the driver PM handling know how to do the right thing?
For endpoints this is not an issue as they always have been expected to be in D3 before passing control to the platform firmware on S3 entry, but we've never done that for bridges by default, except for PCIe ports with PM enabled (in which case the driver decides whether or not to enable it).
If there's any spec reference for the expected power states of devices when entering S3, that would be useful here. I can't tell if there's any guidance for this or if it's just figured out experimentally.
Quoted 8 lines
Quoted 3 lines
Does it need to know whether
it's safe to put the device in D3? Or maybe a device is never put in D3 for system suspend if it has a driver?As per the above, endpoints should be OK (or they are quirky if not), but bridges are sort of a gray area. PCIe ports for which we enable PM should be fine, for the rest it's better to be conservative and resume them IMO.
Rafael J. Wysocki
maintainerQuoted 26 lines · Bjorn Helgaas
Quoted 17 lines · Rafael J. Wysocki
Quoted 11 lines · Bjorn Helgaas
drivers/pci/pci-acpi.c static bool acpi_pci_need_resume(struct · line 647
Quoted 9 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
drivers/pci/pci-acpi.c +7
-0+/* +* In some cases (eg. Samsung 305V4A) leaving a bridge in suspend +* confuses the platform firmware, so avoid doing that, unless the +* bridge has a driver that should take care of PM handling. +*/ +if (pci_is_bridge (dev) && !dev->driver) +return true;Quoted 2 lines
It sounds like the question of whether leaving a bridge in D3 confuses the firmware has a platform-specific answer.
Well, it may confuse the platform firmware in general.
Quoted 7 lines
Quoted 1 line
How does the driver PM handling know how to do the right thing?
For endpoints this is not an issue as they always have been expected to be in D3 before passing control to the platform firmware on S3 entry, but we've never done that for bridges by default, except for PCIe ports with PM enabled (in which case the driver decides whether or not to enable it).
Quoted 3 lines
If there's any spec reference for the expected power states of devices when entering S3, that would be useful here. I can't tell if there's any guidance for this or if it's just figured out experimentally.
It is not direct, but Section 16.1.6 of ACPI 6.2 says this in step 4 of the system suspend outline:
OSPM places all device drivers into their respective Dx state. If the device is enabled for wake,
it enters the Dx state associated with the wake capability. If the device is not enabled to wake
the system, it enters the D3 state.
Quoted 31 lines · Rafael J. Wysocki
Quoted 26 lines · Bjorn Helgaas
Quoted 17 lines · Rafael J. Wysocki
Quoted 11 lines · Bjorn Helgaas
drivers/pci/pci-acpi.c static bool acpi_pci_need_resume(struct · line 647
Quoted 9 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
drivers/pci/pci-acpi.c +7
-0+/* +* In some cases (eg. Samsung 305V4A) leaving a bridge in suspend +* confuses the platform firmware, so avoid doing that, unless the +* bridge has a driver that should take care of PM handling. +*/ +if (pci_is_bridge (dev) && !dev->driver) +return true;Quoted 2 lines
It sounds like the question of whether leaving a bridge in D3 confuses the firmware has a platform-specific answer.
Well, it may confuse the platform firmware in general.
Quoted 7 lines
Quoted 1 line
How does the driver PM handling know how to do the right thing?
For endpoints this is not an issue as they always have been expected to be in D3 before passing control to the platform firmware on S3 entry, but we've never done that for bridges by default, except for PCIe ports with PM enabled (in which case the driver decides whether or not to enable it).
Quoted 3 lines
If there's any spec reference for the expected power states of devices when entering S3, that would be useful here. I can't tell if there's any guidance for this or if it's just figured out experimentally.
Quoted 8 lines
It is not direct, but Section 16.1.6 of ACPI 6.2 says this in step 4 of the system suspend outline:
OSPM places all device drivers into their respective Dx state. If the device is enabled for wake,
it enters the Dx state associated with the wake capability. If the device is not enabled to wake
the system, it enters the D3 state.
Thanks, that's a very useful citation!
Bjorn
Rafael J. Wysocki
maintainerQuoted 35 lines · Bjorn Helgaas
Quoted 34 lines · Rafael J. Wysocki
Quoted 26 lines · Bjorn Helgaas
Quoted 17 lines · Rafael J. Wysocki
Quoted 11 lines · Bjorn Helgaas
drivers/pci/pci-acpi.c static bool acpi_pci_need_resume(struct · line 647
Quoted 9 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
drivers/pci/pci-acpi.c +7
-0+/* +* In some cases (eg. Samsung 305V4A) leaving a bridge in suspend +* confuses the platform firmware, so avoid doing that, unless the +* bridge has a driver that should take care of PM handling. +*/ +if (pci_is_bridge (dev) && !dev->driver) +return true;Quoted 2 lines
It sounds like the question of whether leaving a bridge in D3 confuses the firmware has a platform-specific answer.
Well, it may confuse the platform firmware in general.
Quoted 7 lines
Quoted 1 line
How does the driver PM handling know how to do the right thing?
For endpoints this is not an issue as they always have been expected to be in D3 before passing control to the platform firmware on S3 entry, but we've never done that for bridges by default, except for PCIe ports with PM enabled (in which case the driver decides whether or not to enable it).
Quoted 3 lines
If there's any spec reference for the expected power states of devices when entering S3, that would be useful here. I can't tell if there's any guidance for this or if it's just figured out experimentally.
It is not direct, but Section 16.1.6 of ACPI 6.2 says this in step 4 of the system suspend outline:
Quoted 7 lines
Quoted 5 lines
OSPM places all device drivers into their respective Dx state. If the device is enabled for wake,
it enters the Dx state associated with the wake capability. If the device is not enabled to wake
the system, it enters the D3 state.Thanks, that's a very useful citation!
You're welcome! :-)
I actually need to withdraw the $subject patch as it doesn't help (I misread the reporters response) and the one that does work is a bit too intrusive IMO, so I'll investigate this a bit more.
PATCH v2 1/1 PCI / ACPI / PM: Resume bridges w/o drivers on suspend-to-RAM
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
It is reported that commit c62ec4610c40 (PM / core: Fix direct_complete handling for devices with no callbacks) introduced a system suspend regression on Samsung 305V4A by allowing a PCI bridge (not a PCIe port) to stay in D3 over suspend-to-RAM, which is a side effect of setting power.direct_complete for the children of that bridge that have no PM callbacks.
On the majority of systems PCI bridges are not allowed to be runtime-suspended (the power/control sysfs attribute is set to "on" for them by default), but user space can change that setting and if it does so and a given bridge has no children with PM callbacks, the direct_complete optimization will be applied to it and it will stay in suspend over system suspend. Apparently, that confuses the platform firmware on the affected machine and that may very well happen elsewhere, so avoid the direct_complete optimization for PCI bridges with no drivers (if there is a driver, it should take care of the PM handling) on suspend-to-RAM altogether (that should not matter for suspend-to-idle as platform firmware is not involved in it).
---
-> v2: Make the patch work for PCI bridges without ACPI companion objects.
Since that doesn't really change the idea etc, but only makes the check to be made earlier, I've added the Reviewed-by and Acked-by tags given to the previous version. If that's not right, please let me know.
--- drivers/pci/pci-acpi.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/pci/pci-acpi.c +9 -0
@@ -629,6 +629,15 @@ static bool acpi_pci_need_resume(struct {struct acpi_device *adev =ACPI_COMPANION (&dev->dev); +/* +* In some cases (eg. Samsung 305V4A) leaving a bridge in suspend +* confuses the platform firmware, so avoid doing that, unless the +* bridge has a driver that should take care of PM handling. +*/ +if (pci_is_bridge (dev) && !dev->driver && +acpi_target_system_state () !=ACPI_STATE_S0 ) +return true; +if (!adev || !acpi_device_power_manageable (adev))return false;
Quoted 29 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
It is reported that commit
c62ec4610c40(PM / core: Fixdirect_completehandling for devices with no callbacks) introduced a system suspend regression on Samsung 305V4A by allowing a PCI bridge (not a PCIe port) to stay in D3 over suspend-to-RAM, which is a side effect of setting power.direct_complete for the children of that bridge that have no PM callbacks.On the majority of systems PCI bridges are not allowed to be runtime-suspended (the power/control sysfs attribute is set to "on" for them by default), but user space can change that setting and if it does so and a given bridge has no children with PM callbacks, the
direct_completeoptimization will be applied to it and it will stay in suspend over system suspend. Apparently, that confuses the platform firmware on the affected machine and that may very well happen elsewhere, so avoid thedirect_completeoptimization for PCI bridges with no drivers (if there is a driver, it should take care of the PM handling) on suspend-to-RAM altogether (that should not matter for suspend-to-idle as platform firmware is not involved in it).Fixes c62ec4610c40 (PM / core: Fix direct_complete handling for devices with no callbacks)Reported-by [email protected]Tested-by [email protected]Reviewed-by Mika Westerberg <[email protected]>Acked-by Bjorn Helgaas <[email protected]>Signed-off-by Rafael J. Wysocki <[email protected]>
Quoted 7 lines
---
-> v2: Make the patch work for PCI bridges without ACPI companion objects.
Since that doesn't really change the idea etc, but only makes the check to be made earlier, I've added the Reviewed-by and Acked-by tags given to the previous version. If that's not right, please let me know.
Keeping my ack is fine, and I assume you'll apply this.
It would be nice to see that ACPI spec reference (the spec version and section number, not necessarily all the text) in the changelog or maybe even a comment in the code.
Quoted 29 lines
--- drivers/pci/pci-acpi.c | 9 +++++++++ 1 file changed, 9 insertions(+)Index:
linux-pm/drivers/pci/pci-acpi.c
===================================================================drivers/pci/pci-acpi.c +9
-1@@ -629,6 +629,15 @@ static bool acpi_pci_need_resume(struct {struct acpi_device *adev =ACPI_COMPANION (&dev->dev); +/* +* In some cases (eg. Samsung 305V4A) leaving a bridge in suspend +* confuses the platform firmware, so avoid doing that, unless the +* bridge has a driver that should take care of PM handling. +*/ +if (pci_is_bridge (dev) && !dev->driver && +acpi_target_system_state () !=ACPI_STATE_S0 ) +return true; +if (!adev || !acpi_device_power_manageable (adev))return false; --To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Rafael J. Wysocki
maintainerQuoted 32 lines · Bjorn Helgaas
Quoted 31 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
It is reported that commit
c62ec4610c40(PM / core: Fixdirect_completehandling for devices with no callbacks) introduced a system suspend regression on Samsung 305V4A by allowing a PCI bridge (not a PCIe port) to stay in D3 over suspend-to-RAM, which is a side effect of setting power.direct_complete for the children of that bridge that have no PM callbacks.On the majority of systems PCI bridges are not allowed to be runtime-suspended (the power/control sysfs attribute is set to "on" for them by default), but user space can change that setting and if it does so and a given bridge has no children with PM callbacks, the
direct_completeoptimization will be applied to it and it will stay in suspend over system suspend. Apparently, that confuses the platform firmware on the affected machine and that may very well happen elsewhere, so avoid thedirect_completeoptimization for PCI bridges with no drivers (if there is a driver, it should take care of the PM handling) on suspend-to-RAM altogether (that should not matter for suspend-to-idle as platform firmware is not involved in it).Fixes c62ec4610c40 (PM / core: Fix direct_complete handling for devices with no callbacks)Reported-by [email protected]Tested-by [email protected]Reviewed-by Mika Westerberg <[email protected]>Acked-by Bjorn Helgaas <[email protected]>Signed-off-by Rafael J. Wysocki <[email protected]>---
Quoted 7 lines
Quoted 5 lines
-> v2: Make the patch work for PCI bridges without ACPI companion objects.
Since that doesn't really change the idea etc, but only makes the check to be made earlier, I've added the Reviewed-by and Acked-by tags given to the previous version. If that's not right, please let me know.
Keeping my ack is fine, and I assume you'll apply this.
I will, thanks!
Quoted 3 lines
It would be nice to see that ACPI spec reference (the spec version and section number, not necessarily all the text) in the changelog or maybe even a comment in the code.
OK