Skip to content

Commit d0b26a9

Browse files
rafaeljwgregkh
authored andcommitted
cpufreq: intel_pstate: Read global.no_turbo under READ_ONCE()
[ Upstream commit 9558fae ] Because global.no_turbo is generally not read under intel_pstate_driver_lock make store_no_turbo() use WRITE_ONCE() for updating it (this is the only place at which it is updated except for the initialization) and make the majority of places reading it use READ_ONCE(). Also remove redundant global.turbo_disabled checks from places that depend on the 'true' value of global.no_turbo because it can only be 'true' if global.turbo_disabled is also 'true'. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Stable-dep-of: 350cbb5 ("cpufreq: intel_pstate: Check turbo_is_disabled() in store_no_turbo()") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent a44d090 commit d0b26a9

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

drivers/cpufreq/intel_pstate.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,7 @@ static ssize_t store_no_turbo(struct kobject *a, struct kobj_attribute *b,
12971297
goto unlock_driver;
12981298
}
12991299

1300-
global.no_turbo = no_turbo;
1300+
WRITE_ONCE(global.no_turbo, no_turbo);
13011301

13021302
mutex_lock(&intel_pstate_limits_lock);
13031303

@@ -1766,7 +1766,7 @@ static u64 atom_get_val(struct cpudata *cpudata, int pstate)
17661766
u32 vid;
17671767

17681768
val = (u64)pstate << 8;
1769-
if (global.no_turbo && !global.turbo_disabled)
1769+
if (READ_ONCE(global.no_turbo) && !global.turbo_disabled)
17701770
val |= (u64)1 << 32;
17711771

17721772
vid_fp = cpudata->vid.min + mul_fp(
@@ -1931,7 +1931,7 @@ static u64 core_get_val(struct cpudata *cpudata, int pstate)
19311931
u64 val;
19321932

19331933
val = (u64)pstate << 8;
1934-
if (global.no_turbo && !global.turbo_disabled)
1934+
if (READ_ONCE(global.no_turbo) && !global.turbo_disabled)
19351935
val |= (u64)1 << 32;
19361936

19371937
return val;
@@ -2229,7 +2229,7 @@ static inline int32_t get_target_pstate(struct cpudata *cpu)
22292229

22302230
sample->busy_scaled = busy_frac * 100;
22312231

2232-
target = global.no_turbo || global.turbo_disabled ?
2232+
target = READ_ONCE(global.no_turbo) ?
22332233
cpu->pstate.max_pstate : cpu->pstate.turbo_pstate;
22342234
target += target >> 2;
22352235
target = mul_fp(target, busy_frac);
@@ -2490,7 +2490,7 @@ static void intel_pstate_clear_update_util_hook(unsigned int cpu)
24902490

24912491
static int intel_pstate_get_max_freq(struct cpudata *cpu)
24922492
{
2493-
return global.turbo_disabled || global.no_turbo ?
2493+
return READ_ONCE(global.no_turbo) ?
24942494
cpu->pstate.max_freq : cpu->pstate.turbo_freq;
24952495
}
24962496

@@ -2627,7 +2627,7 @@ static void intel_pstate_verify_cpu_policy(struct cpudata *cpu,
26272627

26282628
if (hwp_active) {
26292629
intel_pstate_get_hwp_cap(cpu);
2630-
max_freq = global.no_turbo || global.turbo_disabled ?
2630+
max_freq = READ_ONCE(global.no_turbo) ?
26312631
cpu->pstate.max_freq : cpu->pstate.turbo_freq;
26322632
} else {
26332633
max_freq = intel_pstate_get_max_freq(cpu);

0 commit comments

Comments
 (0)