Skip to contentSkip to conversation

PM: introduce voltage domain abstraction

RFC PATCH In review Nishanth Menon 4 participants 22 messages Feb 18, 2014 – Mar 19, 2014

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover PM: introduce voltage domain abstraction

Hi,

On many SoCs such as OMAP, hardware blocks are isolated into voltage domains allowing for individual tweaks for optimal power-performance tradeoffs. Frameworks such as cpufreq, devfreq provide a top level control of these hardware blocks. Most SoCs have different knobs to fine tune the voltages. They may supply multiple supplies to various voltage planes on the same voltage domains.

Regulator framework provides us a with an appropriate representation of consumer model, however, we lack the abstraction necessary to isolate the necessary sequencing for a specific voltage domain.

There has been few attempts previously taken such as [3] [4], this series is a further development of of Mike's series[1] where cpufreq-cpu0 driver was first targetted with clk notifiers. While I do understand the concerns Mike has in [2], this could be a base on which further work may be done.

In a nutshell, this (for cpufreq-cpu0 as an example):
maintains the legacy definitions used by cpufreq/devfreq such as:

&cpu0 {
	cpu0-supply = <&regulator_x>;
};

on other SoCs where this might turn out to be a more detailed implementation,

&cpu0 {
	cpu0-voltdm = <&voltdm_x>;
};

To enure this is split off from clk framework, I chose drivers/power/voltdm as the location for the new files, I'd love to hear opinions and suggestions on the approach.

The series is based on 3.14-rc3 and is available here:
https://github.com/nmenon/linux-2.6-playground/commits/push/voltdm-notifier-rfc

A testing branch for Beagle-XM (OMAP3630 as testbed):

	https://github.com/nmenon/linux-2.6-playground/commits/testing/beagle-xm-voltdm-notifier-rfc
	Log: http://slexy.org/view/s20TgkN7kf

NOTE: TI platforms potentially need further development, however, this forms the basis of the development.

Mike Turquette (2):
PM / Voltagedomain: Add generic clk notifier handler for regulator
based dynamic voltage scaling
cpufreq: cpufreq-cpu0: use clk rate-change notifiers

Nishanth Menon (4):
PM / Voltagedomain: introduce voltage domain driver support
devicetree: bindings: add documentation for voltagedomain PM / Voltagedomain: introduce basic voltage domain support for OMAP
devicetree: bindings: voltagedomain: add bindings for OMAP compatible
SoCs

 .../bindings/power/voltdm/voltage_domain.txt       |   65 +++
 .../bindings/power/voltdm/voltdm_omap.txt          |   24 +
 drivers/cpufreq/Kconfig                            |    1 +
 drivers/cpufreq/cpufreq-cpu0.c                     |  140 ++----
 drivers/power/Kconfig                              |    1 +
 drivers/power/Makefile                             |    1 +
 drivers/power/voltdm/Kconfig                       |   19 +
 drivers/power/voltdm/Makefile                      |    6 +
 drivers/power/voltdm/core.c                        |  508 ++++++++++++++++++++
 drivers/power/voltdm/voltage_domain_private.h      |   86 ++++
 drivers/power/voltdm/voltdm_omap.c                 |  287 +++++++++++
 include/linux/pm_voltage_domain.h                  |   47 ++
 12 files changed, 1086 insertions(+), 99 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/power/voltdm/voltage_domain.txt
 create mode 100644 Documentation/devicetree/bindings/power/voltdm/voltdm_omap.txt
 create mode 100644 drivers/power/voltdm/Kconfig
 create mode 100644 drivers/power/voltdm/Makefile
 create mode 100644 drivers/power/voltdm/core.c
 create mode 100644 drivers/power/voltdm/voltage_domain_private.h
 create mode 100644 drivers/power/voltdm/voltdm_omap.c
 create mode 100644 include/linux/pm_voltage_domain.h

[1] https://lkml.org/lkml/2013/7/7/110 (original RFC)
[2] http://marc.info/?l=linux-arm-kernel&m=137947787621572&w=2 (runtime pm should enable regulator)
[3] http://marc.info/?t=136603111700006&r=1&w=2
[4] http://git.omapzoom.org/?p=kernel/omap.git;a=blob;f=arch/arm/mach-omap2/dvfs.c;hb=p-linux-omap-3.4

Signature · 1 line
1.7.9.5
#1 lore raw

RFC PATCH 1/6 PM / Voltagedomain: Add generic clk notifier handler for regulator based dynamic voltage scaling

From: Mike Turquette <[email protected]>

This patch provides helper functions for drivers that wish to scale voltage through the clock rate-change notifiers. The approach taken is that the user-driver(cpufreq/devfreq) do not care about the details of the OPP table, nor does it care about handling the voltage regulator directly.

By using the clk notifier flags, we are able to sequence the operations in the right order. The current logic is heavily influenced by implementation done in cpufreq-cpu0.

[[email protected]: Fixes in logic, and broken out from clk to allow building a generic voltagedomain solution independent of cpufreq]

---
 drivers/power/Kconfig             |    1 +
 drivers/power/Makefile            |    1 +
 drivers/power/voltdm/Kconfig      |    7 ++
 drivers/power/voltdm/Makefile     |    2 +
 drivers/power/voltdm/core.c       |  195 +++++++++++++++++++++++++++++++++++++
 include/linux/pm_voltage_domain.h |   47 +++++++++
 6 files changed, 253 insertions(+)
 create mode 100644 drivers/power/voltdm/Kconfig
 create mode 100644 drivers/power/voltdm/Makefile
 create mode 100644 drivers/power/voltdm/core.c
 create mode 100644 include/linux/pm_voltage_domain.h
drivers/power/Kconfig +1 -0
index ba69751..5c4fe16 100644
@@ -394,3 +394,4 @@ source "drivers/power/reset/Kconfig"
 endif # POWER_SUPPLY
 
 source "drivers/power/avs/Kconfig"
+source "drivers/power/voltdm/Kconfig"
drivers/power/Makefile +1 -0
index ee54a3e..3d47072 100644
@@ -58,3 +58,4 @@ obj-$(CONFIG_POWER_AVS)		+= avs/
 obj-$(CONFIG_CHARGER_SMB347)	+= smb347-charger.o
 obj-$(CONFIG_CHARGER_TPS65090)	+= tps65090-charger.o
 obj-$(CONFIG_POWER_RESET)	+= reset/
+obj-$(CONFIG_VOLTAGE_DOMAIN)	+= voltdm/
drivers/power/voltdm/Kconfig new file +7 -0
new file mode 100644
index 0000000..c5353bd
@@ -0,0 +1,7 @@
+config VOLTAGE_DOMAIN
+	bool
+	depends on COMMON_CLK && OF && PM_OPP
+	default y if COMMON_CLK
+	---help---
+	  Core voltage domain framework using common clock framework's
+	  notifier mechanism.
drivers/power/voltdm/Makefile new file +2 -0
new file mode 100644
index 0000000..3fa4408
@@ -0,0 +1,2 @@
+# Generic voltage domain
+obj-$(CONFIG_VOLTAGE_DOMAIN)	+= core.o
drivers/power/voltdm/core.c new file +195 -0

195 lines not on this page · raw message

include/linux/pm_voltage_domain.h new file +47 -0

47 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#2 lore raw

Re: [RFC PATCH 1/6] PM / Voltagedomain: Add generic clk notifier handler for regulator based dynamic voltage scaling

Quoting Nishanth Menon (2014-02-18 12:32:18)

Quoted 8 lines

From: Mike Turquette <[email protected]>

This patch provides helper functions for drivers that wish to scale voltage through the clock rate-change notifiers. The approach taken is that the user-driver(cpufreq/devfreq) do not care about the details of the OPP table, nor does it care about handling the voltage regulator directly.

Quoted 8 lines

By using the clk notifier flags, we are able to sequence the operations in the right order. The current logic is heavily influenced by implementation done in cpufreq-cpu0.

[[email protected]: Fixes in logic, and broken out from clk to allow building a generic voltagedomain solution independent of cpufreq]

I haven't reviewed this series and it is a pretty big deviation from my original RFC. You can have authorship of the patches if you want.

