intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
To: Intel graphics driver community testing & development
	<intel-gfx@lists.freedesktop.org>
Cc: linux-pm@vger.kernel.org, "Rafael J. Wysocki" <rjw@rjwysocki.net>
Subject: [PATCH v2] PM / Runtime: Introduce pm_runtime_get_noidle
Date: Wed,  9 Dec 2015 18:22:19 +0200	[thread overview]
Message-ID: <1449678139-17782-1-git-send-email-joonas.lahtinen@linux.intel.com> (raw)
In-Reply-To: <1449675920-12986-1-git-send-email-joonas.lahtinen@linux.intel.com>

Introduce pm_runtime_get_noidle to for situations where it is not
desireable to touch an idling device. One use scenario is periodic
hangchecks performed by the drm/i915 driver which can be omitted
on a device in a runtime idle state.

v2:
- Fix inconsistent return value when !CONFIG_PM.
- Update documentation for bool return value

Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Reported-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: linux-pm@vger.kernel.org
---
 Documentation/power/runtime_pm.txt | 4 ++++
 include/linux/pm_runtime.h         | 6 ++++++
 2 files changed, 10 insertions(+)

diff --git a/Documentation/power/runtime_pm.txt b/Documentation/power/runtime_pm.txt
index 0784bc3..a0cbfe1 100644
--- a/Documentation/power/runtime_pm.txt
+++ b/Documentation/power/runtime_pm.txt
@@ -363,6 +363,10 @@ drivers/base/power/runtime.c and include/linux/pm_runtime.h:
   void pm_runtime_get_noresume(struct device *dev);
     - increment the device's usage counter
 
+  bool pm_runtime_get_noidle(struct device *dev);
+    - increment the device's usage counter if it is not 0 and return
+      whether usage counter was incremented
+
   int pm_runtime_get(struct device *dev);
     - increment the device's usage counter, run pm_request_resume(dev) and
       return its result
diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
index 3bdbb41..8f429bc 100644
--- a/include/linux/pm_runtime.h
+++ b/include/linux/pm_runtime.h
@@ -66,6 +66,11 @@ static inline void pm_runtime_get_noresume(struct device *dev)
 	atomic_inc(&dev->power.usage_count);
 }
 
+static inline bool pm_runtime_get_noidle(struct device *dev)
+{
+	return atomic_add_unless(&dev->power.usage_count, 1, 0) > 0;
+}
+
 static inline void pm_runtime_put_noidle(struct device *dev)
 {
 	atomic_add_unless(&dev->power.usage_count, -1, 0);
@@ -153,6 +158,7 @@ static inline void pm_runtime_forbid(struct device *dev) {}
 
 static inline bool pm_children_suspended(struct device *dev) { return false; }
 static inline void pm_runtime_get_noresume(struct device *dev) {}
+static inline bool pm_runtime_get_noidle(struct device *dev) { return true; }
 static inline void pm_runtime_put_noidle(struct device *dev) {}
 static inline bool device_run_wake(struct device *dev) { return false; }
 static inline void device_set_run_wake(struct device *dev, bool enable) {}
-- 
2.4.3

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2015-12-09 16:22 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-09 15:45 [PATCH 1/3] PM / Runtime: Introduce pm_runtime_get_noidle Joonas Lahtinen
2015-12-09 15:45 ` [PATCH 2/3] drm/i915: Take runtime pm wakelock during hangcheck Joonas Lahtinen
2015-12-09 15:45 ` [PATCH 3/3] drm/i915: Do not cancel hangcheck prior to runtime suspend Joonas Lahtinen
2015-12-09 16:22 ` Joonas Lahtinen [this message]
2015-12-10  0:58   ` [PATCH v2] PM / Runtime: Introduce pm_runtime_get_noidle Rafael J. Wysocki
2015-12-10  9:43     ` [Intel-gfx] " Imre Deak
2015-12-10 21:36       ` Rafael J. Wysocki
2015-12-10 21:42         ` Rafael J. Wysocki
2015-12-10 21:20           ` Imre Deak
2015-12-10 22:14             ` Rafael J. Wysocki
2015-12-11 11:08               ` Dave Gordon
2015-12-11 12:03               ` Ulf Hansson
2015-12-11 15:13                 ` Rafael J. Wysocki
2015-12-11 15:59                   ` Ulf Hansson
2015-12-11 23:37                     ` Rafael J. Wysocki
2015-12-11 12:54               ` Imre Deak
2015-12-11 15:40                 ` [Intel-gfx] " Rafael J. Wysocki
2015-12-11 15:47                   ` Imre Deak
2015-12-11 23:21                     ` Rafael J. Wysocki
2015-12-11 23:41                       ` Rafael J. Wysocki
2015-12-12  1:51                         ` Rafael J. Wysocki
2015-12-12 19:40                           ` Imre Deak
2015-12-12 19:49                             ` Chris Wilson
2015-12-14  2:04                               ` Rafael J. Wysocki
2015-12-14 22:22                               ` [PATCH] PM / runtime: Add new helper for conditional usage count incrementation Rafael J. Wysocki
2015-12-15 10:21                                 ` Joonas Lahtinen
2015-12-15 14:28                                 ` Ulf Hansson
2015-12-16  3:10                                   ` Rafael J. Wysocki
2015-12-15 15:06                                 ` Alan Stern
2015-12-16  3:11                                   ` Rafael J. Wysocki
2015-12-17  1:54                                 ` [PATCH v2] " Rafael J. Wysocki
2015-12-17  9:03                                   ` Ulf Hansson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1449678139-17782-1-git-send-email-joonas.lahtinen@linux.intel.com \
    --to=joonas.lahtinen@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).