From patchwork Mon Feb 20 20:33:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 9583651 X-Patchwork-Delegate: geert@linux-m68k.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 D6E1A6057F for ; Mon, 20 Feb 2017 20:35:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C864D2886C for ; Mon, 20 Feb 2017 20:35:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BCC492888F; Mon, 20 Feb 2017 20:35:24 +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 77FA728889 for ; Mon, 20 Feb 2017 20:35:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752665AbdBTUey (ORCPT ); Mon, 20 Feb 2017 15:34:54 -0500 Received: from xavier.telenet-ops.be ([195.130.132.52]:40414 "EHLO xavier.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752244AbdBTUeD (ORCPT ); Mon, 20 Feb 2017 15:34:03 -0500 Received: from ayla.of.borg ([84.193.137.253]) by xavier.telenet-ops.be with bizsmtp id n8Zs1u0065UCtCs018ZsuK; Mon, 20 Feb 2017 21:33:59 +0100 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1cfuee-0003mn-3O; Mon, 20 Feb 2017 21:33:52 +0100 Received: from geert by ramsan with local (Exim 4.86_2) (envelope-from ) id 1cfuee-0006YL-1t; Mon, 20 Feb 2017 21:33:52 +0100 From: Geert Uytterhoeven To: Lorenzo Pieralisi , Mark Rutland , Sudeep Holla , Lina Iyer , John Stultz , Thomas Gleixner , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Rob Herring Cc: Magnus Damm , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH/RFC 3/6] drivers: firmware: psci: Implement shallow suspend mode Date: Mon, 20 Feb 2017 21:33:26 +0100 Message-Id: <1487622809-25127-4-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487622809-25127-1-git-send-email-geert+renesas@glider.be> References: <1487622809-25127-1-git-send-email-geert+renesas@glider.be> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Enable support for "shallow" suspend mode, also known as "Standby" or "Power-On Suspend". As secondary CPU cores are taken offline, "shallow" suspend mode saves slightly more power than "s2idle", but less than "deep" suspend mode. However, unlike "deep" suspend mode, "shallow" suspend mode can be used regardless of the presence of support for PSCI_SYSTEM_SUSPEND, which is an optional API in PSCI v1.0. List the available system suspend modes: $ cat /sys/power/mem_sleep s2idle shallow [deep] Suspend to "shallow" mode: $ echo shallow > /sys/power/mem_sleep $ echo mem > /sys/power/state Signed-off-by: Geert Uytterhoeven --- drivers/firmware/psci.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 493a56a4cfc4a836..13b4d50bb3577384 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -85,6 +85,7 @@ static u32 psci_function_id[PSCI_FN_MAX]; PSCI_1_0_EXT_POWER_STATE_TYPE_MASK) static u32 psci_cpu_suspend_feature; +static bool psci_suspend_mem_supported; static inline bool psci_has_ext_power_state(void) { @@ -422,13 +423,36 @@ static int psci_system_suspend(unsigned long unused) __pa_symbol(cpu_resume), 0, 0); } +static int psci_system_suspend_valid(suspend_state_t state) +{ + switch (state) { + case PM_SUSPEND_STANDBY: + return true; + + case PM_SUSPEND_MEM: + return psci_suspend_mem_supported; + + default: + return false; + } +} + static int psci_system_suspend_enter(suspend_state_t state) { - return cpu_suspend(0, psci_system_suspend); + switch (state) { + case PM_SUSPEND_STANDBY: + cpu_do_idle(); + break; + + case PM_SUSPEND_MEM: + return cpu_suspend(0, psci_system_suspend); + } + + return 0; } static const struct platform_suspend_ops psci_suspend_ops = { - .valid = suspend_valid_only_mem, + .valid = psci_system_suspend_valid, .enter = psci_system_suspend_enter, }; @@ -442,7 +466,9 @@ static void __init psci_init_system_suspend(void) ret = psci_features(PSCI_FN_NATIVE(1_0, SYSTEM_SUSPEND)); if (ret != PSCI_RET_NOT_SUPPORTED) - suspend_set_ops(&psci_suspend_ops); + psci_suspend_mem_supported = true; + + suspend_set_ops(&psci_suspend_ops); } static void __init psci_init_cpu_suspend(void)