Skip to contentSkip to conversation

cpufreq: dt: Minor fixes for 4.3

PATCH In review Viresh Kumar 3 participants 7 messages Sep 2, 2015 – Sep 3, 2015 CPU frequency scaling framework

lore
Share & tools
lore
author maintainer
#1 lore raw

PATCH 1/3 cpufreq: dt: Check OPP count before marking them shared

In reply to Viresh Kumar

We need to explicitly mark OPPs as shared, when they are not defined with OPP-v2 bindings. But this isn't required to be done if we failed to initialize OPP table.

Reorder code to verify OPP count before marking them shared.

Fixes 2e02d8723edf ("cpufreq: dt: Add support for operating-points-v2 bindings")
---
 drivers/cpufreq/cpufreq-dt.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/cpufreq/cpufreq-dt.c +11 -11
index c3583cdfadbd..8c38b5192baa 100644
@@ -239,6 +239,17 @@ static int cpufreq_init(struct cpufreq_policy *policy)
 	 */
 	of_cpumask_init_opp_table(policy->cpus);
 
+	/*
+	 * But we need OPP table to function so if it is not there let's
+	 * give platform code chance to provide it for us.
+	 */
+	ret = dev_pm_opp_get_opp_count(cpu_dev);
+	if (ret <= 0) {
+		pr_debug("OPP table is not ready, deferring probe\n");
+		ret = -EPROBE_DEFER;
+		goto out_free_opp;
+	}
+
 	if (need_update) {
 		struct cpufreq_dt_platform_data *pd = cpufreq_get_driver_data();
 
@@ -256,17 +267,6 @@ static int cpufreq_init(struct cpufreq_policy *policy)
 		transition_latency = dev_pm_opp_get_max_clock_latency(cpu_dev);
 	}
 
