All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw-KKrjLPT3xs0@public.gmane.org>
To: Mark Brown
	<broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
Cc: Rabin Vincent <rabin-66gdRtMMWGc@public.gmane.org>,
	Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>,
	Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-pm-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	Alan Stern
	<stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org>
Subject: Re: [PATCH] i2c: Factor out runtime suspend checks from PM operations
Date: Wed, 22 Dec 2010 22:25:22 +0100	[thread overview]
Message-ID: <201012222225.22368.rjw@sisk.pl> (raw)
In-Reply-To: <20101222201413.GB8167-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>

On Wednesday, December 22, 2010, Mark Brown wrote:
> On Thu, Dec 23, 2010 at 12:49:39AM +0530, Rabin Vincent wrote:
> 
> > And even if we did want to support runtime PM interaction for legacy
> > ops, the code for restore() above suffers from the problem of setting
> > active even when no callback exists, like I mentioned in the same email
> > for resume():
> 
> I agree it's confused, I posted an updated patch which should behave
> exactly as the old code did - I think the confusion with the legacy
> behaviour should be addressed seperately (and ideally in 2.6.37 or at
> least a stable patch rather than 2.6.38 which is where the current patch
> is targetted).

Rabin is right, runtime PM cannot be supported in the "legacy" case.
Still, I see that __pm_generic_resume() has the problem that it sets
RPM_ACTIVE unconditionally, which it shouldn't do if the runtime PM has been
already disabled.

So, I think we need this patch:

---
 drivers/base/power/generic_ops.c |    2 +-
 include/linux/pm_runtime.h       |    6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

Index: linux-2.6/drivers/base/power/generic_ops.c
===================================================================
--- linux-2.6.orig/drivers/base/power/generic_ops.c
+++ linux-2.6/drivers/base/power/generic_ops.c
@@ -185,7 +185,7 @@ static int __pm_generic_resume(struct de
 		return 0;
 
 	ret = callback(dev);
-	if (!ret) {
+	if (!ret && pm_runtime_enabled(dev)) {
 		pm_runtime_disable(dev);
 		pm_runtime_set_active(dev);
 		pm_runtime_enable(dev);
Index: linux-2.6/include/linux/pm_runtime.h
===================================================================
--- linux-2.6.orig/include/linux/pm_runtime.h
+++ linux-2.6/include/linux/pm_runtime.h
@@ -82,6 +82,11 @@ static inline bool pm_runtime_suspended(
 		&& !dev->power.disable_depth;
 }
 
+static inline bool pm_runtime_enabled(struct device *dev)
+{
+	return !dev->power.disable_depth;
+}
+
 static inline void pm_runtime_mark_last_busy(struct device *dev)
 {
 	ACCESS_ONCE(dev->power.last_busy) = jiffies;
@@ -120,6 +125,7 @@ static inline void pm_runtime_put_noidle
 static inline bool device_run_wake(struct device *dev) { return false; }
 static inline void device_set_run_wake(struct device *dev, bool enable) {}
 static inline bool pm_runtime_suspended(struct device *dev) { return false; }
+static inline bool pm_runtime_enabled(struct device *dev) { return false; }
 
 static inline int pm_generic_runtime_idle(struct device *dev) { return 0; }
 static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; }

  parent reply	other threads:[~2010-12-22 21:25 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-22 18:07 [PATCH] i2c: Factor out runtime suspend checks from PM operations Mark Brown
     [not found] ` <1293041268-7707-1-git-send-email-broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2010-12-22 19:19   ` Rabin Vincent
     [not found]     ` <AANLkTin5eSg8vL4Q8yZ9tme38fbS2aAZ-xeLQSNu809B-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-12-22 20:14       ` Mark Brown
2010-12-22 21:25         ` Rafael J. Wysocki
     [not found]         ` <20101222201413.GB8167-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2010-12-22 21:25           ` Rafael J. Wysocki [this message]
2010-12-22 20:14     ` Mark Brown
2010-12-22 19:19 ` Rabin Vincent
  -- strict thread matches above, loose matches on Subject: below --
2010-12-22 18:07 Mark Brown
2010-12-30 12:40 Mark Brown
2010-12-30 12:40 Mark Brown
2010-12-30 12:40 ` Mark Brown
2011-01-04 23:07 ` Abhijeet Dharmapurikar
     [not found] ` <1293712813-4090-1-git-send-email-broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2011-01-04 23:07   ` Abhijeet Dharmapurikar
2011-01-04 23:07     ` Abhijeet Dharmapurikar
2011-01-04 23:10     ` Mark Brown
     [not found]     ` <4D23A839.6030205-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2011-01-04 23:10       ` Mark Brown
2011-01-04 23:10         ` Mark Brown
2011-01-05  8:28         ` Rafael J. Wysocki
     [not found]         ` <20110104231021.GA18024-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2011-01-05  8:28           ` Rafael J. Wysocki
2011-01-05  8:28             ` Rafael J. Wysocki
     [not found]             ` <201101050928.53979.rjw-KKrjLPT3xs0@public.gmane.org>
2011-01-13 20:17               ` Jean Delvare
2011-01-13 20:17                 ` Jean Delvare
     [not found]                 ` <20110113211751.62e878d8-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2011-01-13 20:28                   ` Rafael J. Wysocki
2011-01-13 20:28                     ` Rafael J. Wysocki
2011-01-13 20:28                 ` Rafael J. Wysocki
2011-01-13 20:17             ` Jean Delvare

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=201012222225.22368.rjw@sisk.pl \
    --to=rjw-kkrjlpt3xs0@public.gmane.org \
    --cc=ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
    --cc=broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org \
    --cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-pm-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=rabin-66gdRtMMWGc@public.gmane.org \
    --cc=stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.