Skip to contentSkip to conversation

scpi: RfC - Allow to ignore invalid SCPI DVFS clock rates

PATCH New Heiner Kallweit 2 participants 3 messages Feb 4, 2017 – Feb 6, 2017

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

cover scpi: RfC - Allow to ignore invalid SCPI DVFS clock rates

On the Odroid C2 (Amlogic S905GXBB) the firmware defines SCPI DVFS cpu clock rates which make the system crash or at least unstable. Therefore cpufreq can't be used on this system as of today. Other systems might face similar issues with too optimistic SCPI SVFS clock rates.

This RfC patch series addresses this by allowing to define a max frequency per clock via DT. All frequencies for the respective clock exceeding this threshold will be ignored.

Heiner Kallweit (2):
clk: scpi: RfC - Allow to ignore invalid SCPI DVFS clock rates
cpufreq: scpi: RfC - Allow to ignore invalid SCPI DVFS clock rates

 Documentation/devicetree/bindings/arm/arm,scpi.txt |  7 +++++++
 drivers/clk/clk-scpi.c                             | 15 ++++++++++++++-
 drivers/cpufreq/scpi-cpufreq.c                     | 22 ++++++++++++++++++++++
 3 files changed, 43 insertions(+), 1 deletion(-)
Signature · 1 line
2.11.0
#1 lore raw

cover scpi: RfC - Allow to ignore invalid SCPI DVFS clock rates

Quoted 10 lines · Heiner Kallweit

On the Odroid C2 (Amlogic S905GXBB) the firmware defines SCPI DVFS cpu clock rates which make the system crash or at least unstable. Therefore cpufreq can't be used on this system as of today. Other systems might face similar issues with too optimistic SCPI SVFS clock rates.

This RfC patch series addresses this by allowing to define a max frequency per clock via DT. All frequencies for the respective clock exceeding this threshold will be ignored.

Quoted 9 lines

Heiner Kallweit (2):
clk: scpi: RfC - Allow to ignore invalid SCPI DVFS clock rates
cpufreq: scpi: RfC - Allow to ignore invalid SCPI DVFS clock rates

 Documentation/devicetree/bindings/arm/arm,scpi.txt |  7 +++++++
 drivers/clk/clk-scpi.c                             | 15 ++++++++++++++-
 drivers/cpufreq/scpi-cpufreq.c                     | 22 ++++++++++++++++++++++
 3 files changed, 43 insertions(+), 1 deletion(-)

Hi Heiner,

Thanks for this pathset, I have an alternative patchset for this feature.

My patchset adds a maximum frequency in the cpu node, this permits cleanly specifying a max frequency per cluster and leave the SCPI code intact since it's only a protocol implementation.

Please find below a simpler implementation only touching the scpi-cpufreq code.

Anyway, Sudeep, could you give us your point of view about such changes ?

Neil

----><--

Documentation/devicetree/bindings/arm/cpus.txt +8 -0
index a1bcfee..b813933 100644
@@ -276,6 +276,14 @@ nodes to be present and contain the properties described below.
 
 			    where voltage is in uV, frequency is in MHz.
 
+	- arm,scpi-dvfs-max-freq
+		Usage: optional
+		Value type: <u32>
+		Definition:
+			Specifies the maximum DVFS frequency in Hz unit this
+			CPU can support when the OPP tables are obtained via
+			the SCP interface.
+
 Example 1 (dual-cluster big.LITTLE system 32-bit):
 
 	cpus {
arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts +16 -0
index 238fbea..881f20c 100644
@@ -137,6 +137,22 @@
 	};
 };
 
