Re: [PATCH RESEND] cpufreq: Make sure target freq is within limits
On Friday, October 26, 2012 06:05:21 PM Viresh Kumar wrote: > __cpufreq_driver_target() must not pass target frequency beyond the limits of > current policy. > > Today most of cpufreq platform drivers are doing this check in their target > routines. Why not move it to __cpufreq_driver_target(). > > Signed-off-by: Viresh Kumar > --- > Hi Rafael, > > Resend doesn't contain any change, but fixed commit log Applied to the linux-next branch of linux-pm.git as v3.8 material. Thanks, Rafael > drivers/cpufreq/cpufreq.c | 11 +-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index 28dc134..2f5ac2d 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -1470,12 +1470,19 @@ int __cpufreq_driver_target(struct cpufreq_policy > *policy, > unsigned int relation) > { > int retval = -EINVAL; > + unsigned int old_target_freq = target_freq; > > if (cpufreq_disabled()) > return -ENODEV; > > - pr_debug("target for CPU %u: %u kHz, relation %u\n", policy->cpu, > - target_freq, relation); > + /* Make sure that target_freq is within supported range */ > + if (target_freq > policy->max) > + target_freq = policy->max; > + if (target_freq < policy->min) > + target_freq = policy->min; > + > + pr_debug("target for CPU %u: %u kHz, relation %u, requested %u kHz\n", > + policy->cpu, target_freq, relation, old_target_freq); > > if (target_freq == policy->cur) > return 0; > -- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH RESEND] cpufreq: Make sure target freq is within limits
On Friday, October 26, 2012 06:05:21 PM Viresh Kumar wrote: __cpufreq_driver_target() must not pass target frequency beyond the limits of current policy. Today most of cpufreq platform drivers are doing this check in their target routines. Why not move it to __cpufreq_driver_target(). Signed-off-by: Viresh Kumar viresh.ku...@linaro.org --- Hi Rafael, Resend doesn't contain any change, but fixed commit log Applied to the linux-next branch of linux-pm.git as v3.8 material. Thanks, Rafael drivers/cpufreq/cpufreq.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 28dc134..2f5ac2d 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1470,12 +1470,19 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, unsigned int relation) { int retval = -EINVAL; + unsigned int old_target_freq = target_freq; if (cpufreq_disabled()) return -ENODEV; - pr_debug(target for CPU %u: %u kHz, relation %u\n, policy-cpu, - target_freq, relation); + /* Make sure that target_freq is within supported range */ + if (target_freq policy-max) + target_freq = policy-max; + if (target_freq policy-min) + target_freq = policy-min; + + pr_debug(target for CPU %u: %u kHz, relation %u, requested %u kHz\n, + policy-cpu, target_freq, relation, old_target_freq); if (target_freq == policy-cur) return 0; -- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH RESEND] cpufreq: Make sure target freq is within limits
__cpufreq_driver_target() must not pass target frequency beyond the limits of current policy. Today most of cpufreq platform drivers are doing this check in their target routines. Why not move it to __cpufreq_driver_target(). Signed-off-by: Viresh Kumar --- Hi Rafael, Resend doesn't contain any change, but fixed commit log drivers/cpufreq/cpufreq.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 28dc134..2f5ac2d 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1470,12 +1470,19 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, unsigned int relation) { int retval = -EINVAL; + unsigned int old_target_freq = target_freq; if (cpufreq_disabled()) return -ENODEV; - pr_debug("target for CPU %u: %u kHz, relation %u\n", policy->cpu, - target_freq, relation); + /* Make sure that target_freq is within supported range */ + if (target_freq > policy->max) + target_freq = policy->max; + if (target_freq < policy->min) + target_freq = policy->min; + + pr_debug("target for CPU %u: %u kHz, relation %u, requested %u kHz\n", + policy->cpu, target_freq, relation, old_target_freq); if (target_freq == policy->cur) return 0; -- 1.7.12.rc2.18.g61b472e -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH RESEND] cpufreq: Make sure target freq is within limits
__cpufreq_driver_target() must not pass target frequency beyond the limits of current policy. Today most of cpufreq platform drivers are doing this check in their target routines. Why not move it to __cpufreq_driver_target(). Signed-off-by: Viresh Kumar viresh.ku...@linaro.org --- Hi Rafael, Resend doesn't contain any change, but fixed commit log drivers/cpufreq/cpufreq.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 28dc134..2f5ac2d 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1470,12 +1470,19 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, unsigned int relation) { int retval = -EINVAL; + unsigned int old_target_freq = target_freq; if (cpufreq_disabled()) return -ENODEV; - pr_debug(target for CPU %u: %u kHz, relation %u\n, policy-cpu, - target_freq, relation); + /* Make sure that target_freq is within supported range */ + if (target_freq policy-max) + target_freq = policy-max; + if (target_freq policy-min) + target_freq = policy-min; + + pr_debug(target for CPU %u: %u kHz, relation %u, requested %u kHz\n, + policy-cpu, target_freq, relation, old_target_freq); if (target_freq == policy-cur) return 0; -- 1.7.12.rc2.18.g61b472e -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/