mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 04:04:43 +01:00
cpufreq: intel_pstate: Rearrange max frequency updates handling code
Rename __intel_pstate_update_max_freq() to intel_pstate_update_max_freq() and move the cpufreq policy reference counting and locking into it (and implement the locking with the recently introduced cpufreq policy "write" locking guard). No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Link: https://patch.msgid.link/2315023.iZASKD2KPV@rjwysocki.net
This commit is contained in:
parent
6fec833b9d
commit
973207ae3d
1 changed files with 17 additions and 35 deletions
|
|
@ -1353,9 +1353,16 @@ static void intel_pstate_update_policies(void)
|
||||||
cpufreq_update_policy(cpu);
|
cpufreq_update_policy(cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __intel_pstate_update_max_freq(struct cpudata *cpudata,
|
static bool intel_pstate_update_max_freq(struct cpudata *cpudata)
|
||||||
struct cpufreq_policy *policy)
|
|
||||||
{
|
{
|
||||||
|
struct cpufreq_policy *policy __free(put_cpufreq_policy);
|
||||||
|
|
||||||
|
policy = cpufreq_cpu_get(cpudata->cpu);
|
||||||
|
if (!policy)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
guard(cpufreq_policy_write)(policy);
|
||||||
|
|
||||||
if (hwp_active)
|
if (hwp_active)
|
||||||
intel_pstate_get_hwp_cap(cpudata);
|
intel_pstate_get_hwp_cap(cpudata);
|
||||||
|
|
||||||
|
|
@ -1363,44 +1370,24 @@ static void __intel_pstate_update_max_freq(struct cpudata *cpudata,
|
||||||
cpudata->pstate.max_freq : cpudata->pstate.turbo_freq;
|
cpudata->pstate.max_freq : cpudata->pstate.turbo_freq;
|
||||||
|
|
||||||
refresh_frequency_limits(policy);
|
refresh_frequency_limits(policy);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void intel_pstate_update_limits(unsigned int cpu)
|
static void intel_pstate_update_limits(unsigned int cpu)
|
||||||
{
|
{
|
||||||
struct cpufreq_policy *policy = cpufreq_cpu_acquire(cpu);
|
struct cpudata *cpudata = all_cpu_data[cpu];
|
||||||
struct cpudata *cpudata;
|
|
||||||
|
|
||||||
if (!policy)
|
if (intel_pstate_update_max_freq(cpudata))
|
||||||
return;
|
hybrid_update_capacity(cpudata);
|
||||||
|
|
||||||
cpudata = all_cpu_data[cpu];
|
|
||||||
|
|
||||||
__intel_pstate_update_max_freq(cpudata, policy);
|
|
||||||
|
|
||||||
/* Prevent the driver from being unregistered now. */
|
|
||||||
mutex_lock(&intel_pstate_driver_lock);
|
|
||||||
|
|
||||||
cpufreq_cpu_release(policy);
|
|
||||||
|
|
||||||
hybrid_update_capacity(cpudata);
|
|
||||||
|
|
||||||
mutex_unlock(&intel_pstate_driver_lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void intel_pstate_update_limits_for_all(void)
|
static void intel_pstate_update_limits_for_all(void)
|
||||||
{
|
{
|
||||||
int cpu;
|
int cpu;
|
||||||
|
|
||||||
for_each_possible_cpu(cpu) {
|
for_each_possible_cpu(cpu)
|
||||||
struct cpufreq_policy *policy = cpufreq_cpu_acquire(cpu);
|
intel_pstate_update_max_freq(all_cpu_data[cpu]);
|
||||||
|
|
||||||
if (!policy)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
__intel_pstate_update_max_freq(all_cpu_data[cpu], policy);
|
|
||||||
|
|
||||||
cpufreq_cpu_release(policy);
|
|
||||||
}
|
|
||||||
|
|
||||||
mutex_lock(&hybrid_capacity_lock);
|
mutex_lock(&hybrid_capacity_lock);
|
||||||
|
|
||||||
|
|
@ -1840,13 +1827,8 @@ static void intel_pstate_notify_work(struct work_struct *work)
|
||||||
{
|
{
|
||||||
struct cpudata *cpudata =
|
struct cpudata *cpudata =
|
||||||
container_of(to_delayed_work(work), struct cpudata, hwp_notify_work);
|
container_of(to_delayed_work(work), struct cpudata, hwp_notify_work);
|
||||||
struct cpufreq_policy *policy = cpufreq_cpu_acquire(cpudata->cpu);
|
|
||||||
|
|
||||||
if (policy) {
|
|
||||||
__intel_pstate_update_max_freq(cpudata, policy);
|
|
||||||
|
|
||||||
cpufreq_cpu_release(policy);
|
|
||||||
|
|
||||||
|
if (intel_pstate_update_max_freq(cpudata)) {
|
||||||
/*
|
/*
|
||||||
* The driver will not be unregistered while this function is
|
* The driver will not be unregistered while this function is
|
||||||
* running, so update the capacity without acquiring the driver
|
* running, so update the capacity without acquiring the driver
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue