Commit c3a49c89 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

cpufreq: intel_pstate: Fix limits issue with operation mode switching

There is a problem with intel_pstate operation mode switching
introduced by commit fb1fe104 (cpufreq: intel_pstate: Operation
mode control from sysfs), because the global sysfs limits are
preserved across operation modes while per-policy limits are
reinitialized from scratch on a mode switch and both sets of limits
may get out of sync this way.

Fix that by always reinitializing the global limits upon the
registration of the driver.

Fixes: fb1fe104 (cpufreq: intel_pstate: Operation mode control from sysfs)
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
parent 17b4eaf4
...@@ -364,37 +364,25 @@ static bool driver_registered __read_mostly; ...@@ -364,37 +364,25 @@ static bool driver_registered __read_mostly;
static bool acpi_ppc; static bool acpi_ppc;
#endif #endif
static struct perf_limits performance_limits = { static struct perf_limits performance_limits;
.no_turbo = 0, static struct perf_limits powersave_limits;
.turbo_disabled = 0, static struct perf_limits *limits;
.max_perf_pct = 100,
.max_perf = int_ext_tofp(1),
.min_perf_pct = 100,
.min_perf = int_ext_tofp(1),
.max_policy_pct = 100,
.max_sysfs_pct = 100,
.min_policy_pct = 0,
.min_sysfs_pct = 0,
};
static struct perf_limits powersave_limits = { static void intel_pstate_init_limits(struct perf_limits *limits)
.no_turbo = 0, {
.turbo_disabled = 0, memset(limits, 0, sizeof(*limits));
.max_perf_pct = 100, limits->max_perf_pct = 100;
.max_perf = int_ext_tofp(1), limits->max_perf = int_ext_tofp(1);
.min_perf_pct = 0, limits->max_policy_pct = 100;
.min_perf = 0, limits->max_sysfs_pct = 100;
.max_policy_pct = 100, }
.max_sysfs_pct = 100,
.min_policy_pct = 0,
.min_sysfs_pct = 0,
};
#ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE static void intel_pstate_set_performance_limits(struct perf_limits *limits)
static struct perf_limits *limits = &performance_limits; {
#else intel_pstate_init_limits(limits);
static struct perf_limits *limits = &powersave_limits; limits->min_perf_pct = 100;
#endif limits->min_perf = int_ext_tofp(1);
}
static DEFINE_MUTEX(intel_pstate_driver_lock); static DEFINE_MUTEX(intel_pstate_driver_lock);
static DEFINE_MUTEX(intel_pstate_limits_lock); static DEFINE_MUTEX(intel_pstate_limits_lock);
...@@ -2084,20 +2072,6 @@ static void intel_pstate_clear_update_util_hook(unsigned int cpu) ...@@ -2084,20 +2072,6 @@ static void intel_pstate_clear_update_util_hook(unsigned int cpu)
synchronize_sched(); synchronize_sched();
} }
static void intel_pstate_set_performance_limits(struct perf_limits *limits)
{
limits->no_turbo = 0;
limits->turbo_disabled = 0;
limits->max_perf_pct = 100;
limits->max_perf = int_ext_tofp(1);
limits->min_perf_pct = 100;
limits->min_perf = int_ext_tofp(1);
limits->max_policy_pct = 100;
limits->max_sysfs_pct = 100;
limits->min_policy_pct = 0;
limits->min_sysfs_pct = 0;
}
static void intel_pstate_update_perf_limits(struct cpufreq_policy *policy, static void intel_pstate_update_perf_limits(struct cpufreq_policy *policy,
struct perf_limits *limits) struct perf_limits *limits)
{ {
...@@ -2466,6 +2440,11 @@ static int intel_pstate_register_driver(void) ...@@ -2466,6 +2440,11 @@ static int intel_pstate_register_driver(void)
{ {
int ret; int ret;
intel_pstate_init_limits(&powersave_limits);
intel_pstate_set_performance_limits(&performance_limits);
limits = IS_ENABLED(CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE) ?
&performance_limits : &powersave_limits;
ret = cpufreq_register_driver(intel_pstate_driver); ret = cpufreq_register_driver(intel_pstate_driver);
if (ret) { if (ret) {
intel_pstate_driver_cleanup(); intel_pstate_driver_cleanup();
......
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