I'm not sure about trying to capture the "voltdm" as a core concept. It feels a bit unwieldy to me. I have wondered about making an abstract "performance domain" which is the dvfs analogue to generic power domains. This a reasonable split since gpd are good for idle power savings (e.g. clock gate, power gate, sleep state, etc) and "perf domains" would be good for active power savings (dvfs).

Having a generic container for performance domains might make a good place to stuff all of this glue logic that we keep running into (e.g. CPU and GPU max frequencies that are related), and it might make another nice knob for the thermal folks to use.

For the case of the OMAP voltage domains, it would be a place to stuff all of the VC/VP -> ABB -> Smart Reflex AVS stuff.

Anyways, I don't have a real proposal. I just don't want my name on these patches since they are really yours now. I might resurrect them some day in a different context.

Regards,
Mike

#3 lore raw

Re: [RFC PATCH 1/6] PM / Voltagedomain: Add generic clk notifier handler for regulator based dynamic voltage scaling

Hi Mike,

Quoted 18 lines · Mike Turquette

Quoting Nishanth Menon (2014-02-18 12:32:18)

Quoted 8 lines

From: Mike Turquette <[email protected]>

This patch provides helper functions for drivers that wish to scale voltage through the clock rate-change notifiers. The approach taken is that the user-driver(cpufreq/devfreq) do not care about the details of the OPP table, nor does it care about handling the voltage regulator directly.

Quoted 8 lines

By using the clk notifier flags, we are able to sequence the operations in the right order. The current logic is heavily influenced by implementation done in cpufreq-cpu0.

[[email protected]: Fixes in logic, and broken out from clk to allow building a generic voltagedomain solution independent of cpufreq]

Quoted 4 lines

I haven't reviewed this series and it is a pretty big deviation from my original RFC. You can have authorship of the patches if you want.

Sure, I had send a private note requesting clarification about the authorship, but I guess I can take this as the response :).

Quoted 3 lines

I'm not sure about trying to capture the "voltdm" as a core concept. It feels a bit unwieldy to me.

Considering it is a simple collation of regulators and SoC specific "magic" which have to be operated in tandem to clock operation, Why does it seem unwieldy? Usage of multiple voltage planes in a single voltage domain concept does not seem unique to TI processors either:
For example, imx6q-cpufreq.c uses 3 regulators (arm, pu, soc), s5pv210-cpufreq.c uses two regulators (vddarm, vddint), ideally OMAP implementation would use two (vdd_mpu, vbb_mpu).

Quoted 10 lines

I have wondered about making an abstract
"performance domain" which is the dvfs analogue to generic power domains. This a reasonable split since gpd are good for idle power savings (e.g. clock gate, power gate, sleep state, etc) and "perf domains" would be good for active power savings (dvfs).

Having a generic container for performance domains might make a good place to stuff all of this glue logic that we keep running into (e.g. CPU and GPU max frequencies that are related), and it might make another nice knob for the thermal folks to use.

This sounds like one level higher abstraction that we are speaking of here? I was'nt intending to solve the bigger picture problem here - just an abstraction level that might allow reusablity for multiple SoCs. In fact, having an abstraction away for voltage domain(which may consist of multiple regulators and any SoC specific magic) purely allows us to move towards a direction you mention here.

Quoted 4 lines

For the case of the OMAP voltage domains, it would be a place to stuff all of the VC/VP -> ABB -> Smart Reflex AVS stuff.

Unfortunately, I dont completely comprehend objection we have to this approach (other than an higher level abstraction is needed) and if we do have an objection, what is the alternate approach should be for representing hardware which this series attempts to present.

Signature · 2 lines
Regards,
Nishanth Menon
#4 lore raw

Re: [RFC PATCH 1/6] PM / Voltagedomain: Add generic clk notifier handler for regulator based dynamic voltage scaling

Quoted 2 lines · Nishanth Menon
Quoted 1 line · Mike Turquette

Quoting Nishanth Menon (2014-02-18 12:32:18)

[...]

Quoted 30 lines
Quoted 2 lines

I'm not sure about trying to capture the "voltdm" as a core concept. It feels a bit unwieldy to me.

Considering it is a simple collation of regulators and SoC specific "magic" which have to be operated in tandem to clock operation, Why does it seem unwieldy? Usage of multiple voltage planes in a single voltage domain concept does not seem unique to TI processors either:
For example, imx6q-cpufreq.c uses 3 regulators (arm, pu, soc), s5pv210-cpufreq.c uses two regulators (vddarm, vddint), ideally OMAP implementation would use two (vdd_mpu, vbb_mpu).

Quoted 10 lines

I have wondered about making an abstract
"performance domain" which is the dvfs analogue to generic power domains. This a reasonable split since gpd are good for idle power savings (e.g. clock gate, power gate, sleep state, etc) and "perf domains" would be good for active power savings (dvfs).

Having a generic container for performance domains might make a good place to stuff all of this glue logic that we keep running into (e.g. CPU and GPU max frequencies that are related), and it might make another nice knob for the thermal folks to use.

This sounds like one level higher abstraction that we are speaking of here? I was'nt intending to solve the bigger picture problem here - just an abstraction level that might allow reusablity for multiple SoCs. In fact, having an abstraction away for voltage domain(which may consist of multiple regulators and any SoC specific magic) purely allows us to move towards a direction you mention here.

Quoted 1 line
Quoted 8 lines
Quoted 3 lines

For the case of the OMAP voltage domains, it would be a place to stuff all of the VC/VP -> ABB -> Smart Reflex AVS stuff.

Unfortunately, I dont completely comprehend objection we have to this approach (other than an higher level abstraction is needed) and if we do have an objection, what is the alternate approach should be for representing hardware which this series attempts to present.

I think the following is around the lines of your thought direction - if Rafael or others have comments on the following approach, it'd be a good starting point for me to progress.

-->8--
From 62e50b9f920495db88e5594aa6bceb52e83a443d Mon Sep 17 00:00:00 2001
From: Nishanth Menon <[email protected]>
Date: Wed, 26 Feb 2014 10:59:59 -0600
Subject: [PATCH] PM / Runtime: introduce active power management callbacks
for pm_domain

dev_pm_domain currently handles just device idle power management using the generic pm_runtime_get|put and related family of functions.

Logically with appropriate pm_domain hooks this can translate to hardware specific clock and related operations. Given that pm_domains may contain this information, this provides an opportunity to extend current pm_runtime do dynamic power operations as well.

What this means for drivers is as follows:

Today, drivers(with some level of complexity) do:
pm_runtime_get_sync(dev);
clk = clk_get(dev, "name");
old_rate = clk_get_rate(clk);
...
clk_set_rate(clk, new_rate);
...
clk_put(clk);
pm_runtime_get_sync(dev);

Instead, on pm_domains that can handle this as part of pm_domain->active_ops functions, They can now do the following:
pm_runtime_get_sync(dev);
old_rate = pm_runtime_get_rate(dev);
...
pm_runtime_set_rate(dev, new_rate);
...
pm_runtime_put_sync(dev);

Obviously, this'd work for devices that handle a single main functional clock, but this could reduce complexity of drivers having to deal with power management details to have pm_runtime as the main point of interface.

CAVEAT: For power domains that are capable of handling multiple clocks (example on OMAP, where there are the concepts of interface, functional and optional clocks per block), appropriate handling will be necessary from pm_domain callbacks. So, the question about which clock rate is being controlled or returned to is entirely upto the pm_domain implementation.

On the otherhand, we can debate about defining and querying ACPI style "Performance state" instead of frequencies and wrap P-states inside or the other way around.. but given that majority of drivers using pm_runtime would rather be interested in frequencies and my naieve belief that we can index P-states with frequencies, kind of influenced my choice here of proposing frequencies as base query parameter.. ofcourse, debate is still open here.

Yes, we can still debate if providing yet another wrapper on top of clock APIs makes sense at all as well.

---
 drivers/base/power/runtime.c |  101 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/pm.h           |   25 +++++++++--
 include/linux/pm_runtime.h   |   21 +++++++++
 3 files changed, 143 insertions(+), 4 deletions(-)
drivers/base/power/runtime.c +101 -0
index 72e00e6..ef230b4 100644
@@ -1401,3 +1401,104 @@ void pm_runtime_remove(struct device *dev)
 	if (dev->power.irq_safe && dev->parent)
 		pm_runtime_put(dev->parent);
 }
