Skip to contentSkip to conversation

dt-bindings: Powerzone new bindings

PATCH In review Daniel Lezcano 2 participants 8 messages Dec 5, 2021 – Dec 13, 2021

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

PATCH v4 1/5 dt-bindings: Powerzone new bindings

The proposed bindings are describing a set of powerzones.

A power zone is the logical name for a component which is capable of power capping and where we can measure the power consumption.

A power zone can aggregate several power zones in terms of power measurement and power limitations. That allows to apply power constraint to a group of components and let the system balance the allocated power in order to comply with the constraint.

The ARM System Control and Management Interface (SCMI) can provide a power zone description.

The powerzone semantic is also found on the Intel platform with the RAPL register.

The Linux kernel powercap framework deals with the powerzones:

https://www.kernel.org/doc/html/latest/power/powercap/powercap.html

The powerzone can also represent a group of children powerzones, hence the description can result on a hierarchy. Such hierarchy already exists with the hardware or can be represented and computed from the kernel.

The hierarchical description was initially proposed but not desired given there are other descriptions like the power domain proposing almost the same description.

https://lore.kernel.org/all/CAL_JsqLuLcHj7525tTUmh7pLqe7T2j6UcznyhV7joS8ipyb_VQ@mail.gmail.com/

The description gives the power constraint dependencies to apply on a specific group of logically or physically aggregated devices. They do not represent the physical location or the power domains of the SoC even if the description could be similar.

---
V3:
- Removed required property 'compatible'
- Removed powerzone-cells from the topmost node
- Removed powerzone-cells from cpus 'consumers' in example
- Set additionnal property to false
V2:
- Added pattern properties and stick to powerzone-*
- Added required property compatible and powerzone-cells
- Added additionnal property
- Added compatible
- Renamed to 'powerzones'
- Added missing powerzone-cells to the topmost node
- Fixed errors reported by 'make DT_CHECKER_FLAGS=-m dt_binding_check'
V1: Initial post

---
 .../devicetree/bindings/power/powerzones.yaml | 97 +++++++++++++++++++
 1 file changed, 97 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/powerzones.yaml
Documentation/devicetree/bindings/power/powerzones.yaml new file +97 -0
new file mode 100644
index 000000000000..ddb790acfea6
@@ -0,0 +1,97 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/power/powerzones.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Power zones description
+
+maintainers:
+  - Daniel Lezcano <[email protected]>
+
+description: |+
+
+  A System on Chip contains a multitude of active components and each
+  of them is a source of heat. Even if a temperature sensor is not
+  present, a source of heat can be controlled by acting on the
+  consumed power via different techniques.
+
+  A powerzone describes a component or a group of components where we
+  can control the maximum power consumption. For instance, a group of
+  CPUs via the performance domain, a LCD screen via the brightness,
+  etc ...
+
+  Different components when they are used together can significantly
+  increase the overall temperature, so the description needs to
+  reflect this dependency in order to assign a power budget for a
+  group of powerzones.
+
+  This description is done via a hierarchy and the DT reflects it. It
+  does not represent the physical location or a topology, eg. on a
+  big.Little system, the little CPUs may not be represented as they do
+  not contribute significantly to the heat, however the GPU can be
+  tied with the big CPUs as they usually have a connection for
+  multimedia or game workloads.
+    
+properties:
+  $nodename:
+    const: powerzones
+
+patternProperties:
+  "^(powerzone)([@-].*)?$":
+    type: object
+    description:
+      A node representing a powerzone acting as an aggregator for all
+      its children powerzones.
+
+    properties:
+      "#powerzone-cells":
+        description:
+          Number of cells in powerzone specifier. Typically 0 for nodes
+          representing but it can be any number in the future to
+          describe parameters of the powerzone.
+
+      powerzones:
+        description:
+          A phandle to a parent powerzone. If no powerzone attribute is
+          set, the described powerzone is the topmost in the hierarchy.
+
+    required:
+      - "#powerzone-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    powerzones {
+
+      SOC_PZ: powerzone-soc {
+        #powerzone-cells = <0>;
+      };
+
+      PKG_PZ: powerzone-pkg {
+        #powerzone-cells = <0>;
+        powerzones = <&SOC_PZ>;
+      };
+
+      GPU_PZ: powerzone-gpu {
+        #powerzone-cells = <0>;
+        powerzones = <&PKG_PZ>;
+      };
+    };
+
+  - |
+    A57_0: big@0 {
+      compatible = "arm,cortex-a57";
+      reg = <0x0 0x0>;
+      device_type = "cpu";
+      powerzones = <&PKG_PZ>;
+    };
+
+    A57_1: big@1 {
+      compatible = "arm,cortex-a57";
+      reg = <0x0 0x0>;
+      device_type = "cpu";
+      powerzones = <&PKG_PZ>;
+    };
+...
Signature · 1 line
2.25.1
#1 lore raw

