Message ID | 20200828173303.11939-2-ionela.voinescu@arm.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | cpufreq: improve frequency invariance support | expand |
On 28-08-20, 18:32, Ionela Voinescu wrote: > The current frequency passed to arch_set_freq_scale() could end up > being 0, signaling an error in setting a new frequency. Also, if the > maximum frequency in 0, this will result in a division by 0 error. > > Therefore, validate these input values before using them for the > setting of the frequency scale factor. > > Signed-off-by: Ionela Voinescu <ionela.voinescu@arm.com> > Cc: Sudeep Holla <sudeep.holla@arm.com> > Cc: Rafael J. Wysocki <rjw@rjwysocki.net> > --- > drivers/base/arch_topology.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c > index 75f72d684294..5708eb724790 100644 > --- a/drivers/base/arch_topology.c > +++ b/drivers/base/arch_topology.c > @@ -33,6 +33,11 @@ void arch_set_freq_scale(struct cpumask *cpus, unsigned long cur_freq, > unsigned long scale; > int i; > > + if (unlikely(!cur_freq || !max_freq)) { > + WARN_ON_ONCE(1); > + return; > + } This can be written as: if (WARN_ON_ONCE(!cur_freq || !max_freq)) return; With that. Acked-by: Viresh Kumar <viresh.kumar@linaro.org> > + > /* > * If the use of counters for FIE is enabled, just return as we don't > * want to update the scale factor with information from CPUFREQ. > -- > 2.17.1
Hi Viresh, On Monday 31 Aug 2020 at 16:43:08 (+0530), Viresh Kumar wrote: > On 28-08-20, 18:32, Ionela Voinescu wrote: > > The current frequency passed to arch_set_freq_scale() could end up > > being 0, signaling an error in setting a new frequency. Also, if the > > maximum frequency in 0, this will result in a division by 0 error. > > > > Therefore, validate these input values before using them for the > > setting of the frequency scale factor. > > > > Signed-off-by: Ionela Voinescu <ionela.voinescu@arm.com> > > Cc: Sudeep Holla <sudeep.holla@arm.com> > > Cc: Rafael J. Wysocki <rjw@rjwysocki.net> > > --- > > drivers/base/arch_topology.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c > > index 75f72d684294..5708eb724790 100644 > > --- a/drivers/base/arch_topology.c > > +++ b/drivers/base/arch_topology.c > > @@ -33,6 +33,11 @@ void arch_set_freq_scale(struct cpumask *cpus, unsigned long cur_freq, > > unsigned long scale; > > int i; > > > > + if (unlikely(!cur_freq || !max_freq)) { > > + WARN_ON_ONCE(1); > > + return; > > + } > > This can be written as: > > if (WARN_ON_ONCE(!cur_freq || !max_freq)) > return; Yes, that's better. I've pushed v5 with this and your Acked-by. Thanks for all your reviews, Ionela. > > With that. > > Acked-by: Viresh Kumar <viresh.kumar@linaro.org> > > > + > > /* > > * If the use of counters for FIE is enabled, just return as we don't > > * want to update the scale factor with information from CPUFREQ. > > -- > > 2.17.1 > > -- > viresh
diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 75f72d684294..5708eb724790 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -33,6 +33,11 @@ void arch_set_freq_scale(struct cpumask *cpus, unsigned long cur_freq, unsigned long scale; int i; + if (unlikely(!cur_freq || !max_freq)) { + WARN_ON_ONCE(1); + return; + } + /* * If the use of counters for FIE is enabled, just return as we don't * want to update the scale factor with information from CPUFREQ.
The current frequency passed to arch_set_freq_scale() could end up being 0, signaling an error in setting a new frequency. Also, if the maximum frequency in 0, this will result in a division by 0 error. Therefore, validate these input values before using them for the setting of the frequency scale factor. Signed-off-by: Ionela Voinescu <ionela.voinescu@arm.com> Cc: Sudeep Holla <sudeep.holla@arm.com> Cc: Rafael J. Wysocki <rjw@rjwysocki.net> --- drivers/base/arch_topology.c | 5 +++++ 1 file changed, 5 insertions(+)