Skip to content

Commit 2c85025

Browse files
oceanhehyrafaeljw
authored andcommitted
ACPI: Execute _PTS before system reboot
The _PTS control method is defined in the section 7.4.1 of acpi 6.0 spec. The _PTS control method is executed by the OS during the sleep transition process for S1, S2, S3, S4, and for orderly S5 shutdown. The _PTS control method provides the BIOS a mechanism for performing some housekeeping, such as writing the sleep type value to the embedded controller, before entering the system sleeping state. Note that some Lenovo Server BIOS use this mechanism to detect reboot event and prompt user by popped dialog box. According to section 7.5 of acpi 6.0 spec, _PTS should run after _TTS. Add a _PTS evaulation to the existing _TTS reboot notifier and change the notifier name to reflect the fact that it's not for _TTS only any more. Signed-off-by: Ocean He <hehy1@lenovo.com> Signed-off-by: Nagananda Chumbalkar <nchumbalkar@lenovo.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 4c2e07c commit 2c85025

1 file changed

Lines changed: 23 additions & 6 deletions

File tree

drivers/acpi/sleep.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,32 @@ static void acpi_sleep_tts_switch(u32 acpi_state)
4747
}
4848
}
4949

50-
static int tts_notify_reboot(struct notifier_block *this,
50+
static void acpi_sleep_pts_switch(u32 acpi_state)
51+
{
52+
acpi_status status;
53+
54+
status = acpi_execute_simple_method(NULL, "\\_PTS", acpi_state);
55+
if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
56+
/*
57+
* OS can't evaluate the _PTS object correctly. Some warning
58+
* message will be printed. But it won't break anything.
59+
*/
60+
printk(KERN_NOTICE "Failure in evaluating _PTS object\n");
61+
}
62+
}
63+
64+
static int sleep_notify_reboot(struct notifier_block *this,
5165
unsigned long code, void *x)
5266
{
5367
acpi_sleep_tts_switch(ACPI_STATE_S5);
68+
69+
acpi_sleep_pts_switch(ACPI_STATE_S5);
70+
5471
return NOTIFY_DONE;
5572
}
5673

57-
static struct notifier_block tts_notifier = {
58-
.notifier_call = tts_notify_reboot,
74+
static struct notifier_block sleep_notifier = {
75+
.notifier_call = sleep_notify_reboot,
5976
.next = NULL,
6077
.priority = 0,
6178
};
@@ -899,9 +916,9 @@ int __init acpi_sleep_init(void)
899916
pr_info(PREFIX "(supports%s)\n", supported);
900917

901918
/*
902-
* Register the tts_notifier to reboot notifier list so that the _TTS
903-
* object can also be evaluated when the system enters S5.
919+
* Register the sleep_notifier to reboot notifier list so that the _TTS
920+
* and _PTS object can also be evaluated when the system enters S5.
904921
*/
905-
register_reboot_notifier(&tts_notifier);
922+
register_reboot_notifier(&sleep_notifier);
906923
return 0;
907924
}

0 commit comments

Comments
 (0)