Commit 9558fae8 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

cpufreq: intel_pstate: Read global.no_turbo under READ_ONCE()

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: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
parent c626a438
...@@ -1296,7 +1296,7 @@ static ssize_t store_no_turbo(struct kobject *a, struct kobj_attribute *b, ...@@ -1296,7 +1296,7 @@ static ssize_t store_no_turbo(struct kobject *a, struct kobj_attribute *b,
goto unlock_driver; goto unlock_driver;
} }
global.no_turbo = no_turbo; WRITE_ONCE(global.no_turbo, no_turbo);
mutex_lock(&intel_pstate_limits_lock); mutex_lock(&intel_pstate_limits_lock);
...@@ -1748,7 +1748,7 @@ static u64 atom_get_val(struct cpudata *cpudata, int pstate) ...@@ -1748,7 +1748,7 @@ static u64 atom_get_val(struct cpudata *cpudata, int pstate)
u32 vid; u32 vid;
val = (u64)pstate << 8; val = (u64)pstate << 8;
if (global.no_turbo && !global.turbo_disabled) if (READ_ONCE(global.no_turbo) && !global.turbo_disabled)
val |= (u64)1 << 32; val |= (u64)1 << 32;
vid_fp = cpudata->vid.min + mul_fp( vid_fp = cpudata->vid.min + mul_fp(
...@@ -1913,7 +1913,7 @@ static u64 core_get_val(struct cpudata *cpudata, int pstate) ...@@ -1913,7 +1913,7 @@ static u64 core_get_val(struct cpudata *cpudata, int pstate)
u64 val; u64 val;
val = (u64)pstate << 8; val = (u64)pstate << 8;
if (global.no_turbo && !global.turbo_disabled) if (READ_ONCE(global.no_turbo) && !global.turbo_disabled)
val |= (u64)1 << 32; val |= (u64)1 << 32;
return val; return val;
...@@ -2211,7 +2211,7 @@ static inline int32_t get_target_pstate(struct cpudata *cpu) ...@@ -2211,7 +2211,7 @@ static inline int32_t get_target_pstate(struct cpudata *cpu)
sample->busy_scaled = busy_frac * 100; sample->busy_scaled = busy_frac * 100;
target = global.no_turbo || global.turbo_disabled ? target = READ_ONCE(global.no_turbo) ?
cpu->pstate.max_pstate : cpu->pstate.turbo_pstate; cpu->pstate.max_pstate : cpu->pstate.turbo_pstate;
target += target >> 2; target += target >> 2;
target = mul_fp(target, busy_frac); target = mul_fp(target, busy_frac);
...@@ -2473,7 +2473,7 @@ static void intel_pstate_clear_update_util_hook(unsigned int cpu) ...@@ -2473,7 +2473,7 @@ static void intel_pstate_clear_update_util_hook(unsigned int cpu)
static int intel_pstate_get_max_freq(struct cpudata *cpu) static int intel_pstate_get_max_freq(struct cpudata *cpu)
{ {
return global.turbo_disabled || global.no_turbo ? return READ_ONCE(global.no_turbo) ?
cpu->pstate.max_freq : cpu->pstate.turbo_freq; cpu->pstate.max_freq : cpu->pstate.turbo_freq;
} }
...@@ -2610,7 +2610,7 @@ static void intel_pstate_verify_cpu_policy(struct cpudata *cpu, ...@@ -2610,7 +2610,7 @@ static void intel_pstate_verify_cpu_policy(struct cpudata *cpu,
if (hwp_active) { if (hwp_active) {
intel_pstate_get_hwp_cap(cpu); intel_pstate_get_hwp_cap(cpu);
max_freq = global.no_turbo || global.turbo_disabled ? max_freq = READ_ONCE(global.no_turbo) ?
cpu->pstate.max_freq : cpu->pstate.turbo_freq; cpu->pstate.max_freq : cpu->pstate.turbo_freq;
} else { } else {
max_freq = intel_pstate_get_max_freq(cpu); max_freq = intel_pstate_get_max_freq(cpu);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment