PM / Domains: Add initial PM clock support to genpd
Subsystems (9)
cover PM / Domains: Add initial PM clock support to genpd
It's quite common for PM domains to use PM clocks. Typically from SOC specific code, the per device PM clock list is created and pm_clk_suspend|resume() are invoked to handle clock gating/ungating.
A step towards consolidation is to integrate PM clock support into genpd, which is what this patchset does.
In this initial step, the calls to the pm_clk_suspend|resume() are handled within genpd, but the per device PM clock list still needs to be created from SOC specific code. It seems reasonable to have gendp to handle that as well, but that left to future patchsets to address.
It's not every users of genpd that are keen on using PM clocks thus we need to provide this a configuration option for genpd.
In patch 2 and patch 3, we convert some of the SH-MOBILE SOCs to start using the new PM clock support in genpd.
Ulf Hansson (3):
PM / Domains: Initial PM clock support for genpd
ARM: shmobile: Convert to genpd flags for PM clocks for r8a7779
ARM: shmobile: Convert to genpd flags for PM clocks for R-mobile
arch/arm/mach-shmobile/pm-r8a7779.c | 3 +-- arch/arm/mach-shmobile/pm-rmobile.c | 3 +-- drivers/base/power/domain.c | 7 +++++++ include/linux/pm_domain.h | 3 +++ 4 files changed, 12 insertions(+), 4 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/3 PM / Domains: Initial PM clock support for genpd
It's quite common for PM domains to use PM clocks. Typically from SOC specific code, the per device PM clock list is created and pm_clk_suspend|resume() are invoked to handle clock gating/ungating.
A step towards consolidation is to integrate PM clock support into genpd, which is what this patch does.
In this initial step, the calls to the pm_clk_suspend|resume() are handled within genpd, but the per device PM clock list still needs to be created from SOC specific code. It seems reasonable to have gendp to handle that as well, but that left to future patches to address.
It's not every users of genpd that are keen on using PM clocks thus we need to provide this a configuration option for genpd. Therefore let's add flag field in the genpd struct to keep this information and define a new PM_DOMAIN_PM_CLK bit can then be set at initialization.
--- drivers/base/power/domain.c | 7 +++++++ include/linux/pm_domain.h | 3 +++ 2 files changed, 10 insertions(+)
drivers/base/power/domain.c +7 -0
@@ -12,6 +12,7 @@#include <linux/pm_runtime.h> #include <linux/pm_domain.h> #include <linux/pm_qos.h> +#include <linux/pm_clock.h> #include <linux/slab.h> #include <linux/err.h> #include <linux/sched.h>
@@ -1948,6 +1949,12 @@ void pm_genpd_init(struct generic_pm_domain *genpd, genpd->domain.ops.complete = pm_genpd_complete; genpd->dev_ops.save_state = pm_genpd_default_save_state; genpd->dev_ops.restore_state = pm_genpd_default_restore_state; + +if (genpd->flags &PM_DOMAIN_PM_CLK ) { + genpd->dev_ops.stop = pm_clk_suspend; + genpd->dev_ops.start = pm_clk_suspend; + } +mutex_lock (&gpd_list_lock);list_add (&genpd->gpd_list_node, &gpd_list);mutex_unlock (&gpd_list_lock);
include/linux/pm_domain.h +3 -0
@@ -14,6 +14,7 @@#include <linux/pm.h> #include <linux/err.h> #include <linux/of.h> +#include <linux/bitops.h> #include <linux/notifier.h> #include <linux/cpuidle.h>
@@ -76,6 +77,8 @@ struct generic_pm_domain { struct device *dev);void (*detach_dev)(struct generic_pm_domain *domain,struct device *dev); +unsigned int flags;/* Bit field of configs for genpd */ +#define PM_DOMAIN_PM_CLK BIT(0)/* PM domain use PM clk */ };static inline struct generic_pm_domain *pd_to_genpd (struct dev_pm_domain *pd)
Signature · 1 line
1.9.1
PATCH 1/3 PM / Domains: Initial PM clock support for genpd
Quoted 36 lines · Ulf Hansson
It's quite common for PM domains to use PM clocks. Typically from SOC specific code, the per device PM clock list is created and pm_clk_suspend|resume() are invoked to handle clock gating/ungating.
A step towards consolidation is to integrate PM clock support into genpd, which is what this patch does.
In this initial step, the calls to the pm_clk_suspend|resume() are handled within genpd, but the per device PM clock list still needs to be created from SOC specific code. It seems reasonable to have gendp to handle that as well, but that left to future patches to address.
It's not every users of genpd that are keen on using PM clocks thus we need to provide this a configuration option for genpd. Therefore let's add flag field in the genpd struct to keep this information and define a new
PM_DOMAIN_PM_CLKbit can then be set at initialization.Signed-off-by Ulf Hansson <[email protected]>--- drivers/base/power/domain.c | 7 +++++++ include/linux/pm_domain.h | 3 +++ 2 files changed, 10 insertions(+)drivers/base/power/domain.c +1
-0@@ -12,6 +12,7 @@#include <linux/pm_runtime.h> #include <linux/pm_domain.h> #include <linux/pm_qos.h> +#include <linux/pm_clock.h> #include <linux/slab.h> #include <linux/err.h> #include <linux/sched.h>
drivers/base/power/domain.c void pm_genpd_init(struct generic_pm_domain *genpd, · line 1955
Quoted 7 lines
drivers/base/power/domain.c +4
-0@@ -1948,6 +1949,12 @@ void pm_genpd_init(struct generic_pm_domain *genpd, genpd->domain.ops.complete = pm_genpd_complete; genpd->dev_ops.save_state = pm_genpd_default_save_state; genpd->dev_ops.restore_state = pm_genpd_default_restore_state; + +if (genpd->flags &PM_DOMAIN_PM_CLK ) { + genpd->dev_ops.stop = pm_clk_suspend; + genpd->dev_ops.start = pm_clk_suspend;
The 2nd one is wrong.
Quoted 18 lines
drivers/base/power/domain.c +2
-0+ } +mutex_lock (&gpd_list_lock);list_add (&genpd->gpd_list_node, &gpd_list);mutex_unlock (&gpd_list_lock);include/linux/pm_domain.h +1
-0@@ -14,6 +14,7 @@#include <linux/pm.h> #include <linux/err.h> #include <linux/of.h> +#include <linux/bitops.h> #include <linux/notifier.h> #include <linux/cpuidle.h>
include/linux/pm_domain.h struct generic_pm_domain { · line 81
Quoted 5 lines
include/linux/pm_domain.h +2
-0@@ -76,6 +77,8 @@ struct generic_pm_domain { struct device *dev);void (*detach_dev)(struct generic_pm_domain *domain,struct device *dev); +unsigned int flags;/* Bit field of configs for genpd */ +#define PM_DOMAIN_PM_CLK BIT(0)/* PM domain use PM clk */
s/use/uses ?
Are you planning on adding a separate flag for collecting clocks from OF on attach/detach?
Quoted 6 lines
include/linux/pm_domain.h +0
-0};static inline struct generic_pm_domain *pd_to_genpd (struct dev_pm_domain *pd)Signature · 1 line
1.9.1
Thanks.
Signature · 1 line
Dmitry
PATCH 1/3 PM / Domains: Initial PM clock support for genpd
Quoted 38 lines · Dmitry Torokhov
Quoted 37 lines · Ulf Hansson
It's quite common for PM domains to use PM clocks. Typically from SOC specific code, the per device PM clock list is created and pm_clk_suspend|resume() are invoked to handle clock gating/ungating.
A step towards consolidation is to integrate PM clock support into genpd, which is what this patch does.
In this initial step, the calls to the pm_clk_suspend|resume() are handled within genpd, but the per device PM clock list still needs to be created from SOC specific code. It seems reasonable to have gendp to handle that as well, but that left to future patches to address.
It's not every users of genpd that are keen on using PM clocks thus we need to provide this a configuration option for genpd. Therefore let's add flag field in the genpd struct to keep this information and define a new
PM_DOMAIN_PM_CLKbit can then be set at initialization.Signed-off-by Ulf Hansson <[email protected]>--- drivers/base/power/domain.c | 7 +++++++ include/linux/pm_domain.h | 3 +++ 2 files changed, 10 insertions(+)drivers/base/power/domain.c +1
-0@@ -12,6 +12,7 @@#include <linux/pm_runtime.h> #include <linux/pm_domain.h> #include <linux/pm_qos.h> +#include <linux/pm_clock.h> #include <linux/slab.h> #include <linux/err.h> #include <linux/sched.h> @@ -1948,6 +1949,12 @@ void pm_genpd_init(struct generic_pm_domain *genpd, genpd->domain.ops.complete = pm_genpd_complete;
Quoted 8 lines
drivers/base/power/domain.c void pm_genpd_init(struct generic_pm_domain *genpd, · line 1955
Quoted 6 lines
drivers/base/power/domain.c +4
-0genpd->dev_ops.save_state = pm_genpd_default_save_state; genpd->dev_ops.restore_state = pm_genpd_default_restore_state; + +if (genpd->flags &PM_DOMAIN_PM_CLK ) { + genpd->dev_ops.stop = pm_clk_suspend; + genpd->dev_ops.start = pm_clk_suspend;The 2nd one is wrong.
Huh, thanks for spotting this.
Quoted 27 lines
Quoted 19 lines
drivers/base/power/domain.c +2
-0+ } +mutex_lock (&gpd_list_lock);list_add (&genpd->gpd_list_node, &gpd_list);mutex_unlock (&gpd_list_lock);include/linux/pm_domain.h +1
-0@@ -14,6 +14,7 @@#include <linux/pm.h> #include <linux/err.h> #include <linux/of.h> +#include <linux/bitops.h> #include <linux/notifier.h> #include <linux/cpuidle.h> include/linux/pm_domain.h struct generic_pm_domain { · line 81
Quoted 5 lines
include/linux/pm_domain.h +2
-0@@ -76,6 +77,8 @@ struct generic_pm_domain { struct device *dev);void (*detach_dev)(struct generic_pm_domain *domain,struct device *dev); +unsigned int flags;/* Bit field of configs for genpd */ +#define PM_DOMAIN_PM_CLK BIT(0)/* PM domain use PM clk */ s/use/uses ?
Quoted 2 lines
Are you planning on adding a separate flag for collecting clocks from OF on attach/detach?
Yes, I am thinking on that approach. Do you have any suggestions around this?
Kind regards
Uffe
PATCH 2/3 ARM: shmobile: Convert to genpd flags for PM clocks for r8a7779
In reply to Ulf HanssonInstead of using the dev_ops ->stop|start() callbacks for genpd, let's convert to use genpd's flag field and set it to PM_DOMAIN_PM_CLK.
--- arch/arm/mach-shmobile/pm-r8a7779.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/mach-shmobile/pm-r8a7779.c +1 -2
@@ -83,9 +83,8 @@ static void r8a7779_init_pm_domain(struct r8a7779_pm_domain *r8a7779_pd) {struct generic_pm_domain *genpd = &r8a7779_pd->genpd; + genpd->flags =PM_DOMAIN_PM_CLK ;pm_genpd_init (genpd,NULL , false); - genpd->dev_ops.stop = pm_clk_suspend; - genpd->dev_ops.start = pm_clk_resume; genpd->dev_ops.active_wakeup = pd_active_wakeup; genpd->power_off = pd_power_down; genpd->power_on = pd_power_up;
Signature · 1 line
1.9.1
PATCH 3/3 ARM: shmobile: Convert to genpd flags for PM clocks for R-mobile
In reply to Ulf HanssonInstead of using the dev_ops ->stop|start() callbacks for genpd, let's convert to use genpd's flag field and set it to PM_DOMAIN_PM_CLK.
--- arch/arm/mach-shmobile/pm-rmobile.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/mach-shmobile/pm-rmobile.c +1 -2
@@ -106,9 +106,8 @@ static void rmobile_init_pm_domain(struct rmobile_pm_domain *rmobile_pd)struct generic_pm_domain *genpd = &rmobile_pd->genpd;struct dev_power_governor *gov = rmobile_pd->gov; + genpd->flags =PM_DOMAIN_PM_CLK ;pm_genpd_init (genpd, gov ? : &simple_qos_governor, false); - genpd->dev_ops.stop = pm_clk_suspend; - genpd->dev_ops.start = pm_clk_resume; genpd->dev_ops.active_wakeup = rmobile_pd_active_wakeup; genpd->power_off = rmobile_pd_power_down; genpd->power_on = rmobile_pd_power_up;
Signature · 1 line
1.9.1
cover PM / Domains: Add initial PM clock support to genpd
In reply to Ulf HanssonHi Ulf,
Quoted 6 lines · Ulf Hansson
It's quite common for PM domains to use PM clocks. Typically from SOC specific code, the per device PM clock list is created and pm_clk_suspend|resume() are invoked to handle clock gating/ungating.
A step towards consolidation is to integrate PM clock support into genpd, which is what this patchset does.
Thanks, this sounds like a good idea.
Quoted 3 lines
In this initial step, the calls to the pm_clk_suspend|resume() are handled within genpd, but the per device PM clock list still needs to be created from SOC specific code. It seems reasonable to have gendp to handle that as well, but
s/gendp/genpd/
Quoted 1 line
that left to future patchsets to address.
If/when genpd will handle the clock creation, perhaps the flag can just be replaced by a pointer to a list of clocks?
Or do you have other uses in mind for adding the flags field now?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
cover PM / Domains: Add initial PM clock support to genpd
In reply to Ulf HanssonQuoted 11 lines · Ulf Hansson
It's quite common for PM domains to use PM clocks. Typically from SOC specific code, the per device PM clock list is created and pm_clk_suspend|resume() are invoked to handle clock gating/ungating.
A step towards consolidation is to integrate PM clock support into genpd, which is what this patchset does.
In this initial step, the calls to the pm_clk_suspend|resume() are handled within genpd, but the per device PM clock list still needs to be created from SOC specific code. It seems reasonable to have gendp to handle that as well, but that left to future patchsets to address.
I think we need to get rid of the SoC specific code already. For example, we're already seeing SoCs where the arm32 core is being replaced by an arm64 core but the other IPs, and power-domain logic is staying more or less the same.
Quoted 2 lines
It's not every users of genpd that are keen on using PM clocks thus we need to provide this a configuration option for genpd.
Or more likely, probably some compatible string, or property in the domain node. Grygorii, Arnd and myself were discussing this elsewhere in the context of the TI Keystone2 PM domain support[1].
Kevin
[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-November/304099.html
cover PM / Domains: Add initial PM clock support to genpd
Quoted 19 lines · Kevin Hilman
Quoted 11 lines · Ulf Hansson
It's quite common for PM domains to use PM clocks. Typically from SOC specific code, the per device PM clock list is created and pm_clk_suspend|resume() are invoked to handle clock gating/ungating.
A step towards consolidation is to integrate PM clock support into genpd, which is what this patchset does.
In this initial step, the calls to the pm_clk_suspend|resume() are handled within genpd, but the per device PM clock list still needs to be created from SOC specific code. It seems reasonable to have gendp to handle that as well, but that left to future patchsets to address.
I think we need to get rid of the SoC specific code already. For example, we're already seeing SoCs where the arm32 core is being replaced by an arm64 core but the other IPs, and power-domain logic is staying more or less the same.
Quoted 6 lines
Quoted 2 lines
It's not every users of genpd that are keen on using PM clocks thus we need to provide this a configuration option for genpd.
Or more likely, probably some compatible string, or property in the domain node. Grygorii, Arnd and myself were discussing this elsewhere in the context of the TI Keystone2 PM domain support[1].
Thanks for pointing that out. It was actually the reason to why I posted this patchset now, I have been keeping the patches locally in my tree for too long. :-)
Let me comment of that thread, instead of here.
Kind regards
Uffe