From patchwork Sun Mar 2 00:53:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aubrey Li X-Patchwork-Id: 3748611 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 16B77BF13A for ; Sun, 2 Mar 2014 00:54:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4519720396 for ; Sun, 2 Mar 2014 00:54:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D7DE52038F for ; Sun, 2 Mar 2014 00:54:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753335AbaCBAyA (ORCPT ); Sat, 1 Mar 2014 19:54:00 -0500 Received: from mga02.intel.com ([134.134.136.20]:58441 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753330AbaCBAyA (ORCPT ); Sat, 1 Mar 2014 19:54:00 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 01 Mar 2014 16:53:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,569,1389772800"; d="scan'208";a="492262349" Received: from cli6-desk.ccr.corp.intel.com (HELO [10.239.37.134]) ([10.239.37.134]) by orsmga002.jf.intel.com with ESMTP; 01 Mar 2014 16:53:58 -0800 Message-ID: <53128125.1080809@linux.intel.com> Date: Sun, 02 Mar 2014 08:53:57 +0800 From: "Li, Aubrey" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: "Rafael J. Wysocki" CC: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Len.Brown@intel.com, "alan@linux.intel.com" , "Raj, Ashok" Subject: Re: [PATCH] ACPI/Sleep: pm_power_off need more sanity check to be installed References: <530D558D.6090607@linux.intel.com> <53101FAB.3080609@linux.intel.com> <53110C97.3040207@linux.intel.com> <2386234.LOj9mo4PX0@vostro.rjw.lan> In-Reply-To: <2386234.LOj9mo4PX0@vostro.rjw.lan> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 2014/3/2 8:39, Rafael J. Wysocki wrote: > On Saturday, March 01, 2014 06:24:23 AM Li, Aubrey wrote: >>>> Do we still want to set this if the check below fails? If so, then why? >>> >>> We know \_S5_ is valid. The fault is sleep registers, not S5 ACPI object >> >> Hi Rafael, do you still have any concern? > > Well, I simply don't think we should say that it is "supported" if we aren't > going to do anything with it. > Make sense to me. Patch refined as below: Sleep control and status registers need santity check as well before ACPI install acpi_power_off to pm_power_off hook. The checking code in acpi_enter_sleep_state() is too late, we should not allow a not-working pm_power_off function hooked. Signed-off-by: Aubrey Li --- drivers/acpi/sleep.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index b718806..0abfbb1 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c @@ -807,7 +807,12 @@ int __init acpi_sleep_init(void) acpi_sleep_hibernate_setup(); status = acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b); - if (ACPI_SUCCESS(status)) { + /* + * Check both ACPI S5 object and ACPI sleep registers to + * install pm_power_off_prepare/pm_power_off hook + */ + if (ACPI_SUCCESS(status) && acpi_gbl_FADT.sleep_control.address && + acpi_gbl_FADT.sleep_status.address) { sleep_states[ACPI_STATE_S5] = 1; pm_power_off_prepare = acpi_power_off_prepare; pm_power_off = acpi_power_off;