+
+/**
+ * pm_runtime_get_rate() - Returns the device operational frequency
+ * @dev:	Device to handle
+ * @rate:	Returns rate in Hz.
+ *
+ * Returns appropriate error value in case of error conditions, else
+ * returns 0 and rate is updated. The pm_domain logic does all the necessary
+ * operation (which may consider magic hardware stuff) to provide the rate.
+ *
+ * NOTE: the rate returned is a snapshot and in many cases just a bypass
+ * to clk api to set the rate.
+ */
+int pm_runtime_get_rate(struct device *dev, unsigned long *rate)
+{
+	unsigned long flags;
+	int error = -ENOSYS;
+
+	if (!rate || !dev)
+		return -EINVAL;
+
+	spin_lock_irqsave(&dev->power.lock, flags);
+	if (!pm_runtime_active(dev)) {
+		error = -EINVAL;
+		goto out;
+	}
+
+	if (dev->pm_domain && dev->pm_domain->active_ops.get_rate)
+		error = dev->pm_domain->active_ops.get_rate(dev, rate);
+out:
+	spin_unlock_irqrestore(&dev->power.lock, flags);
+
+	return error;
+}
+
+/**
+ * pm_runtime_set_rate() - Set a specific rate for the device operation
+ * @dev:	Device to handle
+ * @rate:	Rate to set in Hz
+ *
+ * Returns appropriate error value in case of error conditions, else
+ * returns 0. The pm_domain logic does all the necessary operation (which
+ * may include voltage scale operations or other magic hardware stuff) to
+ * achieve the operation. It is guarenteed that the requested rate is achieved
+ * on returning from this function if return value is 0.
+ */
+int pm_runtime_set_rate(struct device *dev, unsigned long rate)
+{
+	unsigned long flags;
+	int error = -ENOSYS;
+
+	if (!rate || !dev)
+		return -EINVAL;
+
+	spin_lock_irqsave(&dev->power.lock, flags);
+	if (!pm_runtime_active(dev)) {
+		error = -EINVAL;
+		goto out;
+	}
+
+	if (dev->pm_domain && dev->pm_domain->active_ops.set_rate)
+		error = dev->pm_domain->active_ops.set_rate(dev, rate);
+out:
+	spin_unlock_irqrestore(&dev->power.lock, flags);
+
+	return error;
+}
+
+/**
+ * pm_runtime_get_transition_latency() - determine transition latency`
+ * @dev:	Device to handle
+ * @from_rate:	Transition from which rate
+ * @to_rate:	Transition to which rate
+ *
+ * Returns appropriate error value in case of error conditions, else
+ * returns the latency in uSecs for transition between two given rates
+ */
+int pm_runtime_get_transition_latency(struct device *dev,
+				      unsigned long from_rate,
+				      unsigned long to_rate)
+{
+	unsigned long flags;
+	int error = -ENOSYS;
+
+	if (!from_rate || !to_rate || !dev)
+		return -EINVAL;
+
+	spin_lock_irqsave(&dev->power.lock, flags);
+	if (!pm_runtime_active(dev)) {
+		error = -EINVAL;
+		goto out;
+	}
+
+	if (dev->pm_domain && dev->pm_domain->active_ops.get_transition_latency)
+		error = dev->pm_domain->active_ops.get_transition_latency(dev,
+				from_rate, to_rate);
+out:
+	spin_unlock_irqrestore(&dev->power.lock, flags);
+
+	return error;
+}
include/linux/pm.h +21 -4
index 8c6583a..f907b27 100644
@@ -299,6 +299,20 @@ struct dev_pm_ops {
 	int (*runtime_idle)(struct device *dev);
 };
 
+/**
+ * struct dev_pm_active_ops - Active power management operations
+ * @get_rate:	get the current operational frequency
+ * @set_rate:	set the current operational frequency
+ * @get_transition_latency: get the transition latency in uSeconds
+ */
+struct dev_pm_active_ops {
+	int (*get_rate)(struct device *dev, unsigned long *rate);
+	int (*set_rate)(struct device *dev, unsigned long rate);
+	int (*get_transition_latency)(struct device *dev,
+				      unsigned long from_rate,
+				      unsigned long to_rate);
+};
+
 #ifdef CONFIG_PM_SLEEP
 #define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
 	.suspend = suspend_fn, \
@@ -589,13 +603,16 @@ extern void update_pm_runtime_accounting(struct device *dev);
 extern int dev_pm_get_subsys_data(struct device *dev);
 extern int dev_pm_put_subsys_data(struct device *dev);
 
-/*
- * Power domains provide callbacks that are executed during system suspend,
- * hibernation, system resume and during runtime PM transitions along with
- * subsystem-level and driver-level callbacks.
+/**
+ * struct dev_pm_domain - power domain information
+ * @ops: Power domains provide callbacks that are executed during system
+ *	suspend, hibernation, system resume and during runtime PM transitions
+ *	along with subsystem-level and driver-level callbacks.
+ * @active_ops: Active operational callbacks
  */
 struct dev_pm_domain {
 	struct dev_pm_ops	ops;
+	struct dev_pm_active_ops active_ops;
 };
 
 /*
include/linux/pm_runtime.h +21 -0
index 16c9a62..731a6e4 100644
@@ -112,6 +112,11 @@ static inline void pm_runtime_mark_last_busy(struct device *dev)
 	ACCESS_ONCE(dev->power.last_busy) = jiffies;
 }
 
+extern int pm_runtime_get_rate(struct device *dev, unsigned long *rate);
+extern int pm_runtime_set_rate(struct device *dev, unsigned long rate);
+extern int pm_runtime_get_transition_latency(struct device *dev,
+					     unsigned long from_rate,
+					     unsigned long to_rate);
 #else /* !CONFIG_PM_RUNTIME */
 
 static inline int __pm_runtime_idle(struct device *dev, int rpmflags)
