* [PATCH 00/04] PM: Runtime PM v11 patches 20090731
@ 2009-07-31 12:26 Magnus Damm
2009-07-31 12:26 ` [PATCH 01/04] PM: Runtime PM v11 - add dev_pm_ops helpers Magnus Damm
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Magnus Damm @ 2009-07-31 12:26 UTC (permalink / raw)
To: linux-pm; +Cc: gregkh
PM: Runtime PM v11 patches 20090731
[PATCH 01/04] PM: Runtime PM v11 - add dev_pm_ops helpers
[PATCH 02/04] PM: Runtime PM v11 - let bus-less devices succeed
[PATCH 03/04] PM: Runtime PM v11 - add debug printouts
[PATCH 04/04] PM: Runtime PM v11 - CONFIG_PM_SLEEP=n support
These patches contain architecture independent changes for
Runtime PM and are meant to be applied on top of:
"PM: Introduce core framework for run-time PM of I/O devices (rev. 11)"
by Rafael J. Wysocki.
Patch 01 + 03 are very straightforward and would be useful to have
upstream from the perspective of a Runtime PM bus developer.
Patch 02 + 04 try to address some problems I ran into while hacking
on the Runtime PM platform bus code for SuperH. There may be better
ways to solve those issues.
Please see each individual patch for more information. Thanks!
Signed-off-by: Magnus Damm <damm@igel.co.jp>
---
drivers/base/core.c | 3 ++
drivers/base/power/main.c | 3 --
drivers/base/power/runtime.c | 55 ++++++++++++++++++++++++++----------------
include/linux/pm_runtime.h | 19 ++++++++++++++
4 files changed, 57 insertions(+), 23 deletions(-)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 01/04] PM: Runtime PM v11 - add dev_pm_ops helpers
2009-07-31 12:26 [PATCH 00/04] PM: Runtime PM v11 patches 20090731 Magnus Damm
@ 2009-07-31 12:26 ` Magnus Damm
2009-07-31 12:26 ` [PATCH 02/04] PM: Runtime PM v11 - let bus-less devices succeed Magnus Damm
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Magnus Damm @ 2009-07-31 12:26 UTC (permalink / raw)
To: linux-pm; +Cc: gregkh
From: Magnus Damm <damm@igel.co.jp>
This patch breaks out the dev_pm_ops handling code
for Runtime PM into separate functions. This change
makes is possible for the main code and separate
bus implementations to deal with callbacks and error
codes in a consistent fashion.
The broken out functions are used by the Runtime PM
platform device bus implementation for SuperH.
Signed-off-by: Magnus Damm <damm@igel.co.jp>
---
drivers/base/power/runtime.c | 10 ++++------
include/linux/pm_runtime.h | 19 +++++++++++++++++++
2 files changed, 23 insertions(+), 6 deletions(-)
--- 0010/drivers/base/power/runtime.c
+++ work/drivers/base/power/runtime.c 2009-07-30 19:20:23.000000000 +0900
@@ -79,8 +79,8 @@ static int __pm_runtime_idle(struct devi
spin_unlock_irq(&dev->power.lock);
- if (dev->bus && dev->bus->pm && dev->bus->pm->runtime_idle)
- dev->bus->pm->runtime_idle(dev);
+ if (dev->bus)
+ pm_runtime_ops_idle(dev, dev->bus->pm);
spin_lock_irq(&dev->power.lock);
@@ -177,8 +177,7 @@ int __pm_runtime_suspend(struct device *
spin_unlock_irq(&dev->power.lock);
- retval = dev->bus && dev->bus->pm && dev->bus->pm->runtime_suspend ?
- dev->bus->pm->runtime_suspend(dev) : -ENOSYS;
+ retval = dev->bus ? pm_runtime_ops_suspend(dev, dev->bus->pm) : -ENOSYS;
spin_lock_irq(&dev->power.lock);
@@ -319,8 +318,7 @@ int __pm_runtime_resume(struct device *d
spin_unlock_irq(&dev->power.lock);
- retval = dev->bus && dev->bus->pm && dev->bus->pm->runtime_resume ?
- dev->bus->pm->runtime_resume(dev) : -ENOSYS;
+ retval = dev->bus ? pm_runtime_ops_resume(dev, dev->bus->pm) : -ENOSYS;
spin_lock_irq(&dev->power.lock);
--- 0010/include/linux/pm_runtime.h
+++ work/include/linux/pm_runtime.h 2009-07-30 19:27:17.000000000 +0900
@@ -108,4 +108,23 @@ static inline void pm_runtime_set_suspen
__pm_runtime_set_status(dev, RPM_SUSPENDED);
}
+static inline int pm_runtime_ops_suspend(struct device *dev,
+ struct dev_pm_ops *p)
+{
+ return p && p->runtime_suspend ? p->runtime_suspend(dev) : -ENOSYS;
+}
+
+static inline int pm_runtime_ops_resume(struct device *dev,
+ struct dev_pm_ops *p)
+{
+ return p && p->runtime_resume ? p->runtime_resume(dev) : -ENOSYS;
+}
+
+static inline void pm_runtime_ops_idle(struct device *dev,
+ struct dev_pm_ops *p)
+{
+ if (p && p->runtime_idle)
+ p->runtime_idle(dev);
+}
+
#endif
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 02/04] PM: Runtime PM v11 - let bus-less devices succeed
2009-07-31 12:26 [PATCH 00/04] PM: Runtime PM v11 patches 20090731 Magnus Damm
2009-07-31 12:26 ` [PATCH 01/04] PM: Runtime PM v11 - add dev_pm_ops helpers Magnus Damm
@ 2009-07-31 12:26 ` Magnus Damm
2009-07-31 12:27 ` [PATCH 03/04] PM: Runtime PM v11 - add debug printouts Magnus Damm
2009-07-31 12:27 ` [PATCH 04/04] PM: Runtime PM v11 - CONFIG_PM_SLEEP=n support Magnus Damm
3 siblings, 0 replies; 5+ messages in thread
From: Magnus Damm @ 2009-07-31 12:26 UTC (permalink / raw)
To: linux-pm; +Cc: gregkh
From: Magnus Damm <damm@igel.co.jp>
This patch allows bus-less devices to pass as being
suspended even though there is no dev_pm_ops structure
to use to get the Runtime PM callbacks.
Workarounds the fact that "struct device platform_bus"
becomes the parent of otherwise parent-less platform
devices. Runtime suspend and resume of devices on the
platform bus is impossible without this change. It may
however be better to modify the actual struct device
than working around things in the Runtime PM core code.
Signed-off-by: Magnus Damm <damm@igel.co.jp>
---
drivers/base/power/runtime.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- 0012/drivers/base/power/runtime.c
+++ work/drivers/base/power/runtime.c 2009-07-30 19:21:54.000000000 +0900
@@ -177,7 +177,7 @@ int __pm_runtime_suspend(struct device *
spin_unlock_irq(&dev->power.lock);
- retval = dev->bus ? pm_runtime_ops_suspend(dev, dev->bus->pm) : -ENOSYS;
+ retval = dev->bus ? pm_runtime_ops_suspend(dev, dev->bus->pm) : 0;
spin_lock_irq(&dev->power.lock);
@@ -318,7 +318,7 @@ int __pm_runtime_resume(struct device *d
spin_unlock_irq(&dev->power.lock);
- retval = dev->bus ? pm_runtime_ops_resume(dev, dev->bus->pm) : -ENOSYS;
+ retval = dev->bus ? pm_runtime_ops_resume(dev, dev->bus->pm) : 0;
spin_lock_irq(&dev->power.lock);
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 03/04] PM: Runtime PM v11 - add debug printouts
2009-07-31 12:26 [PATCH 00/04] PM: Runtime PM v11 patches 20090731 Magnus Damm
2009-07-31 12:26 ` [PATCH 01/04] PM: Runtime PM v11 - add dev_pm_ops helpers Magnus Damm
2009-07-31 12:26 ` [PATCH 02/04] PM: Runtime PM v11 - let bus-less devices succeed Magnus Damm
@ 2009-07-31 12:27 ` Magnus Damm
2009-07-31 12:27 ` [PATCH 04/04] PM: Runtime PM v11 - CONFIG_PM_SLEEP=n support Magnus Damm
3 siblings, 0 replies; 5+ messages in thread
From: Magnus Damm @ 2009-07-31 12:27 UTC (permalink / raw)
To: linux-pm; +Cc: gregkh
From: Magnus Damm <damm@igel.co.jp>
This patch adds dev_dbg() printouts to the Runtime PM
code. Just add a #define DEBUG at the top of the file
to get suspend and resume printouts. Also add a missing
newline to the pm_runtime_enable() printout while at it.
Signed-off-by: Magnus Damm <damm@igel.co.jp>
---
drivers/base/power/runtime.c | 41 +++++++++++++++++++++++++++++------------
1 file changed, 29 insertions(+), 12 deletions(-)
--- 0017/drivers/base/power/runtime.c
+++ work/drivers/base/power/runtime.c 2009-07-31 19:48:32.000000000 +0900
@@ -125,16 +125,22 @@ int __pm_runtime_suspend(struct device *
bool notify = false;
int retval = 0;
+ dev_dbg(dev, "__pm_runtime_suspend() %d!\n", from_wq);
repeat:
- if (dev->power.runtime_failure)
- return -EINVAL;
+ if (dev->power.runtime_failure) {
+ retval = -EINVAL;
+ goto out;
+ }
pm_runtime_deactivate_timer(dev);
if (dev->power.request_pending) {
/* Pending resume requests take precedence over us. */
- if (dev->power.request == RPM_REQ_RESUME)
- return -EAGAIN;
+ if (dev->power.request == RPM_REQ_RESUME) {
+ retval = -EAGAIN;
+ goto out;
+ }
+
/* Other pending requests need to be canceled. */
dev->power.request = RPM_REQ_NONE;
}
@@ -148,13 +154,15 @@ int __pm_runtime_suspend(struct device *
else if (!pm_children_suspended(dev))
retval = -EBUSY;
if (retval)
- return retval;
+ goto out;
if (dev->power.runtime_status == RPM_SUSPENDING) {
DEFINE_WAIT(wait);
- if (from_wq)
- return -EINPROGRESS;
+ if (from_wq) {
+ retval = -EINPROGRESS;
+ goto out;
+ }
/* Wait for the other suspend running in parallel with us. */
for (;;) {
@@ -217,6 +225,8 @@ int __pm_runtime_suspend(struct device *
pm_runtime_idle(dev);
spin_lock_irq(&dev->power.lock);
+ out:
+ dev_dbg(dev, "__pm_runtime_suspend() returns %d!\n", retval);
return retval;
}
@@ -256,9 +266,12 @@ int __pm_runtime_resume(struct device *d
struct device *parent = NULL;
int retval = 0;
+ dev_dbg(dev, "__pm_runtime_resume() %d!\n", from_wq);
repeat:
- if (dev->power.runtime_failure)
- return -EINVAL;
+ if (dev->power.runtime_failure) {
+ retval = -EINVAL;
+ goto out;
+ }
pm_runtime_cancel_pending(dev);
@@ -267,7 +280,7 @@ int __pm_runtime_resume(struct device *d
else if (dev->power.disable_depth > 0)
retval = -EAGAIN;
if (retval)
- return retval;
+ goto out;
if (dev->power.runtime_status == RPM_RESUMING
|| dev->power.runtime_status == RPM_SUSPENDING) {
@@ -276,7 +289,9 @@ int __pm_runtime_resume(struct device *d
if (from_wq) {
if (dev->power.runtime_status == RPM_SUSPENDING)
dev->power.deferred_resume = true;
- return -EINPROGRESS;
+
+ retval = -EINPROGRESS;
+ goto out;
}
/* Wait for the operation carried out in parallel with us. */
@@ -347,6 +362,8 @@ int __pm_runtime_resume(struct device *d
pm_request_idle(dev);
spin_lock_irq(&dev->power.lock);
+ out:
+ dev_dbg(dev, "__pm_runtime_resume() returns %d!\n", retval);
return retval;
}
@@ -771,7 +788,7 @@ void pm_runtime_enable(struct device *de
if (dev->power.disable_depth > 0)
dev->power.disable_depth--;
else
- dev_warn(dev, "Unbalanced %s!", __func__);
+ dev_warn(dev, "Unbalanced %s!\n", __func__);
spin_unlock_irqrestore(&dev->power.lock, flags);
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 04/04] PM: Runtime PM v11 - CONFIG_PM_SLEEP=n support
2009-07-31 12:26 [PATCH 00/04] PM: Runtime PM v11 patches 20090731 Magnus Damm
` (2 preceding siblings ...)
2009-07-31 12:27 ` [PATCH 03/04] PM: Runtime PM v11 - add debug printouts Magnus Damm
@ 2009-07-31 12:27 ` Magnus Damm
3 siblings, 0 replies; 5+ messages in thread
From: Magnus Damm @ 2009-07-31 12:27 UTC (permalink / raw)
To: linux-pm; +Cc: gregkh
From: Magnus Damm <damm@igel.co.jp>
This patch contains a few fixes to allow Runtime PM
to be used even though suspend and hibernation are disabled
in the kconfig. Without this patch the Runtime PM code
compiles just fine with CONFIG_PM_SLEEP=n but the functions
pm_runtime_init() and pm_runtime_remove() never gets called
during runtime.
Not sure if CONFIG_PM_RUNTIME=y and CONFIG_PM_SLEEP=n really
is a valid combination, but I can easily imagine use cases
for Runtime PM without system suspend/hibernation support.
Signed-off-by: Magnus Damm <damm@igel.co.jp>
---
drivers/base/core.c | 3 +++
drivers/base/power/main.c | 3 ---
2 files changed, 3 insertions(+), 3 deletions(-)
--- 0001/drivers/base/core.c
+++ work/drivers/base/core.c 2009-07-31 19:52:26.000000000 +0900
@@ -23,6 +23,7 @@
#include <linux/semaphore.h>
#include <linux/mutex.h>
#include <linux/async.h>
+#include <linux/pm_runtime.h>
#include "base.h"
#include "power/power.h"
@@ -555,6 +556,7 @@ void device_initialize(struct device *de
INIT_LIST_HEAD(&dev->devres_head);
device_init_wakeup(dev, 0);
device_pm_init(dev);
+ pm_runtime_init(dev);
set_dev_node(dev, -1);
}
@@ -1063,6 +1065,7 @@ void device_del(struct device *dev)
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
BUS_NOTIFY_DEL_DEVICE, dev);
device_pm_remove(dev);
+ pm_runtime_remove(dev);
dpm_sysfs_remove(dev);
if (parent)
klist_del(&dev->p->knode_parent);
--- 0015/drivers/base/power/main.c
+++ work/drivers/base/power/main.c 2009-07-31 19:52:26.000000000 +0900
@@ -56,7 +56,6 @@ static bool transition_started;
void device_pm_init(struct device *dev)
{
dev->power.status = DPM_ON;
- pm_runtime_init(dev);
}
/**
@@ -116,8 +115,6 @@ void device_pm_remove(struct device *dev
mutex_lock(&dpm_list_mtx);
list_del_init(&dev->power.entry);
mutex_unlock(&dpm_list_mtx);
-
- pm_runtime_remove(dev);
}
/**
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-07-31 12:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-31 12:26 [PATCH 00/04] PM: Runtime PM v11 patches 20090731 Magnus Damm
2009-07-31 12:26 ` [PATCH 01/04] PM: Runtime PM v11 - add dev_pm_ops helpers Magnus Damm
2009-07-31 12:26 ` [PATCH 02/04] PM: Runtime PM v11 - let bus-less devices succeed Magnus Damm
2009-07-31 12:27 ` [PATCH 03/04] PM: Runtime PM v11 - add debug printouts Magnus Damm
2009-07-31 12:27 ` [PATCH 04/04] PM: Runtime PM v11 - CONFIG_PM_SLEEP=n support Magnus Damm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox