Skip to content

Commit e8217b4

Browse files
committed
cpufreq: intel_pstate: Update the maximum CPU frequency consistently
There are 3 places at which the maximum CPU frequency may change, store_no_turbo(), intel_pstate_update_limits() (when called by the cpufreq core) and intel_pstate_notify_work() (when handling a HWP change notification). Currently, cpuinfo.max_freq is only updated by store_no_turbo() and intel_pstate_notify_work(), although it principle it may be necessary to update it in intel_pstate_update_limits() either. Make all of them mutually consistent. Signed-off-by: Rafael J. Wysocki <[email protected]> Acked-by: Srinivas Pandruvada <[email protected]>
1 parent f32587d commit e8217b4

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

drivers/cpufreq/intel_pstate.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,18 +1153,32 @@ static void intel_pstate_update_policies(void)
11531153
static void __intel_pstate_update_max_freq(struct cpudata *cpudata,
11541154
struct cpufreq_policy *policy)
11551155
{
1156+
intel_pstate_get_hwp_cap(cpudata);
1157+
11561158
policy->cpuinfo.max_freq = READ_ONCE(global.no_turbo) ?
11571159
cpudata->pstate.max_freq : cpudata->pstate.turbo_freq;
1160+
11581161
refresh_frequency_limits(policy);
11591162
}
11601163

11611164
static void intel_pstate_update_limits(unsigned int cpu)
11621165
{
1163-
mutex_lock(&intel_pstate_driver_lock);
1166+
struct cpufreq_policy *policy = cpufreq_cpu_acquire(cpu);
11641167

1165-
cpufreq_update_policy(cpu);
1168+
if (!policy)
1169+
return;
11661170

1167-
mutex_unlock(&intel_pstate_driver_lock);
1171+
__intel_pstate_update_max_freq(all_cpu_data[cpu], policy);
1172+
1173+
cpufreq_cpu_release(policy);
1174+
}
1175+
1176+
static void intel_pstate_update_limits_for_all(void)
1177+
{
1178+
int cpu;
1179+
1180+
for_each_possible_cpu(cpu)
1181+
intel_pstate_update_limits(cpu);
11681182
}
11691183

11701184
/************************** sysfs begin ************************/
@@ -1311,7 +1325,7 @@ static ssize_t store_no_turbo(struct kobject *a, struct kobj_attribute *b,
13111325

13121326
mutex_unlock(&intel_pstate_limits_lock);
13131327

1314-
intel_pstate_update_policies();
1328+
intel_pstate_update_limits_for_all();
13151329
arch_set_max_freq_ratio(no_turbo);
13161330

13171331
unlock_driver:
@@ -1595,7 +1609,6 @@ static void intel_pstate_notify_work(struct work_struct *work)
15951609
struct cpufreq_policy *policy = cpufreq_cpu_acquire(cpudata->cpu);
15961610

15971611
if (policy) {
1598-
intel_pstate_get_hwp_cap(cpudata);
15991612
__intel_pstate_update_max_freq(cpudata, policy);
16001613

16011614
cpufreq_cpu_release(policy);

0 commit comments

Comments
 (0)