* exactly same freq is called again and so we can save on few function
* calls.
*/
- if (target_freq == policy->cur &&
- !(cpufreq_driver->flags & CPUFREQ_NEED_UPDATE_LIMITS))
- return 0;
+ if (target_freq == policy->cur) {
+ if (!(cpufreq_driver->flags & CPUFREQ_NEED_UPDATE_LIMITS) ||
+ !policy->update_limits)
+ return 0;
+
+ policy->update_limits = false;
+ }
if (cpufreq_driver->target) {
/*
{
struct cpufreq_policy_data new_data;
struct cpufreq_governor *old_gov;
+ unsigned int freq;
int ret;
memcpy(&new_data.cpuinfo, &policy->cpuinfo, sizeof(policy->cpuinfo));
* compiler optimizations around them because they may be accessed
* concurrently by cpufreq_driver_resolve_freq() during the update.
*/
- WRITE_ONCE(policy->max, __resolve_freq(policy, new_data.max,
- new_data.min, new_data.max,
- CPUFREQ_RELATION_H));
- new_data.min = __resolve_freq(policy, new_data.min, new_data.min,
- new_data.max, CPUFREQ_RELATION_L);
- WRITE_ONCE(policy->min, new_data.min > policy->max ? policy->max : new_data.min);
+ freq = __resolve_freq(policy, new_data.max, new_data.min, new_data.max,
+ CPUFREQ_RELATION_H);
+ if (freq != policy->max) {
+ WRITE_ONCE(policy->max, freq);
+ policy->update_limits = true;
+ }
+
+ freq = __resolve_freq(policy, new_data.min, new_data.min, new_data.max,
+ CPUFREQ_RELATION_L);
+ freq = min(freq, policy->max);
+ if (freq != policy->min) {
+ WRITE_ONCE(policy->min, freq);
+ policy->update_limits = true;
+ }
trace_cpu_frequency_limits(policy);