@@ -162,6 +167,22 @@ static inline unsigned long pm_runtime_autosuspend_expiration(
 static inline void pm_runtime_set_memalloc_noio(struct device *dev,
 						bool enable){}
 
+static inline int pm_runtime_get_rate(struct device *dev, unsigned long *rate)
+{
+	return -ENOSYS;
+}
+
+static inline int pm_runtime_set_rate(struct device *dev, unsigned long rate)
+{
+	return -ENOSYS;
+}
+
+static inline int pm_runtime_get_transition_latency(struct device *dev,
+						    unsigned long from_rate,
+						    unsigned long to_rate)
+{
+	return -ENOSYS;
+}
 #endif /* !CONFIG_PM_RUNTIME */
 
 static inline int pm_runtime_idle(struct device *dev)
Signature · 5 lines
1.7.9.5

-- 
Regards,
Nishanth Menon
#5 lore raw

Re: [RFC PATCH 1/6] PM / Voltagedomain: Add generic clk notifier handler for regulator based dynamic voltage scaling

Quoting Nishanth Menon (2014-02-26 18:34:55)

drivers/base/power/runtime.c void pm_runtime_remove(struct device *dev) · line 1417

Quoted 13 lines
drivers/base/power/runtime.c +13 -0
+/**
+ * pm_runtime_get_rate() - Returns the device operational frequency
+ * @dev:       Device to handle
+ * @rate:      Returns rate in Hz.
+ *
+ * Returns appropriate error value in case of error conditions, else
+ * returns 0 and rate is updated. The pm_domain logic does all the necessary
+ * operation (which may consider magic hardware stuff) to provide the rate.
+ *
+ * NOTE: the rate returned is a snapshot and in many cases just a bypass
+ * to clk api to set the rate.
+ */
+int pm_runtime_get_rate(struct device *dev, unsigned long *rate)

Instead of "rate", how about we use "level" and leave it undefined as to what that means? It would be equally valid for level to represent a clock rate, or an opp from a table of opp's, or a p-state, or some value passed to a PM microcontroller.

Code that is tightly coupled to the hardware would simply know what value to use with no extra sugar.

Generic code would need to get the various supported "levels" populated at run time, but a DT binding could do that, or a query to the ACPI tables, or whatever.

Quoted 23 lines
drivers/base/power/runtime.c +23 -0
+{
+       unsigned long flags;
+       int error = -ENOSYS;
+
+       if (!rate || !dev)
+               return -EINVAL;
+
+       spin_lock_irqsave(&dev->power.lock, flags);
+       if (!pm_runtime_active(dev)) {
+               error = -EINVAL;
+               goto out;
+       }
+
+       if (dev->pm_domain && dev->pm_domain->active_ops.get_rate)
+               error = dev->pm_domain->active_ops.get_rate(dev, rate);
+out:
+       spin_unlock_irqrestore(&dev->power.lock, flags);
+
+       return error;
+}
+
+/**
+ * pm_runtime_set_rate() - Set a specific rate for the device operation

drivers/base/power/runtime.c void pm_runtime_remove(struct device *dev) · line 1450

Quoted 10 lines
drivers/base/power/runtime.c +10 -0
+ * @dev:       Device to handle
+ * @rate:      Rate to set in Hz
+ *
+ * Returns appropriate error value in case of error conditions, else
+ * returns 0. The pm_domain logic does all the necessary operation (which
+ * may include voltage scale operations or other magic hardware stuff) to
+ * achieve the operation. It is guarenteed that the requested rate is achieved
+ * on returning from this function if return value is 0.
+ */
+int pm_runtime_set_rate(struct device *dev, unsigned long rate)

Additionally I wonder if the function signature should include a way to specify the sub-unit of a device that we are operating on? This is a way to tackle the issues you raised regarding multiple clocks per device, etc. Two approaches come to mind:

int pm_runtime_set_rate(struct device *dev, int index,

				unsigned long rate);

Where index is a sub-unit of struct device *dev. The second approach is to create a publicly declared structure representing the sub-unit. Some variations on that theme:

int pm_runtime_set_rate(struct perf_domain *perfdm, unsigned long rate);

or,

int pm_runtime_set_rate(struct generic_power_domain *gpd,

				unsigned long rate);

or whatever that sub-unit looks like. The gpd thing might be a total layering violation, I don't know. Or perhaps it's a decent idea but it shouldn't be as a PM runtime call. Again, I dunno.

Regards,
Mike

#6 lore raw

Re: [RFC PATCH 1/6] PM / Voltagedomain: Add generic clk notifier handler for regulator based dynamic voltage scaling

Quoted 11 lines · Mike Turquette

Quoting Nishanth Menon (2014-02-26 18:34:55)

Quoted 10 lines

+/**
+ * pm_runtime_get_rate() - Returns the device operational frequency
+ * @dev: Device to handle
+ * @rate: Returns rate in Hz.
+ *
+ * Returns appropriate error value in case of error conditions, else
+ * returns 0 and rate is updated. The pm_domain logic does all the necessary
+ * operation (which may consider magic hardware stuff) to provide the rate.
+ *
+ * NOTE: the rate returned is a snapshot and in many cases just a bypass

Quoted 8 lines
Quoted 3 lines

+ * to clk api to set the rate.
+ */
+int pm_runtime_get_rate(struct device *dev, unsigned long *rate)

Instead of "rate", how about we use "level" and leave it undefined as to what that means? It would be equally valid for level to represent a clock rate, or an opp from a table of opp's, or a p-state, or some value passed to a PM microcontroller.

IMHO, from a driver which already exists for multiple SoCs/ architectures, we cannot have variant definitions that a generic driver will be unable to depend upon. what should such a driver expect? level == rate OR level == index to p-state or magic PM controller value?

Today the definitions are very clear to such a driver, pm_runtime APIs are used for device specific idle management, but for active management, use clk and regulator code as needed - ofcourse, that machine specificity triggers the need for the 50 odd cpufreq drivers we have today - intent was to be able to abstract it enough for a generic logic to exist.

Quoted 3 lines

Code that is tightly coupled to the hardware would simply know what value to use with no extra sugar.

agreed on the machine specific implementation, but the logic at driver level will then get tied down to machine specific implementation as well

Quoted 4 lines

Generic code would need to get the various supported "levels" populated at run time, but a DT binding could do that, or a query to the ACPI tables, or whatever.

then we'd also have to introduce a translator API for drivers that need frequency -> we go back to the old world of having specific functions depending on usage in the frequency world, ACPI world, PM controller world.

That completely breaks the concept of having a higher level function, right?

Quoted 40 lines
Quoted 24 lines
drivers/base/power/runtime.c +23 -0
+{
+       unsigned long flags;
+       int error = -ENOSYS;
+
+       if (!rate || !dev)
+               return -EINVAL;
+
+       spin_lock_irqsave(&dev->power.lock, flags);
+       if (!pm_runtime_active(dev)) {
+               error = -EINVAL;
+               goto out;
+       }
+
+       if (dev->pm_domain && dev->pm_domain->active_ops.get_rate)
+               error = dev->pm_domain->active_ops.get_rate(dev, rate);
+out:
+       spin_unlock_irqrestore(&dev->power.lock, flags);
+
+       return error;
+}
+
+/**
+ * pm_runtime_set_rate() - Set a specific rate for the device operation

drivers/base/power/runtime.c void pm_runtime_remove(struct device *dev) · line 1450

Quoted 10 lines
drivers/base/power/runtime.c +10 -0
+ * @dev:       Device to handle
+ * @rate:      Rate to set in Hz
+ *
+ * Returns appropriate error value in case of error conditions, else
+ * returns 0. The pm_domain logic does all the necessary operation (which
+ * may include voltage scale operations or other magic hardware stuff) to
+ * achieve the operation. It is guarenteed that the requested rate is achieved
+ * on returning from this function if return value is 0.
+ */
+int pm_runtime_set_rate(struct device *dev, unsigned long rate)

Additionally I wonder if the function signature should include a way to specify the sub-unit of a device that we are operating on? This is a way to tackle the issues you raised regarding multiple clocks per device, etc. Two approaches come to mind:

Quoted 4 lines

int pm_runtime_set_rate(struct device *dev, int index,

				unsigned long rate);

Where index is a sub-unit of struct device *dev.

Here the problem is trying to define what that index is. should it be clk index? how again would a generic driver be able to consistently function? lets, for a moment replace that with a string - "clk_name" to uniquely identify the clk -> but then, it still, in concept makes it no better than a clk_set_rate since we are uniquely identifying the clk to operate upon -> and we can definitely add "magic dvfs" stuff on existing clock framework without a need for additional wrappers (which what the original $subject series does).

Quoted 6 lines

The second approach is
to create a publicly declared structure representing the sub-unit. Some variations on that theme:

int pm_runtime_set_rate(struct perf_domain *perfdm, unsigned long rate);

Quoted 8 lines

or,

int pm_runtime_set_rate(struct generic_power_domain *gpd,

				unsigned long rate);

or whatever that sub-unit looks like. The gpd thing might be a total layering violation, I don't know. Or perhaps it's a decent idea but it shouldn't be as a PM runtime call. Again, I dunno.

Again, we goes back to the same question, right? which clock in a power_domain/perf_domain are we intending with the rate? a device belongs to a perf domain -> Taking drivers/cpufreq/imx6q-cpufreq.c as an example.
Clocks needed: arm_clk, pll1_sys_clk, pll1_sw_clk, step_clk, pll2_pfd2_396m_clk.
regulators needed: arm_reg, pu_reg, soc_reg.

The device we want to set a frequency is the ARM processor. by describing "perf_domain" or "generic power domain" as a single clock entity, we might as well use clk_set_rate instead to be specific, instead of writing one wrapper on top of the entire thing.

I apologize, more I think in this angle, less I think such a generic api seems feasible.

Signature · 2 lines
Regards,
Nishanth Menon
#7 lore raw

Re: [RFC PATCH 1/6] PM / Voltagedomain: Add generic clk notifier handler for regulator based dynamic voltage scaling

In reply to Nishanth Menon

Hi,

Quoted 145 lines · Nishanth Menon
Quoted 2 lines · Nishanth Menon
Quoted 1 line · Mike Turquette

Quoting Nishanth Menon (2014-02-18 12:32:18)

[...]

Quoted 30 lines
Quoted 2 lines

I'm not sure about trying to capture the "voltdm" as a core concept. It feels a bit unwieldy to me.

Considering it is a simple collation of regulators and SoC specific "magic" which have to be operated in tandem to clock operation, Why does it seem unwieldy? Usage of multiple voltage planes in a single voltage domain concept does not seem unique to TI processors either:
For example, imx6q-cpufreq.c uses 3 regulators (arm, pu, soc), s5pv210-cpufreq.c uses two regulators (vddarm, vddint), ideally OMAP implementation would use two (vdd_mpu, vbb_mpu).

Quoted 10 lines

I have wondered about making an abstract
"performance domain" which is the dvfs analogue to generic power domains. This a reasonable split since gpd are good for idle power savings (e.g. clock gate, power gate, sleep state, etc) and "perf domains" would be good for active power savings (dvfs).

Having a generic container for performance domains might make a good place to stuff all of this glue logic that we keep running into (e.g. CPU and GPU max frequencies that are related), and it might make another nice knob for the thermal folks to use.

This sounds like one level higher abstraction that we are speaking of here? I was'nt intending to solve the bigger picture problem here - just an abstraction level that might allow reusablity for multiple SoCs. In fact, having an abstraction away for voltage domain(which may consist of multiple regulators and any SoC specific magic) purely allows us to move towards a direction you mention here.

Quoted 1 line
Quoted 8 lines
Quoted 3 lines

For the case of the OMAP voltage domains, it would be a place to stuff all of the VC/VP -> ABB -> Smart Reflex AVS stuff.

Unfortunately, I dont completely comprehend objection we have to this approach (other than an higher level abstraction is needed) and if we do have an objection, what is the alternate approach should be for representing hardware which this series attempts to present.

I think the following is around the lines of your thought direction - if Rafael or others have comments on the following approach, it'd be a good starting point for me to progress.

-->8--
From 62e50b9f920495db88e5594aa6bceb52e83a443d Mon Sep 17 00:00:00 2001
From: Nishanth Menon <[email protected]>
Date: Wed, 26 Feb 2014 10:59:59 -0600
Subject: [PATCH] PM / Runtime: introduce active power management callbacks
for pm_domain

dev_pm_domain currently handles just device idle power management using the generic pm_runtime_get|put and related family of functions.

Logically with appropriate pm_domain hooks this can translate to hardware specific clock and related operations. Given that pm_domains may contain this information, this provides an opportunity to extend current pm_runtime do dynamic power operations as well.

What this means for drivers is as follows:

Today, drivers(with some level of complexity) do:
pm_runtime_get_sync(dev);
clk = clk_get(dev, "name");
old_rate = clk_get_rate(clk);
...
clk_set_rate(clk, new_rate);
...
clk_put(clk);
pm_runtime_get_sync(dev);

Instead, on pm_domains that can handle this as part of pm_domain->active_ops functions, They can now do the following:
pm_runtime_get_sync(dev);
old_rate = pm_runtime_get_rate(dev);
...
pm_runtime_set_rate(dev, new_rate);
...
pm_runtime_put_sync(dev);

Obviously, this'd work for devices that handle a single main functional clock, but this could reduce complexity of drivers having to deal with power management details to have pm_runtime as the main point of interface.

CAVEAT: For power domains that are capable of handling multiple clocks (example on OMAP, where there are the concepts of interface, functional and optional clocks per block), appropriate handling will be necessary from pm_domain callbacks. So, the question about which clock rate is being controlled or returned to is entirely upto the pm_domain implementation.

On the otherhand, we can debate about defining and querying ACPI style "Performance state" instead of frequencies and wrap P-states inside or the other way around.. but given that majority of drivers using pm_runtime would rather be interested in frequencies and my naieve belief that we can index P-states with frequencies, kind of influenced my choice here of proposing frequencies as base query parameter.. ofcourse, debate is still open here.

Yes, we can still debate if providing yet another wrapper on top of clock APIs makes sense at all as well.

---
 drivers/base/power/runtime.c |  101 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/pm.h           |   25 +++++++++--
 include/linux/pm_runtime.h   |   21 +++++++++
 3 files changed, 143 insertions(+), 4 deletions(-)
drivers/base/power/runtime.c +24 -0
index 72e00e6..ef230b4 100644
@@ -1401,3 +1401,104 @@ void pm_runtime_remove(struct device *dev)
 	if (dev->power.irq_safe && dev->parent)
 		pm_runtime_put(dev->parent);
 }
