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(-)
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") Signed-off-by: Viresh Kumar viresh.kumar@linaro.org --- drivers/cpufreq/cpufreq-dt.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index c3583cdfadbd..8c38b5192baa 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c @@ -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;
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") Signed-off-by: Viresh Kumar viresh.kumar@linaro.org --- drivers/cpufreq/cpufreq-dt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index 8c38b5192baa..b1131cf89757 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c @@ -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 {
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 l.stach@pengutronix.de Fixes: 045ee45c4ff2 ("cpufreq: cpufreq-dt: disable unsupported OPPs") Signed-off-by: Viresh Kumar viresh.kumar@linaro.org --- drivers/cpufreq/cpufreq-dt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index b1131cf89757..3b64c203bf99 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c @@ -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;
Am Mittwoch, den 02.09.2015, 14:36 +0530 schrieb Viresh Kumar:
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.
Reviewed-by: Lucas Stach l.stach@pengutronix.de
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 l.stach@pengutronix.de Fixes: 045ee45c4ff2 ("cpufreq: cpufreq-dt: disable unsupported OPPs") Signed-off-by: Viresh Kumar viresh.kumar@linaro.org
drivers/cpufreq/cpufreq-dt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index b1131cf89757..3b64c203bf99 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c @@ -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;
On 02-09-15, 11:39, Lucas Stach wrote:
Am Mittwoch, den 02.09.2015, 14:36 +0530 schrieb Viresh Kumar:
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.
Reviewed-by: Lucas Stach l.stach@pengutronix.de
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..
On Wednesday, September 02, 2015 02:36:47 PM Viresh Kumar wrote:
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(-)
I'm queuing this one up for the next PM pull request.
Thanks, Rafael
linaro-kernel@lists.linaro.org