From patchwork Wed Jun 29 13:52:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 9205309 X-Patchwork-Delegate: sboyd@codeaurora.org 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 058BC607D8 for ; Wed, 29 Jun 2016 14:01:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA78D2865C for ; Wed, 29 Jun 2016 14:01:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DCCEC2865A; Wed, 29 Jun 2016 14:01:37 +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=unavailable 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 3E1272865A for ; Wed, 29 Jun 2016 14:01:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753007AbcF2OBR (ORCPT ); Wed, 29 Jun 2016 10:01:17 -0400 Received: from mail-bn1bon0090.outbound.protection.outlook.com ([157.56.111.90]:62720 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752902AbcF2N7f (ORCPT ); Wed, 29 Jun 2016 09:59:35 -0400 Received: from BLUPR0301CA0028.namprd03.prod.outlook.com (10.162.113.166) by BY1PR0301MB0854.namprd03.prod.outlook.com (10.160.193.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.528.16; Wed, 29 Jun 2016 13:59:32 +0000 Received: from BN1BFFO11FD034.protection.gbl (2a01:111:f400:7c10::1:198) by BLUPR0301CA0028.outlook.office365.com (2a01:111:e400:5259::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.528.16 via Frontend Transport; Wed, 29 Jun 2016 13:59:32 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; nxp.com; dmarc=fail action=none header.from=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD034.mail.protection.outlook.com (10.58.144.97) with Microsoft SMTP Server (TLS) id 15.1.523.9 via Frontend Transport; Wed, 29 Jun 2016 13:59:32 +0000 Received: from shlinux2.ap.freescale.net (shlinux2.ap.freescale.net [10.192.224.44]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u5TDx9x7014881; Wed, 29 Jun 2016 06:59:28 -0700 From: Dong Aisheng To: CC: , , , , , , , , , , , Subject: [PATCH RFC 4/7] PM: add SYSTEM_SUSPEND system_state Date: Wed, 29 Jun 2016 21:52:12 +0800 Message-ID: <1467208335-29876-5-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467208335-29876-1-git-send-email-aisheng.dong@nxp.com> References: <1467208335-29876-1-git-send-email-aisheng.dong@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131116823722972588; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(105606002)(87936001)(86362001)(305945005)(97736004)(2906002)(2351001)(110136002)(8666005)(81166006)(106466001)(8676002)(229853001)(81156014)(68736007)(36756003)(4326007)(586003)(19580405001)(33646002)(2950100001)(104016004)(50986999)(19580395003)(11100500001)(76176999)(92566002)(48376002)(6806005)(356003)(7846002)(47776003)(189998001)(5003940100001)(50466002)(85426001)(8936002)(50226002)(77096005)(7059030)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR0301MB0854; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD034; 1:70ubUHLZjaZ+6PEN72wBtvaZLa0zIdfnIJoA8lvaueTa8QJcCUdnNza5ssKq7F7NhOkgOVofyrwhHfdLeH1VtOIJQlABTXNk75f/hc4QEjDj2Jb4B7qaquaDfK+O+JW5njYjzrxXTMw83OwhZryp7r2k/TRpbbVF/bf8qaaV2D08zOaUTQc9GPjFW3znhTF13u31mZFqPn60A2acIBFi78rN2Jvau3NqVhEAYa5jA3ub5bEAoJ2rqlWN6WvzxYAaWwceNaBPwfA/xKFuf+eE8oeUu3RHlAiUqtX/M3+dlmIKKLJ0VGl79l+brRNozLcRk8YtIpc80XLUK3uGbbkYE6ccthFVPEb/W6jigVN5zYkWLIyFoGkxGcdfUuA+NDQmnRkb9DxGk/3yJ+DH5ZrBD4FDvqJXGhrzon0UHQqbZVdTwcHcCeZIQtyjiGDBlbHhndDcmpMCdZbuOAnVK2UV1xIK+Lr1l28JLOLaLHxOYyFFeHGCzX32/EEtEHWYh8hz7JhrHZulMYAUKkjBul0jsCebHVv7LVeOrovDz7OKJ9q8C9erX5vrsJ1fCtdYMK+vQk4z9+5gcUZw+YCQqM/cZ0LE8pw3WY91ZTvUewlAYFTIpF0JlMQtjBCDYlUoctKhYWQRS4zvm9N94foKEbuoGVbDwwp9pUrrRb6SzCJ9c6snCvdyP5ZiICsHLB6BIBR0K8GadWpq/nc0gH4JWlZudlwDEDwkEuHq2GBjdsshjaY= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: de1d2f19-0b78-4689-d5ac-08d3a025988c X-Microsoft-Exchange-Diagnostics: 1; BY1PR0301MB0854; 2:5pviz07zo7/ufI/8YlLabRPOvz9bH7r/NZCk7RtG1hd3viBcxuOx+wVX14om+fwcKUKOTTTe8JM4fwv7r4H5uEqDtO/+SZgSBAtJEN1JIOOm9/tP2A8NaUDSVr44BfQA+hBOsoAxoywWqySMSqUe+rIgbRJCaFCyyqpQgVLI5tX/5AcAZ3C3B/W6fO5s5pXo; 3:2O6IVN7geoYiHgCmxT6sumFYVwmaOzc7/ve5jL1FxnXvUiT0Wa97lhiViQUxxXomAv5pUMXv6PMxbtcZIaCtFkvY2xzs4QGhSCJw7ny43y8k9pP8XYx4PQgaBbUsjS0LzmEV5i/oY975buDFJKtmE+2qvmSwLQQ9SwaHsRT7Px2cBJ4otroK610Px/li7LA1xIAPkXhst6V+1TJ8m8haUlU72WdlvKhw+51AKaN6rtI=; 25:Op0FkYr5/ih4aUl/ULsO+n5GPz2ABG3ORRFkEsWSIWNPpbXI40aNTNbdxRpahH5FSxHTW61Shx6PWU9Qe56OOdan9Cee94T3oZavhnxmsCGTdoA/w53Yerhx706goaU2lZx0mNRKinu3Aw0dHwmOvFh0vVHDAaTGvHRUzab65YZURNM/8nHREAHUbNU/dBe4tilk/oXNqcjibMsqQAuLmd/e/dOmefh+DlVd4HEZ6qqD/Y4POhodcaxa/kRELA9pChJKyUUAidnPAq2YdBePq1tFjeqTlbAcBdshdJHabpLZ9hDPP9QLa7Jr5VA3HPqofGqBiURpYHva+bwCD1pPhHelGEg5FUmEZx+XnJ3mJmDblgnZEK1dIMEHNnOpPTK+3VKeD1YMTNh/s9o6JzL6fp1l7nqetMNehBU43wBnS7I= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0301MB0854; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0301MB0854; 31:LNnswMtiyOxDdwboK4A+I3zkuxXN3bUmFZos7nHELDEiG9FBGusslQ0JdIKwgO/cNB3UaqQfUycD2q1+mg2Cn2nnvm3IPTXPTndP0a8EE3sfPwSxozorn/iGt7IoZKpZ7uDHDc1R+YXULhiciuK1nO4Y6OUiYz5WnJtzd3WcnCLiw1gZ4zedGq/FFyYgFxy9K1RTTOEGygGDpQTLnfpOkQ==; 4:emvuC5PSpWdgNy2Wj8eva09EBx7Ac7DYstPO6PNCj7OPXwyrGpYYyxuZvSFvGcubeaEiznd11kPaRTNOPgYT2E8dMmJ+lVtN0TVNfLPXMc1ufXiwaTdslo5sALNVFY33Xtn6NaBrQWvmSkGONwAqmbcBnHr6/kN++5mejHlUrPY0YhPebSjJtR3S5W4mFt5GSlKO++/lDDRIHRhYrb2A4PVOBEsKKCvZB4Y8RPGPBr6G3Gy5IYSEVC9R6MTF//v8p1dQ8/IVr1qDQ5jdAsYykDhl6LJh24fyKaWE9ivIZjhRL6Hah0PLIASCaPGiWrh3JNxJsilDDNsadkPwLGGE54jC5+vz4efJve3LeFVfF5SNsSR1WGIGsK56dVcFgzSF+6GgItF0tInB21b9q39BAZzpE8U3yzcuPp/BA+hwAfImyl6XKIrTTlDX7iI3lDiGVHXu5tl+/NnN0yWMl8UmAT/FHJF0r94fSLy93lOTQg+d+GlP7F05T/kTvKx18IobTu8PGyF1hZbsKJ9GVE5+pw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13024025)(13023025)(13018025)(13017025)(5005006)(8121501046)(13015025)(10201501046)(3002001)(6055026); SRVR:BY1PR0301MB0854; BCL:0; PCL:0; RULEID:(400006); SRVR:BY1PR0301MB0854; X-Forefront-PRVS: 09888BC01D X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY1PR0301MB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EbLN9SgU+9JEtpBAyUwvOCQMm0j8oC+Vlklf/gf+KAnGUWJ1Gokii5rugpIwAA3Apcjy+H6IDkwPb4f5nljojJCKK/mWq6099eoTW+sIpR9taC24NRTk01gZY/9QZj54s7DkRFZJ6Glpj7PsJYHGHGYa2dMZ/Ok/UAgwxYNyhxkETdAby/qiFc5UA0uWpA20dH SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jun 2016 13:59:32.0788 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0301MB0854 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Thomas Gleixner During the late system suspend phase, the arch irq is disabled and sleeping is not allowed. Let's add SYSTEM_SUSPEND to represent this state. The reset of the system can then check this flag to do the correct work. [ Aisheng: back ported from rt tree and did comments change ] Signed-off-by: Thomas Gleixner Signed-off-by: Dong Aisheng --- include/linux/kernel.h | 1 + kernel/power/hibernate.c | 7 +++++++ kernel/power/suspend.c | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 94aa10ffe156..92a42312b749 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -491,6 +491,7 @@ extern enum system_states { SYSTEM_HALT, SYSTEM_POWER_OFF, SYSTEM_RESTART, + SYSTEM_SUSPEND, } system_state; #define TAINT_PROPRIETARY_MODULE 0 diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index fca9254280ee..36f420e54848 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -285,6 +285,8 @@ static int create_image(int platform_mode) local_irq_disable(); + system_state = SYSTEM_SUSPEND; + error = syscore_suspend(); if (error) { printk(KERN_ERR "PM: Some system devices failed to power down, " @@ -314,6 +316,7 @@ static int create_image(int platform_mode) syscore_resume(); Enable_irqs: + system_state = SYSTEM_RUNNING; local_irq_enable(); Enable_cpus: @@ -438,6 +441,7 @@ static int resume_target_kernel(bool platform_mode) goto Enable_cpus; local_irq_disable(); + system_state = SYSTEM_SUSPEND; error = syscore_suspend(); if (error) @@ -471,6 +475,7 @@ static int resume_target_kernel(bool platform_mode) syscore_resume(); Enable_irqs: + system_state = SYSTEM_RUNNING; local_irq_enable(); Enable_cpus: @@ -556,6 +561,7 @@ int hibernation_platform_enter(void) goto Enable_cpus; local_irq_disable(); + system_state = SYSTEM_SUSPEND; syscore_suspend(); if (pm_wakeup_pending()) { error = -EAGAIN; @@ -568,6 +574,7 @@ int hibernation_platform_enter(void) Power_up: syscore_resume(); + system_state = SYSTEM_RUNNING; local_irq_enable(); Enable_cpus: diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 5b70d64b871e..1258d093ae48 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -359,6 +359,8 @@ static int suspend_enter(suspend_state_t state, bool *wakeup) arch_suspend_disable_irqs(); BUG_ON(!irqs_disabled()); + system_state = SYSTEM_SUSPEND; + error = syscore_suspend(); if (!error) { *wakeup = pm_wakeup_pending(); @@ -375,6 +377,8 @@ static int suspend_enter(suspend_state_t state, bool *wakeup) syscore_resume(); } + system_state = SYSTEM_RUNNING; + arch_suspend_enable_irqs(); BUG_ON(irqs_disabled());