+
+/**
+ * pm_runtime_get_rate() - Returns the device operational frequency
+ * @dev:	Device to handle
+ * @rate:	Returns rate in Hz.
+ *
+ * Returns appropriate error value in case of error conditions, else
+ * returns 0 and rate is updated. The pm_domain logic does all the necessary
+ * operation (which may consider magic hardware stuff) to provide the rate.
+ *
+ * NOTE: the rate returned is a snapshot and in many cases just a bypass
+ * to clk api to set the rate.
+ */
+int pm_runtime_get_rate(struct device *dev, unsigned long *rate)
+{
+	unsigned long flags;
+	int error = -ENOSYS;
+
+	if (!rate || !dev)
+		return -EINVAL;
+
+	spin_lock_irqsave(&dev->power.lock, flags);
+	if (!pm_runtime_active(dev)) {
+		error = -EINVAL;

drivers/base/power/runtime.c void pm_runtime_remove(struct device *dev) · line 1437

Quoted 10 lines
drivers/base/power/runtime.c +10 -0
+		goto out;
+	}
+
+	if (dev->pm_domain && dev->pm_domain->active_ops.get_rate)
+		error = dev->pm_domain->active_ops.get_rate(dev, rate);
+out:
+	spin_unlock_irqrestore(&dev->power.lock, flags);
+
+	return error;
+}

IMHO coupling device drivers even more with pm_runtime is wrong, and Kevin Hilman seems to agree [1].

I would much rather go with Nishanth's initial approach of subscribing to clock notifiers. They are, after all, supposed to tell the kernel about any clock changes. In just so happens that in the case discussed in this thread, OMAP needs to change voltages to match clock frequency and, IMHO, using clock notifiers for that is correct.

The sematics are well defined and it's something which has been in the tree for quite some time.

[1] https://lkml.org/lkml/2014/1/30/469

Signature · 1 line
balbi
#8 lore raw

RFC PATCH 2/6 cpufreq: cpufreq-cpu0: use clk rate-change notifiers

In reply to Nishanth Menon

From: Mike Turquette <[email protected]>

Removes directly handling of OPP tables and voltage regulators by calling of_clk_cpufreq_notifier_handler, introduced by commit "clk:
cpufreq helper for voltage scaling".

In the future this can help consolidate code found across similar CPUfreq drivers.

[[email protected]: updates to keep the OPP logic still in cpufreq-cpu0 - optimization to generalize that for cpufreq is to be done in a later series]

---
 drivers/cpufreq/Kconfig        |    1 +
 drivers/cpufreq/cpufreq-cpu0.c |  140 ++++++++++++----------------------------
 2 files changed, 42 insertions(+), 99 deletions(-)
drivers/cpufreq/Kconfig +1 -0
index 4b029c0..70b07ab 100644
@@ -187,6 +187,7 @@ config GENERIC_CPUFREQ_CPU0
 	tristate "Generic CPU0 cpufreq driver"
 	depends on HAVE_CLK && REGULATOR && OF && THERMAL && CPU_THERMAL
 	select PM_OPP
+	select VOLTAGE_DOMAIN
 	help
 	  This adds a generic cpufreq driver for CPU0 frequency management.
 	  It supports both uniprocessor (UP) and symmetric multiprocessor (SMP)
drivers/cpufreq/cpufreq-cpu0.c +41 -99

211 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#9 lore raw

RFC PATCH 3/6 PM / Voltagedomain: introduce voltage domain driver support

In reply to Nishanth Menon

Many SoCs have basic concepts of voltage rails supplying a specific SoC device. These voltage rails may be as simple as a single regulator or complex to be three or more regulators that are transitioned in tandem with respect to clock changes. In some cases, they may tend to use custom frameworks to do the actual voltage transition OR use hardware modules that takes hints about the required configuration and does optimized voltage transitions.

The current regulator model provides the basic building blocks for the transitions, however SoC drivers specific to each of these devices, be it cpufreq/devfreq have to replicate the logic for functionality.

To simply the logic, we can hence introduce a layer that takes care of the mundane transition logic, registration mechanisms to provide the "user drivers" such as cpufreq/devfreq a generic interface, whose details are abstracted by the device tree description for the SoC on which the driver operates on.

