diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 65d3f79104bd..8d61ff261c61 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -1305,7 +1305,7 @@ static ssize_t store_no_turbo(struct kobject *a, struct kobj_attribute *b, if (no_turbo == global.no_turbo) goto unlock_driver; - if (global.turbo_disabled) { + if (READ_ONCE(global.turbo_disabled)) { pr_notice_once("Turbo disabled by BIOS or unavailable on processor\n"); count = -EPERM; goto unlock_driver; @@ -1762,7 +1762,7 @@ static u64 atom_get_val(struct cpudata *cpudata, int pstate) u32 vid; val = (u64)pstate << 8; - if (READ_ONCE(global.no_turbo) && !global.turbo_disabled) + if (READ_ONCE(global.no_turbo) && !READ_ONCE(global.turbo_disabled)) val |= (u64)1 << 32; vid_fp = cpudata->vid.min + mul_fp( @@ -1927,7 +1927,7 @@ static u64 core_get_val(struct cpudata *cpudata, int pstate) u64 val; val = (u64)pstate << 8; - if (READ_ONCE(global.no_turbo) && !global.turbo_disabled) + if (READ_ONCE(global.no_turbo) && !READ_ONCE(global.turbo_disabled)) val |= (u64)1 << 32; return val; @@ -3102,6 +3102,29 @@ static void intel_pstate_driver_cleanup(void) intel_pstate_driver = NULL; } +static void check_turbo_work_handler(struct work_struct *work) +{ + bool no_turbo; + + no_turbo = turbo_is_disabled(); + + if (no_turbo) + return; + + /* Same processing as sysfs no_turbo update */ + mutex_lock(&intel_pstate_driver_lock); + + WRITE_ONCE(global.turbo_disabled, no_turbo); + WRITE_ONCE(global.no_turbo, no_turbo); + + intel_pstate_update_limits_for_all(); + arch_set_max_freq_ratio(false); + + mutex_unlock(&intel_pstate_driver_lock); +} + +DECLARE_DELAYED_WORK(turbo_work, check_turbo_work_handler); + static int intel_pstate_register_driver(struct cpufreq_driver *driver) { int ret; @@ -3114,6 +3137,9 @@ static int intel_pstate_register_driver(struct cpufreq_driver *driver) global.turbo_disabled = turbo_is_disabled(); global.no_turbo = global.turbo_disabled; + if (global.turbo_disabled) + schedule_delayed_work(&turbo_work, HZ); + arch_set_max_freq_ratio(global.turbo_disabled); intel_pstate_driver = driver;