From patchwork Tue May 13 01:03:08 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: 4161921 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8326C9F1C0 for ; Tue, 13 May 2014 01:12:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C0D5220218 for ; Tue, 13 May 2014 01:12:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D68C42021B for ; Tue, 13 May 2014 01:12:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753649AbaEMBL5 (ORCPT ); Mon, 12 May 2014 21:11:57 -0400 Received: from v094114.home.net.pl ([79.96.170.134]:55562 "HELO v094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752407AbaEMBLz (ORCPT ); Mon, 12 May 2014 21:11:55 -0400 Received: from aerf2.neoplus.adsl.tpnet.pl [79.191.187.2] (HELO vostro.rjw.lan) by serwer1319399.home.pl [79.96.170.134] with SMTP (IdeaSmtpServer v0.80) id a3e1102cd8659fa7; Tue, 13 May 2014 03:11:54 +0200 From: "Rafael J. Wysocki" To: Alan Stern Cc: Linux PM list , ACPI Devel Maling List , Aaron Lu , Mika Westerberg , Linux Kernel Mailing List , Kevin Hilman , Ulf Hansson Subject: [RFC][PATCH 1/3] PM / sleep: Move runtime PM barrier invocation to device_prepare() Date: Tue, 13 May 2014 03:03:08 +0200 Message-ID: <2675141.cAMB9masRU@vostro.rjw.lan> User-Agent: KMail/4.11.5 (Linux/3.14.0-rc7+; KDE/4.11.5; x86_64; ; ) In-Reply-To: <4649019.is79p6EySp@vostro.rjw.lan> References: <4649019.is79p6EySp@vostro.rjw.lan> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.5 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 Move the invocation of the runtime PM barrier during system suspend (or hibernation) from __device_suspend() to device_prepare() to make all runtime PM transitions in progress complete before executing ->prepare() callbacks for devices. That will allow those callbacks to check if devices are runtime suspended in a non-racy way. Signed-off-by: Rafael J. Wysocki --- drivers/base/power/main.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) -- 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 Index: linux-pm/drivers/base/power/main.c =================================================================== --- linux-pm.orig/drivers/base/power/main.c +++ linux-pm/drivers/base/power/main.c @@ -1312,24 +1312,7 @@ static int __device_suspend(struct devic dpm_wait_for_children(dev, async); - if (async_error) - goto Complete; - - /* - * If a device configured to wake up the system from sleep states - * has been suspended at run time and there's a resume request pending - * for it, this is equivalent to the device signaling wakeup, so the - * system suspend operation should be aborted. - */ - if (pm_runtime_barrier(dev) && device_may_wakeup(dev)) - pm_wakeup_event(dev, 0); - - if (pm_wakeup_pending()) { - async_error = -EBUSY; - goto Complete; - } - - if (dev->power.syscore) + if (async_error || dev->power.syscore) goto Complete; dpm_watchdog_set(&wd, dev); @@ -1500,6 +1483,18 @@ static int device_prepare(struct device */ pm_runtime_get_noresume(dev); + /* + * If a device configured to wake up the system from sleep states + * has been suspended at run time and there's a resume request pending + * for it, this is equivalent to the device signaling wakeup, so the + * system suspend operation should be aborted. + */ + if (pm_runtime_barrier(dev) && device_may_wakeup(dev)) + pm_wakeup_event(dev, 0); + + if (pm_wakeup_pending()) + return -EBUSY; + device_lock(dev); dev->power.wakeup_path = device_may_wakeup(dev);