This allows us opportunity to make generic cpufreq / devfreq drivers which may deal with a single clock, however the actual voltage change mechanism can be customized specific to SoC without impact to the generic driver.

---
 drivers/power/voltdm/Kconfig                  |    5 +
 drivers/power/voltdm/Makefile                 |    3 +
 drivers/power/voltdm/core.c                   |  347 +++++++++++++++++++++++--
 drivers/power/voltdm/voltage_domain_private.h |   86 ++++++
 4 files changed, 424 insertions(+), 17 deletions(-)
 create mode 100644 drivers/power/voltdm/voltage_domain_private.h
drivers/power/voltdm/Kconfig +5 -0
index c5353bd..270fdab 100644
@@ -5,3 +5,8 @@ config VOLTAGE_DOMAIN
 	---help---
 	  Core voltage domain framework using common clock framework's
 	  notifier mechanism.
+
+menu "Voltage Domain Framework Drivers"
+	depends on VOLTAGE_DOMAIN
+
+endmenu
drivers/power/voltdm/Makefile +3 -0
index 3fa4408..fd32040 100644
@@ -1,2 +1,5 @@
 # Generic voltage domain
 obj-$(CONFIG_VOLTAGE_DOMAIN)	+= core.o
+
+# Hardware specific voltage domain
+# please keep this section sorted lexicographically by file/directory path name
drivers/power/voltdm/core.c +330 -17

426 lines not on this page · raw message

drivers/power/voltdm/voltage_domain_private.h new file +86 -0

86 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#10 lore raw

Re: [RFC PATCH 3/6] PM / Voltagedomain: introduce voltage domain driver support

Quoted 9 lines · Nishanth Menon

The current regulator model provides the basic building blocks for the transitions, however SoC drivers specific to each of these devices, be it cpufreq/devfreq have to replicate the logic for functionality.

To simply the logic, we can hence introduce a layer that takes care of the mundane transition logic, registration mechanisms to provide the "user drivers" such as cpufreq/devfreq a generic interface, whose details are abstracted by the device tree description for the SoC on which the driver operates on.

This doesn't really provide a picture of what the generic interface that's being offered is and...

Quoted 5 lines
 drivers/power/voltdm/Kconfig                  |    5 +
 drivers/power/voltdm/Makefile                 |    3 +
 drivers/power/voltdm/core.c                   |  347 +++++++++++++++++++++++--
 drivers/power/voltdm/voltage_domain_private.h |   86 ++++++
 4 files changed, 424 insertions(+), 17 deletions(-)

...the diffstat doesn't make it obvious what the external interface is either. It would be much easier to review this with a clearer picture of what it's aiming to implement.

drivers/power/voltdm/core.c struct volt_scale_data { · line 131

Quoted 6 lines
drivers/power/voltdm/core.c +6 -0
+	voltdm_np = of_parse_phandle(np, prop_name, 0);
+	if (voltdm_np) {
+		ret = of_parse_phandle_with_args(np, prop_name, "#voltdm-cells",
+						 0, args);
+		if (ret)
+			return ERR_PTR(ret);

There seems to be some DT stuff going on here, is the interface DT only?

#11 lore raw

Re: [RFC PATCH 3/6] PM / Voltagedomain: introduce voltage domain driver support

Quoted 6 lines · Mark Brown
Quoted 3 lines · Nishanth Menon

The current regulator model provides the basic building blocks for the transitions, however SoC drivers specific to each of these devices, be it cpufreq/devfreq have to replicate the logic for functionality.

Quoted 8 lines
Quoted 5 lines

To simply the logic, we can hence introduce a layer that takes care of the mundane transition logic, registration mechanisms to provide the "user drivers" such as cpufreq/devfreq a generic interface, whose details are abstracted by the device tree description for the SoC on which the driver operates on.

This doesn't really provide a picture of what the generic interface that's being offered is and...

I should have probably picked up part of the cover letter[1] and elaborated further in the commit message here.

Intent here is to allow drivers such as cpufreq-cpu0 to be reused on platforms such as TI's OMAP derivatives, and other SoCs which differ only by the sequence involved in voltage scale operations. So, this patch provides a framework for registering the underlying implementation of the SoC specific voltage change methodology.

Overall the sequence takes place after this patch is as follows:
a) voltage domain drivers such as those of TI or others register with voltage domain with devm_voltdm_register.
b) cpufreq-cpu0/devfreq drivers:
of_pm_voltdm_notifier_register(introduced as part of patch #1) to register notifiers around clk of interest. This request is linked to the specific voltage domain using phandle in device tree.
c) when cpufreq-cpu0/devfreq does a clk_set_rate, the common clock framework triggers notifiers in voltage domain core which in turn, invokes the corresponding handlers for the voltage domain driver ensuring the right dvfs sequence specific to the SoC is triggered.

With this patch, the logic for a SoC specific voltage domain intricacies can now be abstracted out to the voltage domain layer. This allows reuse of the logic by multiple drivers such as devfreq/cpufreq and allows these to remain consistent with very minimal SoC(if any at all) specific implementations in them.

Among the other obvious alternatives to this approach are:
a) To duplicate the logic multiple times for various drivers such as devfreq/cpufreq and try to ensure the logic sequences are proper. basically, create cpufreq-abb-omap, cpufreq-avs-omap, devfreq-abb-omap, devfreq-avs-omap etc..
b) introduce a specific API for voltage change (something like pm_dev_scale_opp_frequency or the equivalent).

Quoted 10 lines
Quoted 6 lines
 drivers/power/voltdm/Kconfig                  |    5 +
 drivers/power/voltdm/Makefile                 |    3 +
 drivers/power/voltdm/core.c                   |  347 +++++++++++++++++++++++--
 drivers/power/voltdm/voltage_domain_private.h |   86 ++++++
 4 files changed, 424 insertions(+), 17 deletions(-)

...the diffstat doesn't make it obvious what the external interface is either. It would be much easier to review this with a clearer picture of what it's aiming to implement.

The drivers such as cpufreq/devfreq has the same interface introduced by patch #1 in this series of_pm_voltdm_notifier_register/unregister which is exposed by include/linux/pm_voltage_domain.h

Underlying implementation of the SoC specific voltage change methodology can now be isolated by voltage domain driver using voltage_domain_private.h and services provided by core.c

Quoted 10 lines

drivers/power/voltdm/core.c struct volt_scale_data { · line 131

Quoted 7 lines
drivers/power/voltdm/core.c +6 -0
+	voltdm_np = of_parse_phandle(np, prop_name, 0);
+	if (voltdm_np) {
+		ret = of_parse_phandle_with_args(np, prop_name, "#voltdm-cells",
+						 0, args);
+		if (ret)
+			return ERR_PTR(ret);

There seems to be some DT stuff going on here, is the interface DT only?

yes. i will make that clear in the documentation.

[1] http://marc.info/?l=linux-kernel&m=139275560531711&w=2

Signature · 2 lines
Regards,
Nishanth Menon
#12 lore raw

Re: [RFC PATCH 3/6] PM / Voltagedomain: introduce voltage domain driver support

Quoted 5 lines · Nishanth Menon

Intent here is to allow drivers such as cpufreq-cpu0 to be reused on platforms such as TI's OMAP derivatives, and other SoCs which differ only by the sequence involved in voltage scale operations. So, this patch provides a framework for registering the underlying implementation of the SoC specific voltage change methodology.

That bit is clear, what's very opaque from the code is how this is going to be accomplished.

Quoted 11 lines

Overall the sequence takes place after this patch is as follows:
a) voltage domain drivers such as those of TI or others register with voltage domain with devm_voltdm_register.
b) cpufreq-cpu0/devfreq drivers:
of_pm_voltdm_notifier_register(introduced as part of patch #1) to register notifiers around clk of interest. This request is linked to the specific voltage domain using phandle in device tree.
c) when cpufreq-cpu0/devfreq does a clk_set_rate, the common clock framework triggers notifiers in voltage domain core which in turn, invokes the corresponding handlers for the voltage domain driver ensuring the right dvfs sequence specific to the SoC is triggered.

