* [PATCH V2 0/3] PM: Enable option of re-use runtime PM callbacks at system suspend
@ 2013-12-10 13:37 Ulf Hansson
2013-12-10 13:37 ` [PATCH V2 1/3] PM / Runtime: Add second macro for definition of runtime PM callbacks Ulf Hansson
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Ulf Hansson @ 2013-12-10 13:37 UTC (permalink / raw)
To: linux-arm-kernel
To put devices into low power state during system suspend, it is convenient
for some runtime PM supported power domains, subsystems and drivers to have
the option of re-using and invoking the runtime PM callbacks from their system
PM callbacks.
The benefit is that we don't need to implement wrapper functions which
handles runtime PM resourses, typically called from both runtime PM and system
PM callbacks.
Some new helper macros for defining the PM callbacks are added.
SET_PM_RUNTIME_PM_OPS; to define runtime PM callbacks for CONFIG_PM instead of
CONFIG_PM_RUNTIME.
SET_LATE_SYSTEM_SLEEP_PM_OPS; to define common late/early system PM callbacks,
same approach is applicable to the existing SET_SYSTEM_SLEEP_PM_OPS which
defines common suspend/resume system PM callbacks.
A minor fix was needed for the platform bus, which runtime PM callbacks are set
to the pm_generic_runtime_suspend|resume functions. These were implemented only
for CONFIG_PM_RUNTIME and thus the platform bus prevented driver's runtime PM
callbacks to be invoked when only CONFIG_PM_SLEEP was used. We move them into
CONFIG_PM to resolve the problem.
Changes in v2:
Updated commit messages to try to better reflect the changes.
Removed the below patches from this patch set. Let's leave those to be
addressed separately, if needed.
- PM / Sleep: Add pm_generic functions to re-use runtime PM callbacks
- drm/exynos: Convert to suspend_late/resume_early callbacks for fimc
Ulf Hansson (3):
PM / Runtime: Add second macro for definition of runtime PM callbacks
PM / Runtime: Implement the pm_generic_runtime functions for
CONFIG_PM
PM / Sleep: Add macro to define common late/early system PM callbacks
drivers/base/power/generic_ops.c | 4 ++--
include/linux/pm.h | 21 +++++++++++++++++++++
include/linux/pm_runtime.h | 12 ++++++++----
3 files changed, 31 insertions(+), 6 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH V2 1/3] PM / Runtime: Add second macro for definition of runtime PM callbacks
2013-12-10 13:37 [PATCH V2 0/3] PM: Enable option of re-use runtime PM callbacks at system suspend Ulf Hansson
@ 2013-12-10 13:37 ` Ulf Hansson
2013-12-10 13:37 ` [PATCH V2 2/3] PM / Runtime: Implement the pm_generic_runtime functions for CONFIG_PM Ulf Hansson
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Ulf Hansson @ 2013-12-10 13:37 UTC (permalink / raw)
To: linux-arm-kernel
By having the runtime PM callbacks implemented for CONFIG_PM, these
becomes available in all combinations of CONFIG_PM_SLEEP and
CONFIG_PM_RUNTIME.
The benefit using this, is that we don't need to implement the wrapper
functions which handles runtime PM resourses, typically called from
both runtime PM and system PM callbacks. Instead the runtime PM
callbacks can be invoked directly from system PM callbacks, which is
useful for some drivers, subsystems and power domains.
Use the new macro SET_PM_RUNTIME_PM_OPS in cases were the above makes
sense. Make sure the callbacks are encapsulated within CONFIG_PM
instead of CONFIG_PM_RUNTIME.
Do note that the old macro SET_RUNTIME_PM_OPS, which is being quite
widely used right now, requires the callbacks to be defined for
CONFIG_PM_RUNTIME. In many cases it will certainly be convenient to
convert to the new macro above, but that will have to be distinguished
in case by case.
Cc: Kevin Hilman <khilman@linaro.org>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
include/linux/pm.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/include/linux/pm.h b/include/linux/pm.h
index a224c7f..7a830a7 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -320,6 +320,15 @@ struct dev_pm_ops {
#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn)
#endif
+#ifdef CONFIG_PM
+#define SET_PM_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
+ .runtime_suspend = suspend_fn, \
+ .runtime_resume = resume_fn, \
+ .runtime_idle = idle_fn,
+#else
+#define SET_PM_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn)
+#endif
+
/*
* Use this if you want to use the same suspend and resume callbacks for suspend
* to RAM and hibernation.
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH V2 2/3] PM / Runtime: Implement the pm_generic_runtime functions for CONFIG_PM
2013-12-10 13:37 [PATCH V2 0/3] PM: Enable option of re-use runtime PM callbacks at system suspend Ulf Hansson
2013-12-10 13:37 ` [PATCH V2 1/3] PM / Runtime: Add second macro for definition of runtime PM callbacks Ulf Hansson
@ 2013-12-10 13:37 ` Ulf Hansson
2013-12-10 13:37 ` [PATCH V2 3/3] PM / Sleep: Add macro to define common late/early system PM callbacks Ulf Hansson
2013-12-20 8:43 ` [PATCH V2 0/3] PM: Enable option of re-use runtime PM callbacks at system suspend Ulf Hansson
3 siblings, 0 replies; 7+ messages in thread
From: Ulf Hansson @ 2013-12-10 13:37 UTC (permalink / raw)
To: linux-arm-kernel
The pm_generic_runtime_suspend|resume functions were implemented within
CONFIG_PM_RUNTIME.
As we also may use runtime PM callbacks during system suspend, to put
devices into low power state, we need to move the implementation of
pm_generic_runtime_suspend|resume to CONFIG_PM.
This change gives a power domain provision to invoke a platform
driver's runtime PM callback from a power domain's system PM callback.
This were earlier prevented by the platform bus, since it uses the
pm_generic_runtime_suspend|resume functions as runtime PM callbacks.
Cc: Kevin Hilman <khilman@linaro.org>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
drivers/base/power/generic_ops.c | 4 ++--
include/linux/pm_runtime.h | 12 ++++++++----
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/base/power/generic_ops.c b/drivers/base/power/generic_ops.c
index 5ee030a..a2e55bf 100644
--- a/drivers/base/power/generic_ops.c
+++ b/drivers/base/power/generic_ops.c
@@ -10,7 +10,7 @@
#include <linux/pm_runtime.h>
#include <linux/export.h>
-#ifdef CONFIG_PM_RUNTIME
+#ifdef CONFIG_PM
/**
* pm_generic_runtime_suspend - Generic runtime suspend callback for subsystems.
* @dev: Device to suspend.
@@ -48,7 +48,7 @@ int pm_generic_runtime_resume(struct device *dev)
return ret;
}
EXPORT_SYMBOL_GPL(pm_generic_runtime_resume);
-#endif /* CONFIG_PM_RUNTIME */
+#endif /* CONFIG_PM */
#ifdef CONFIG_PM_SLEEP
/**
diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
index 6fa7cea..16c9a62 100644
--- a/include/linux/pm_runtime.h
+++ b/include/linux/pm_runtime.h
@@ -23,6 +23,14 @@
usage_count */
#define RPM_AUTO 0x08 /* Use autosuspend_delay */
+#ifdef CONFIG_PM
+extern int pm_generic_runtime_suspend(struct device *dev);
+extern int pm_generic_runtime_resume(struct device *dev);
+#else
+static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; }
+static inline int pm_generic_runtime_resume(struct device *dev) { return 0; }
+#endif
+
#ifdef CONFIG_PM_RUNTIME
extern struct workqueue_struct *pm_wq;
@@ -37,8 +45,6 @@ extern void pm_runtime_enable(struct device *dev);
extern void __pm_runtime_disable(struct device *dev, bool check_resume);
extern void pm_runtime_allow(struct device *dev);
extern void pm_runtime_forbid(struct device *dev);
-extern int pm_generic_runtime_suspend(struct device *dev);
-extern int pm_generic_runtime_resume(struct device *dev);
extern void pm_runtime_no_callbacks(struct device *dev);
extern void pm_runtime_irq_safe(struct device *dev);
extern void __pm_runtime_use_autosuspend(struct device *dev, bool use);
@@ -142,8 +148,6 @@ static inline bool pm_runtime_active(struct device *dev) { return true; }
static inline bool pm_runtime_status_suspended(struct device *dev) { return false; }
static inline bool pm_runtime_enabled(struct device *dev) { return false; }
-static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; }
-static inline int pm_generic_runtime_resume(struct device *dev) { return 0; }
static inline void pm_runtime_no_callbacks(struct device *dev) {}
static inline void pm_runtime_irq_safe(struct device *dev) {}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH V2 3/3] PM / Sleep: Add macro to define common late/early system PM callbacks
2013-12-10 13:37 [PATCH V2 0/3] PM: Enable option of re-use runtime PM callbacks at system suspend Ulf Hansson
2013-12-10 13:37 ` [PATCH V2 1/3] PM / Runtime: Add second macro for definition of runtime PM callbacks Ulf Hansson
2013-12-10 13:37 ` [PATCH V2 2/3] PM / Runtime: Implement the pm_generic_runtime functions for CONFIG_PM Ulf Hansson
@ 2013-12-10 13:37 ` Ulf Hansson
2013-12-20 8:43 ` [PATCH V2 0/3] PM: Enable option of re-use runtime PM callbacks at system suspend Ulf Hansson
3 siblings, 0 replies; 7+ messages in thread
From: Ulf Hansson @ 2013-12-10 13:37 UTC (permalink / raw)
To: linux-arm-kernel
We use the same approach as for the existing SET_SYSTEM_SLEEP_PM_OPS,
but for the late and early callbacks instead.
The new SET_LATE_SYSTEM_SLEEP_PM_OPS, defined for CONFIG_PM_SLEEP, will
point ->suspend_late, ->freeze_late and ->poweroff_late to the same
function. Vice verse happens for ->resume_early, ->thaw_early and
->restore_early.
Cc: Kevin Hilman <khilman@linaro.org>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
include/linux/pm.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 7a830a7..8c6583a 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -311,6 +311,18 @@ struct dev_pm_ops {
#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
#endif
+#ifdef CONFIG_PM_SLEEP
+#define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
+ .suspend_late = suspend_fn, \
+ .resume_early = resume_fn, \
+ .freeze_late = suspend_fn, \
+ .thaw_early = resume_fn, \
+ .poweroff_late = suspend_fn, \
+ .restore_early = resume_fn,
+#else
+#define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
+#endif
+
#ifdef CONFIG_PM_RUNTIME
#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
.runtime_suspend = suspend_fn, \
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH V2 0/3] PM: Enable option of re-use runtime PM callbacks at system suspend
2013-12-10 13:37 [PATCH V2 0/3] PM: Enable option of re-use runtime PM callbacks at system suspend Ulf Hansson
` (2 preceding siblings ...)
2013-12-10 13:37 ` [PATCH V2 3/3] PM / Sleep: Add macro to define common late/early system PM callbacks Ulf Hansson
@ 2013-12-20 8:43 ` Ulf Hansson
2013-12-20 13:18 ` Rafael J. Wysocki
3 siblings, 1 reply; 7+ messages in thread
From: Ulf Hansson @ 2013-12-20 8:43 UTC (permalink / raw)
To: linux-arm-kernel
On 10 December 2013 14:37, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> To put devices into low power state during system suspend, it is convenient
> for some runtime PM supported power domains, subsystems and drivers to have
> the option of re-using and invoking the runtime PM callbacks from their system
> PM callbacks.
>
> The benefit is that we don't need to implement wrapper functions which
> handles runtime PM resourses, typically called from both runtime PM and system
> PM callbacks.
>
> Some new helper macros for defining the PM callbacks are added.
>
> SET_PM_RUNTIME_PM_OPS; to define runtime PM callbacks for CONFIG_PM instead of
> CONFIG_PM_RUNTIME.
>
> SET_LATE_SYSTEM_SLEEP_PM_OPS; to define common late/early system PM callbacks,
> same approach is applicable to the existing SET_SYSTEM_SLEEP_PM_OPS which
> defines common suspend/resume system PM callbacks.
>
> A minor fix was needed for the platform bus, which runtime PM callbacks are set
> to the pm_generic_runtime_suspend|resume functions. These were implemented only
> for CONFIG_PM_RUNTIME and thus the platform bus prevented driver's runtime PM
> callbacks to be invoked when only CONFIG_PM_SLEEP was used. We move them into
> CONFIG_PM to resolve the problem.
>
> Changes in v2:
> Updated commit messages to try to better reflect the changes.
> Removed the below patches from this patch set. Let's leave those to be
> addressed separately, if needed.
> - PM / Sleep: Add pm_generic functions to re-use runtime PM callbacks
> - drm/exynos: Convert to suspend_late/resume_early callbacks for fimc
>
>
> Ulf Hansson (3):
> PM / Runtime: Add second macro for definition of runtime PM callbacks
> PM / Runtime: Implement the pm_generic_runtime functions for
> CONFIG_PM
> PM / Sleep: Add macro to define common late/early system PM callbacks
>
> drivers/base/power/generic_ops.c | 4 ++--
> include/linux/pm.h | 21 +++++++++++++++++++++
> include/linux/pm_runtime.h | 12 ++++++++----
> 3 files changed, 31 insertions(+), 6 deletions(-)
>
> --
> 1.7.9.5
>
Hi,
Just wanted to send a kind ping on this patchset.
Would be nice to try to conclude on the way forward after the quite
long and good discussions we had around this topic.
Kind regards
Uffe
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH V2 0/3] PM: Enable option of re-use runtime PM callbacks at system suspend
2013-12-20 8:43 ` [PATCH V2 0/3] PM: Enable option of re-use runtime PM callbacks at system suspend Ulf Hansson
@ 2013-12-20 13:18 ` Rafael J. Wysocki
2013-12-22 1:01 ` Rafael J. Wysocki
0 siblings, 1 reply; 7+ messages in thread
From: Rafael J. Wysocki @ 2013-12-20 13:18 UTC (permalink / raw)
To: linux-arm-kernel
On Friday, December 20, 2013 09:43:16 AM Ulf Hansson wrote:
> On 10 December 2013 14:37, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > To put devices into low power state during system suspend, it is convenient
> > for some runtime PM supported power domains, subsystems and drivers to have
> > the option of re-using and invoking the runtime PM callbacks from their system
> > PM callbacks.
> >
> > The benefit is that we don't need to implement wrapper functions which
> > handles runtime PM resourses, typically called from both runtime PM and system
> > PM callbacks.
> >
> > Some new helper macros for defining the PM callbacks are added.
> >
> > SET_PM_RUNTIME_PM_OPS; to define runtime PM callbacks for CONFIG_PM instead of
> > CONFIG_PM_RUNTIME.
> >
> > SET_LATE_SYSTEM_SLEEP_PM_OPS; to define common late/early system PM callbacks,
> > same approach is applicable to the existing SET_SYSTEM_SLEEP_PM_OPS which
> > defines common suspend/resume system PM callbacks.
> >
> > A minor fix was needed for the platform bus, which runtime PM callbacks are set
> > to the pm_generic_runtime_suspend|resume functions. These were implemented only
> > for CONFIG_PM_RUNTIME and thus the platform bus prevented driver's runtime PM
> > callbacks to be invoked when only CONFIG_PM_SLEEP was used. We move them into
> > CONFIG_PM to resolve the problem.
> >
> > Changes in v2:
> > Updated commit messages to try to better reflect the changes.
> > Removed the below patches from this patch set. Let's leave those to be
> > addressed separately, if needed.
> > - PM / Sleep: Add pm_generic functions to re-use runtime PM callbacks
> > - drm/exynos: Convert to suspend_late/resume_early callbacks for fimc
> >
> >
> > Ulf Hansson (3):
> > PM / Runtime: Add second macro for definition of runtime PM callbacks
> > PM / Runtime: Implement the pm_generic_runtime functions for
> > CONFIG_PM
> > PM / Sleep: Add macro to define common late/early system PM callbacks
> >
> > drivers/base/power/generic_ops.c | 4 ++--
> > include/linux/pm.h | 21 +++++++++++++++++++++
> > include/linux/pm_runtime.h | 12 ++++++++----
> > 3 files changed, 31 insertions(+), 6 deletions(-)
> >
> > --
> > 1.7.9.5
> >
>
> Hi,
>
> Just wanted to send a kind ping on this patchset.
>
> Would be nice to try to conclude on the way forward after the quite
> long and good discussions we had around this topic.
Sorry, I was traveling last week. I'm processing my backlog now, hopefully
I'll get to your patches shortly.
Thanks,
Rafael
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH V2 0/3] PM: Enable option of re-use runtime PM callbacks at system suspend
2013-12-20 13:18 ` Rafael J. Wysocki
@ 2013-12-22 1:01 ` Rafael J. Wysocki
0 siblings, 0 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2013-12-22 1:01 UTC (permalink / raw)
To: linux-arm-kernel
On Friday, December 20, 2013 02:18:22 PM Rafael J. Wysocki wrote:
> On Friday, December 20, 2013 09:43:16 AM Ulf Hansson wrote:
> > On 10 December 2013 14:37, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > > To put devices into low power state during system suspend, it is convenient
> > > for some runtime PM supported power domains, subsystems and drivers to have
> > > the option of re-using and invoking the runtime PM callbacks from their system
> > > PM callbacks.
> > >
> > > The benefit is that we don't need to implement wrapper functions which
> > > handles runtime PM resourses, typically called from both runtime PM and system
> > > PM callbacks.
> > >
> > > Some new helper macros for defining the PM callbacks are added.
> > >
> > > SET_PM_RUNTIME_PM_OPS; to define runtime PM callbacks for CONFIG_PM instead of
> > > CONFIG_PM_RUNTIME.
> > >
> > > SET_LATE_SYSTEM_SLEEP_PM_OPS; to define common late/early system PM callbacks,
> > > same approach is applicable to the existing SET_SYSTEM_SLEEP_PM_OPS which
> > > defines common suspend/resume system PM callbacks.
> > >
> > > A minor fix was needed for the platform bus, which runtime PM callbacks are set
> > > to the pm_generic_runtime_suspend|resume functions. These were implemented only
> > > for CONFIG_PM_RUNTIME and thus the platform bus prevented driver's runtime PM
> > > callbacks to be invoked when only CONFIG_PM_SLEEP was used. We move them into
> > > CONFIG_PM to resolve the problem.
> > >
> > > Changes in v2:
> > > Updated commit messages to try to better reflect the changes.
> > > Removed the below patches from this patch set. Let's leave those to be
> > > addressed separately, if needed.
> > > - PM / Sleep: Add pm_generic functions to re-use runtime PM callbacks
> > > - drm/exynos: Convert to suspend_late/resume_early callbacks for fimc
> > >
> > >
> > > Ulf Hansson (3):
> > > PM / Runtime: Add second macro for definition of runtime PM callbacks
> > > PM / Runtime: Implement the pm_generic_runtime functions for
> > > CONFIG_PM
> > > PM / Sleep: Add macro to define common late/early system PM callbacks
> > >
> > > drivers/base/power/generic_ops.c | 4 ++--
> > > include/linux/pm.h | 21 +++++++++++++++++++++
> > > include/linux/pm_runtime.h | 12 ++++++++----
> > > 3 files changed, 31 insertions(+), 6 deletions(-)
> > >
> > > --
> > > 1.7.9.5
> > >
> >
> > Hi,
> >
> > Just wanted to send a kind ping on this patchset.
> >
> > Would be nice to try to conclude on the way forward after the quite
> > long and good discussions we had around this topic.
>
> Sorry, I was traveling last week. I'm processing my backlog now, hopefully
> I'll get to your patches shortly.
So I've just queued them up for 3.14.
Thanks!
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-12-22 1:01 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-10 13:37 [PATCH V2 0/3] PM: Enable option of re-use runtime PM callbacks at system suspend Ulf Hansson
2013-12-10 13:37 ` [PATCH V2 1/3] PM / Runtime: Add second macro for definition of runtime PM callbacks Ulf Hansson
2013-12-10 13:37 ` [PATCH V2 2/3] PM / Runtime: Implement the pm_generic_runtime functions for CONFIG_PM Ulf Hansson
2013-12-10 13:37 ` [PATCH V2 3/3] PM / Sleep: Add macro to define common late/early system PM callbacks Ulf Hansson
2013-12-20 8:43 ` [PATCH V2 0/3] PM: Enable option of re-use runtime PM callbacks at system suspend Ulf Hansson
2013-12-20 13:18 ` Rafael J. Wysocki
2013-12-22 1:01 ` Rafael J. Wysocki
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).