+&cpu0 {
+	arm,scpi-dvfs-max-freq = <1536000000>;
+};
+
+&cpu1 {
+	arm,scpi-dvfs-max-freq = <1536000000>;
+};
+
+&cpu2 {
+	arm,scpi-dvfs-max-freq = <1536000000>;
+};
+
+&cpu3 {
+	arm,scpi-dvfs-max-freq = <1536000000>;
+};
+
 &uart_AO {
 	status = "okay";
 	pinctrl-0 = <&uart_ao_a_pins>;
drivers/cpufreq/scpi-cpufreq.c +10 -0
index ea7a4e1..80a6f27b 100644
@@ -25,6 +25,7 @@
 #include <linux/pm_opp.h>
 #include <linux/scpi_protocol.h>
 #include <linux/types.h>
+#include <linux/of.h>
 
 #include "arm_big_little.h"
 
@@ -54,6 +55,11 @@ static int scpi_init_opp_table(const struct cpumask *cpumask)
 	struct scpi_opp *opp;
 	struct device *cpu_dev = get_cpu_device(cpumask_first(cpumask));
 	struct scpi_dvfs_info *info = scpi_get_dvfs_info(cpu_dev);
+	u32 max_freq = 0;
+
+	/* Eventually get a platform frequency limitation */
+	of_property_read_u32(cpu_dev->of_node, "arm,scpi-dvfs-max-freq",
+			     &max_freq);
 
 	if (IS_ERR(info))
 		return PTR_ERR(info);
@@ -62,6 +68,10 @@ static int scpi_init_opp_table(const struct cpumask *cpumask)
 		return -EIO;
 
 	for (opp = info->opps, idx = 0; idx < info->count; idx++, opp++) {
+		/* Drop unsupported frequencies */
+		if (max_freq && opp->freq > max_freq)
+			continue;
+
 		ret = dev_pm_opp_add(cpu_dev, opp->freq, opp->m_volt * 1000);
 		if (ret) {
 			dev_warn(cpu_dev, "failed to add opp %uHz %umV\n",
#2 lore raw

cover scpi: RfC - Allow to ignore invalid SCPI DVFS clock rates

Am 06.02.2017 um 10:27 schrieb Neil Armstrong:

Quoted 21 lines · Heiner Kallweit
Quoted 10 lines

On the Odroid C2 (Amlogic S905GXBB) the firmware defines SCPI DVFS cpu clock rates which make the system crash or at least unstable. Therefore cpufreq can't be used on this system as of today. Other systems might face similar issues with too optimistic SCPI SVFS clock rates.

This RfC patch series addresses this by allowing to define a max frequency per clock via DT. All frequencies for the respective clock exceeding this threshold will be ignored.

Quoted 9 lines

Heiner Kallweit (2):
clk: scpi: RfC - Allow to ignore invalid SCPI DVFS clock rates
cpufreq: scpi: RfC - Allow to ignore invalid SCPI DVFS clock rates

 Documentation/devicetree/bindings/arm/arm,scpi.txt |  7 +++++++
 drivers/clk/clk-scpi.c                             | 15 ++++++++++++++-
 drivers/cpufreq/scpi-cpufreq.c                     | 22 ++++++++++++++++++++++
 3 files changed, 43 insertions(+), 1 deletion(-)
Quoted 8 lines

Hi Heiner,

Thanks for this pathset, I have an alternative patchset for this feature.

My patchset adds a maximum frequency in the cpu node, this permits cleanly specifying a max frequency per cluster and leave the SCPI code intact since it's only a protocol implementation.

I also thought about this option. Right, it's simpler and most likely sufficient. To me the other option seems to be more generic as it covers also potential similar issues with other SCPI DVFS clocks and their consumers.

I'm fine with either option, I just want a working cpufreq on my Odroid C2 ..

Heiner

Quoted 89 lines

Please find below a simpler implementation only touching the scpi-cpufreq code.

Anyway, Sudeep, could you give us your point of view about such changes ?

Neil

----><--

Documentation/devicetree/bindings/arm/cpus.txt +8 -0
index a1bcfee..b813933 100644
@@ -276,6 +276,14 @@ nodes to be present and contain the properties described below.
 
 			    where voltage is in uV, frequency is in MHz.
 
+	- arm,scpi-dvfs-max-freq
+		Usage: optional
+		Value type: <u32>
+		Definition:
+			Specifies the maximum DVFS frequency in Hz unit this
+			CPU can support when the OPP tables are obtained via
+			the SCP interface.
+
 Example 1 (dual-cluster big.LITTLE system 32-bit):
 
 	cpus {
arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts +16 -0
index 238fbea..881f20c 100644
@@ -137,6 +137,22 @@
 	};
 };
 
+&cpu0 {
+	arm,scpi-dvfs-max-freq = <1536000000>;
+};
+
+&cpu1 {
+	arm,scpi-dvfs-max-freq = <1536000000>;
+};
+
+&cpu2 {
+	arm,scpi-dvfs-max-freq = <1536000000>;
+};
+
+&cpu3 {
+	arm,scpi-dvfs-max-freq = <1536000000>;
+};
+
 &uart_AO {
 	status = "okay";
 	pinctrl-0 = <&uart_ao_a_pins>;
drivers/cpufreq/scpi-cpufreq.c +10 -0
index ea7a4e1..80a6f27b 100644
@@ -25,6 +25,7 @@
 #include <linux/pm_opp.h>
 #include <linux/scpi_protocol.h>
 #include <linux/types.h>
+#include <linux/of.h>
 
 #include "arm_big_little.h"
 
@@ -54,6 +55,11 @@ static int scpi_init_opp_table(const struct cpumask *cpumask)
 	struct scpi_opp *opp;
 	struct device *cpu_dev = get_cpu_device(cpumask_first(cpumask));
 	struct scpi_dvfs_info *info = scpi_get_dvfs_info(cpu_dev);
+	u32 max_freq = 0;
+
+	/* Eventually get a platform frequency limitation */
+	of_property_read_u32(cpu_dev->of_node, "arm,scpi-dvfs-max-freq",
+			     &max_freq);
 
 	if (IS_ERR(info))
 		return PTR_ERR(info);
@@ -62,6 +68,10 @@ static int scpi_init_opp_table(const struct cpumask *cpumask)
 		return -EIO;
 
 	for (opp = info->opps, idx = 0; idx < info->count; idx++, opp++) {
+		/* Drop unsupported frequencies */
+		if (max_freq && opp->freq > max_freq)
+			continue;
+
 		ret = dev_pm_opp_add(cpu_dev, opp->freq, opp->m_volt * 1000);
 		if (ret) {
 			dev_warn(cpu_dev, "failed to add opp %uHz %umV\n",