So the first question I have here is what happens if multiple clocks need to be updated in lock step - if we're only triggering off clock notifiers that seems tricky. The other thing here is that the fact that your API is "of_" suggests that it is in fact linked very srongly to DT
- it'd be good to split out the layers to make sure things make sense standalone, the DT helpers are obviously good but the API should be able to stand separately.

#13 lore raw

Re: [RFC PATCH 3/6] PM / Voltagedomain: introduce voltage domain driver support

Quoted 10 lines · Mark Brown
Quoted 5 lines · Nishanth Menon

Intent here is to allow drivers such as cpufreq-cpu0 to be reused on platforms such as TI's OMAP derivatives, and other SoCs which differ only by the sequence involved in voltage scale operations. So, this patch provides a framework for registering the underlying implementation of the SoC specific voltage change methodology.

That bit is clear, what's very opaque from the code is how this is going to be accomplished.

The SoC specific voltage domain drivers register with devm_voltdm_register. the fops provide the abstraction needed for the SoC (example in patch #5 - which introduces OMAP specific voltage domain which handles ABB and VDD regulators).

What would you suggest that we do to clarify the usage here?

Quoted 12 lines
Quoted 11 lines

Overall the sequence takes place after this patch is as follows:
a) voltage domain drivers such as those of TI or others register with voltage domain with devm_voltdm_register.
b) cpufreq-cpu0/devfreq drivers:
of_pm_voltdm_notifier_register(introduced as part of patch #1) to register notifiers around clk of interest. This request is linked to the specific voltage domain using phandle in device tree.
c) when cpufreq-cpu0/devfreq does a clk_set_rate, the common clock framework triggers notifiers in voltage domain core which in turn, invokes the corresponding handlers for the voltage domain driver ensuring the right dvfs sequence specific to the SoC is triggered.

Quoted 3 lines

So the first question I have here is what happens if multiple clocks need to be updated in lock step - if we're only triggering off clock notifiers that seems tricky. The other thing here is that the fact that

Yes, that is true, however, there are ways to implement them, for
example: We could implement an higher level clock that takes care of the multiple clock node control to handle this kind of scenario.

I can elaborate that in the commit message, if that is desirable.

Quoted 4 lines

your API is "of_" suggests that it is in fact linked very srongly to DT
- it'd be good to split out the layers to make sure things make sense standalone, the DT helpers are obviously good but the API should be able to stand separately.

You are correct, I had intended the RFC as purely "OF only". I will make it independent of of in the next revision.

Signature · 2 lines
Regards,
Nishanth Menon
#14 lore raw

Re: [RFC PATCH 3/6] PM / Voltagedomain: introduce voltage domain driver support

Quoted 12 lines · Nishanth Menon
Quoted 10 lines · Mark Brown
Quoted 5 lines · Nishanth Menon

Intent here is to allow drivers such as cpufreq-cpu0 to be reused on platforms such as TI's OMAP derivatives, and other SoCs which differ only by the sequence involved in voltage scale operations. So, this patch provides a framework for registering the underlying implementation of the SoC specific voltage change methodology.

That bit is clear, what's very opaque from the code is how this is going to be accomplished.

Quoted 6 lines

The SoC specific voltage domain drivers register with devm_voltdm_register. the fops provide the abstraction needed for the SoC (example in patch #5 - which introduces OMAP specific voltage domain which handles ABB and VDD regulators).

What would you suggest that we do to clarify the usage here?

Probably saying something about this in the commit message would be enough - mentioning how the registration occurs and that things are triggered by clock frequency changes.

Quoted 7 lines
Quoted 3 lines

So the first question I have here is what happens if multiple clocks need to be updated in lock step - if we're only triggering off clock notifiers that seems tricky. The other thing here is that the fact that

Yes, that is true, however, there are ways to implement them, for
example: We could implement an higher level clock that takes care of the multiple clock node control to handle this kind of scenario.

That seems concerning given the fact that people seem to like describing their entire clock trees in DT, we shouldn't be putting implementation stuff there.

#15 lore raw

Re: [RFC PATCH 3/6] PM / Voltagedomain: introduce voltage domain driver support

Quoted 18 lines · Mark Brown
Quoted 16 lines · Nishanth Menon
Quoted 10 lines · Mark Brown
Quoted 5 lines · Nishanth Menon

Intent here is to allow drivers such as cpufreq-cpu0 to be reused on platforms such as TI's OMAP derivatives, and other SoCs which differ only by the sequence involved in voltage scale operations. So, this patch provides a framework for registering the underlying implementation of the SoC specific voltage change methodology.

That bit is clear, what's very opaque from the code is how this is going to be accomplished.

The SoC specific voltage domain drivers register with devm_voltdm_register. the fops provide the abstraction needed for the SoC (example in patch #5 - which introduces OMAP specific voltage domain which handles ABB and VDD regulators).

Quoted 5 lines
Quoted 1 line

What would you suggest that we do to clarify the usage here?

Probably saying something about this in the commit message would be enough - mentioning how the registration occurs and that things are triggered by clock frequency changes.

OK. will do, thanks for suggesting the same.

Quoted 11 lines
Quoted 7 lines
Quoted 3 lines

So the first question I have here is what happens if multiple clocks need to be updated in lock step - if we're only triggering off clock notifiers that seems tricky. The other thing here is that the fact that

Yes, that is true, however, there are ways to implement them, for
example: We could implement an higher level clock that takes care of the multiple clock node control to handle this kind of scenario.

That seems concerning given the fact that people seem to like describing their entire clock trees in DT, we shouldn't be putting implementation stuff there.

The only other options are:
a) Abstract it at a higher level at "user drivers", since they are aware of the sequencing needs - but this partially defeats the purpose, unless ofcourse, we do a tricky implementation such as:
clk a, b, c -> prenotifiers in a, postnotifiers in c (which as you mentioned is a little trickier to get right).
b) introduce a higher level generic dvfs function[1] which does not seem very attractive either.

Any other suggestions other than limiting the usage(and documenting it so) and hoping for a future evolution to take this into consideration?

[1] http://marc.info/?t=139275581900004&r=1&w=2

Signature · 2 lines
Regards,
Nishanth Menon
#16 lore raw

Re: [RFC PATCH 3/6] PM / Voltagedomain: introduce voltage domain driver support

Quoted 11 lines · Nishanth Menon

The only other options are:
a) Abstract it at a higher level at "user drivers", since they are aware of the sequencing needs - but this partially defeats the purpose, unless ofcourse, we do a tricky implementation such as:
clk a, b, c -> prenotifiers in a, postnotifiers in c (which as you mentioned is a little trickier to get right).
b) introduce a higher level generic dvfs function[1] which does not seem very attractive either.

Any other suggestions other than limiting the usage(and documenting it so) and hoping for a future evolution to take this into consideration?

Something might be doable with telling the clock API about maintianing ratios between clocks? I do think we should have an idea where we'd go with such requirements, even if we don't currently handle it, so that we can hopefully avoid another round of refactoring everything but it doesn't seem 100% essential, just very nice to have.

#17 lore raw

Re: [RFC PATCH 3/6] PM / Voltagedomain: introduce voltage domain driver support

Quoted 11 lines · Mark Brown
Quoted 8 lines · Nishanth Menon

The only other options are:
a) Abstract it at a higher level at "user drivers", since they are aware of the sequencing needs - but this partially defeats the purpose, unless ofcourse, we do a tricky implementation such as:
clk a, b, c -> prenotifiers in a, postnotifiers in c (which as you mentioned is a little trickier to get right).
b) introduce a higher level generic dvfs function[1] which does not seem very attractive either.

Quoted 9 lines
Quoted 2 lines

Any other suggestions other than limiting the usage(and documenting it so) and hoping for a future evolution to take this into consideration?

Something might be doable with telling the clock API about maintianing ratios between clocks? I do think we should have an idea where we'd go with such requirements, even if we don't currently handle it, so that we can hopefully avoid another round of refactoring everything but it doesn't seem 100% essential, just very nice to have.

Mike,
Any suggestions about the above? could we use composite clocks in some manner here(even though I think the original intent of the same was not the same)?

Signature · 2 lines
Regards,
Nishanth Menon
#18 lore raw

Re: [RFC PATCH 3/6] PM / Voltagedomain: introduce voltage domain driver support

Quoting Nishanth Menon (2014-03-10 12:25:43)

