From patchwork Tue Jun 14 16:09:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 879442 Received: from smtp1.linux-foundation.org (smtp1.linux-foundation.org [140.211.169.13]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5EGCHEP012223 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Tue, 14 Jun 2011 16:12:37 GMT Received: from daredevil.linux-foundation.org (localhost [127.0.0.1]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p5EGAoDb028790; Tue, 14 Jun 2011 09:10:51 -0700 Received: from mail-pw0-f47.google.com (mail-pw0-f47.google.com [209.85.160.47]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p5EGAHaX028701 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Tue, 14 Jun 2011 09:10:19 -0700 Received: by pwj9 with SMTP id 9so2836617pwj.6 for ; Tue, 14 Jun 2011 09:10:17 -0700 (PDT) Received: by 10.68.34.7 with SMTP id v7mr3114444pbi.371.1308067817225; Tue, 14 Jun 2011 09:10:17 -0700 (PDT) Received: from localhost ([183.37.195.61]) by mx.google.com with ESMTPS id p5sm5671578pbd.12.2011.06.14.09.10.10 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 14 Jun 2011 09:10:16 -0700 (PDT) From: tom.leiming@gmail.com To: rjw@sisk.pl, stern@rowland.harvard.edu Date: Wed, 15 Jun 2011 00:09:53 +0800 Message-Id: <1308067793-19551-1-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 1.7.4.1 Received-SPF: pass (localhost is always allowed.) X-Spam-Status: No, hits=-6.132 required=5 tests=AWL, BAYES_00, OSDL_HEADER_SPF_PASS, OSDL_HEADER_SUBJECT_BRACKETED, PATCH_SUBJECT_OSDL X-Spam-Checker-Version: SpamAssassin 3.2.4-osdl_revision__1.47__ X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.21 Cc: linux-pm@lists.linux-foundation.org Subject: [linux-pm] [PATCH] PM: runtime: return at once for active device in rpm_resume X-BeenThere: linux-pm@lists.linux-foundation.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux power management List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-pm-bounces@lists.linux-foundation.org Errors-To: linux-pm-bounces@lists.linux-foundation.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 14 Jun 2011 16:12:47 +0000 (UTC) From: Ming Lei This patch moves ahead check for active rpm state of device, so that rpm_resume can return immediately for device with active rpm state. Considered rpm_resume is run in atomic context and is often in hot path(such as in usbnet, called before transmitting every network frame), this patch should make sense. Signed-off-by: Ming Lei --- drivers/base/power/runtime.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 0d4587b..dcc3008 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -455,6 +455,11 @@ static int rpm_resume(struct device *dev, int rpmflags) dev_dbg(dev, "%s flags 0x%x\n", __func__, rpmflags); repeat: + if (dev->power.runtime_status == RPM_ACTIVE) { + retval = 1; + goto out; + } + if (dev->power.runtime_error) retval = -EINVAL; else if (dev->power.disable_depth > 0) @@ -472,11 +477,6 @@ static int rpm_resume(struct device *dev, int rpmflags) if (!dev->power.timer_autosuspends) pm_runtime_deactivate_timer(dev); - if (dev->power.runtime_status == RPM_ACTIVE) { - retval = 1; - goto out; - } - if (dev->power.runtime_status == RPM_RESUMING || dev->power.runtime_status == RPM_SUSPENDING) { DEFINE_WAIT(wait);