Skip to contentSkip to conversation

PM: Add resume event mapping for PMSG_POWEROFF

PATCH In review Mario Limonciello (AMD) 2 participants 2 messages Sep 16 – Sep 25

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PM: Add resume event mapping for PMSG_POWEROFF

PM_EVENT_POWEROFF (0x0800) and PMSG_POWEROFF were already defined in include/linux/pm.h. Add the resume_event() which is used when a shutdown sequence needs to be aborted and the system should return to normal operation.

This completes the PMSG_POWEROFF infrastructure needed to support differentiating between hibernation and shutdown sequences 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.

Later shutdown will be initiated with the reboot() syscall with arguments on whether to halt the system or power it off.

---
 drivers/base/power/main.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/base/power/main.c +2 -0
index e130da4281410..7265553ba24ca 100644
@@ -1472,6 +1472,8 @@ static pm_message_t resume_event(pm_message_t sleep_state)
 		return PMSG_RECOVER;
 	case PM_EVENT_HIBERNATE:
 		return PMSG_RESTORE;
+	case PM_EVENT_POWEROFF:
+		return PMSG_ON;
 	}
 	return PMSG_ON;
 }
Signature · 1 line
2.53.0
#1 lore raw
Quoted 28 lines · Mario Limonciello (AMD)

PM_EVENT_POWEROFF (0x0800) and PMSG_POWEROFF were already defined in include/linux/pm.h. Add the resume_event() which is used when a shutdown sequence needs to be aborted and the system should return to normal operation.

This completes the PMSG_POWEROFF infrastructure needed to support differentiating between hibernation and shutdown sequences 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.

Later shutdown will be initiated with the reboot() syscall with arguments on whether to halt the system or power it off.

---
 drivers/base/power/main.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/base/power/main.c +0 -0
index e130da4281410..7265553ba24ca 100644

drivers/base/power/main.c static pm_message_t resume_event(pm_message_t sleep_state) · line 1476

Quoted 5 lines
drivers/base/power/main.c +2 -0
@@ -1472,6 +1472,8 @@ static pm_message_t resume_event(pm_message_t sleep_state)
                return PMSG_RECOVER;
        case PM_EVENT_HIBERNATE:
                return PMSG_RESTORE;
+       case PM_EVENT_POWEROFF:
+               return PMSG_ON;

Why should it be PMSG_ON?

pm_op() doesn't actually take PM_EVENT_ON into account, so I'm not sure how the change helps.

Quoted 6 lines
drivers/base/power/main.c +0 -1
        }
        return PMSG_ON;
 }
--

2.53.0