Quoted 11 lines · Mark Brown
Quoted 10 lines · Nishanth Menon
Quoted 9 lines

The only other options are:
a) Abstract it at a higher level at "user drivers", since they are aware of the sequencing needs - but this partially defeats the purpose, unless ofcourse, we do a tricky implementation such as:
clk a, b, c -> prenotifiers in a, postnotifiers in c (which as you mentioned is a little trickier to get right).
b) introduce a higher level generic dvfs function[1] which does not seem very attractive either.

I disagree that a higher level DVFS interface is unattractive. I think it has taken a while to get there but people are finally interested in this. A small amount of discussion about this took place at Linaro Connect earlier this month (just hallway talk) but we shouldn't rule out the idea of a general framework for managing DVFS, which frankly is complex enough to merit not being shoved into the clock layer.

Quoted 9 lines
Quoted 9 lines
Quoted 3 lines

Any other suggestions other than limiting the usage(and documenting it so) and hoping for a future evolution to take this into consideration?

Something might be doable with telling the clock API about maintianing ratios between clocks? I do think we should have an idea where we'd go with such requirements, even if we don't currently handle it, so that we can hopefully avoid another round of refactoring everything but it doesn't seem 100% essential, just very nice to have.

This sounds reasonable but I must point out that the clock framework today (based on the existing clk.h api) does not have a single instance of constraint-based logic. For instance there is no clk_set_min_rate or clk_set_max_rate or clk_set_rate_range. These have been discussed before but I feel that pushing something before now would have been premature given that the level of discussion around those features never hit critical mass.

So the ratio thing is sensible, but it would be the first constraint-like mechanism in the clock framework so what that looks like bares careful consideration.

Quoted 5 lines
Quoted 1 line

Mike,
Any suggestions about the above? could we use composite clocks in some manner here(even though I think the original intent of the same was not the same)?

NACK. Let's just model the hardware in the clock framework, please. If you need to invent fake clocks to represent other constructs then it means the framework is missing something (or we're missing an entire framework, e.g. DVFS).

Regards,
Mike

Quoted 4 lines
Signature · 3 lines
-- 
Regards,
Nishanth Menon
#19 lore raw

RFC PATCH 4/6 devicetree: bindings: add documentation for voltagedomain

In reply to Nishanth Menon

Add documentation for voltage domain binding format. Specific voltage domains will have bindings corresponding to them.

---
 .../bindings/power/voltdm/voltage_domain.txt       |   65 ++++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/voltdm/voltage_domain.txt
Documentation/devicetree/bindings/power/voltdm/voltage_domain.txt new file +65 -0
new file mode 100644
index 0000000..da48a19
@@ -0,0 +1,65 @@
+Specifying Voltage Domain information for devices
+=================================================
+
+1. Specifying a voltage domain.
+
+SoCs may have multiple voltage domains under which various clocks operate.
+
+Mandatory Properties:
+- #voltdm-cells - indicates if there are specifiers needed to reference the
+  voltage domain
+
+Optional Properties:
+- voltage-tolerance: Specify the voltage tolerance in percentage
+
+2. Voltage domain consumer
+consumer nodes can be reference using the below binding:
+- <name>-voltdm: phandle to the voltage domain node.
+
+Examples:
+
+A. Voltage Domain controlling multiple regulator
+voltage_domain_mpu: voltdm@1 {
+	compatible = "xyz";
+	#voltdm-cells = <0>;
+	vdd-supply = <&vcc>;
+	vbb-supply = <&abb_mpu>;
+	...
+};
+
+voltage_domain_gpu: voltdm@2 {
+	compatible = "xyz";
+	#voltdm-cells = <0>;
+	vdd-supply = <&dcdc2>;
+	vbb-supply = <&abb_gpu>;
+	...
+};
+...
+&cpu0 {
+	cpu0-voltdm = <&voltage_domain_mpu>;
+	voltage-tolerance = <1>;
+};
+
+&gpu {
+	gpu-voltdm = <&voltage_domain_gpu>;
+};
+
+B. Indexed voltage domain device
+
+#define SOC_XYZ_VOLTAGE_DOMAIN_MPU	0
+#define SOC_XYZ_VOLTAGE_DOMAIN_GFX	1
+
+voltage_domain_socx: voltdm@1 {
+	compatible = "abc";
+	#voltdm-cells = <1>;
+	...
+};
+...
+&cpu0 {
+	cpu0-voltdm = <&voltage_domain_socx SOC_XYZ_VOLTAGE_DOMAIN_MPU>;
+	voltage-tolerance = <1>;
+};
+
+&gpu {
+	gpu-voltdm = <&voltage_domain_socx SOC_XYZ_VOLTAGE_DOMAIN_GFX>;
+};
Signature · 1 line
1.7.9.5
#20 lore raw

RFC PATCH 5/6 PM / Voltagedomain: introduce basic voltage domain support for OMAP

In reply to Nishanth Menon

OMAP platforms have multiple voltage domains, but each with consistent behavior of controlling the VDD (supply) and VBB(ABB/Bias voltage).

These need to be sequenced in a specific order for functionality. Further optimization such as AVS(Adaptive Voltage Scaling), optimized voltages from efuse(Class0) can also be introduced based on this basic framework.

This now allows reuse by voltage domain devices which may share the same voltage domain by allowing the regulator framework to maintain per consumer usage information.

---
 drivers/power/voltdm/Kconfig       |    7 +
 drivers/power/voltdm/Makefile      |    1 +
 drivers/power/voltdm/voltdm_omap.c |  287 ++++++++++++++++++++++++++++++++++++
 3 files changed, 295 insertions(+)
 create mode 100644 drivers/power/voltdm/voltdm_omap.c
drivers/power/voltdm/Kconfig +7 -0
index 270fdab..41bfbc3 100644
@@ -9,4 +9,11 @@ config VOLTAGE_DOMAIN
 menu "Voltage Domain Framework Drivers"
 	depends on VOLTAGE_DOMAIN
 
+config VOLTAGE_DOMAIN_OMAP
+	tristate "TI OMAP Voltage domain driver"
+	---help---
+	  Voltage domain support for OMAP platforms which need
+	  vdd regulator and Adaptive Body Bias(ABB) regulator
+	  support
+
 endmenu
drivers/power/voltdm/Makefile +1 -0
index fd32040..e1cb50d 100644
@@ -3,3 +3,4 @@ obj-$(CONFIG_VOLTAGE_DOMAIN)	+= core.o
 
 # Hardware specific voltage domain
 # please keep this section sorted lexicographically by file/directory path name
+obj-$(CONFIG_VOLTAGE_DOMAIN_OMAP)	+= voltdm_omap.o
drivers/power/voltdm/voltdm_omap.c new file +287 -0

287 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#21 lore raw

RFC PATCH 6/6 devicetree: bindings: voltagedomain: add bindings for OMAP compatible SoCs

In reply to Nishanth Menon

Add documentation for device tree description for basic voltage domain for Texas Instruments OMAP compatible SoC family of processors which controls both bias and supply voltage planes.

---
 .../bindings/power/voltdm/voltdm_omap.txt          |   24 ++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/voltdm/voltdm_omap.txt
Documentation/devicetree/bindings/power/voltdm/voltdm_omap.txt new file +24 -0
new file mode 100644
index 0000000..30cd3d2
@@ -0,0 +1,24 @@
+Texas Instruments OMAP compatible voltage domain description
+
+This binding uses [1] and describes the voltage domain devices
+typically used on Texas Instruments OMAP compatible SoC family of
+processors.
+
+[1] Documentation/devicetree/bindings/power/voltdm/voltage_domain.txt
+
+Required Properties:
+- compatible: Should be one of:
+	"ti,omap-voltdm" - basic voltage domain controlling VDD and VBB
+- vdd-supply: phandle to regulator controlling VDD supply
+- vbb-supply: phandle to regulator controlling Body Bias supply
+  (Usually Adaptive Body Bias regulator)
+- #voltdm-cells: shall be <0>
+
+Example:
+voltage_domain_mpu: voltdm@1 {
+	compatible = "ti,omap-voltdm";
+	#voltdm-cells = <0>;
+
+	vdd-supply = <&vcc>;
+	vbb-supply = <&abb_mpu>;
+};
Signature · 1 line
1.7.9.5