PM: PCI/ACPI: Hibernation handling fixes
v2 cover PM: PCI/ACPI: Hibernation handling fixes
Hi All,
This series of patches addresses a few issues related to the handling of hibernation in the PCI bus type and the ACPI PM domain and ACPI LPSS driver.
The v2 addresses Hans' concerns regarding the LPSS changes.
First of all, all of the runtime-suspended PCI devices and devices in the ACPI PM and LPSS PM domains will be resumed during hibernation (first patch). This appears to be the only way to avoid weird corner cases and the benefit from avoiding to resume those devices during hibernation is questionable.
That change allows the the hibernation callbacks in all of the involved subsystems to be simplified (patches 2 and 3).
Moreover, reusing bus-level suspend callbacks for the "poweroff" transition during hibernation (which is the case for the ACPI PM domain and LPSS) is incorrect, so patch 4 fixes that.
Finally, there are some leftover items in linux/acpi.h that can be dropped (patch 5).
Thanks,
Rafael
PATCH v2 1/5 PM: ACPI/PCI: Resume all devices during hibernation
From: Rafael J. Wysocki <[email protected]>
Both the PCI bus type and the ACPI PM domain avoid resuming runtime-suspended devices with DPM_FLAG_SMART_SUSPEND set during hibernation (before creating the snapshot image of system memory), but that turns out to be a mistake. It leads to functional issues and adds complexity that's hard to justify.
For this reason, resume all runtime-suspended PCI devices and all devices in the ACPI PM domains before creating a snapshot image of system memory during hibernation.
---
-> v2: No changes.
--- drivers/acpi/device_pm.c | 13 +++++++------ drivers/pci/pci-driver.c | 16 ++++++++-------- 2 files changed, 15 insertions(+), 14 deletions(-)
drivers/acpi/device_pm.c +7 -6
@@ -1155,13 +1155,14 @@ EXPORT_SYMBOL_GPL(acpi_subsys_resume_earint acpi_subsys_freeze (struct device *dev) {/* -* This used to be done in acpi_subsys_prepare() for all devices and -* some drivers may depend on it, so do it here. Ideally, however, -* runtime-suspended devices should not be touched during freeze/thaw -* transitions. +* Resume all runtime-suspended devices before creating a snapshot +* image of system memory, because the restore kernel generally cannot +* be expected to always handle them consistently and they need to be +* put into the runtime-active metastate during system resume anyway, +* so it is better to ensure that the state saved in the image will be +* alwyas consistent with that. */ -if (!dev_pm_test_driver_flags (dev,DPM_FLAG_SMART_SUSPEND )) -pm_runtime_resume (dev); +pm_runtime_resume (dev);return pm_generic_freeze (dev); }
drivers/pci/pci-driver.c +8 -8
@@ -1012,15 +1012,15 @@ static int pci_pm_freeze(struct device * }/* -* This used to be done in pci_pm_prepare() for all devices and some -* drivers may depend on it, so do it here. Ideally, runtime-suspended -* devices should not be touched during freeze/thaw transitions, -* however. +* Resume all runtime-suspended devices before creating a snapshot +* image of system memory, because the restore kernel generally cannot +* be expected to always handle them consistently and they need to be +* put into the runtime-active metastate during system resume anyway, +* so it is better to ensure that the state saved in the image will be +* alwyas consistent with that. */ -if (!dev_pm_smart_suspend_and_suspended (dev)) { -pm_runtime_resume (dev); - pci_dev->state_saved = false; - } +pm_runtime_resume (dev); + pci_dev->state_saved = false;if (pm->freeze) {int error;
Re: [PATCH v2 1/5] PM: ACPI/PCI: Resume all devices during hibernation
Quoted 35 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Both the PCI bus type and the ACPI PM domain avoid resuming runtime-suspended devices with
DPM_FLAG_SMART_SUSPENDset during hibernation (before creating the snapshot image of system memory), but that turns out to be a mistake. It leads to functional issues and adds complexity that's hard to justify.For this reason, resume all runtime-suspended PCI devices and all devices in the ACPI PM domains before creating a snapshot image of system memory during hibernation.
Fixes 05087360fd7a (ACPI / PM: Take SMART_SUSPEND driver flag into account)Fixes c4b65157aeef (PCI / PM: Take SMART_SUSPEND driver flag into account)Link https://lore.kernel.org/linux-acpi/[email protected]/T/#maf065fe6e4974f2a9d79f332ab99dfaba635f64c open hereReported-by Robert R. Howell <[email protected]>Tested-by Robert R. Howell <[email protected]>Signed-off-by Rafael J. Wysocki <[email protected]>---
-> v2: No changes.
--- drivers/acpi/device_pm.c | 13 +++++++------ drivers/pci/pci-driver.c | 16 ++++++++-------- 2 files changed, 15 insertions(+), 14 deletions(-)Index:
linux-pm/drivers/acpi/device_pm.c
===================================================================drivers/acpi/device_pm.c +0
-0@@ -1155,13 +1155,14 @@ EXPORT_SYMBOL_GPL(acpi_subsys_resume_earint acpi_subsys_freeze (struct device *dev) {/*
drivers/acpi/device_pm.c EXPORT_SYMBOL_GPL(acpi_subsys_resume_ear · line 1163
Quoted 10 lines
drivers/acpi/device_pm.c +6
-4-* This used to be done in acpi_subsys_prepare() for all devices and -* some drivers may depend on it, so do it here. Ideally, however, -* runtime-suspended devices should not be touched during freeze/thaw -* transitions. +* Resume all runtime-suspended devices before creating a snapshot +* image of system memory, because the restore kernel generally cannot +* be expected to always handle them consistently and they need to be +* put into the runtime-active metastate during system resume anyway, +* so it is better to ensure that the state saved in the image will be +* alwyas consistent with that.
alwyas -> always
Quoted 15 lines
drivers/acpi/device_pm.c +1
-2*/ -if (!dev_pm_test_driver_flags (dev,DPM_FLAG_SMART_SUSPEND )) -pm_runtime_resume (dev); +pm_runtime_resume (dev);return pm_generic_freeze (dev); }Index:
linux-pm/drivers/pci/pci-driver.c
===================================================================drivers/pci/pci-driver.c +0
-0@@ -1012,15 +1012,15 @@ static int pci_pm_freeze(struct device * }/*
drivers/pci/pci-driver.c static int pci_pm_freeze(struct device * · line 1020
Quoted 10 lines
drivers/pci/pci-driver.c +6
-4-* This used to be done in pci_pm_prepare() for all devices and some -* drivers may depend on it, so do it here. Ideally, runtime-suspended -* devices should not be touched during freeze/thaw transitions, -* however. +* Resume all runtime-suspended devices before creating a snapshot +* image of system memory, because the restore kernel generally cannot +* be expected to always handle them consistently and they need to be +* put into the runtime-active metastate during system resume anyway, +* so it is better to ensure that the state saved in the image will be +* alwyas consistent with that.
ditto
Quoted 13 lines
drivers/pci/pci-driver.c +2
-4*/ -if (!dev_pm_smart_suspend_and_suspended (dev)) { -pm_runtime_resume (dev); - pci_dev->state_saved = false; - } +pm_runtime_resume (dev); + pci_dev->state_saved = false;if (pm->freeze) {int error;
Rafael J. Wysocki
maintainerRe: [PATCH v2 1/5] PM: ACPI/PCI: Resume all devices during hibernation
Quoted 64 lines · Mika Westerberg
Quoted 35 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Both the PCI bus type and the ACPI PM domain avoid resuming runtime-suspended devices with
DPM_FLAG_SMART_SUSPENDset during hibernation (before creating the snapshot image of system memory), but that turns out to be a mistake. It leads to functional issues and adds complexity that's hard to justify.For this reason, resume all runtime-suspended PCI devices and all devices in the ACPI PM domains before creating a snapshot image of system memory during hibernation.
Fixes 05087360fd7a (ACPI / PM: Take SMART_SUSPEND driver flag into account)Fixes c4b65157aeef (PCI / PM: Take SMART_SUSPEND driver flag into account)Link https://lore.kernel.org/linux-acpi/[email protected]/T/#maf065fe6e4974f2a9d79f332ab99dfaba635f64c open hereReported-by Robert R. Howell <[email protected]>Tested-by Robert R. Howell <[email protected]>Signed-off-by Rafael J. Wysocki <[email protected]>---
-> v2: No changes.
--- drivers/acpi/device_pm.c | 13 +++++++------ drivers/pci/pci-driver.c | 16 ++++++++-------- 2 files changed, 15 insertions(+), 14 deletions(-)Index:
linux-pm/drivers/acpi/device_pm.c
===================================================================drivers/acpi/device_pm.c +0
-0@@ -1155,13 +1155,14 @@ EXPORT_SYMBOL_GPL(acpi_subsys_resume_earint acpi_subsys_freeze (struct device *dev) {/* drivers/acpi/device_pm.c EXPORT_SYMBOL_GPL(acpi_subsys_resume_ear · line 1163
Quoted 10 lines
drivers/acpi/device_pm.c +6
-4-* This used to be done in acpi_subsys_prepare() for all devices and -* some drivers may depend on it, so do it here. Ideally, however, -* runtime-suspended devices should not be touched during freeze/thaw -* transitions. +* Resume all runtime-suspended devices before creating a snapshot +* image of system memory, because the restore kernel generally cannot +* be expected to always handle them consistently and they need to be +* put into the runtime-active metastate during system resume anyway, +* so it is better to ensure that the state saved in the image will be +* alwyas consistent with that. alwyas -> always
Quoted 14 lines
drivers/acpi/device_pm.c +1
-2*/ -if (!dev_pm_test_driver_flags (dev,DPM_FLAG_SMART_SUSPEND )) -pm_runtime_resume (dev); +pm_runtime_resume (dev);return pm_generic_freeze (dev); }Index:
linux-pm/drivers/pci/pci-driver.c
===================================================================drivers/pci/pci-driver.c +0
-0@@ -1012,15 +1012,15 @@ static int pci_pm_freeze(struct device * }
Quoted 13 lines
drivers/pci/pci-driver.c static int pci_pm_freeze(struct device * · line 1020
Quoted 11 lines
drivers/pci/pci-driver.c +6
-4/* -* This used to be done in pci_pm_prepare() for all devices and some -* drivers may depend on it, so do it here. Ideally, runtime-suspended -* devices should not be touched during freeze/thaw transitions, -* however. +* Resume all runtime-suspended devices before creating a snapshot +* image of system memory, because the restore kernel generally cannot +* be expected to always handle them consistently and they need to be +* put into the runtime-active metastate during system resume anyway, +* so it is better to ensure that the state saved in the image will be +* alwyas consistent with that. ditto
Thanks, I'll fix these up when applying the patch.
Re: [PATCH v2 1/5] PM: ACPI/PCI: Resume all devices during hibernation
In reply to Rafael J. WysockiQuoted 18 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Both the PCI bus type and the ACPI PM domain avoid resuming runtime-suspended devices with
DPM_FLAG_SMART_SUSPENDset during hibernation (before creating the snapshot image of system memory), but that turns out to be a mistake. It leads to functional issues and adds complexity that's hard to justify.For this reason, resume all runtime-suspended PCI devices and all devices in the ACPI PM domains before creating a snapshot image of system memory during hibernation.
Fixes 05087360fd7a (ACPI / PM: Take SMART_SUSPEND driver flag into account)Fixes c4b65157aeef (PCI / PM: Take SMART_SUSPEND driver flag into account)Link https://lore.kernel.org/linux-acpi/[email protected]/T/#maf065fe6e4974f2a9d79f332ab99dfaba635f64c open hereReported-by Robert R. Howell <[email protected]>Tested-by Robert R. Howell <[email protected]>Signed-off-by Rafael J. Wysocki <[email protected]>
Quoted 3 lines
---
-> v2: No changes.
I've tested your v2 patch set on my ASUS T100TA, applying just those 5 patches to the 5.2-rc7 kernel, and they do fix the hibernation problem. The i2c_designware timeout errors are now gone and sound does now work after resume from both suspend and hibernate.
As before I still see the "i2c_designware 80860F41:00: Transfer while suspended" error on the first resume from either suspend or hibernate, but also as before that particular error doesn't seem to cause a persistent problem and the system works normally after the resume.
Bob Howell
PATCH v2 2/5 PCI: PM: Simplify bus-level hibernation callbacks
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
After a previous change causing all runtime-suspended PCI devices to be resumed before creating a snapshot image of memory during hibernation, it is not necessary to worry about the case in which them might be left in runtime-suspend any more, so get rid of the code related to that from bus-level PCI hibernation callbacks.
---
-> v2: No changes.
--- drivers/pci/pci-driver.c | 27 --------------------------- 1 file changed, 27 deletions(-)
drivers/pci/pci-driver.c +0 -27
@@ -1034,22 +1034,11 @@ static int pci_pm_freeze(struct device *return 0 ; } -static int pci_pm_freeze_late (struct device *dev) -{ -if (dev_pm_smart_suspend_and_suspended (dev)) -return 0 ; - -return pm_generic_freeze_late (dev); -} -static int pci_pm_freeze_noirq (struct device *dev) {struct pci_dev *pci_dev =to_pci_dev (dev);struct device_driver *drv = dev->driver; -if (dev_pm_smart_suspend_and_suspended (dev)) -return 0 ; -if (pci_has_legacy_pm_support (pci_dev))return pci_legacy_suspend_late (dev,PMSG_FREEZE );
@@ -1079,16 +1068,6 @@ static int pci_pm_thaw_noirq(struct devistruct device_driver *drv = dev->driver;int error =0 ; -/* -* If the device is in runtime suspend, the code below may not work -* correctly with it, so skip that code and make the PM core skip all of -* the subsequent "thaw" callbacks for the device. -*/ -if (dev_pm_smart_suspend_and_suspended (dev)) { -dev_pm_skip_next_resume_phases (dev); -return 0 ; - } -if (pcibios_pm_ops.thaw_noirq) { error = pcibios_pm_ops.thaw_noirq (dev);if (error)
@@ -1226,10 +1205,6 @@ static int pci_pm_restore_noirq(struct dstruct device_driver *drv = dev->driver;int error =0 ; -/* This is analogous to the pci_pm_resume_noirq() case. */ -if (dev_pm_smart_suspend_and_suspended (dev)) -pm_runtime_set_active (dev); -if (pcibios_pm_ops.restore_noirq) { error = pcibios_pm_ops.restore_noirq (dev);if (error)
@@ -1279,7 +1254,6 @@ static int pci_pm_restore(struct device#else /* !CONFIG_HIBERNATE_CALLBACKS */ #define pci_pm_freeze NULL -#define pci_pm_freeze_late NULL#define pci_pm_freeze_noirq NULL#define pci_pm_thaw NULL#define pci_pm_thaw_noirq NULL
@@ -1405,7 +1379,6 @@ static const struct dev_pm_ops pci_dev_p .suspend_late = pci_pm_suspend_late, .resume = pci_pm_resume, .freeze = pci_pm_freeze, - .freeze_late = pci_pm_freeze_late, .thaw = pci_pm_thaw, .poweroff = pci_pm_poweroff, .poweroff_late = pci_pm_poweroff_late,
PATCH v2 3/5 ACPI: PM: Simplify and fix PM domain hibernation callbacks
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
First, after a previous change causing all runtime-suspended devices in the ACPI PM domain (and ACPI LPSS devices) to be resumed before creating a snapshot image of memory during hibernation, it is not necessary to worry about the case in which them might be left in runtime-suspend any more, so get rid of the code related to that from ACPI PM domain and ACPI LPSS hibernation callbacks.
Second, it is not correct to use pm_generic_resume_early() and acpi_subsys_resume_noirq() in hibernation "restore" callbacks (which currently happens in the ACPI PM domain and ACPI LPSS), so introduce proper _restore_late and _restore_noirq callbacks for the ACPI PM domain and ACPI LPSS.
---
-> v2:
* Add a comment explaining the acpi_lpss_resume_noirq() behavior.
* Make the new LPSS "restore" callbacks follow that behavior.
--- drivers/acpi/acpi_lpss.c | 61 ++++++++++++++++++++++++++++++++++++++++------- drivers/acpi/device_pm.c | 61 ++++++----------------------------------------- include/linux/acpi.h | 10 ------- 3 files changed, 61 insertions(+), 71 deletions(-)
drivers/acpi/device_pm.c +9 -52
@@ -1116,7 +1116,7 @@ EXPORT_SYMBOL_GPL(acpi_subsys_suspend_no* acpi_subsys_resume_noirq - Run the device driver's "noirq" resume callback. * @dev: Device to handle. */ -int acpi_subsys_resume_noirq (struct device *dev) +static int acpi_subsys_resume_noirq (struct device *dev) {if (dev_pm_may_skip_resume (dev))return 0 ;
@@ -1131,7 +1131,6 @@ int acpi_subsys_resume_noirq(struct devireturn pm_generic_resume_noirq (dev); } -EXPORT_SYMBOL_GPL (acpi_subsys_resume_noirq);/** * acpi_subsys_resume_early - Resume device using ACPI.
@@ -1141,12 +1140,11 @@ EXPORT_SYMBOL_GPL(acpi_subsys_resume_noi* generic early resume procedure for it during system transition into the * working state. */ -int acpi_subsys_resume_early (struct device *dev) +static int acpi_subsys_resume_early (struct device *dev) {int ret =acpi_dev_resume (dev);return ret ? ret :pm_generic_resume_early (dev); } -EXPORT_SYMBOL_GPL (acpi_subsys_resume_early);/** * acpi_subsys_freeze - Run the device driver's freeze callback.
@@ -1169,52 +1167,15 @@ int acpi_subsys_freeze(struct device *deEXPORT_SYMBOL_GPL (acpi_subsys_freeze);/** -* acpi_subsys_freeze_late - Run the device driver's "late" freeze callback. -* @dev: Device to handle. -*/ -int acpi_subsys_freeze_late (struct device *dev) -{ - -if (dev_pm_smart_suspend_and_suspended (dev)) -return 0 ; - -return pm_generic_freeze_late (dev); -} -EXPORT_SYMBOL_GPL (acpi_subsys_freeze_late); - -/** -* acpi_subsys_freeze_noirq - Run the device driver's "noirq" freeze callback. -* @dev: Device to handle. -*/ -int acpi_subsys_freeze_noirq (struct device *dev) -{ - -if (dev_pm_smart_suspend_and_suspended (dev)) -return 0 ; - -return pm_generic_freeze_noirq (dev); -} -EXPORT_SYMBOL_GPL (acpi_subsys_freeze_noirq); - -/** -* acpi_subsys_thaw_noirq - Run the device driver's "noirq" thaw callback. -* @dev: Device to handle. +* acpi_subsys_restore_early - Restore device using ACPI. +* @dev: Device to restore. */ -int acpi_subsys_thaw_noirq (struct device *dev) +int acpi_subsys_restore_early (struct device *dev) { -/* -* If the device is in runtime suspend, the "thaw" code may not work -* correctly with it, so skip the driver callback and make the PM core -* skip all of the subsequent "thaw" callbacks for the device. -*/ -if (dev_pm_smart_suspend_and_suspended (dev)) { -dev_pm_skip_next_resume_phases (dev); -return 0 ; - } - -return pm_generic_thaw_noirq (dev); +int ret =acpi_dev_resume (dev); +return ret ? ret :pm_generic_restore_early (dev); } -EXPORT_SYMBOL_GPL (acpi_subsys_thaw_noirq); +EXPORT_SYMBOL_GPL (acpi_subsys_restore_early);#endif /* CONFIG_PM_SLEEP */ static struct dev_pm_domain acpi_general_pm_domain = {
@@ -1230,14 +1191,10 @@ static struct dev_pm_domain acpi_general .resume_noirq = acpi_subsys_resume_noirq, .resume_early = acpi_subsys_resume_early, .freeze = acpi_subsys_freeze, - .freeze_late = acpi_subsys_freeze_late, - .freeze_noirq = acpi_subsys_freeze_noirq, - .thaw_noirq = acpi_subsys_thaw_noirq, .poweroff = acpi_subsys_suspend, .poweroff_late = acpi_subsys_suspend_late, .poweroff_noirq = acpi_subsys_suspend_noirq, - .restore_noirq = acpi_subsys_resume_noirq, - .restore_early = acpi_subsys_resume_early, + .restore_early = acpi_subsys_restore_early,#endif }, };
include/linux/acpi.h +0 -10
@@ -918,26 +918,16 @@ int acpi_subsys_prepare(struct device *dvoid acpi_subsys_complete (struct device *dev);int acpi_subsys_suspend_late (struct device *dev);int acpi_subsys_suspend_noirq (struct device *dev); -int acpi_subsys_resume_noirq (struct device *dev); -int acpi_subsys_resume_early (struct device *dev);int acpi_subsys_suspend (struct device *dev);int acpi_subsys_freeze (struct device *dev); -int acpi_subsys_freeze_late (struct device *dev); -int acpi_subsys_freeze_noirq (struct device *dev); -int acpi_subsys_thaw_noirq (struct device *dev);#else static inline int acpi_dev_resume_early (struct device *dev) {return 0 ; }static inline int acpi_subsys_prepare (struct device *dev) {return 0 ; }static inline void acpi_subsys_complete (struct device *dev) {}static inline int acpi_subsys_suspend_late (struct device *dev) {return 0 ; }static inline int acpi_subsys_suspend_noirq (struct device *dev) {return 0 ; } -static inline int acpi_subsys_resume_noirq (struct device *dev) {return 0 ; } -static inline int acpi_subsys_resume_early (struct device *dev) {return 0 ; }static inline int acpi_subsys_suspend (struct device *dev) {return 0 ; }static inline int acpi_subsys_freeze (struct device *dev) {return 0 ; } -static inline int acpi_subsys_freeze_late (struct device *dev) {return 0 ; } -static inline int acpi_subsys_freeze_noirq (struct device *dev) {return 0 ; } -static inline int acpi_subsys_thaw_noirq (struct device *dev) {return 0 ; }#endif #ifdef CONFIG_ACPI
drivers/acpi/acpi_lpss.c +52 -9
82 lines not on this page · raw message
PATCH v2 4/5 ACPI: PM: Introduce "poweroff" callbacks for ACPI PM domain and LPSS
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
In general, it is not correct to call pm_generic_suspend(), pm_generic_suspend_late() and pm_generic_suspend_noirq() during the hibernation's "poweroff" transition, because device drivers may provide special callbacks to be invoked then and the wrappers in question cause system suspend callbacks to be run. Unfortunately, that happens in the ACPI PM domain and ACPI LPSS.
To address this potential issue, introduce "poweroff" callbacks for the ACPI PM and LPSS that will use pm_generic_poweroff(), pm_generic_poweroff_late() and pm_generic_poweroff_noirq() as appropriate.
---
-> v2:
* Make the new "poweroff" callbacks for the LPSS follow the current acpi_lpss_suspend_late/noirq() behavior.
--- drivers/acpi/acpi_lpss.c | 50 ++++++++++++++++++++++++++++++++++++++-- drivers/acpi/device_pm.c | 58 ++++++++++++++++++++++++++++++++++++++++++++--- include/linux/acpi.h | 2 + 3 files changed, 104 insertions(+), 6 deletions(-)
drivers/acpi/acpi_lpss.c +47 -3
@@ -1061,6 +1061,13 @@ static int acpi_lpss_suspend_noirq(strucint ret;if (pdata->dev_desc->resume_from_noirq) { +/* +* The driver's ->suspend_late callback will be invoked by +* acpi_lpss_do_suspend_late(), with the assumption that the +* driver really wanted to run that code in ->suspend_noirq, but +* it could not run after acpi_dev_suspend() and the driver +* expected the latter to be called in the "late" phase. +*/ ret =acpi_lpss_do_suspend_late (dev);if (ret)return ret;
@@ -1147,6 +1154,43 @@ static int acpi_lpss_restore_noirq(struc/* This is analogous to what happens in acpi_lpss_resume_noirq(). */ return acpi_lpss_do_restore_early (dev); } + +static int acpi_lpss_do_poweroff_late (struct device *dev) +{ +int ret =pm_generic_poweroff_late (dev); + +return ret ? ret :acpi_lpss_suspend (dev,device_may_wakeup (dev)); +} + +static int acpi_lpss_poweroff_late (struct device *dev) +{ +struct lpss_private_data *pdata =acpi_driver_data (ACPI_COMPANION (dev)); + +if (dev_pm_smart_suspend_and_suspended (dev)) +return 0 ; + +if (pdata->dev_desc->resume_from_noirq) +return 0 ; + +return acpi_lpss_do_poweroff_late (dev); +} + +static int acpi_lpss_poweroff_noirq (struct device *dev) +{ +struct lpss_private_data *pdata =acpi_driver_data (ACPI_COMPANION (dev)); + +if (dev_pm_smart_suspend_and_suspended (dev)) +return 0 ; + +if (pdata->dev_desc->resume_from_noirq) { +/* This is analogous to the acpi_lpss_suspend_noirq() case. */ +int ret =acpi_lpss_do_poweroff_late (dev); +if (ret) +return ret; + } + +return pm_generic_poweroff_noirq (dev); +}#endif /* CONFIG_PM_SLEEP */ static int acpi_lpss_runtime_suspend (struct device *dev)
@@ -1180,9 +1224,9 @@ static struct dev_pm_domain acpi_lpss_pm .resume_noirq = acpi_lpss_resume_noirq, .resume_early = acpi_lpss_resume_early, .freeze = acpi_subsys_freeze, - .poweroff = acpi_subsys_suspend, - .poweroff_late = acpi_lpss_suspend_late, - .poweroff_noirq = acpi_lpss_suspend_noirq, + .poweroff = acpi_subsys_poweroff, + .poweroff_late = acpi_lpss_poweroff_late, + .poweroff_noirq = acpi_lpss_poweroff_noirq, .restore_noirq = acpi_lpss_restore_noirq, .restore_early = acpi_lpss_restore_early,#endif
drivers/acpi/device_pm.c +55 -3
70 lines not on this page · raw message
include/linux/acpi.h +2 -0
@@ -920,6 +920,7 @@ int acpi_subsys_suspend_late(struct deviint acpi_subsys_suspend_noirq (struct device *dev);int acpi_subsys_suspend (struct device *dev);int acpi_subsys_freeze (struct device *dev); +int acpi_subsys_poweroff (struct device *dev);#else static inline int acpi_dev_resume_early (struct device *dev) {return 0 ; }static inline int acpi_subsys_prepare (struct device *dev) {return 0 ; }
@@ -928,6 +929,7 @@ static inline int acpi_subsys_suspend_lastatic inline int acpi_subsys_suspend_noirq (struct device *dev) {return 0 ; }static inline int acpi_subsys_suspend (struct device *dev) {return 0 ; }static inline int acpi_subsys_freeze (struct device *dev) {return 0 ; } +static inline int acpi_subsys_poweroff (struct device *dev) {return 0 ; }#endif #ifdef CONFIG_ACPI
PATCH v2 5/5 ACPI: PM: Drop unused function and function header
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Remove a leftover function header and a static inline stub with no users from the ACPI header file.
---
-> v2: No changes.
--- include/linux/acpi.h | 2 -- 1 file changed, 2 deletions(-)
include/linux/acpi.h +0 -2
@@ -913,7 +913,6 @@ static inline int acpi_dev_pm_attach(str#endif #if defined(CONFIG_ACPI ) && defined(CONFIG_PM_SLEEP ) -int acpi_dev_suspend_late (struct device *dev);int acpi_subsys_prepare (struct device *dev);void acpi_subsys_complete (struct device *dev);int acpi_subsys_suspend_late (struct device *dev);
@@ -922,7 +921,6 @@ int acpi_subsys_suspend(struct device *dint acpi_subsys_freeze (struct device *dev);int acpi_subsys_poweroff (struct device *dev);#else -static inline int acpi_dev_resume_early (struct device *dev) {return 0 ; }static inline int acpi_subsys_prepare (struct device *dev) {return 0 ; }static inline void acpi_subsys_complete (struct device *dev) {}static inline int acpi_subsys_suspend_late (struct device *dev) {return 0 ; }
Hi Rafael,
Quoted 12 lines · Rafael J. Wysocki
Hi All,
This series of patches addresses a few issues related to the handling of hibernation in the PCI bus type and the ACPI PM domain and ACPI LPSS driver.
The v2 addresses Hans' concerns regarding the LPSS changes.
First of all, all of the runtime-suspended PCI devices and devices in the ACPI PM and LPSS PM domains will be resumed during hibernation (first patch). This appears to be the only way to avoid weird corner cases and the benefit from avoiding to resume those devices during hibernation is questionable.
Quoted 8 lines
That change allows the the hibernation callbacks in all of the involved subsystems to be simplified (patches 2 and 3).
Moreover, reusing bus-level suspend callbacks for the "poweroff" transition during hibernation (which is the case for the ACPI PM domain and LPSS) is incorrect, so patch 4 fixes that.
Finally, there are some leftover items in
linux/acpi.hthat can be dropped (patch 5).
Thank you for the new version, the entire series looks good to me now:
Regards,
Hans
p.s.
FWIW I agree that the calling of the suspend_late method of the i2c-designware driver at suspend_noirq time is ugly, thank you for adding the comment documenting this.
Quoted 12 lines · Rafael J. Wysocki
Hi All,
This series of patches addresses a few issues related to the handling of hibernation in the PCI bus type and the ACPI PM domain and ACPI LPSS driver.
The v2 addresses Hans' concerns regarding the LPSS changes.
First of all, all of the runtime-suspended PCI devices and devices in the ACPI PM and LPSS PM domains will be resumed during hibernation (first patch). This appears to be the only way to avoid weird corner cases and the benefit from avoiding to resume those devices during hibernation is questionable.
Quoted 8 lines
That change allows the the hibernation callbacks in all of the involved subsystems to be simplified (patches 2 and 3).
Moreover, reusing bus-level suspend callbacks for the "poweroff" transition during hibernation (which is the case for the ACPI PM domain and LPSS) is incorrect, so patch 4 fixes that.
Finally, there are some leftover items in
linux/acpi.hthat can be dropped (patch 5).
For the whole series,
Quoted 20 lines · CEST Mika Westerberg
Quoted 19 lines · Rafael J. Wysocki
Hi All,
This series of patches addresses a few issues related to the handling of hibernation in the PCI bus type and the ACPI PM domain and ACPI LPSS driver.
The v2 addresses Hans' concerns regarding the LPSS changes.
First of all, all of the runtime-suspended PCI devices and devices in the ACPI PM and LPSS PM domains will be resumed during hibernation (first patch). This appears to be the only way to avoid weird corner cases and the benefit from avoiding to resume those devices during hibernation is questionable.
That change allows the the hibernation callbacks in all of the involved subsystems to be simplified (patches 2 and 3).
Moreover, reusing bus-level suspend callbacks for the "poweroff" transition during hibernation (which is the case for the ACPI PM domain and LPSS) is incorrect, so patch 4 fixes that.
Quoted 6 lines
Quoted 1 line
Finally, there are some leftover items in
linux/acpi.hthat can be dropped (patch 5).For the whole series,
Reviewed-by Mika Westerberg <[email protected]>
Thanks!
Queued for 5.3 with the tags from you and Hans (I've fixed up comments in the first patch while applying it).