Skip to contentSkip to conversation

PM / Domains: Add initial PM clock support to genpd

PATCH Superseded Ulf Hansson 3 participants 7 messages Nov 28, 2014 – Dec 1, 2014

Subsystems (10)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover PM / Domains: Add initial PM clock support to genpd

Changes in v3:
-Fixed comments from Rafael for patch 1. -Change name of define, affects all patches.

Changes in v2:
-Small fixes in patch 1.

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           | 4 ++++
 4 files changed, 13 insertions(+), 4 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH v3 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 GENDP_PM_CLK bit for it.

---

Changes in v3:
Moved define out of struct definition.
Don't use bitops.h
Rename define to GENDP_PM_CLK.

Changes in v2:

	Set ->start() callback to pm_clk_resume() and fixed comment.
---
 drivers/base/power/domain.c | 7 +++++++
 include/linux/pm_domain.h   | 4 ++++
 2 files changed, 11 insertions(+)
drivers/base/power/domain.c +7 -0
index 735c473..a2424a7 100644
@@ -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>
@@ -1928,6 +1929,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 & GENPD_PM_CLK) {
+		genpd->dev_ops.stop = pm_clk_suspend;
+		genpd->dev_ops.start = pm_clk_resume;
+	}
+
 	mutex_lock(&gpd_list_lock);
 	list_add(&genpd->gpd_list_node, &gpd_list);
 	mutex_unlock(&gpd_list_lock);
include/linux/pm_domain.h +4 -0
index 8cbd32e..173cc67 100644
@@ -17,6 +17,9 @@
 #include <linux/notifier.h>
 #include <linux/cpuidle.h>
 
+/* Defines used for the flags field in the struct generic_pm_domain */
+#define GENPD_PM_CLK		(1U << 0) /* PM domain uses PM clk */
+
 enum gpd_status {
 	GPD_STATE_ACTIVE = 0,	/* PM domain is active */
 	GPD_STATE_WAIT_MASTER,	/* PM domain's master is being waited for */
@@ -76,6 +79,7 @@ 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 */
 };
 
 static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd)
Signature · 1 line
1.9.1
#2 lore raw

PATCH v3 1/3 PM / Domains: Initial PM clock support for genpd

Quoted 63 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 GENDP_PM_CLK bit for it.

---

Changes in v3:
Moved define out of struct definition.
Don't use bitops.h
Rename define to GENDP_PM_CLK.

Changes in v2:

	Set ->start() callback to pm_clk_resume() and fixed comment.
---
 drivers/base/power/domain.c | 7 +++++++
 include/linux/pm_domain.h   | 4 ++++
 2 files changed, 11 insertions(+)
drivers/base/power/domain.c +7 -0
index 735c473..a2424a7 100644
@@ -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>
@@ -1928,6 +1929,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 & GENPD_PM_CLK) {
+		genpd->dev_ops.stop = pm_clk_suspend;
+		genpd->dev_ops.start = pm_clk_resume;
+	}
+
 	mutex_lock(&gpd_list_lock);
 	list_add(&genpd->gpd_list_node, &gpd_list);
 	mutex_unlock(&gpd_list_lock);
include/linux/pm_domain.h +0 -0
index 8cbd32e..173cc67 100644

include/linux/pm_domain.h line 21

Quoted 5 lines
include/linux/pm_domain.h +2 -0
@@ -17,6 +17,9 @@
 #include <linux/notifier.h>
 #include <linux/cpuidle.h>
 
+/* Defines used for the flags field in the struct generic_pm_domain */
+#define GENPD_PM_CLK		(1U << 0) /* PM domain uses PM clk */

I'd prefer GENPD_FLAG_PM_CLK to indicate in the name that this is, well, a flag.

Otherwise it looks OK to me.

If you want me to apply [2-3/3] too, ACKs from the ARM/shmobile maintainers are needed.

Quoted 13 lines
include/linux/pm_domain.h +2 -0
+
 enum gpd_status {
 	GPD_STATE_ACTIVE = 0,	/* PM domain is active */
 	GPD_STATE_WAIT_MASTER,	/* PM domain's master is being waited for */
@@ -76,6 +79,7 @@ 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 */
 };
 
 static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd)
Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#3 lore raw

PATCH v3 2/3 ARM: shmobile: Convert to genpd flags for PM clocks for r8a7779

In reply to Ulf Hansson

Instead of using the dev_ops ->stop|start() callbacks for genpd, let's convert to use genpd's flag field and set it to GENPD_PM_CLK.

---

Changes in v3:
Convert to renamed define.

Changes in v2:
None.

---
 arch/arm/mach-shmobile/pm-r8a7779.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/mach-shmobile/pm-r8a7779.c +1 -2
index 82fe3d7..3a09ae7 100644
@@ -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 = GENPD_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
#4 lore raw

PATCH v3 3/3 ARM: shmobile: Convert to genpd flags for PM clocks for R-mobile

In reply to Ulf Hansson

Instead of using the dev_ops ->stop|start() callbacks for genpd, let's convert to use genpd's flag field and set it to GENPD_PM_CLK.

---

Changes in v3:
Convert to renamed define.

Changes in v2:
None.

---
 arch/arm/mach-shmobile/pm-rmobile.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/mach-shmobile/pm-rmobile.c +1 -2
index 717e641..5aa277d 100644
@@ -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 = GENPD_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
#5 lore raw

PATCH v3 3/3 ARM: shmobile: Convert to genpd flags for PM clocks for R-mobile

Quoted 4 lines · Ulf Hansson

Instead of using the dev_ops ->stop|start() callbacks for genpd, let's convert to use genpd's flag field and set it to GENPD_PM_CLK.

(tested on r8a7740/armadillo-multiplatform and sh73a0/kzm9g-multiplatform).

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

#6 lore raw

v3 cover PM / Domains: Add initial PM clock support to genpd

In reply to Ulf Hansson
Quoted 32 lines · Ulf Hansson

Changes in v3:
-Fixed comments from Rafael for patch 1. -Change name of define, affects all patches.

Changes in v2:
-Small fixes in patch 1.

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

Quoted 5 lines
 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           | 4 ++++
 4 files changed, 13 insertions(+), 4 deletions(-)

For the series:

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