From patchwork Thu Aug 18 09:19:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 9287091 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 77BD9607FF for ; Thu, 18 Aug 2016 09:19:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67A0629064 for ; Thu, 18 Aug 2016 09:19:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C3D8290C2; Thu, 18 Aug 2016 09:19: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 AB2DF29064 for ; Thu, 18 Aug 2016 09:19:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753186AbcHRJTc (ORCPT ); Thu, 18 Aug 2016 05:19:32 -0400 Received: from foss.arm.com ([217.140.101.70]:56693 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752864AbcHRJTb (ORCPT ); Thu, 18 Aug 2016 05:19:31 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 11B8B30C; Thu, 18 Aug 2016 02:21:05 -0700 (PDT) Received: from e107155-lin.cambridge.arm.com (e107155-lin.cambridge.arm.com [10.1.210.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9A61C3F215; Thu, 18 Aug 2016 02:19:29 -0700 (PDT) From: Sudeep Holla To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, "Rafael J . Wysocki" Cc: Sudeep Holla , Andy Gross , Lorenzo Pieralisi Subject: [PATCH] PM / sleep: enable suspend-to-idle even without registered suspend_ops Date: Thu, 18 Aug 2016 10:19:24 +0100 Message-Id: <1471511964-6341-1-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Suspend-to-idle (aka the "freeze" sleep state) is a system sleep state in which all of the processors enter deepest possible idle state and wait for interrupts right after suspending all the devices. There is no hard requirement for a platform to support and register platform specific suspend_ops to enter suspend-to-idle/freeze state. Only deeper system sleep states like PM_SUSPEND_STANDBY and PM_SUSPEND_MEM rely on such low level support/implementation. suspend-to-idle can be entered as along as all the devices can be suspended. This patch enables the support for suspend-to-idle even on systems that don't have any low level support for deeper system sleep states and/or don't register any platform specific suspend_ops. Cc: "Rafael J. Wysocki" Signed-off-by: Sudeep Holla --- kernel/power/main.c | 5 +++++ kernel/power/suspend.c | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) Hi Rafael, I am not sure if you like this approach. I found this to be the simplest but I may have missed to consider all possible corner cases especially for x86 and other platforms. I don't see any such issues/cases with ARM systems. Regards, Sudeep -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-pm" 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/kernel/power/main.c b/kernel/power/main.c index 5ea50b1b7595..0f0fd9184f39 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c @@ -651,6 +651,11 @@ static int __init pm_init(void) if (error) return error; pm_print_times_init(); + /* + * freeze state should be supported even without any suspend_ops, + * calling suspend_set_ops without any ops will setup freeze state + */ + suspend_set_ops(NULL); return pm_autosleep_init(); } diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 0acab9d7f96f..37d64f811ecd 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -138,7 +138,9 @@ void suspend_set_ops(const struct platform_suspend_ops *ops) lock_system_sleep(); - suspend_ops = ops; + WARN_ONCE(ops && suspend_ops, "overriding suspend_ops"); + if (ops) + suspend_ops = ops; for (i = PM_SUSPEND_MEM; i >= PM_SUSPEND_STANDBY; i--) if (valid_state(i)) { pm_states[i] = pm_labels[j++]; @@ -211,7 +213,7 @@ static int platform_suspend_begin(suspend_state_t state) { if (state == PM_SUSPEND_FREEZE && freeze_ops && freeze_ops->begin) return freeze_ops->begin(); - else if (suspend_ops->begin) + else if (suspend_ops && suspend_ops->begin) return suspend_ops->begin(state); else return 0; @@ -221,7 +223,7 @@ static void platform_resume_end(suspend_state_t state) { if (state == PM_SUSPEND_FREEZE && freeze_ops && freeze_ops->end) freeze_ops->end(); - else if (suspend_ops->end) + else if (suspend_ops && suspend_ops->end) suspend_ops->end(); }