PATCH v4 2/5 arm64: dts: rockchip: Add powerzones definition for rock960

Add the powerzones description. This first step introduces the big, the little as powerzone places.

---
V4:
- Added missing powerzone-cells
- Changed powerzone name to comply with the pattern property
V3:
- Remove GPU section as no power is available (yet)
- Remove '#powerzone-cells' conforming to the bindings change
V2:
- Move description in the SoC dtsi specific file
V1: Initial post

---
 arch/arm64/boot/dts/rockchip/rk3399.dtsi | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
arch/arm64/boot/dts/rockchip/rk3399.dtsi +18 -0
index d3cdf6f42a30..901515898b5e 100644
@@ -76,6 +76,7 @@ cpu_l0: cpu@0 {
 			#cooling-cells = <2>; /* min followed by max */
 			dynamic-power-coefficient = <100>;
 			cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>;
+			powerzone = <&PKG_PZ>;
 		};
 
 		cpu_l1: cpu@1 {
@@ -88,6 +89,7 @@ cpu_l1: cpu@1 {
 			#cooling-cells = <2>; /* min followed by max */
 			dynamic-power-coefficient = <100>;
 			cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>;
+			powerzone = <&PKG_PZ>;
 		};
 
 		cpu_l2: cpu@2 {
@@ -100,6 +102,7 @@ cpu_l2: cpu@2 {
 			#cooling-cells = <2>; /* min followed by max */
 			dynamic-power-coefficient = <100>;
 			cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>;
+			powerzone = <&PKG_PZ>;
 		};
 
 		cpu_l3: cpu@3 {
@@ -112,6 +115,7 @@ cpu_l3: cpu@3 {
 			#cooling-cells = <2>; /* min followed by max */
 			dynamic-power-coefficient = <100>;
 			cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>;
+			powerzone = <&PKG_PZ>;
 		};
 
 		cpu_b0: cpu@100 {
@@ -124,6 +128,7 @@ cpu_b0: cpu@100 {
 			#cooling-cells = <2>; /* min followed by max */
 			dynamic-power-coefficient = <436>;
 			cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>;
+			powerzone = <&PKG_PZ>;
 
 			thermal-idle {
 				#cooling-cells = <2>;
@@ -142,6 +147,7 @@ cpu_b1: cpu@101 {
 			#cooling-cells = <2>; /* min followed by max */
 			dynamic-power-coefficient = <436>;
 			cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>;
+			powerzone = <&PKG_PZ>;
 
 			thermal-idle {
 				#cooling-cells = <2>;
@@ -791,6 +797,18 @@ spi5: spi@ff200000 {
 		status = "disabled";
 	};
 
+	powerzones {
+
+		PKG_PZ: powerzone-pkg {
+			#powerzone-cells = <0>;
+                        powerzone = <&SOC_PZ>;
+		};
+
+		SOC_PZ: powerzone-soc {
+			#powerzone-cells = <0>;
+		};
+	};
+
 	thermal_zones: thermal-zones {
 		cpu_thermal: cpu-thermal {
 			polling-delay-passive = <100>;
Signature · 1 line
2.25.1
#2 lore raw

PATCH v4 3/5 powercap/drivers/dtpm: Add DT initialization support

In reply to Daniel Lezcano

The DTPM framework is available but without a way to configure it.

These changes add DT support to initialize the powercap hierarchy via the powerzones description.

It acts in two steps. First it reads the powerzone dependencies and build the DTPM hierarchy. Second, it search for all devices which belongs to a powerzone and attach them to the hierarchy.

This approach makes the initialization self-encapsulated for the DTPM components.

In order to ensure a nice self-encapsulation, the DTPM table descriptors contains a couple of initialization functions, one to setup the DTPM backend and one to initialize it up. With this approach, the DTPM framework has a very few functions to export.

---
 drivers/powercap/Kconfig    |  1 +
 drivers/powercap/dtpm.c     | 95 +++++++++++++++++++++++++++++++++++--
 drivers/powercap/dtpm_cpu.c |  2 +-
 include/linux/dtpm.h        | 19 +++++++-
 4 files changed, 110 insertions(+), 7 deletions(-)
drivers/powercap/Kconfig +1 -0
index 8242e8c5ed77..b1ca339957e3 100644
@@ -46,6 +46,7 @@ config IDLE_INJECT
 
 config DTPM
 	bool "Power capping for Dynamic Thermal Power Management (EXPERIMENTAL)"
+	depends on OF
 	help
 	  This enables support for the power capping for the dynamic
 	  thermal power management userspace engine.
drivers/powercap/dtpm.c +91 -4

115 lines not on this page · raw message

drivers/powercap/dtpm_cpu.c +1 -1
index b740866b228d..6bffb44c75aa 100644
@@ -269,4 +269,4 @@ static int __init dtpm_cpu_init(void)
 	return 0;
 }
 
-DTPM_DECLARE(dtpm_cpu, dtpm_cpu_init);
+DTPM_DECLARE(dtpm_cpu, dtpm_cpu_init, NULL);
include/linux/dtpm.h +17 -2
index d37e5d06a357..7328682f24c9 100644
@@ -32,23 +32,28 @@ struct dtpm_ops {
 	void (*release)(struct dtpm *);
 };
 
+struct device_node;
+
 typedef int (*dtpm_init_t)(void);
+typedef int (*dtpm_setup_t)(struct dtpm *, struct device_node *);
 
 struct dtpm_descr {
 	dtpm_init_t init;
+	dtpm_setup_t setup;
 };
 
 /* Init section thermal table */
 extern struct dtpm_descr __dtpm_table[];
 extern struct dtpm_descr __dtpm_table_end[];
 
-#define DTPM_TABLE_ENTRY(name, __init)				\
+#define DTPM_TABLE_ENTRY(name, __init, __setup)			\
 	static struct dtpm_descr __dtpm_table_entry_##name	\
 	__used __section("__dtpm_table") = {			\
 		.init = __init,					\
+		.setup = __setup,				\
 	}
 
-#define DTPM_DECLARE(name, init)	DTPM_TABLE_ENTRY(name, init)
+#define DTPM_DECLARE(name, init, setup)	DTPM_TABLE_ENTRY(name, init, setup)
 
 #define for_each_dtpm_table(__dtpm)	\
 	for (__dtpm = __dtpm_table;	\
@@ -60,6 +65,16 @@ static inline struct dtpm *to_dtpm(struct powercap_zone *zone)
 	return container_of(zone, struct dtpm, zone);
 }
 
+static inline void dtpm_set_data(struct dtpm *dtpm, void *data)
+{
+	powercap_set_zone_data(&dtpm->zone, data);
+}
+
+static inline void *dtpm_get_data(struct dtpm *dtpm)
+{
+	return powercap_get_zone_data(&dtpm->zone);
+}
+
 int dtpm_update_power(struct dtpm *dtpm);
 
 int dtpm_release_zone(struct powercap_zone *pcz);
Signature · 1 line
2.25.1
#3 lore raw

PATCH v4 4/5 powercap/drivers/dtpm: Add CPU DT initialization support

In reply to Daniel Lezcano

Based on the previous DT changes in the core code, use the 'setup' callback to initialize the CPU DTPM backend.

Code is reorganized to stick to the DTPM table description. No functional changes.

---
 drivers/powercap/dtpm_cpu.c | 35 +++++++++++++++++++++++++++++------
 1 file changed, 29 insertions(+), 6 deletions(-)
drivers/powercap/dtpm_cpu.c +29 -6
index 6bffb44c75aa..64cec0770803 100644
@@ -21,6 +21,7 @@
 #include <linux/cpuhotplug.h>
 #include <linux/dtpm.h>
 #include <linux/energy_model.h>
+#include <linux/of.h>
 #include <linux/pm_qos.h>
 #include <linux/slab.h>
 #include <linux/units.h>
@@ -176,6 +177,17 @@ static int cpuhp_dtpm_cpu_offline(unsigned int cpu)
 }
 
 static int cpuhp_dtpm_cpu_online(unsigned int cpu)
+{
+	struct dtpm_cpu *dtpm_cpu;
+
+	dtpm_cpu = per_cpu(dtpm_per_cpu, cpu);
+	if (dtpm_cpu)
+		return dtpm_update_power(&dtpm_cpu->dtpm);
+
+	return 0;
+}
+
+static int __dtpm_cpu_setup(int cpu, struct dtpm *parent)
 {
 	struct dtpm_cpu *dtpm_cpu;
 	struct cpufreq_policy *policy;
@@ -183,6 +195,10 @@ static int cpuhp_dtpm_cpu_online(unsigned int cpu)
 	char name[CPUFREQ_NAME_LEN];
 	int ret = -ENOMEM;
 
+	dtpm_cpu = per_cpu(dtpm_per_cpu, cpu);
+	if (dtpm_cpu)
+		return 0;
+
 	policy = cpufreq_cpu_get(cpu);
 	if (!policy)
 		return 0;
@@ -191,10 +207,6 @@ static int cpuhp_dtpm_cpu_online(unsigned int cpu)
 	if (!pd)
 		return -EINVAL;
 
-	dtpm_cpu = per_cpu(dtpm_per_cpu, cpu);
-	if (dtpm_cpu)
-		return dtpm_update_power(&dtpm_cpu->dtpm);
-
 	dtpm_cpu = kzalloc(sizeof(*dtpm_cpu), GFP_KERNEL);
 	if (!dtpm_cpu)
 		return -ENOMEM;
@@ -207,7 +219,7 @@ static int cpuhp_dtpm_cpu_online(unsigned int cpu)
 
 	snprintf(name, sizeof(name), "cpu%d-cpufreq", dtpm_cpu->cpu);
 
-	ret = dtpm_register(name, &dtpm_cpu->dtpm, NULL);
+	ret = dtpm_register(name, &dtpm_cpu->dtpm, parent);
 	if (ret)
 		goto out_kfree_dtpm_cpu;
 
@@ -231,6 +243,17 @@ static int cpuhp_dtpm_cpu_online(unsigned int cpu)
 	return ret;
 }
 
+static int __init dtpm_cpu_setup(struct dtpm *dtpm, struct device_node *np)
+{
+	int cpu;
+
+	cpu = of_cpu_node_to_id(np);
+	if (cpu < 0)
+		return 0;
+
+	return __dtpm_cpu_setup(cpu, dtpm);
+}
+
 static int __init dtpm_cpu_init(void)
 {
 	int ret;
@@ -269,4 +292,4 @@ static int __init dtpm_cpu_init(void)
 	return 0;
 }
 
-DTPM_DECLARE(dtpm_cpu, dtpm_cpu_init, NULL);
+DTPM_DECLARE(dtpm_cpu, dtpm_cpu_init, dtpm_cpu_setup);
Signature · 1 line
2.25.1
#4 lore raw

PATCH v4 5/5 powercap/drivers/dtpm: Add dtpm devfreq with energy model support

In reply to Daniel Lezcano

Currently the dtpm supports the CPUs via cpufreq and the energy model. This change provides the same for the device which supports devfreq.

Each device supporting devfreq and having an energy model will be added to the hierarchy if the corresponding powerzone is described in the DT.

The concept is the same as the cpufreq DTPM support: the QoS is used to aggregate the requests and the energy model gives the value of the instantaneous power consumption ponderated by the load of the device.

Cc Chanwoo Choi <[email protected]>
Cc Lukasz Luba <[email protected]>
Cc Kyungmin Park <[email protected]>
Cc MyungJoo Ham <[email protected]>

---
V2:
- Fixed missing prototype warning reported by lkp@
V1: Initial post

---
 drivers/powercap/Kconfig        |   7 ++
 drivers/powercap/Makefile       |   1 +
 drivers/powercap/dtpm_devfreq.c | 201 ++++++++++++++++++++++++++++++++
 3 files changed, 209 insertions(+)
 create mode 100644 drivers/powercap/dtpm_devfreq.c
drivers/powercap/Kconfig +7 -0
index b1ca339957e3..515e3ceb3393 100644
@@ -57,4 +57,11 @@ config DTPM_CPU
 	help
 	  This enables support for CPU power limitation based on
 	  energy model.
+
+config DTPM_DEVFREQ
+	bool "Add device power capping based on the energy model"
+	depends on DTPM && ENERGY_MODEL
+	help
+	  This enables support for device power limitation based on
+	  energy model.
 endif
drivers/powercap/Makefile +1 -0
index fabcf388a8d3..494617cdad88 100644
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 obj-$(CONFIG_DTPM) += dtpm.o
 obj-$(CONFIG_DTPM_CPU) += dtpm_cpu.o
+obj-$(CONFIG_DTPM_DEVFREQ) += dtpm_devfreq.o
 obj-$(CONFIG_POWERCAP)	+= powercap_sys.o
 obj-$(CONFIG_INTEL_RAPL_CORE) += intel_rapl_common.o
 obj-$(CONFIG_INTEL_RAPL) += intel_rapl_msr.o
drivers/powercap/dtpm_devfreq.c new file +201 -0

201 lines not on this page · raw message

Signature · 1 line
2.25.1
maintainer
#5 lore raw
In reply to Daniel Lezcano
Quoted 5 lines · Daniel Lezcano

The proposed bindings are describing a set of powerzones.

A power zone is the logical name for a component which is capable of power capping and where we can measure the power consumption.

How is the power consumption measured? I don't see anything in the binding allowing for that.

Quoted 7 lines

A power zone can aggregate several power zones in terms of power measurement and power limitations. That allows to apply power constraint to a group of components and let the system balance the allocated power in order to comply with the constraint.

The ARM System Control and Management Interface (SCMI) can provide a power zone description.

Instead of DT?

Quoted 3 lines

The powerzone semantic is also found on the Intel platform with the RAPL register.

That means nothing to me...

Quoted 52 lines

The Linux kernel powercap framework deals with the powerzones:

https://www.kernel.org/doc/html/latest/power/powercap/powercap.html

The powerzone can also represent a group of children powerzones, hence the description can result on a hierarchy. Such hierarchy already exists with the hardware or can be represented and computed from the kernel.

The hierarchical description was initially proposed but not desired given there are other descriptions like the power domain proposing almost the same description.

https://lore.kernel.org/all/CAL_JsqLuLcHj7525tTUmh7pLqe7T2j6UcznyhV7joS8ipyb_VQ@mail.gmail.com/

The description gives the power constraint dependencies to apply on a specific group of logically or physically aggregated devices. They do not represent the physical location or the power domains of the SoC even if the description could be similar.

---
V3:
- Removed required property 'compatible'
- Removed powerzone-cells from the topmost node
- Removed powerzone-cells from cpus 'consumers' in example
- Set additionnal property to false
V2:
- Added pattern properties and stick to powerzone-*
- Added required property compatible and powerzone-cells
- Added additionnal property
- Added compatible
- Renamed to 'powerzones'
- Added missing powerzone-cells to the topmost node
- Fixed errors reported by 'make DT_CHECKER_FLAGS=-m dt_binding_check'
V1: Initial post

---
 .../devicetree/bindings/power/powerzones.yaml | 97 +++++++++++++++++++
 1 file changed, 97 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/powerzones.yaml
Documentation/devicetree/bindings/power/powerzones.yaml new file +0 -0
new file mode 100644
index 000000000000..ddb790acfea6

Documentation/devicetree/bindings/power/powerzones.yaml line 1

Quoted 1 line
Documentation/devicetree/bindings/power/powerzones.yaml new file +1 -0
@@ -0,0 +1,97 @@
+# SPDX-License-Identifier: GPL-2.0

New bindings should be dual licensed (add BSD-2-Clause).

Quoted 23 lines
Documentation/devicetree/bindings/power/powerzones.yaml new file +23 -0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/power/powerzones.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Power zones description
+
+maintainers:
+  - Daniel Lezcano <[email protected]>
+
+description: |+
+
+  A System on Chip contains a multitude of active components and each
+  of them is a source of heat. Even if a temperature sensor is not
+  present, a source of heat can be controlled by acting on the
+  consumed power via different techniques.
+
+  A powerzone describes a component or a group of components where we
+  can control the maximum power consumption. For instance, a group of
+  CPUs via the performance domain, a LCD screen via the brightness,
+  etc ...
+
+  Different components when they are used together can significantly

Documentation/devicetree/bindings/power/powerzones.yaml line 34

Quoted 10 lines
Documentation/devicetree/bindings/power/powerzones.yaml new file +10 -0
+  increase the overall temperature, so the description needs to
+  reflect this dependency in order to assign a power budget for a
+  group of powerzones.
+
+  This description is done via a hierarchy and the DT reflects it. It
+  does not represent the physical location or a topology, eg. on a
+  big.Little system, the little CPUs may not be represented as they do
+  not contribute significantly to the heat, however the GPU can be
+  tied with the big CPUs as they usually have a connection for
+  multimedia or game workloads.

Can't most of this just be assumed. We have some DT data already for capacity and power per mhz along with opp tables. Isn't that enough information?

The correlation with CPU and GPU usage is totally workload dependent which has nothing to do with DT. Nor it is platform specific really.

Quoted 66 lines
Documentation/devicetree/bindings/power/powerzones.yaml new file +63 -1
+
+properties:
+  $nodename:
+    const: powerzones
+
+patternProperties:
+  "^(powerzone)([@-].*)?$":
+    type: object
+    description:
+      A node representing a powerzone acting as an aggregator for all
+      its children powerzones.
+
+    properties:
+      "#powerzone-cells":
+        description:
+          Number of cells in powerzone specifier. Typically 0 for nodes
+          representing but it can be any number in the future to
+          describe parameters of the powerzone.
+
+      powerzones:
+        description:
+          A phandle to a parent powerzone. If no powerzone attribute is
+          set, the described powerzone is the topmost in the hierarchy.
+
+    required:
+      - "#powerzone-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    powerzones {
+
+      SOC_PZ: powerzone-soc {
+        #powerzone-cells = <0>;
+      };
+
+      PKG_PZ: powerzone-pkg {
+        #powerzone-cells = <0>;
+        powerzones = <&SOC_PZ>;
+      };
+
+      GPU_PZ: powerzone-gpu {
+        #powerzone-cells = <0>;
+        powerzones = <&PKG_PZ>;
+      };
+    };
+
+  - |
+    A57_0: big@0 {
+      compatible = "arm,cortex-a57";
+      reg = <0x0 0x0>;
+      device_type = "cpu";
+      powerzones = <&PKG_PZ>;
+    };
+
+    A57_1: big@1 {
+      compatible = "arm,cortex-a57";
+      reg = <0x0 0x0>;
+      device_type = "cpu";
+      powerzones = <&PKG_PZ>;
+    };
+...
--

2.25.1

#6 lore raw

Hi Rob,

thanks for taking the time to review the bindings.

Quoted 9 lines · Rob Herring
Quoted 5 lines · Daniel Lezcano

The proposed bindings are describing a set of powerzones.

A power zone is the logical name for a component which is capable of power capping and where we can measure the power consumption.

How is the power consumption measured? I don't see anything in the binding allowing for that.

Mmh, good point.

It is based on the energy model which is built from the "dynamic-power-coefficient" but this one provides only for CPUs and GPUs ATM.

In the future, SCMI will provide get/set power/level

What would you suggest?

Quoted 9 lines
Quoted 7 lines

A power zone can aggregate several power zones in terms of power measurement and power limitations. That allows to apply power constraint to a group of components and let the system balance the allocated power in order to comply with the constraint.

The ARM System Control and Management Interface (SCMI) can provide a power zone description.

Instead of DT?

It can use DT or SCMI protocol. That is what I understood from the white paper [1] page 6

Lukasz may confirm / elaborate ?

Quoted 4 lines
Quoted 2 lines

The powerzone semantic is also found on the Intel platform with the RAPL register.

That means nothing to me...

The Running Average Power Limit [2]. Each powerzone has a RAPL register where you can read the power and set the power limit.

Quoted 84 lines
Quoted 51 lines

The Linux kernel powercap framework deals with the powerzones:

https://www.kernel.org/doc/html/latest/power/powercap/powercap.html

The powerzone can also represent a group of children powerzones, hence the description can result on a hierarchy. Such hierarchy already exists with the hardware or can be represented and computed from the kernel.

The hierarchical description was initially proposed but not desired given there are other descriptions like the power domain proposing almost the same description.

https://lore.kernel.org/all/CAL_JsqLuLcHj7525tTUmh7pLqe7T2j6UcznyhV7joS8ipyb_VQ@mail.gmail.com/

The description gives the power constraint dependencies to apply on a specific group of logically or physically aggregated devices. They do not represent the physical location or the power domains of the SoC even if the description could be similar.

---
V3:
- Removed required property 'compatible'
- Removed powerzone-cells from the topmost node
- Removed powerzone-cells from cpus 'consumers' in example
- Set additionnal property to false
V2:
- Added pattern properties and stick to powerzone-*
- Added required property compatible and powerzone-cells
- Added additionnal property
- Added compatible
- Renamed to 'powerzones'
- Added missing powerzone-cells to the topmost node
- Fixed errors reported by 'make DT_CHECKER_FLAGS=-m dt_binding_check'
V1: Initial post

---
 .../devicetree/bindings/power/powerzones.yaml | 97 +++++++++++++++++++
 1 file changed, 97 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/powerzones.yaml
Documentation/devicetree/bindings/power/powerzones.yaml new file +0 -0
new file mode 100644
index 000000000000..ddb790acfea6

Documentation/devicetree/bindings/power/powerzones.yaml line 1

Quoted 1 line
Documentation/devicetree/bindings/power/powerzones.yaml new file +1 -0
@@ -0,0 +1,97 @@
+# SPDX-License-Identifier: GPL-2.0

New bindings should be dual licensed (add BSD-2-Clause).

Quoted 29 lines
Documentation/devicetree/bindings/power/powerzones.yaml new file +29 -0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/power/powerzones.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Power zones description
+
+maintainers:
+  - Daniel Lezcano <[email protected]>
+
+description: |+
+
+  A System on Chip contains a multitude of active components and each
+  of them is a source of heat. Even if a temperature sensor is not
+  present, a source of heat can be controlled by acting on the
+  consumed power via different techniques.
+
+  A powerzone describes a component or a group of components where we
+  can control the maximum power consumption. For instance, a group of
+  CPUs via the performance domain, a LCD screen via the brightness,
+  etc ...
+
+  Different components when they are used together can significantly
+  increase the overall temperature, so the description needs to
+  reflect this dependency in order to assign a power budget for a
+  group of powerzones.
+
+  This description is done via a hierarchy and the DT reflects it. It
+  does not represent the physical location or a topology, eg. on a
Quoted 8 lines

Documentation/devicetree/bindings/power/powerzones.yaml line 34

Quoted 4 lines
Documentation/devicetree/bindings/power/powerzones.yaml new file +4 -0
+  big.Little system, the little CPUs may not be represented as they do
+  not contribute significantly to the heat, however the GPU can be
+  tied with the big CPUs as they usually have a connection for
+  multimedia or game workloads.

Can't most of this just be assumed. We have some DT data already for capacity and power per mhz along with opp tables. Isn't that enough information?

We have a lot of information already and that is the reason why there is few information in the description ATM. We need to describe what is a powerzone and the constraints hierarchy between the powerzones.

The hierarchy could be in the hardware and immutable like the RAPL as described above which has a RAPL per package, per memory and one on top of them reporting their energy consumption.

Here we want to describe how we want to aggregate the powerzones, so the power constraints will be hierarchically described.

Quoted 2 lines

The correlation with CPU and GPU usage is totally workload dependent which has nothing to do with DT.

I was probably unclear, IMO it is platform specific.

For example, let's imagine we have a *thermal* sensor between the Bigs and the GPU. There is no way to know which one is contributing and how to mitigate them.

But if we know the sustainable power for the big+gpu is eg. 5000mW, then we can group them under the same powerzone parent and set its power to the sustainable one. From there it is possible to ensure the power limit and act on the power for each of them.

Quoted 1 line

Nor it is platform specific really.

The problem is we have devices which are powerzones (CPU, GPU, screen backlight, memory, DSP, ...) and AFAICT they can be described in the DT as such (may be just with a property), right?

Unfortunately, we have only a part of the description because we don't have the relationship between them. Can this relationship be described in the DT?

-- D.

[1]
https://developer.arm.com/-/media/Arm%20Developer%20Community/PDF/Arm_Power_and_Performance_Management_SCMI_White_Paper.pdf?revision=15e9d3dd-ecc6-40ab-a8c5-6bb4fa3fc060

[2] https://01.org/blogs/2014/running-average-power-limit-%E2%80%93-rapl

Quoted 66 lines
Quoted 66 lines
Documentation/devicetree/bindings/power/powerzones.yaml new file +63 -1
+
+properties:
+  $nodename:
+    const: powerzones
+
+patternProperties:
+  "^(powerzone)([@-].*)?$":
+    type: object
+    description:
+      A node representing a powerzone acting as an aggregator for all
+      its children powerzones.
+
+    properties:
+      "#powerzone-cells":
+        description:
+          Number of cells in powerzone specifier. Typically 0 for nodes
+          representing but it can be any number in the future to
+          describe parameters of the powerzone.
+
+      powerzones:
+        description:
+          A phandle to a parent powerzone. If no powerzone attribute is
+          set, the described powerzone is the topmost in the hierarchy.
+
+    required:
+      - "#powerzone-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    powerzones {
+
+      SOC_PZ: powerzone-soc {
+        #powerzone-cells = <0>;
+      };
+
+      PKG_PZ: powerzone-pkg {
+        #powerzone-cells = <0>;
+        powerzones = <&SOC_PZ>;
+      };
+
+      GPU_PZ: powerzone-gpu {
+        #powerzone-cells = <0>;
+        powerzones = <&PKG_PZ>;
+      };
+    };
+
+  - |
+    A57_0: big@0 {
+      compatible = "arm,cortex-a57";
+      reg = <0x0 0x0>;
+      device_type = "cpu";
+      powerzones = <&PKG_PZ>;
+    };
+
+    A57_1: big@1 {
+      compatible = "arm,cortex-a57";
+      reg = <0x0 0x0>;
+      device_type = "cpu";
+      powerzones = <&PKG_PZ>;
+    };
+...
--

2.25.1

Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
maintainer
#7 lore raw
Quoted 13 lines · Daniel Lezcano

Hi Rob,

thanks for taking the time to review the bindings.

Quoted 7 lines · Rob Herring
Quoted 5 lines · Daniel Lezcano

The proposed bindings are describing a set of powerzones.

A power zone is the logical name for a component which is capable of power capping and where we can measure the power consumption.

Quoted 8 lines
Quoted 2 lines

How is the power consumption measured? I don't see anything in the binding allowing for that.

Mmh, good point.

It is based on the energy model which is built from the "dynamic-power-coefficient" but this one provides only for CPUs and GPUs ATM.

That's more a calculated power than measured. Measured implies some h/w or firmware interface, but there isn't one it seems.

Wouldn't anything with "dynamic-power-coefficient" be a powerzone implicitly?

Quoted 12 lines

In the future, SCMI will provide get/set power/level

What would you suggest?

Quoted 8 lines
Quoted 7 lines

A power zone can aggregate several power zones in terms of power measurement and power limitations. That allows to apply power constraint to a group of components and let the system balance the allocated power in order to comply with the constraint.

The ARM System Control and Management Interface (SCMI) can provide a power zone description.

Quoted 6 lines
Quoted 1 line

Instead of DT?

It can use DT or SCMI protocol. That is what I understood from the white paper [1] page 6

Lukasz may confirm / elaborate ?

Do you mean the 'performance protocol'? Because we have a binding for that too! And that is exactly the problem. No one, AFAICT, looks at all aspects of power/performance/thermal together.

Quoted 109 lines
Quoted 4 lines
Quoted 2 lines

The powerzone semantic is also found on the Intel platform with the RAPL register.

That means nothing to me...

The Running Average Power Limit [2]. Each powerzone has a RAPL register where you can read the power and set the power limit.

Quoted 84 lines
Quoted 51 lines

The Linux kernel powercap framework deals with the powerzones:

https://www.kernel.org/doc/html/latest/power/powercap/powercap.html

The powerzone can also represent a group of children powerzones, hence the description can result on a hierarchy. Such hierarchy already exists with the hardware or can be represented and computed from the kernel.

The hierarchical description was initially proposed but not desired given there are other descriptions like the power domain proposing almost the same description.

https://lore.kernel.org/all/CAL_JsqLuLcHj7525tTUmh7pLqe7T2j6UcznyhV7joS8ipyb_VQ@mail.gmail.com/

The description gives the power constraint dependencies to apply on a specific group of logically or physically aggregated devices. They do not represent the physical location or the power domains of the SoC even if the description could be similar.

---
V3:
- Removed required property 'compatible'
- Removed powerzone-cells from the topmost node
- Removed powerzone-cells from cpus 'consumers' in example
- Set additionnal property to false
V2:
- Added pattern properties and stick to powerzone-*
- Added required property compatible and powerzone-cells
- Added additionnal property
- Added compatible
- Renamed to 'powerzones'
- Added missing powerzone-cells to the topmost node
- Fixed errors reported by 'make DT_CHECKER_FLAGS=-m dt_binding_check'
V1: Initial post

---
 .../devicetree/bindings/power/powerzones.yaml | 97 +++++++++++++++++++
 1 file changed, 97 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/powerzones.yaml
Documentation/devicetree/bindings/power/powerzones.yaml new file +0 -0
new file mode 100644
index 000000000000..ddb790acfea6

Documentation/devicetree/bindings/power/powerzones.yaml line 1

Quoted 1 line
Documentation/devicetree/bindings/power/powerzones.yaml new file +1 -0
@@ -0,0 +1,97 @@
+# SPDX-License-Identifier: GPL-2.0

New bindings should be dual licensed (add BSD-2-Clause).

Quoted 29 lines
Documentation/devicetree/bindings/power/powerzones.yaml new file +29 -0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/power/powerzones.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Power zones description
+
+maintainers:
+  - Daniel Lezcano <[email protected]>
+
+description: |+
+
+  A System on Chip contains a multitude of active components and each
+  of them is a source of heat. Even if a temperature sensor is not
+  present, a source of heat can be controlled by acting on the
+  consumed power via different techniques.
+
+  A powerzone describes a component or a group of components where we
+  can control the maximum power consumption. For instance, a group of
+  CPUs via the performance domain, a LCD screen via the brightness,
+  etc ...
+
+  Different components when they are used together can significantly
+  increase the overall temperature, so the description needs to
+  reflect this dependency in order to assign a power budget for a
+  group of powerzones.
+
+  This description is done via a hierarchy and the DT reflects it. It
+  does not represent the physical location or a topology, eg. on a
Quoted 8 lines

Documentation/devicetree/bindings/power/powerzones.yaml line 34

Quoted 4 lines
Documentation/devicetree/bindings/power/powerzones.yaml new file +4 -0
+  big.Little system, the little CPUs may not be represented as they do
+  not contribute significantly to the heat, however the GPU can be
+  tied with the big CPUs as they usually have a connection for
+  multimedia or game workloads.

Can't most of this just be assumed. We have some DT data already for capacity and power per mhz along with opp tables. Isn't that enough information?

We have a lot of information already and that is the reason why there is few information in the description ATM. We need to describe what is a powerzone and the constraints hierarchy between the powerzones.

The hierarchy could be in the hardware and immutable like the RAPL as described above which has a RAPL per package, per memory and one on top of them reporting their energy consumption.

Quoted 7 lines

Here we want to describe how we want to aggregate the powerzones, so the power constraints will be hierarchically described.

Quoted 2 lines

The correlation with CPU and GPU usage is totally workload dependent which has nothing to do with DT.

I was probably unclear, IMO it is platform specific.

We can debate that, but it shouldn't come down our opinions. Where are the multiple platforms that show this is different and that we must describe the difference?

Quoted 3 lines

For example, let's imagine we have a *thermal* sensor between the Bigs and the GPU. There is no way to know which one is contributing and how to mitigate them.

So once the h/w is not sharing a thermal sensor, we don't need the powerzone binding and go back to thermal zones? Sounds like thermal zones need to be extended to work without a sensor.

Quoted 10 lines

But if we know the sustainable power for the big+gpu is eg. 5000mW, then we can group them under the same powerzone parent and set its power to the sustainable one. From there it is possible to ensure the power limit and act on the power for each of them.

Quoted 1 line

Nor it is platform specific really.

The problem is we have devices which are powerzones (CPU, GPU, screen backlight, memory, DSP, ...) and AFAICT they can be described in the DT as such (may be just with a property), right?

Right, I would think that is "dynamic-power-coefficient" plus an OPP table for the devices.

Quoted 3 lines

Unfortunately, we have only a part of the description because we don't have the relationship between them. Can this relationship be described in the DT?

I'd rather see this taken as far as possible without DT and when things don't work across multiple platforms look at what needs to be in DT.

Or say the interface must be SCMI and that has to provide everything you need. It wouldn't be the first Arm spec that had to be revised because the DT binding was rejected (FF-A).

Rob