Introduce and plumb PMSG_POWEROFF
Subsystems (7)
v10 cover Introduce and plumb PMSG_POWEROFF
I've been working on a series that uses the hibernate flows (S4) during shutdown (S5) [1], but it's a bit risky because it has changes all around the kernel. To mitigate risk Rafael suggested [2] to split the series into at least 3 parts across different kernel cycles.
Here is the first part, which just introduces a PMSG_POWEROFF event and uses it in any driver that manipulates PM events.
There are no functional changes for these changes and this series is intended for 6.19.
v10:
* Drop resume_event changes
* Drop patch 4 (will come in later phase)
Mario Limonciello (AMD) (3):
PM: Introduce new PMSG_POWEROFF event
scsi: Add PM_EVENT_POWEROFF into suspend callbacks
usb: sl811-hcd: Add PM_EVENT_POWEROFF into suspend callbacks
drivers/base/power/main.c | 5 +++++ drivers/scsi/mesh.c | 1 + drivers/scsi/stex.c | 1 + drivers/usb/host/sl811-hcd.c | 1 + include/linux/pm.h | 3 +++ include/trace/events/power.h | 3 ++- 6 files changed, 13 insertions(+), 1 deletion(-)
Signature · 1 line
2.43.0
PATCH v10 1/3 PM: Introduce new PMSG_POWEROFF event
PMSG_POWEROFF will be used for the PM core to allow differentiating between a hibernation or shutdown sequence when re-using callbacks for common code.
Hibernation is started by writing a hibernation method (such as 'platform' 'shutdown', or 'reboot') to use into /sys/power/disk and writing 'disk' to /sys/power/state.
Shutdown is initiated with the reboot() syscall with arguments on whether to halt the system or power it off.
---
v10:
* Drop resume event
--- drivers/base/power/main.c | 5 +++++ include/linux/pm.h | 3 +++ include/trace/events/power.h | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-)
drivers/base/power/main.c +5 -0
@@ -96,6 +96,8 @@ static const char *pm_verb(int event)return "restore" ;case PM_EVENT_RECOVER :return "recover" ; +case PM_EVENT_POWEROFF : +return "poweroff" ;default :return "(unknown PM event)" ; }
@@ -368,6 +370,7 @@ static pm_callback_t pm_op(const struct dev_pm_ops *ops, pm_message_t state)case PM_EVENT_FREEZE :case PM_EVENT_QUIESCE :return ops->freeze; +case PM_EVENT_POWEROFF :case PM_EVENT_HIBERNATE :return ops->poweroff;case PM_EVENT_THAW :
@@ -402,6 +405,7 @@ static pm_callback_t pm_late_early_op(const struct dev_pm_ops *ops,case PM_EVENT_FREEZE :case PM_EVENT_QUIESCE :return ops->freeze_late; +case PM_EVENT_POWEROFF :case PM_EVENT_HIBERNATE :return ops->poweroff_late;case PM_EVENT_THAW :
@@ -436,6 +440,7 @@ static pm_callback_t pm_noirq_op(const struct dev_pm_ops *ops, pm_message_t statcase PM_EVENT_FREEZE :case PM_EVENT_QUIESCE :return ops->freeze_noirq; +case PM_EVENT_POWEROFF :case PM_EVENT_HIBERNATE :return ops->poweroff_noirq;case PM_EVENT_THAW :
include/linux/pm.h +3 -0
@@ -508,6 +508,7 @@ const struct dev_pm_ops name = { \* RECOVER Creation of a hibernation image or restoration of the main * memory contents from a hibernation image has failed, call * ->thaw() and ->complete() for all devices. +* POWEROFF System will poweroff, call ->poweroff() for all devices. * * The following PM_EVENT_ messages are defined for internal use by * kernel subsystems. They are never issued by the PM core.
@@ -538,6 +539,7 @@ const struct dev_pm_ops name = { \#define PM_EVENT_USER 0x0100#define PM_EVENT_REMOTE 0x0200#define PM_EVENT_AUTO 0x0400 +#define PM_EVENT_POWEROFF 0x0800#define PM_EVENT_SLEEP (PM_EVENT_SUSPEND | PM_EVENT_HIBERNATE)#define PM_EVENT_USER_SUSPEND (PM_EVENT_USER | PM_EVENT_SUSPEND)
@@ -552,6 +554,7 @@ const struct dev_pm_ops name = { \#define PMSG_QUIESCE ((struct pm_message){ .event = PM_EVENT_QUIESCE, })#define PMSG_SUSPEND ((struct pm_message){ .event = PM_EVENT_SUSPEND, })#define PMSG_HIBERNATE ((struct pm_message){ .event = PM_EVENT_HIBERNATE, }) +#define PMSG_POWEROFF ((struct pm_message){ .event = PM_EVENT_POWEROFF, })#define PMSG_RESUME ((struct pm_message){ .event = PM_EVENT_RESUME, })#define PMSG_THAW ((struct pm_message){ .event = PM_EVENT_THAW, })#define PMSG_RESTORE ((struct pm_message){ .event = PM_EVENT_RESTORE, })
include/trace/events/power.h +2 -1
@@ -179,7 +179,8 @@ TRACE_EVENT(pstate_sample, { PM_EVENT_HIBERNATE, "hibernate" }, \ { PM_EVENT_THAW, "thaw" }, \ { PM_EVENT_RESTORE, "restore" }, \ - { PM_EVENT_RECOVER, "recover" }) + { PM_EVENT_RECOVER, "recover" }, \ + { PM_EVENT_POWEROFF, "poweroff" }) DEFINE_EVENT(cpu, cpu_frequency,
Signature · 1 line
2.43.0
PATCH v10 2/3 scsi: Add PM_EVENT_POWEROFF into suspend callbacks
In reply to Mario Limonciello (AMD)If the PM core uses hibernation callbacks for powering off the system, drivers will receive PM_EVENT_POWEROFF and should handle it the same as they previously handled PM_EVENT_HIBERNATE.
Support this case in the scsi driver. No functional changes.
--- drivers/scsi/mesh.c | 1 + drivers/scsi/stex.c | 1 + 2 files changed, 2 insertions(+)
drivers/scsi/mesh.c +1 -0
@@ -1762,6 +1762,7 @@ static int mesh_suspend(struct macio_dev *mdev, pm_message_t mesg)case PM_EVENT_SUSPEND :case PM_EVENT_HIBERNATE :case PM_EVENT_FREEZE : +case PM_EVENT_POWEROFF :break ;default :return 0 ;
drivers/scsi/stex.c +1 -0
@@ -1965,6 +1965,7 @@ static int stex_choice_sleep_mic(struct st_hba *hba, pm_message_t state)case PM_EVENT_SUSPEND :return ST_S3 ;case PM_EVENT_HIBERNATE : +case PM_EVENT_POWEROFF : hba->msi_lock =0 ;return ST_S4 ;default :
Signature · 1 line
2.43.0
PATCH v10 3/3 usb: sl811-hcd: Add PM_EVENT_POWEROFF into suspend callbacks
In reply to Mario Limonciello (AMD)When the ACPI core uses hibernation callbacks for shutdown drivers will receive PM_EVENT_POWEROFF and should handle it the same as PM_EVENT_HIBERNATE would have been used.
--- drivers/usb/host/sl811-hcd.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/host/sl811-hcd.c +1 -0
@@ -1748,6 +1748,7 @@ sl811h_suspend(struct platform_device *dev, pm_message_t state)break ;case PM_EVENT_SUSPEND :case PM_EVENT_HIBERNATE : +case PM_EVENT_POWEROFF :case PM_EVENT_PRETHAW :/* explicitly discard hw state */ port_power (sl811,0 );break ;
Signature · 1 line
2.43.0
Rafael J. Wysocki
maintainerQuoted 29 lines · Mario Limonciello (AMD)
I've been working on a series that uses the hibernate flows (S4) during shutdown (S5) [1], but it's a bit risky because it has changes all around the kernel. To mitigate risk Rafael suggested [2] to split the series into at least 3 parts across different kernel cycles.
Here is the first part, which just introduces a
PMSG_POWEROFFevent and uses it in any driver that manipulates PM events.There are no functional changes for these changes and this series is intended for 6.19.
v10:
* Dropresume_eventchanges
* Drop patch 4 (will come in later phase)Mario Limonciello (AMD) (3):
PM: Introduce newPMSG_POWEROFFevent
scsi: AddPM_EVENT_POWEROFFinto suspend callbacks
usb: sl811-hcd: AddPM_EVENT_POWEROFFinto suspend callbacksdrivers/base/power/main.c | 5 +++++ drivers/scsi/mesh.c | 1 + drivers/scsi/stex.c | 1 + drivers/usb/host/sl811-hcd.c | 1 + include/linux/pm.h | 3 +++ include/trace/events/power.h | 3 ++- 6 files changed, 13 insertions(+), 1 deletion(-)
Quoted 1 line
--
All 3 patches applied as 6.19 material, thanks!