Skip to contentSkip to conversation

Control PL310 pwr_ctrl register through DT

PATCH Superseded Brad Mouring 4 participants 23 messages Feb 23, 2016 – Apr 28, 2016

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

cover Control PL310 pwr_ctrl register through DT

During some performance-oriented benchmarking on a Cortex A9 platform, a slight performance degradation was noted on datasets that spanned into the L2 cache (<10%). This performance hit was minor, but it prompted investigation into the cause.

One difference in the actual PL310 configuration that was concerning was the enabling of two PM-related changes: Dynamic Clock Gating and Standby Mode Enabling. As the kernel being tested was patched and configured to use the PREEMPT_RT patchset, it was desired to disable these settings for our use-case since anything PM can (and usually does) impact determinism.

Making these changes resulted in a modest performance improvement and those wonderful warm-n-fuzzies regarding determinism and enabling system control without needing to change the kernel.

In the following set, there's the actual change to control these features given DT presence of a couple of new bindings and the documenation to accompany those changes. Thanks!

#1 lore raw

PATCH 1/2 pl2x0: Add OF control of cache power management

Add ability to override power management bits of 310 controllers through OF entries. As the saved register is only applied when working on a supported controller, it is safe to save the settings.

Additionally, to control the actual configuration of the power control register, remove the unconditional enabling of features in the l2c310_enable function.

---
 arch/arm/mm/cache-l2x0.c | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)
arch/arm/mm/cache-l2x0.c +24 -5
index d6e43d8..42f4ad1 100644
@@ -639,11 +639,6 @@ static void __init l2c310_enable(void __iomem *base, u32 aux, unsigned num_lock)
 		aux &= ~(L310_AUX_CTRL_FULL_LINE_ZERO | L310_AUX_CTRL_EARLY_BRESP);
 	}
 
