From patchwork Mon Jan 20 08:44:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuansheng Liu X-Patchwork-Id: 3511131 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 17D429F2D6 for ; Mon, 20 Jan 2014 08:53:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3086C2015A for ; Mon, 20 Jan 2014 08:53:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3E1AA200E1 for ; Mon, 20 Jan 2014 08:53:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753069AbaATIxh (ORCPT ); Mon, 20 Jan 2014 03:53:37 -0500 Received: from mga09.intel.com ([134.134.136.24]:40905 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753057AbaATIxf (ORCPT ); Mon, 20 Jan 2014 03:53:35 -0500 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP; 20 Jan 2014 00:49:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.95,689,1384329600"; d="scan'208";a="461529637" Received: from shsibuild003.sh.intel.com ([10.239.146.212]) by fmsmga001.fm.intel.com with ESMTP; 20 Jan 2014 00:53:31 -0800 From: "Liu, Chuansheng" To: rjw@rjwysocki.net, gregkh@linuxfoundation.org, pavel@ucw.cz, len.brown@intel.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, chuansheng.liu@intel.com, zhuangzhi.li@intel.com Subject: [PATCH 1/5] PM: Adding two flags for async suspend_noirq and suspend_late Date: Mon, 20 Jan 2014 16:44:35 +0800 Message-Id: <1390207479-26064-2-git-send-email-chuansheng.liu@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1390207479-26064-1-git-send-email-chuansheng.liu@intel.com> References: <1390207479-26064-1-git-send-email-chuansheng.liu@intel.com> 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: "Liu, Chuansheng" The patch is one helper that adding two new flags for implementing async threads for suspend_noirq and suspend_late. Signed-off-by: Liu, Chuansheng --- drivers/base/power/main.c | 22 ++++++++++++++++++++-- include/linux/pm.h | 2 ++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 6a33dd8..bf71ddb 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -72,6 +72,8 @@ void device_pm_sleep_init(struct device *dev) { dev->power.is_prepared = false; dev->power.is_suspended = false; + dev->power.is_noirq_suspended = false; + dev->power.is_late_suspended = false; init_completion(&dev->power.completion); complete_all(&dev->power.completion); dev->power.wakeup = NULL; @@ -464,6 +466,9 @@ static int device_resume_noirq(struct device *dev, pm_message_t state) if (dev->power.syscore) goto Out; + if (!dev->power.is_noirq_suspended) + goto Out; + if (dev->pm_domain) { info = "noirq power domain "; callback = pm_noirq_op(&dev->pm_domain->ops, state); @@ -484,6 +489,7 @@ static int device_resume_noirq(struct device *dev, pm_message_t state) } error = dpm_run_callback(callback, dev, state, info); + dev->power.is_noirq_suspended = false; Out: TRACE_RESUME(error); @@ -546,6 +552,9 @@ static int device_resume_early(struct device *dev, pm_message_t state) if (dev->power.syscore) goto Out; + if (!dev->power.is_late_suspended) + goto Out; + if (dev->pm_domain) { info = "early power domain "; callback = pm_late_early_op(&dev->pm_domain->ops, state); @@ -566,6 +575,7 @@ static int device_resume_early(struct device *dev, pm_message_t state) } error = dpm_run_callback(callback, dev, state, info); + dev->power.is_late_suspended = false; Out: TRACE_RESUME(error); @@ -902,6 +912,7 @@ static int device_suspend_noirq(struct device *dev, pm_message_t state) { pm_callback_t callback = NULL; char *info = NULL; + int error; if (dev->power.syscore) return 0; @@ -925,7 +936,10 @@ static int device_suspend_noirq(struct device *dev, pm_message_t state) callback = pm_noirq_op(dev->driver->pm, state); } - return dpm_run_callback(callback, dev, state, info); + error = dpm_run_callback(callback, dev, state, info); + if (!error) + dev->power.is_noirq_suspended = true; + return error; } /** @@ -988,6 +1002,7 @@ static int device_suspend_late(struct device *dev, pm_message_t state) { pm_callback_t callback = NULL; char *info = NULL; + int error; __pm_runtime_disable(dev, false); @@ -1013,7 +1028,10 @@ static int device_suspend_late(struct device *dev, pm_message_t state) callback = pm_late_early_op(dev->driver->pm, state); } - return dpm_run_callback(callback, dev, state, info); + error = dpm_run_callback(callback, dev, state, info); + if (!error) + dev->power.is_late_suspended = true; + return error; } /** diff --git a/include/linux/pm.h b/include/linux/pm.h index a224c7f..fe90a8b 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -521,6 +521,8 @@ struct dev_pm_info { unsigned int async_suspend:1; bool is_prepared:1; /* Owned by the PM core */ bool is_suspended:1; /* Ditto */ + bool is_noirq_suspended:1; + bool is_late_suspended:1; bool ignore_children:1; bool early_init:1; /* Owned by the PM core */ spinlock_t lock;