-	/*
-	 * But we need OPP table to function so if it is not there let's
-	 * give platform code chance to provide it for us.
-	 */
-	ret = dev_pm_opp_get_opp_count(cpu_dev);
-	if (ret <= 0) {
-		pr_debug("OPP table is not ready, deferring probe\n");
-		ret = -EPROBE_DEFER;
-		goto out_free_opp;
-	}
-
 	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
 	if (!priv) {
 		ret = -ENOMEM;
Signature · 1 line
2.4.0
author maintainer
#2 lore raw

PATCH 2/3 cpufreq: dt: Print error on failing to mark OPPs as shared

In reply to Viresh Kumar

We need to explicitly mark OPPs as shared, when they are not defined with OPP-v2 bindings. This operation can potentially fail, and in that case we should at least print an error message.

Fixes 2e02d8723edf ("cpufreq: dt: Add support for operating-points-v2 bindings")
---
 drivers/cpufreq/cpufreq-dt.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/cpufreq/cpufreq-dt.c +4 -1
index 8c38b5192baa..b1131cf89757 100644
@@ -260,7 +260,10 @@ static int cpufreq_init(struct cpufreq_policy *policy)
 		 * OPP tables are initialized only for policy->cpu, do it for
 		 * others as well.
 		 */
-		set_cpus_sharing_opps(cpu_dev, policy->cpus);
+		ret = set_cpus_sharing_opps(cpu_dev, policy->cpus);
+		if (ret)
+			dev_err(cpu_dev, "%s: failed to mark OPPs as shared: %d\n",
+				__func__, ret);
 
 		of_property_read_u32(np, "clock-latency", &transition_latency);
 	} else {
Signature · 1 line
2.4.0
author maintainer
#3 lore raw

PATCH 3/3 cpufreq: dt: Tolerance applies on both sides of target voltage

In reply to Viresh Kumar

Tolerance applies on both sides of the target voltage, i.e. both min and max sides. But while checking if a voltage is supported by the regulator or not, we haven't taken care of tolerance on the lower side. Fix that.

Cc Lucas Stach <[email protected]>
Fixes 045ee45c4ff2 ("cpufreq: cpufreq-dt: disable unsupported OPPs")
---
 drivers/cpufreq/cpufreq-dt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/cpufreq/cpufreq-dt.c +2 -1
index b1131cf89757..3b64c203bf99 100644
@@ -303,7 +303,8 @@ static int cpufreq_init(struct cpufreq_policy *policy)
 			rcu_read_unlock();
 
 			tol_uV = opp_uV * priv->voltage_tolerance / 100;
-			if (regulator_is_supported_voltage(cpu_reg, opp_uV,
+			if (regulator_is_supported_voltage(cpu_reg,
+							   opp_uV - tol_uV,
 							   opp_uV + tol_uV)) {
 				if (opp_uV < min_uV)
 					min_uV = opp_uV;
Signature · 1 line
2.4.0

Viresh Kumar

author maintainer
#0 lore raw

cover cpufreq: dt: Minor fixes for 4.3

Hi Rafael,

These are minor fixes for cpufreq-dt driver.

--
viresh

Viresh Kumar (3):
cpufreq: dt: Check OPP count before marking them shared
cpufreq: dt: Print error on failing to mark OPPs as shared
cpufreq: dt: Tolerance applies on both sides of target voltage

 drivers/cpufreq/cpufreq-dt.c | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)
Signature · 1 line
2.4.0
Reviewed-by on v1 3/3
#4 lore raw

Re: [PATCH 3/3] cpufreq: dt: Tolerance applies on both sides of target voltage

In reply to Viresh Kumar

Am Mittwoch, den 02.09.2015, 14:36 +0530 schrieb Viresh Kumar:

Quoted 2 lines

Tolerance applies on both sides of the target voltage, i.e. both min and max sides.

While I'm not really comfortable with the above, it is exactly how OPPv1 and the voltage tolerance property are specified.

Quoted 24 lines

But while checking if a voltage is supported by the regulator or not, we haven't taken care of tolerance on the lower side. Fix that.

Cc Lucas Stach <[email protected]>
Fixes 045ee45c4ff2 ("cpufreq: cpufreq-dt: disable unsupported OPPs")
---
 drivers/cpufreq/cpufreq-dt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/cpufreq/cpufreq-dt.c +2 -1
index b1131cf89757..3b64c203bf99 100644
@@ -303,7 +303,8 @@ static int cpufreq_init(struct cpufreq_policy *policy)
 			rcu_read_unlock();
 
 			tol_uV = opp_uV * priv->voltage_tolerance / 100;
-			if (regulator_is_supported_voltage(cpu_reg, opp_uV,
+			if (regulator_is_supported_voltage(cpu_reg,
+							   opp_uV - tol_uV,
 							   opp_uV + tol_uV)) {
 				if (opp_uV < min_uV)
 					min_uV = opp_uV;
Signature · 2 lines
Pengutronix e.K.             | Lucas Stach                 |
Industrial Linux Solutions   | http://www.pengutronix.de/  |
author maintainer
#5 lore raw

Re: [PATCH 3/3] cpufreq: dt: Tolerance applies on both sides of target voltage

Quoted 8 lines · Lucas Stach

Am Mittwoch, den 02.09.2015, 14:36 +0530 schrieb Viresh Kumar:

Quoted 2 lines

Tolerance applies on both sides of the target voltage, i.e. both min and max sides.

While I'm not really comfortable with the above, it is exactly how OPPv1 and the voltage tolerance property are specified.

Thanks.

And this is exactly how the regulator API work:

static inline int regulator_set_voltage_tol(struct regulator *regulator,
int new_uV, int tol_uV)

{
	if (regulator_set_voltage(regulator, new_uV, new_uV + tol_uV) == 0)
		return 0;
	else
		return regulator_set_voltage(regulator,
					     new_uV - tol_uV, new_uV + tol_uV);
}

But yeah, OPP-v2 is going to take care of this with target/min/max values..

Signature · 1 line
viresh
#6 lore raw
In reply to Viresh Kumar
Quoted 7 lines · Viresh Kumar

Hi Rafael,

These are minor fixes for cpufreq-dt driver.

--
viresh

Quoted 7 lines

Viresh Kumar (3):
cpufreq: dt: Check OPP count before marking them shared
cpufreq: dt: Print error on failing to mark OPPs as shared
cpufreq: dt: Tolerance applies on both sides of target voltage

 drivers/cpufreq/cpufreq-dt.c | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)

I'm queuing this one up for the next PM pull request.

Thanks,
Rafael