From patchwork Mon Aug 11 13:58:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 4707321 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@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 C5422C0338 for ; Mon, 11 Aug 2014 13:46:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D6D6E20122 for ; Mon, 11 Aug 2014 13:46:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C75872010B for ; Mon, 11 Aug 2014 13:46:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753748AbaHKNoz (ORCPT ); Mon, 11 Aug 2014 09:44:55 -0400 Received: from v094114.home.net.pl ([79.96.170.134]:64780 "HELO v094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1753704AbaHKNoy (ORCPT ); Mon, 11 Aug 2014 09:44:54 -0400 Received: from aayi173.neoplus.adsl.tpnet.pl [83.6.120.173] (HELO vostro.rjw.lan) by serwer1319399.home.pl [79.96.170.134] with SMTP (IdeaSmtpServer v0.80) id 176ffd79e994a84b; Mon, 11 Aug 2014 15:44:53 +0200 From: "Rafael J. Wysocki" To: Thomas Gleixner Cc: Peter Zijlstra , Linux PM list , Linux Kernel Mailing List , Linux PCI Subject: [PATCH 1/6 v2] PM / sleep: Mechanism for aborting system suspends unconditionally Date: Mon, 11 Aug 2014 15:58:27 +0200 Message-ID: <3600808.j5JGM0n4nv@vostro.rjw.lan> User-Agent: KMail/4.11.5 (Linux/3.16.0-rc5+; KDE/4.11.5; x86_64; ; ) In-Reply-To: <26580319.OZP7jvJnA9@vostro.rjw.lan> References: <26580319.OZP7jvJnA9@vostro.rjw.lan> MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.6 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 From: Rafael J. Wysocki Subject: PM / sleep: Mechanism for aborting system suspends unconditionally It sometimes may be necessary to abort a system suspend in progress or wake up the system from suspend-to-idle even if the pm_wakeup_event()/pm_stay_awake() mechanism is not enabled. For this purpose, introduce a new global variable abort_suspend and make pm_wakeup_pending() check its value. Also add routines for manipulating that variable. This is going to be used in subsequent changes. Signed-off-by: Rafael J. Wysocki --- This patch is the same as the previous version. --- drivers/base/power/wakeup.c | 20 ++++++++++++++++++++ include/linux/suspend.h | 4 ++++ kernel/power/process.c | 1 + 3 files changed, 25 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-pm/include/linux/suspend.h =================================================================== --- linux-pm.orig/include/linux/suspend.h +++ linux-pm/include/linux/suspend.h @@ -371,6 +371,8 @@ extern int unregister_pm_notifier(struct extern bool events_check_enabled; extern bool pm_wakeup_pending(void); +extern void pm_system_wakeup(void); +extern void pm_wakeup_clear(void); extern bool pm_get_wakeup_count(unsigned int *count, bool block); extern bool pm_save_wakeup_count(unsigned int count); extern void pm_wakep_autosleep_enabled(bool set); @@ -418,6 +420,8 @@ static inline int unregister_pm_notifier #define pm_notifier(fn, pri) do { (void)(fn); } while (0) static inline bool pm_wakeup_pending(void) { return false; } +static inline void pm_system_wakeup(void) {} +static inline void pm_wakeup_clear(void) {} static inline void lock_system_sleep(void) {} static inline void unlock_system_sleep(void) {} Index: linux-pm/drivers/base/power/wakeup.c =================================================================== --- linux-pm.orig/drivers/base/power/wakeup.c +++ linux-pm/drivers/base/power/wakeup.c @@ -691,6 +691,8 @@ void pm_print_active_wakeup_sources(void } EXPORT_SYMBOL_GPL(pm_print_active_wakeup_sources); +static bool abort_suspend; + /** * pm_wakeup_pending - Check if power transition in progress should be aborted. * @@ -712,6 +714,7 @@ bool pm_wakeup_pending(void) ret = (cnt != saved_count || inpr > 0); events_check_enabled = !ret; } + ret = ret || abort_suspend; spin_unlock_irqrestore(&events_lock, flags); if (ret) { @@ -722,6 +725,23 @@ bool pm_wakeup_pending(void) return ret; } +void pm_system_wakeup(void) +{ + unsigned long flags; + + spin_lock_irqsave(&events_lock, flags); + abort_suspend = true; + spin_unlock_irqrestore(&events_lock, flags); + freeze_wake(); +} + +void pm_wakeup_clear(void) +{ + spin_lock_irq(&events_lock); + abort_suspend = false; + spin_unlock_irq(&events_lock); +} + /** * pm_get_wakeup_count - Read the number of registered wakeup events. * @count: Address to store the value at. Index: linux-pm/kernel/power/process.c =================================================================== --- linux-pm.orig/kernel/power/process.c +++ linux-pm/kernel/power/process.c @@ -129,6 +129,7 @@ int freeze_processes(void) if (!pm_freezing) atomic_inc(&system_freezing_cnt); + pm_wakeup_clear(); printk("Freezing user space processes ... "); pm_freezing = true; error = try_to_freeze_tasks(true);