-	/* r3p0 or later has power control register */
-	if (rev >= L310_CACHE_ID_RTL_R3P0)
-		l2x0_saved_regs.pwr_ctrl = L310_DYNAMIC_CLK_GATING_EN |
-						L310_STNDBY_MODE_EN;
-
 	/*
 	 * Always enable non-secure access to the lockdown registers -
 	 * we write to them as part of the L2C enable sequence so they
@@ -1103,6 +1098,7 @@ static void __init l2c310_of_parse(const struct device_node *np,
 	u32 filter[2] = { 0, 0 };
 	u32 assoc;
 	u32 prefetch;
+	u32 power;
 	u32 val;
 	int ret;
 
@@ -1220,6 +1216,29 @@ static void __init l2c310_of_parse(const struct device_node *np,
 	}
 
 	l2x0_saved_regs.prefetch_ctrl = prefetch;
+
+	power = l2x0_saved_regs.pwr_ctrl;
+
+	ret = of_property_read_u32(np, "arm,dynamic-clock-gating", &val);
+	if (ret == 0) {
+		if (val)
+			power |= L310_DYNAMIC_CLK_GATING_EN;
+		else
+			power &= ~L310_DYNAMIC_CLK_GATING_EN;
+	} else if (ret != -EINVAL) {
+		pr_err("L2C-310 OF dynamic-clock-gating property value is missing\n");
+	}
+	ret = of_property_read_u32(np, "arm,standby-mode", &val);
+	if (ret == 0) {
+		if (val)
+			power |= L310_STNDBY_MODE_EN;
+		else
+			power &= ~L310_STNDBY_MODE_EN;
+	} else if (ret != -EINVAL) {
+		pr_err("L2C-310 OF standby-mode property value is missing\n");
+	}
+
+	l2x0_saved_regs.pwr_ctrl = power;
 }
 
 static const struct l2c_init_data of_l2c310_data __initconst = {
Signature · 1 line
2.7.1
#2 lore raw

PATCH 1/2 pl2x0: Add OF control of cache power management

In reply to Brad Mouring

Add ability to override power management bits of 310 controllers through OF entries. As the saved register is only applied when working on a supported controller, it is safe to save the settings.

Additionally, to control the actual configuration of the power control register, remove the unconditional enabling of features in the l2c310_enable function.

---
 arch/arm/mm/cache-l2x0.c | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)
arch/arm/mm/cache-l2x0.c +24 -5
index 9f9d542..7432dea 100644
@@ -647,11 +647,6 @@ static void __init l2c310_enable(void __iomem *base, unsigned num_lock)
 		aux &= ~(L310_AUX_CTRL_FULL_LINE_ZERO | L310_AUX_CTRL_EARLY_BRESP);
 	}
 
-	/* r3p0 or later has power control register */
-	if (rev >= L310_CACHE_ID_RTL_R3P0)
-		l2x0_saved_regs.pwr_ctrl = L310_DYNAMIC_CLK_GATING_EN |
-						L310_STNDBY_MODE_EN;
-
 	/*
 	 * Always enable non-secure access to the lockdown registers -
 	 * we write to them as part of the L2C enable sequence so they
@@ -1141,6 +1136,7 @@ static void __init l2c310_of_parse(const struct device_node *np,
 	u32 filter[2] = { 0, 0 };
 	u32 assoc;
 	u32 prefetch;
+	u32 power;
 	u32 val;
 	int ret;
 
@@ -1271,6 +1267,29 @@ static void __init l2c310_of_parse(const struct device_node *np,
 	}
 
 	l2x0_saved_regs.prefetch_ctrl = prefetch;
+
+	power = l2x0_saved_regs.pwr_ctrl;
+
+	ret = of_property_read_u32(np, "arm,dynamic-clock-gating", &val);
+	if (ret == 0) {
+		if (val)
+			power |= L310_DYNAMIC_CLK_GATING_EN;
+		else
+			power &= ~L310_DYNAMIC_CLK_GATING_EN;
+	} else if (ret != -EINVAL) {
+		pr_err("L2C-310 OF dynamic-clock-gating property value is missing\n");
+	}
+	ret = of_property_read_u32(np, "arm,standby-mode", &val);
+	if (ret == 0) {
+		if (val)
+			power |= L310_STNDBY_MODE_EN;
+		else
+			power &= ~L310_STNDBY_MODE_EN;
+	} else if (ret != -EINVAL) {
+		pr_err("L2C-310 OF standby-mode property value is missing\n");
+	}
+
+	l2x0_saved_regs.pwr_ctrl = power;
 }
 
 static const struct l2c_init_data of_l2c310_data __initconst = {
Signature · 1 line
2.7.1
#3 lore raw

PATCH 2/2 Documentation: devicetree: Add PL310 PM bindings

Document the DT bindings for controlling ARM PL310 Power Control settings.

---
 Documentation/devicetree/bindings/arm/l2c2x0.txt | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/arm/l2c2x0.txt +4 -0
index fe0398c..6b2366ed 100644
@@ -84,6 +84,10 @@ Optional properties:
 - prefetch-instr : Instruction prefetch. Value: <0> (forcibly disable),
   <1> (forcibly enable), property absent (retain settings set by
   firmware)
+- arm,dynamic-clock-gating : L2 dynamic clock gating. Value: <0> (forcibly
+  disable), <1> (forcibly enable), property absent (retain firmware settings)
+- arm,standby-mode: L2 standby mode enable. Value <0> (forcibly disable),
+  <1> (forcibly enable), property absent (retain firmware settings)
 
 Example:
 
Signature · 1 line
2.7.1
#4 lore raw

PATCH 2/2 Documentation: devicetree: Add PL310 PM bindings

In reply to Brad Mouring

Document the DT bindings for controlling ARM PL310 Power Control settings.

---
 Documentation/devicetree/bindings/arm/l2c2x0.txt | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/arm/l2c2x0.txt +4 -0
index 2251dcc..4c2d764 100644
@@ -72,6 +72,10 @@ Optional properties:
 - prefetch-instr : Instruction prefetch. Value: <0> (forcibly disable),
   <1> (forcibly enable), property absent (retain settings set by
   firmware)
+- arm,dynamic-clock-gating : L2 dynamic clock gating. Value: <0> (forcibly
+  disable), <1> (forcibly enable), property absent (retain firmware settings)
+- arm,standby-mode: L2 standby mode enable. Value <0> (forcibly disable),
+  <1> (forcibly enable), property absent (retain firmware settings)
 
 Example:
 
Signature · 1 line
2.7.1
#6 lore raw

v2 cover Control PL310 pwr_ctrl register through DT

In reply to Brad Mouring

This submission addresses the concerns brought up here:
http://www.spinics.net/lists/arm-kernel/msg495003.html

The of_property_read_u32 returns -EINVAL when the property is not found in the dtb, and we ignore that error. An error message is only printed when the property is present with an invalid value.

The other issue raised was concerning the default behavior if the properties are not in the dtb. The existing behavior prior to this changeset is maintained.

During some performance-oriented benchmarking on a Cortex A9 platform, a slight performance degradation was noted on datasets that spanned into the L2 cache (<10%). This performance hit was minor, but it prompted investigation into the cause.

One difference in the actual PL310 configuration that was concerning was the enabling of two PM-related changes: Dynamic Clock Gating and Standby Mode Enabling. As the kernel being tested was patched and configured to use the PREEMPT_RT patchset, it was desired to disable these settings for our use-case since anything PM can (and usually does) impact determinism.

Making these changes resulted in a modest performance improvement and those wonderful warm-n-fuzzies regarding determinism and enabling system control without needing to change the kernel.

In the following set, there's the actual change to control these features given DT presence of a couple of new bindings and the documenation to accompany those changes.

Thanks for the feedback!

#7 lore raw

PATCH v2 1/2 pl2x0: Add OF control of cache power management

Add ability to override power management bits of 310 controllers (dynamic clock gating and standby mode) through OF entries. As the saved register is only applied when working on a supported controller, it is safe to save the settings.

In order to maintain existing behavior, if the settings are not found in the DT, the corresponding feature will be enabled.

---
 arch/arm/mm/cache-l2x0.c | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)
arch/arm/mm/cache-l2x0.c +25 -5
index 9f9d542..f284bd3 100644
@@ -647,11 +647,6 @@ static void __init l2c310_enable(void __iomem *base, unsigned num_lock)
 		aux &= ~(L310_AUX_CTRL_FULL_LINE_ZERO | L310_AUX_CTRL_EARLY_BRESP);
 	}
 
-	/* r3p0 or later has power control register */
-	if (rev >= L310_CACHE_ID_RTL_R3P0)
-		l2x0_saved_regs.pwr_ctrl = L310_DYNAMIC_CLK_GATING_EN |
-						L310_STNDBY_MODE_EN;
-
 	/*
 	 * Always enable non-secure access to the lockdown registers -
 	 * we write to them as part of the L2C enable sequence so they
@@ -1141,6 +1136,7 @@ static void __init l2c310_of_parse(const struct device_node *np,
 	u32 filter[2] = { 0, 0 };
 	u32 assoc;
 	u32 prefetch;
+	u32 power;
 	u32 val;
 	int ret;
 
@@ -1271,6 +1267,30 @@ static void __init l2c310_of_parse(const struct device_node *np,
 	}
 
 	l2x0_saved_regs.prefetch_ctrl = prefetch;
+
+	power = l2x0_saved_regs.pwr_ctrl |
+		L310_DYNAMIC_CLK_GATING_EN | L310_STNDBY_MODE_EN;
+
+	ret = of_property_read_u32(np, "arm,dynamic-clock-gating", &val);
+	if (ret == 0) {
+		if (val)
+			power |= L310_DYNAMIC_CLK_GATING_EN;
+		else
+			power &= ~L310_DYNAMIC_CLK_GATING_EN;
+	} else if (ret != -EINVAL) {
+		pr_err("L2C-310 OF dynamic-clock-gating property value is missing or invalid\n");
+	}
+	ret = of_property_read_u32(np, "arm,standby-mode", &val);
+	if (ret == 0) {
+		if (val)
+			power |= L310_STNDBY_MODE_EN;
+		else
+			power &= ~L310_STNDBY_MODE_EN;
+	} else if (ret != -EINVAL) {
+		pr_err("L2C-310 OF standby-mode property value is missing or invalid\n");
+	}
+
+	l2x0_saved_regs.pwr_ctrl = power;
 }
 
 static const struct l2c_init_data of_l2c310_data __initconst = {
Signature · 1 line
2.7.3
#8 lore raw

PATCH v2 2/2 Documentation: devicetree: Add PL310 PM bindings

In reply to Brad Mouring

Document the DT bindings for controlling ARM PL310 Power Control settings.

---
 Documentation/devicetree/bindings/arm/l2c2x0.txt | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/arm/l2c2x0.txt +4 -0
index fe0398c..c1c756e 100644
@@ -84,6 +84,10 @@ Optional properties:
 - prefetch-instr : Instruction prefetch. Value: <0> (forcibly disable),
   <1> (forcibly enable), property absent (retain settings set by
   firmware)
+- arm,dynamic-clock-gating : L2 dynamic clock gating. Value: <0> (forcibly
+  disable), <1> or property absent (forcibly enable)
+- arm,standby-mode: L2 standby mode enable. Value <0> (forcibly disable),
+  <1>  or property absent (forcibly enable)
 
 Example:
 
Signature · 1 line
2.7.3
#9 lore raw

PATCH v2 2/2 Documentation: devicetree: Add PL310 PM bindings

Quoted 4 lines · Brad Mouring

Document the DT bindings for controlling ARM PL310 Power Control settings.

What happened to Josh's ack?

Quoted 9 lines
---
 Documentation/devicetree/bindings/arm/l2c2x0.txt | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/arm/l2c2x0.txt +0 -0
index fe0398c..c1c756e 100644

Documentation/devicetree/bindings/arm/l2c2x0.txt Optional properties: · line 90

Quoted 7 lines
Documentation/devicetree/bindings/arm/l2c2x0.txt +4 -0
@@ -84,6 +84,10 @@ Optional properties:
 - prefetch-instr : Instruction prefetch. Value: <0> (forcibly disable),
   <1> (forcibly enable), property absent (retain settings set by
   firmware)
+- arm,dynamic-clock-gating : L2 dynamic clock gating. Value: <0> (forcibly
+  disable), <1> or property absent (forcibly enable)
+- arm,standby-mode: L2 standby mode enable. Value <0> (forcibly disable),
+  <1>  or property absent (forcibly enable)

What happened to "retain settings set by firmware"?

Rob

#10 lore raw

PATCH v2 2/2 Documentation: devicetree: Add PL310 PM bindings

Quoted 12 lines · Rob Herring
Quoted 4 lines · Brad Mouring

Document the DT bindings for controlling ARM PL310 Power Control settings.

What happened to Josh's ack?

Quoted 4 lines
---
 Documentation/devicetree/bindings/arm/l2c2x0.txt | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 14 lines

Documentation/devicetree/bindings/arm/l2c2x0.txt Optional properties: · line 90

Quoted 12 lines
Documentation/devicetree/bindings/arm/l2c2x0.txt +4 -0
index fe0398c..c1c756e 100644
@@ -84,6 +84,10 @@ Optional properties:
 - prefetch-instr : Instruction prefetch. Value: <0> (forcibly disable),
   <1> (forcibly enable), property absent (retain settings set by
   firmware)
+- arm,dynamic-clock-gating : L2 dynamic clock gating. Value: <0> (forcibly
+  disable), <1> or property absent (forcibly enable)
+- arm,standby-mode: L2 standby mode enable. Value <0> (forcibly disable),
+  <1>  or property absent (forcibly enable)

What happened to "retain settings set by firmware"?

I said we shouldn't. Current behaviour is that we enable these features, and moving to missing-means-retain means that everything today ends up with these features disabled. IOW, it's yet another change of actual behaviour that every platform would see.

Signature · 3 lines
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
#11 lore raw

PATCH v2 2/2 Documentation: devicetree: Add PL310 PM bindings

Quoted 28 lines · Russell King - ARM Linux
Quoted 12 lines · Rob Herring
Quoted 4 lines · Brad Mouring

Document the DT bindings for controlling ARM PL310 Power Control settings.

What happened to Josh's ack?

Quoted 4 lines
---
 Documentation/devicetree/bindings/arm/l2c2x0.txt | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 14 lines

Documentation/devicetree/bindings/arm/l2c2x0.txt Optional properties: · line 90

Quoted 12 lines
Documentation/devicetree/bindings/arm/l2c2x0.txt +4 -0
index fe0398c..c1c756e 100644
@@ -84,6 +84,10 @@ Optional properties:
 - prefetch-instr : Instruction prefetch. Value: <0> (forcibly disable),
   <1> (forcibly enable), property absent (retain settings set by
   firmware)
+- arm,dynamic-clock-gating : L2 dynamic clock gating. Value: <0> (forcibly
+  disable), <1> or property absent (forcibly enable)
+- arm,standby-mode: L2 standby mode enable. Value <0> (forcibly disable),
+  <1>  or property absent (forcibly enable)

What happened to "retain settings set by firmware"?

Quoted 4 lines

I said we shouldn't. Current behaviour is that we enable these features, and moving to missing-means-retain means that everything today ends up with these features disabled. IOW, it's yet another change of actual behaviour that every platform would see.

Right, but then the properties are different from prefetch-instr and others IIRC. We're letting the OS define the binding. If BSD doesn't enable these settings currently, then there is a mismatch between the binding and actual behavior. Saying "retain firmware settings" also defines specific OS behavior. I think absent should mean OS is free to do whatever it wants which could be retain firmware settings, enable or disable. In other words, it is undefined as this ship has already sailed.

Rob

#12 lore raw

PATCH v2 2/2 Documentation: devicetree: Add PL310 PM bindings

Quoted 35 lines · Rob Herring
Quoted 28 lines · Russell King - ARM Linux
Quoted 12 lines · Rob Herring
Quoted 4 lines · Brad Mouring

Document the DT bindings for controlling ARM PL310 Power Control settings.

What happened to Josh's ack?

Quoted 4 lines
---
 Documentation/devicetree/bindings/arm/l2c2x0.txt | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 14 lines

Documentation/devicetree/bindings/arm/l2c2x0.txt Optional properties: · line 90

Quoted 12 lines
Documentation/devicetree/bindings/arm/l2c2x0.txt +4 -0
index fe0398c..c1c756e 100644
@@ -84,6 +84,10 @@ Optional properties:
 - prefetch-instr : Instruction prefetch. Value: <0> (forcibly disable),
   <1> (forcibly enable), property absent (retain settings set by
   firmware)
+- arm,dynamic-clock-gating : L2 dynamic clock gating. Value: <0> (forcibly
+  disable), <1> or property absent (forcibly enable)
+- arm,standby-mode: L2 standby mode enable. Value <0> (forcibly disable),
+  <1>  or property absent (forcibly enable)

What happened to "retain settings set by firmware"?

Quoted 4 lines

I said we shouldn't. Current behaviour is that we enable these features, and moving to missing-means-retain means that everything today ends up with these features disabled. IOW, it's yet another change of actual behaviour that every platform would see.

Quoted 8 lines

Right, but then the properties are different from prefetch-instr and others IIRC. We're letting the OS define the binding. If BSD doesn't enable these settings currently, then there is a mismatch between the binding and actual behavior. Saying "retain firmware settings" also defines specific OS behavior. I think absent should mean OS is free to do whatever it wants which could be retain firmware settings, enable or disable. In other words, it is undefined as this ship has already sailed.

Both positions have validity, I think the idealist in me sides with Rob (for something with definite tradeoffs, it's odd to force an assumption when there's no property) while the developer with experience sides with Russell (why needlessly change behavior that may have wide-reaching impact?) At this point, I don't have nearly the perspective to make a call on which is overall the "right" choice for the community, so maybe it should be an [RFC] instead? Thoughts?

Brad

#13 lore raw

PATCH v2 2/2 Documentation: devicetree: Add PL310 PM bindings

In reply to Rob Herring
Quoted 35 lines · Rob Herring
Quoted 28 lines · Russell King - ARM Linux
Quoted 12 lines · Rob Herring
Quoted 4 lines · Brad Mouring

Document the DT bindings for controlling ARM PL310 Power Control settings.

What happened to Josh's ack?

Quoted 4 lines
---
 Documentation/devicetree/bindings/arm/l2c2x0.txt | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 14 lines

Documentation/devicetree/bindings/arm/l2c2x0.txt Optional properties: · line 90

Quoted 12 lines
Documentation/devicetree/bindings/arm/l2c2x0.txt +4 -0
index fe0398c..c1c756e 100644
@@ -84,6 +84,10 @@ Optional properties:
 - prefetch-instr : Instruction prefetch. Value: <0> (forcibly disable),
   <1> (forcibly enable), property absent (retain settings set by
   firmware)
+- arm,dynamic-clock-gating : L2 dynamic clock gating. Value: <0> (forcibly
+  disable), <1> or property absent (forcibly enable)
+- arm,standby-mode: L2 standby mode enable. Value <0> (forcibly disable),
+  <1>  or property absent (forcibly enable)

What happened to "retain settings set by firmware"?

Quoted 4 lines

I said we shouldn't. Current behaviour is that we enable these features, and moving to missing-means-retain means that everything today ends up with these features disabled. IOW, it's yet another change of actual behaviour that every platform would see.

Quoted 8 lines

Right, but then the properties are different from prefetch-instr and others IIRC. We're letting the OS define the binding. If BSD doesn't enable these settings currently, then there is a mismatch between the binding and actual behavior. Saying "retain firmware settings" also defines specific OS behavior. I think absent should mean OS is free to do whatever it wants which could be retain firmware settings, enable or disable. In other words, it is undefined as this ship has already sailed.

I agree with "the ship has already sailed" but I disagree with the rest of your comment. The ship has already sailed in that we have an established behaviour which has been there for 18 months. Given the time period, it's not something I'm going to change at this stage, sorry.

Why? Such a change will go unnoticed, and it's particularly hard to debug why battery life has reduced.

I guess we need to find a way to ensure that the default behaviour stays. Whether that's by _everyone_ updating their DT files with the new properties or some other way, I don't care. I only care that we retain the behaviour we've had for the last 18 months.

Signature · 3 lines
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
#14 lore raw

PATCH v2 2/2 Documentation: devicetree: Add PL310 PM bindings

Quoted 51 lines · Russell King - ARM Linux
Quoted 35 lines · Rob Herring
Quoted 28 lines · Russell King - ARM Linux
Quoted 12 lines · Rob Herring
Quoted 4 lines · Brad Mouring

Document the DT bindings for controlling ARM PL310 Power Control settings.

What happened to Josh's ack?

Quoted 4 lines
---
 Documentation/devicetree/bindings/arm/l2c2x0.txt | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 14 lines

Documentation/devicetree/bindings/arm/l2c2x0.txt Optional properties: · line 90

Quoted 12 lines
Documentation/devicetree/bindings/arm/l2c2x0.txt +4 -0
index fe0398c..c1c756e 100644
@@ -84,6 +84,10 @@ Optional properties:
 - prefetch-instr : Instruction prefetch. Value: <0> (forcibly disable),
   <1> (forcibly enable), property absent (retain settings set by
   firmware)
+- arm,dynamic-clock-gating : L2 dynamic clock gating. Value: <0> (forcibly
+  disable), <1> or property absent (forcibly enable)
+- arm,standby-mode: L2 standby mode enable. Value <0> (forcibly disable),
+  <1>  or property absent (forcibly enable)

What happened to "retain settings set by firmware"?

Quoted 4 lines

I said we shouldn't. Current behaviour is that we enable these features, and moving to missing-means-retain means that everything today ends up with these features disabled. IOW, it's yet another change of actual behaviour that every platform would see.

Quoted 8 lines

Right, but then the properties are different from prefetch-instr and others IIRC. We're letting the OS define the binding. If BSD doesn't enable these settings currently, then there is a mismatch between the binding and actual behavior. Saying "retain firmware settings" also defines specific OS behavior. I think absent should mean OS is free to do whatever it wants which could be retain firmware settings, enable or disable. In other words, it is undefined as this ship has already sailed.

I agree with "the ship has already sailed" but I disagree with the rest of your comment. The ship has already sailed in that we have an established behaviour which has been there for 18 months. Given the time period, it's not something I'm going to change at this stage, sorry.

Quoted 7 lines

Why? Such a change will go unnoticed, and it's particularly hard to debug why battery life has reduced.

I guess we need to find a way to ensure that the default behaviour stays. Whether that's by _everyone_ updating their DT files with the new properties or some other way, I don't care. I only care that we retain the behaviour we've had for the last 18 months.

I'm not suggesting that we change behavior at all. I'm only suggesting that we leave it undefined in the binding documentation because the behavior is possibly OS specific and can't really be defined there.

Rob

#15 lore raw

PATCH v2 2/2 Documentation: devicetree: Add PL310 PM bindings

Quoted 61 lines · Rob Herring
Quoted 51 lines · Russell King - ARM Linux
Quoted 35 lines · Rob Herring
Quoted 28 lines · Russell King - ARM Linux
Quoted 12 lines · Rob Herring
Quoted 4 lines · Brad Mouring

Document the DT bindings for controlling ARM PL310 Power Control settings.

What happened to Josh's ack?

Quoted 4 lines
---
 Documentation/devicetree/bindings/arm/l2c2x0.txt | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 14 lines

Documentation/devicetree/bindings/arm/l2c2x0.txt Optional properties: · line 90

Quoted 12 lines
Documentation/devicetree/bindings/arm/l2c2x0.txt +4 -0
index fe0398c..c1c756e 100644
@@ -84,6 +84,10 @@ Optional properties:
 - prefetch-instr : Instruction prefetch. Value: <0> (forcibly disable),
   <1> (forcibly enable), property absent (retain settings set by
   firmware)
+- arm,dynamic-clock-gating : L2 dynamic clock gating. Value: <0> (forcibly
+  disable), <1> or property absent (forcibly enable)
+- arm,standby-mode: L2 standby mode enable. Value <0> (forcibly disable),
+  <1>  or property absent (forcibly enable)

What happened to "retain settings set by firmware"?

Quoted 4 lines

I said we shouldn't. Current behaviour is that we enable these features, and moving to missing-means-retain means that everything today ends up with these features disabled. IOW, it's yet another change of actual behaviour that every platform would see.

Quoted 8 lines

Right, but then the properties are different from prefetch-instr and others IIRC. We're letting the OS define the binding. If BSD doesn't enable these settings currently, then there is a mismatch between the binding and actual behavior. Saying "retain firmware settings" also defines specific OS behavior. I think absent should mean OS is free to do whatever it wants which could be retain firmware settings, enable or disable. In other words, it is undefined as this ship has already sailed.

I agree with "the ship has already sailed" but I disagree with the rest of your comment. The ship has already sailed in that we have an established behaviour which has been there for 18 months. Given the time period, it's not something I'm going to change at this stage, sorry.

Quoted 7 lines

Why? Such a change will go unnoticed, and it's particularly hard to debug why battery life has reduced.

I guess we need to find a way to ensure that the default behaviour stays. Whether that's by _everyone_ updating their DT files with the new properties or some other way, I don't care. I only care that we retain the behaviour we've had for the last 18 months.

Quoted 5 lines

I'm not suggesting that we change behavior at all. I'm only suggesting that we leave it undefined in the binding documentation because the behavior is possibly OS specific and can't really be defined there.

Rob

Ah, thanks for clarifying. However, I do have some additional clarifying questions:

When you note that it should be left undefined in the binding documentation, do you mean document the actual, well-defined behavior and leave it at that, or document the well-defined behavior and note that, in the case where the binding is missing, behavior is OS specific (my interpretation of your comment), or completely removed from the documentation altogether (I'd want to know the reasoning if this is what you meant, for my own edification).

Thanks as always for the feedback

Brad

#16 lore raw

PATCH v2 2/2 Documentation: devicetree: Add PL310 PM bindings

Quoted 71 lines · Brad Mouring
Quoted 61 lines · Rob Herring
Quoted 51 lines · Russell King - ARM Linux
Quoted 35 lines · Rob Herring
Quoted 28 lines · Russell King - ARM Linux
Quoted 12 lines · Rob Herring
Quoted 4 lines · Brad Mouring

Document the DT bindings for controlling ARM PL310 Power Control settings.

What happened to Josh's ack?

Quoted 4 lines
---
 Documentation/devicetree/bindings/arm/l2c2x0.txt | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 14 lines

Documentation/devicetree/bindings/arm/l2c2x0.txt Optional properties: · line 90

Quoted 12 lines
Documentation/devicetree/bindings/arm/l2c2x0.txt +4 -0
index fe0398c..c1c756e 100644
@@ -84,6 +84,10 @@ Optional properties:
 - prefetch-instr : Instruction prefetch. Value: <0> (forcibly disable),
   <1> (forcibly enable), property absent (retain settings set by
   firmware)
+- arm,dynamic-clock-gating : L2 dynamic clock gating. Value: <0> (forcibly
+  disable), <1> or property absent (forcibly enable)
+- arm,standby-mode: L2 standby mode enable. Value <0> (forcibly disable),
+  <1>  or property absent (forcibly enable)

What happened to "retain settings set by firmware"?

Quoted 4 lines

I said we shouldn't. Current behaviour is that we enable these features, and moving to missing-means-retain means that everything today ends up with these features disabled. IOW, it's yet another change of actual behaviour that every platform would see.

Quoted 8 lines

Right, but then the properties are different from prefetch-instr and others IIRC. We're letting the OS define the binding. If BSD doesn't enable these settings currently, then there is a mismatch between the binding and actual behavior. Saying "retain firmware settings" also defines specific OS behavior. I think absent should mean OS is free to do whatever it wants which could be retain firmware settings, enable or disable. In other words, it is undefined as this ship has already sailed.

I agree with "the ship has already sailed" but I disagree with the rest of your comment. The ship has already sailed in that we have an established behaviour which has been there for 18 months. Given the time period, it's not something I'm going to change at this stage, sorry.

Quoted 7 lines

Why? Such a change will go unnoticed, and it's particularly hard to debug why battery life has reduced.

I guess we need to find a way to ensure that the default behaviour stays. Whether that's by _everyone_ updating their DT files with the new properties or some other way, I don't care. I only care that we retain the behaviour we've had for the last 18 months.

Quoted 5 lines

I'm not suggesting that we change behavior at all. I'm only suggesting that we leave it undefined in the binding documentation because the behavior is possibly OS specific and can't really be defined there.

Rob

Ah, thanks for clarifying. However, I do have some additional clarifying questions:

Quoted 7 lines

When you note that it should be left undefined in the binding documentation, do you mean document the actual, well-defined behavior and leave it at that, or document the well-defined behavior and note that, in the case where the binding is missing, behavior is OS specific (my interpretation of your comment), or completely removed from the documentation altogether (I'd want to know the reasoning if this is what you meant, for my own edification).

The 2nd case. Missing property should be documented as undefined or OS specific. However, that does make this property different from others already present. So perhaps we should document recommended OS behavior even though Linux doesn't follow it. Something like: "If not present, retaining the firmware setting is recommended. However, the actual behavior may be OS specific."

Rob

#17 lore raw

PATCH v2 2/2 Documentation: devicetree: Add PL310 PM bindings

In reply to Rob Herring
Quoted 56 lines · Rob Herring
Quoted 54 lines · Russell King - ARM Linux
Quoted 35 lines · Rob Herring
Quoted 28 lines · Russell King - ARM Linux
Quoted 12 lines · Rob Herring
Quoted 4 lines · Brad Mouring

Document the DT bindings for controlling ARM PL310 Power Control settings.

What happened to Josh's ack?

Quoted 4 lines
---
 Documentation/devicetree/bindings/arm/l2c2x0.txt | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 14 lines

Documentation/devicetree/bindings/arm/l2c2x0.txt Optional properties: · line 90

Quoted 12 lines
Documentation/devicetree/bindings/arm/l2c2x0.txt +4 -0
index fe0398c..c1c756e 100644
@@ -84,6 +84,10 @@ Optional properties:
 - prefetch-instr : Instruction prefetch. Value: <0> (forcibly disable),
   <1> (forcibly enable), property absent (retain settings set by
   firmware)
+- arm,dynamic-clock-gating : L2 dynamic clock gating. Value: <0> (forcibly
+  disable), <1> or property absent (forcibly enable)
+- arm,standby-mode: L2 standby mode enable. Value <0> (forcibly disable),
+  <1>  or property absent (forcibly enable)

What happened to "retain settings set by firmware"?

Quoted 4 lines

I said we shouldn't. Current behaviour is that we enable these features, and moving to missing-means-retain means that everything today ends up with these features disabled. IOW, it's yet another change of actual behaviour that every platform would see.

Quoted 8 lines

Right, but then the properties are different from prefetch-instr and others IIRC. We're letting the OS define the binding. If BSD doesn't enable these settings currently, then there is a mismatch between the binding and actual behavior. Saying "retain firmware settings" also defines specific OS behavior. I think absent should mean OS is free to do whatever it wants which could be retain firmware settings, enable or disable. In other words, it is undefined as this ship has already sailed.

I agree with "the ship has already sailed" but I disagree with the rest of your comment. The ship has already sailed in that we have an established behaviour which has been there for 18 months. Given the time period, it's not something I'm going to change at this stage, sorry.

Why? Such a change will go unnoticed, and it's particularly hard to debug why battery life has reduced.

Quoted 8 lines
Quoted 4 lines

I guess we need to find a way to ensure that the default behaviour stays. Whether that's by _everyone_ updating their DT files with the new properties or some other way, I don't care. I only care that we retain the behaviour we've had for the last 18 months.

I'm not suggesting that we change behavior at all. I'm only suggesting that we leave it undefined in the binding documentation because the behavior is possibly OS specific and can't really be defined there.

Ok.

Signature · 3 lines
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
#18 lore raw

PATCH v2 2/2 Documentation: devicetree: Add PL310 PM bindings

In reply to Rob Herring
Quoted 7 lines · Rob Herring
Quoted 4 lines · Brad Mouring

Document the DT bindings for controlling ARM PL310 Power Control settings.

What happened to Josh's ack?

This is not the change that Josh reviewed, if he does agree with it, I'll put his ack on it. This was done purposefully.

Quoted 19 lines
Quoted 9 lines
---
 Documentation/devicetree/bindings/arm/l2c2x0.txt | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/arm/l2c2x0.txt +0 -0
index fe0398c..c1c756e 100644

Documentation/devicetree/bindings/arm/l2c2x0.txt Optional properties: · line 90

Quoted 7 lines
Documentation/devicetree/bindings/arm/l2c2x0.txt +4 -0
@@ -84,6 +84,10 @@ Optional properties:
 - prefetch-instr : Instruction prefetch. Value: <0> (forcibly disable),
   <1> (forcibly enable), property absent (retain settings set by
   firmware)
+- arm,dynamic-clock-gating : L2 dynamic clock gating. Value: <0> (forcibly
+  disable), <1> or property absent (forcibly enable)
+- arm,standby-mode: L2 standby mode enable. Value <0> (forcibly disable),
+  <1>  or property absent (forcibly enable)

What happened to "retain settings set by firmware"?

Quoted 1 line

Rob

This is the difference. There was discussion that this would be a functional regression for some, and Russell (while noting that he generally agreed with keeping fw settings) noted that this would be a possible functional regression sprung on those who wanted PM.

In all honesty, I don't really care one way or the other, since we'll be defining this property in our dtbs. I'm all ears if you have a strong oppinion (and this *does* seem like the sort of setting that can be overridden in the kernel, but should be left otherwise as the fw set it).

Brad

#20 lore raw

PATCH v3 1/2 arm: pl2x0: Add OF control of cache power management

Add ability to override power management bits of 310 controllers (dynamic clock gating and standby mode) through OF entries. As the saved register is only applied when working on a supported controller, it is safe to save the settings.

In order to maintain existing behavior, if the settings are not found in the DT, the corresponding feature will be enabled.

---
 arch/arm/mm/cache-l2x0.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)
arch/arm/mm/cache-l2x0.c +21 -5
index 9f9d542..c61996c 100644
@@ -647,11 +647,6 @@ static void __init l2c310_enable(void __iomem *base, unsigned num_lock)
 		aux &= ~(L310_AUX_CTRL_FULL_LINE_ZERO | L310_AUX_CTRL_EARLY_BRESP);
 	}
 
-	/* r3p0 or later has power control register */
-	if (rev >= L310_CACHE_ID_RTL_R3P0)
-		l2x0_saved_regs.pwr_ctrl = L310_DYNAMIC_CLK_GATING_EN |
-						L310_STNDBY_MODE_EN;
-
 	/*
 	 * Always enable non-secure access to the lockdown registers -
 	 * we write to them as part of the L2C enable sequence so they
@@ -1141,6 +1136,7 @@ static void __init l2c310_of_parse(const struct device_node *np,
 	u32 filter[2] = { 0, 0 };
 	u32 assoc;
 	u32 prefetch;
+	u32 power;
 	u32 val;
 	int ret;
 
@@ -1271,6 +1267,26 @@ static void __init l2c310_of_parse(const struct device_node *np,
 	}
 
 	l2x0_saved_regs.prefetch_ctrl = prefetch;
+
+	power = l2x0_saved_regs.pwr_ctrl |
+		L310_DYNAMIC_CLK_GATING_EN | L310_STNDBY_MODE_EN;
+
+	ret = of_property_read_u32(np, "arm,dynamic-clock-gating", &val);
+	if (!ret) {
+		if (!val)
+			power &= ~L310_DYNAMIC_CLK_GATING_EN;
+	} else if (ret != -EINVAL) {
+		pr_err("L2C-310 OF dynamic-clock-gating property value is missing or invalid\n");
+	}
+	ret = of_property_read_u32(np, "arm,standby-mode", &val);
+	if (!ret) {
+		if (!val)
+			power &= ~L310_STNDBY_MODE_EN;
+	} else if (ret != -EINVAL) {
+		pr_err("L2C-310 OF standby-mode property value is missing or invalid\n");
+	}
+
+	l2x0_saved_regs.pwr_ctrl = power;
 }
 
 static const struct l2c_init_data of_l2c310_data __initconst = {
Signature · 1 line
2.7.3
#21 lore raw

PATCH 2/2 Documentation: devicetree: Add PL310 PM bindings

In reply to Brad Mouring

Document the DT bindings for controlling ARM PL310 Power Control settings.

Discussion on the binding wording:
http://archive.arm.linux.org.uk/lurker/message/20160427.143444.5141d302.en.html

---
 Documentation/devicetree/bindings/arm/l2c2x0.txt | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/arm/l2c2x0.txt +6 -0
index fe0398c..c453ab5 100644
@@ -84,6 +84,12 @@ Optional properties:
 - prefetch-instr : Instruction prefetch. Value: <0> (forcibly disable),
   <1> (forcibly enable), property absent (retain settings set by
   firmware)
+- arm,dynamic-clock-gating : L2 dynamic clock gating. Value: <0> (forcibly
+  disable), <1> (forcibly enable), property absent (OS specific behavior,
+  preferrably retain firmware settings)
+- arm,standby-mode: L2 standby mode enable. Value <0> (forcibly disable),
+  <1> (forcibly enable), property absent (OS specific behavior,
+  preferrably retain firmware settings)
 
 Example:
 
Signature · 1 line
2.7.3
#22 lore raw

PATCH 2/2 Documentation: devicetree: Add PL310 PM bindings

Quoted 10 lines · Brad Mouring

Document the DT bindings for controlling ARM PL310 Power Control settings.

Discussion on the binding wording:
http://archive.arm.linux.org.uk/lurker/message/20160427.143444.5141d302.en.html

---
 Documentation/devicetree/bindings/arm/l2c2x0.txt | 6 ++++++
 1 file changed, 6 insertions(+)