From patchwork Mon Jun 27 14:50:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ocean HY1 He X-Patchwork-Id: 9200749 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 370CB607D3 for ; Mon, 27 Jun 2016 14:50:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26F6E27F96 for ; Mon, 27 Jun 2016 14:50:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1BF3F28592; Mon, 27 Jun 2016 14:50:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 298AB27F96 for ; Mon, 27 Jun 2016 14:50:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751832AbcF0Ouc (ORCPT ); Mon, 27 Jun 2016 10:50:32 -0400 Received: from mail1.bemta12.messagelabs.com ([216.82.251.12]:31777 "EHLO mail1.bemta12.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751869AbcF0Oub convert rfc822-to-8bit (ORCPT ); Mon, 27 Jun 2016 10:50:31 -0400 Received: from [216.82.251.46] by server-12.bemta-12.messagelabs.com id 0F/FB-32521-33D31775; Mon, 27 Jun 2016 14:50:27 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDIsWRWlGSWpSXmKPExsWSLvdKT9fYtjD coPOymsXOh2/ZLJbv62e0uLxrDpvFx6UbWC3OnL7E6sDqsXjPSyaPTas62Ty2XG1n8fi8SS6A JYo1My8pvyKBNWPp3JOMBbNEKx5cWMzUwPhdsIuRi0NI4DGjRMf3BhYIZyGjxPINN1m7GDk52 ARUJW6ufgVmiwgESpw8cRmsiFngGJPExE1nWUASwgIuEmvP7GGGKPKUmHf4LxOErSfR3fUTzG YBGrRi/Vewel4BB4kZR/axgdiMArIS0x7dB6thFhCXuPVkPpgtISAgsWTPeWYIW1Ti5eN/QEd wANnyEltmCUKU60ncmDqFDcLWlli28DUzxHhBiZMzn7BMYBSahWTqLCQts5C0zELSsoCRZRWj enFqUVlqka6FXlJRZnpGSW5iZo6uoaGRXm5qcXFiempOYlKxXnJ+7iZGYKwwAMEOxm9LnA8xS nIwKYnybnuUGy7El5SfUpmRWJwRX1Sak1p8iFGGg0NJgpfTpjBcSLAoNT21Ii0zBxi1MGkJDh 4lEV5ja6A0b3FBYm5xZjpE6hSjopQ471OQhABIIqM0D64NliguMcpKCfMyAh0ixFOQWpSbWYI q/4pRnINRSZhXCGQ7T2ZeCdz0V0CLmYAWs1bngywuSURISTUwWh6x05jmJmd6ZJLZt22yLTNL n0iqh0yrujFB+5D7/nrd6Qd0GXkyF6/Jk7VYn7bEU+3TD/OdG2LMS5rcb16sEnpgOuHc/ieRd ltX8619KsB7fK94NF/Tf9tpwl43bcNtq1Y7zT/1a52C3Hy5YhndBQa9pi/674S+jZ1wlyVM8a /San8PGe07SizFGYmGWsxFxYkAqRdV9A8DAAA= X-Env-Sender: hehy1@lenovo.com X-Msg-Ref: server-11.tower-47.messagelabs.com!1467039022!8652059!1 X-Originating-IP: [103.30.234.46] X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 5425 invoked from network); 27 Jun 2016 14:50:27 -0000 Received: from unknown (HELO apsmtp03.lenovo.com) (103.30.234.46) by server-11.tower-47.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 27 Jun 2016 14:50:27 -0000 Received: from CNMAILEX02.lenovo.com (unknown [10.96.80.2]) by apsmtp03.lenovo.com with smtp (TLS: TLSv1/SSLv3,256bits,ECDHE-RSA-AES256-SHA) id 6217_2c64_8a3fd5da_b4e0_4d7b_9687_3ca38bb57546; Mon, 27 Jun 2016 22:50:18 +0800 Received: from CNMAILEX03.lenovo.com ([169.254.11.165]) by CNMAILEX02.lenovo.com ([169.254.10.16]) with mapi id 14.03.0248.002; Mon, 27 Jun 2016 22:50:17 +0800 From: Ocean HY1 He To: "rjw@rjwysocki.net" , "lenb@kernel.org" CC: "linux-acpi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , David Tanaka , "lv.zheng@intel.com" , "Sumeet Kochar" , Ocean HY1 He , "Nagananda Chumbalkar" Subject: [PATCH v2] ACPI: Execute the _PTS method when system reboot Thread-Topic: [PATCH v2] ACPI: Execute the _PTS method when system reboot Thread-Index: AQHR0IM3wFOLuag0O0mkS/0ft2sPcA== Date: Mon, 27 Jun 2016 14:50:16 +0000 Message-ID: <1467038724-13455-1-git-send-email-hehy1@lenovo.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.96.19.89] MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Nagananda Chumbalkar --- Patch changelogs v2: To simplify patch, move _PTS evaulation to the existing _TTS notifier https://lkml.org/lkml/2016/5/9/31 drivers/acpi/sleep.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index 7a2e4d4..2b38c1b 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c @@ -47,15 +47,32 @@ static void acpi_sleep_tts_switch(u32 acpi_state) } } -static int tts_notify_reboot(struct notifier_block *this, +static void acpi_sleep_pts_switch(u32 acpi_state) +{ + acpi_status status; + + status = acpi_execute_simple_method(NULL, "\\_PTS", acpi_state); + if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { + /* + * OS can't evaluate the _PTS object correctly. Some warning + * message will be printed. But it won't break anything. + */ + printk(KERN_NOTICE "Failure in evaluating _PTS object\n"); + } +} + +static int sleep_notify_reboot(struct notifier_block *this, unsigned long code, void *x) { acpi_sleep_tts_switch(ACPI_STATE_S5); + + acpi_sleep_pts_switch(ACPI_STATE_S5); + return NOTIFY_DONE; } -static struct notifier_block tts_notifier = { - .notifier_call = tts_notify_reboot, +static struct notifier_block sleep_notifier = { + .notifier_call = sleep_notify_reboot, .next = NULL, .priority = 0, }; @@ -899,9 +916,9 @@ int __init acpi_sleep_init(void) pr_info(PREFIX "(supports%s)\n", supported); /* - * Register the tts_notifier to reboot notifier list so that the _TTS - * object can also be evaluated when the system enters S5. + * Register the sleep_notifier to reboot notifier list so that the _TTS + * and _PTS object can also be evaluated when the system enters S5. */ - register_reboot_notifier(&tts_notifier); + register_reboot_notifier(&sleep_notifier); return 0; }