From patchwork Tue Jan 8 09:52:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 10751743 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A38F13B5 for ; Tue, 8 Jan 2019 09:53:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 438C828B97 for ; Tue, 8 Jan 2019 09:53:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3463F28BC5; Tue, 8 Jan 2019 09:53:31 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B791B28B97 for ; Tue, 8 Jan 2019 09:53:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=axcdVRRPNlkVdWe8AwBy3Wzwm2zHZgbW+SuFFSVtYlQ=; b=GsnUsv8tjF3ims Bny9qKELf/0cnldOSJXdLyzj/UBdM+1EPOXa7QOB5qBy8AoMK4Jh1YiEeXW0WzYIR0P/aLCnNvy75 2sYK43M1DEjbhXggRNJAB/R6YVQ4y2r02wYN9wFdQqfl0BmW9KLGBoVYDSiis5AoZj39tc+VcjCBY sPLH0cmkQHKdhbSKzLz7GX8JpB937zhpKPv4NvEobc5hIVSD2ZzLqhC3U+6Kqy/UCf0N8l3/9txs5 /piglQlbqFzsTEZeBgHfIciMCctGda6gW5KNB6b9kpxf/ywthFHQ9WsBlBWpt05UFwuYWI1jaeMgD LuY00qNACgT72w23UQ8Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ggo4f-0001ye-MI; Tue, 08 Jan 2019 09:53:29 +0000 Received: from esa2.microchip.iphmx.com ([68.232.149.84]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ggo4B-0001Qk-Cz for linux-arm-kernel@lists.infradead.org; Tue, 08 Jan 2019 09:53:05 +0000 X-IronPort-AV: E=Sophos;i="5.56,453,1539673200"; d="scan'208";a="25050721" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 08 Jan 2019 02:52:55 -0700 Received: from NAM04-SN1-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.76.106) with Microsoft SMTP Server (TLS) id 14.3.352.0; Tue, 8 Jan 2019 02:52:55 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector1-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7ypxnDuNXUxh1tSqLT/QnuKbcBjBZLpen7PC47MjcKo=; b=Y/OcdfeRp/VRonsmaG2jwCsT4saizdzuqGE/C9geqBLs5D4XOUx21drHPlMl7LWQWzzP6W23y3GFtIX6ylkdQAuJ3WJYeJAWwRjmpj2qsOtsbVKTi3IJq52SGo0J2Kr1zV2L89wu4HcW08kmj7aykwfpRuH/OyIdrMNodRkhiSQ= Received: from MWHPR11MB1920.namprd11.prod.outlook.com (10.175.54.19) by MWHPR11MB1838.namprd11.prod.outlook.com (10.175.53.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1516.13; Tue, 8 Jan 2019 09:52:53 +0000 Received: from MWHPR11MB1920.namprd11.prod.outlook.com ([fe80::e553:ff9d:8c0b:9627]) by MWHPR11MB1920.namprd11.prod.outlook.com ([fe80::e553:ff9d:8c0b:9627%6]) with mapi id 15.20.1516.010; Tue, 8 Jan 2019 09:52:53 +0000 From: To: , , , , , , , , Subject: [PATCH 1/3] PM / Suspend: Add support to check if platform's power is off in suspend Thread-Topic: [PATCH 1/3] PM / Suspend: Add support to check if platform's power is off in suspend Thread-Index: AQHUpzfs93rBcN8fLkunLXYHWnxjXQ== Date: Tue, 8 Jan 2019 09:52:53 +0000 Message-ID: <1546941147-18410-2-git-send-email-claudiu.beznea@microchip.com> References: <1546941147-18410-1-git-send-email-claudiu.beznea@microchip.com> In-Reply-To: <1546941147-18410-1-git-send-email-claudiu.beznea@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1P195CA0081.EURP195.PROD.OUTLOOK.COM (2603:10a6:802:59::34) To MWHPR11MB1920.namprd11.prod.outlook.com (2603:10b6:300:110::19) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [94.177.32.154] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR11MB1838; 6:kQRGG7fok3dmfdZq1INsIm/iJDAkIILN6nK8LAnM/oJ1R5Mdy25D+h8JcFmoLSLxEHuElpTEWZZetJJMHtkjY3P509XtNp99cQxxlNB77LkqiJDr/9hIRbKFI49WtY3gStoVYoVQST6z7Nl+41dIzmQgXgVdoYOB0stKlL175ovbfnennkw00cXPFJ5Jbn4KwuNJuPIeUqmPeTUNCgPfLX5O+I+WDjAOoDUIJRimGBI9JVDJ1m9kZsA4SbT6GlHf5oO3mt50Qkz9Qq8hzD5HPCZa15wwbL5faTIBSVyQ6sxds4YaoPSylm4VWU7EKbWfGVJuAKeCN2Wzf2avW2fFHP1hFsctf3OgWgv+pnd6T3O+iwGcVI91/nsj0GieY2A9BcEJKmk585GVsZcURZ701OCCtEy5LM2Fh5AA5HRwW/2GYFiHc/andXgspud04NQ/G23nj/FUvU2D83m65HrNug==; 5:cKwpVYFRK4BSQXTfFe15GCiko7SZRKeuUIqaIKD+Irtd3k7q7kak+6LjSzMwBrVbeadalbA9LYDsJonlO96uyPiXIKyOcmLduhf0SuRWW64pahzn9IsDCjpfZeih1kzF766Kq3G84mcO+ID6tS5vsR6MQgia1wBViiwZBQqLfl9mGMQcekXpshBf63MDpcetq0OfK6rl6bgPRP/vSiM2Fw==; 7:KRS8vAeISmuQWJG25cwFuhn4pA/JU8VRJftSIKg/jkDLCXs0g+703cZQnVrSNRuHXuYMHg0WaB2uG/7UJmgD5qOuFqpkVrHALiw3KgHBJb/jMqW4TKq6vIoKLmBXjQUDnBOuZnaqe27LaOARQUiNKw== x-ms-office365-filtering-correlation-id: 81145ac0-d99f-4532-3e92-08d6754f0ea3 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(2017052603328)(7153060)(7193020); SRVR:MWHPR11MB1838; x-ms-traffictypediagnostic: MWHPR11MB1838: x-microsoft-antispam-prvs: x-forefront-prvs: 0911D5CE78 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(366004)(346002)(376002)(136003)(39860400002)(189003)(199004)(6436002)(110136005)(305945005)(107886003)(54906003)(6512007)(76176011)(52116002)(99286004)(8936002)(105586002)(53936002)(5660300001)(81166006)(7416002)(81156014)(8676002)(4326008)(39060400002)(7736002)(316002)(106356001)(25786009)(97736004)(36756003)(14454004)(72206003)(478600001)(6486002)(66066001)(68736007)(2501003)(15650500001)(486006)(386003)(6506007)(575784001)(86362001)(476003)(2616005)(2906002)(71190400001)(71200400001)(186003)(14444005)(6116002)(3846002)(2201001)(102836004)(6346003)(11346002)(446003)(256004)(26005); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR11MB1838; H:MWHPR11MB1920.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Claudiu.Beznea@microchip.com; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: KrudZr9xiBu89BgVPS3QMYOrtwg3ikhla3SW+HYSwJYhgTHftJp5ZXFwfuFb0qzomAePg0rLF5CGYNmL7e6I/wnBA1dtc9yJLbb0aaUl9BAg97HJGV3+aUVDnmZV/o5zK+O46zJuFoLZYWNFGkmqDwzbWKiBqmOUqs/86czMZYjt9YKVNsex0CsHGTd1gueZQGgOcpBMi6j4FcLEpgQCGFpdBxBExo57qhhtYerdPYykROBmhOdchxv96KGLxrZ28e9ytEQUa5qAwH6WmHYmR53JM2TwK6SFAMwYXQZR++YYQj4MVwhyYrD5bXAWEOeW spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 81145ac0-d99f-4532-3e92-08d6754f0ea3 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Jan 2019 09:52:53.1302 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1838 X-OriginatorOrg: microchip.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190108_015300_416485_E602C312 X-CRM114-Status: GOOD ( 13.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Claudiu.Beznea@microchip.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Claudiu Beznea Add support to check if platform's power will be cut off in suspend. This will help drivers shared by multiple platforms to take only the necessary actions while suspending/resuming (some platform may not need to save/restore all the registers if platforms remains powered while suspended). In this way suspend/resume time could be improved. Signed-off-by: Claudiu Beznea --- include/linux/suspend.h | 6 ++++++ kernel/power/suspend.c | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/linux/suspend.h b/include/linux/suspend.h index 3f529ad9a9d2..21f19b167fe2 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -173,6 +173,9 @@ static inline void dpm_save_failed_step(enum suspend_stat_step step) * Called by the PM core if the suspending of devices fails. * This callback is optional and should only be implemented by platforms * which require special recovery actions in that situation. + * + * @off_in_suspend: Returns wheather the platform's power will be cut off at + * the end of suspend procedure or not. */ struct platform_suspend_ops { int (*valid)(suspend_state_t state); @@ -185,6 +188,7 @@ struct platform_suspend_ops { bool (*suspend_again)(void); void (*end)(void); void (*recover)(void); + bool (*off_in_suspend)(suspend_state_t state); }; struct platform_s2idle_ops { @@ -275,6 +279,7 @@ extern void arch_suspend_disable_irqs(void); extern void arch_suspend_enable_irqs(void); extern int pm_suspend(suspend_state_t state); +extern bool platform_off_in_suspend(suspend_state_t state); #else /* !CONFIG_SUSPEND */ #define suspend_valid_only_mem NULL @@ -287,6 +292,7 @@ static inline bool pm_suspend_via_s2idle(void) { return false; } static inline void suspend_set_ops(const struct platform_suspend_ops *ops) {} static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; } +static inline bool platform_off_in_suspend(suspend_state_t state) { return false; } static inline bool idle_should_enter_s2idle(void) { return false; } static inline void __init pm_states_init(void) {} static inline void s2idle_set_ops(const struct platform_s2idle_ops *ops) {} diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 0bd595a0b610..e1f60c8a17b9 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -319,6 +319,19 @@ static bool platform_suspend_again(suspend_state_t state) suspend_ops->suspend_again() : false; } +/** + * platform_off_in_suspend() - specifies if SoC's power will pe cut off at the + * end of suspend procedure. + */ +bool platform_off_in_suspend(suspend_state_t state) +{ + if (!suspend_ops || !suspend_ops->off_in_suspend) + return false; + + return suspend_ops->off_in_suspend(state); +} +EXPORT_SYMBOL_GPL(platform_off_in_suspend); + #ifdef CONFIG_PM_DEBUG static unsigned int pm_test_delay = 5; module_param(pm_test_delay, uint, 0644);