Commit 43dde64b authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

Merge back cpufreq changes for v5.15.

parents a87a1096 e5c6b312
...@@ -163,9 +163,9 @@ static ssize_t store_cpb(struct cpufreq_policy *policy, const char *buf, ...@@ -163,9 +163,9 @@ static ssize_t store_cpb(struct cpufreq_policy *policy, const char *buf,
if (ret || val > 1) if (ret || val > 1)
return -EINVAL; return -EINVAL;
get_online_cpus(); cpus_read_lock();
set_boost(policy, val); set_boost(policy, val);
put_online_cpus(); cpus_read_unlock();
return count; return count;
} }
......
...@@ -2654,18 +2654,18 @@ int cpufreq_boost_trigger_state(int state) ...@@ -2654,18 +2654,18 @@ int cpufreq_boost_trigger_state(int state)
cpufreq_driver->boost_enabled = state; cpufreq_driver->boost_enabled = state;
write_unlock_irqrestore(&cpufreq_driver_lock, flags); write_unlock_irqrestore(&cpufreq_driver_lock, flags);
get_online_cpus(); cpus_read_lock();
for_each_active_policy(policy) { for_each_active_policy(policy) {
ret = cpufreq_driver->set_boost(policy, state); ret = cpufreq_driver->set_boost(policy, state);
if (ret) if (ret)
goto err_reset_state; goto err_reset_state;
} }
put_online_cpus(); cpus_read_unlock();
return 0; return 0;
err_reset_state: err_reset_state:
put_online_cpus(); cpus_read_unlock();
write_lock_irqsave(&cpufreq_driver_lock, flags); write_lock_irqsave(&cpufreq_driver_lock, flags);
cpufreq_driver->boost_enabled = !state; cpufreq_driver->boost_enabled = !state;
......
...@@ -418,7 +418,7 @@ static void od_set_powersave_bias(unsigned int powersave_bias) ...@@ -418,7 +418,7 @@ static void od_set_powersave_bias(unsigned int powersave_bias)
default_powersave_bias = powersave_bias; default_powersave_bias = powersave_bias;
cpumask_clear(&done); cpumask_clear(&done);
get_online_cpus(); cpus_read_lock();
for_each_online_cpu(cpu) { for_each_online_cpu(cpu) {
struct cpufreq_policy *policy; struct cpufreq_policy *policy;
struct policy_dbs_info *policy_dbs; struct policy_dbs_info *policy_dbs;
...@@ -442,7 +442,7 @@ static void od_set_powersave_bias(unsigned int powersave_bias) ...@@ -442,7 +442,7 @@ static void od_set_powersave_bias(unsigned int powersave_bias)
od_tuners = dbs_data->tuners; od_tuners = dbs_data->tuners;
od_tuners->powersave_bias = default_powersave_bias; od_tuners->powersave_bias = default_powersave_bias;
} }
put_online_cpus(); cpus_read_unlock();
} }
void od_register_powersave_bias_handler(unsigned int (*f) void od_register_powersave_bias_handler(unsigned int (*f)
......
...@@ -2969,7 +2969,7 @@ static void intel_pstate_driver_cleanup(void) ...@@ -2969,7 +2969,7 @@ static void intel_pstate_driver_cleanup(void)
{ {
unsigned int cpu; unsigned int cpu;
get_online_cpus(); cpus_read_lock();
for_each_online_cpu(cpu) { for_each_online_cpu(cpu) {
if (all_cpu_data[cpu]) { if (all_cpu_data[cpu]) {
if (intel_pstate_driver == &intel_pstate) if (intel_pstate_driver == &intel_pstate)
...@@ -2979,7 +2979,7 @@ static void intel_pstate_driver_cleanup(void) ...@@ -2979,7 +2979,7 @@ static void intel_pstate_driver_cleanup(void)
all_cpu_data[cpu] = NULL; all_cpu_data[cpu] = NULL;
} }
} }
put_online_cpus(); cpus_read_unlock();
intel_pstate_driver = NULL; intel_pstate_driver = NULL;
} }
......
...@@ -1180,7 +1180,7 @@ static int powernowk8_init(void) ...@@ -1180,7 +1180,7 @@ static int powernowk8_init(void)
if (!x86_match_cpu(powernow_k8_ids)) if (!x86_match_cpu(powernow_k8_ids))
return -ENODEV; return -ENODEV;
get_online_cpus(); cpus_read_lock();
for_each_online_cpu(i) { for_each_online_cpu(i) {
smp_call_function_single(i, check_supported_cpu, &ret, 1); smp_call_function_single(i, check_supported_cpu, &ret, 1);
if (!ret) if (!ret)
...@@ -1188,10 +1188,10 @@ static int powernowk8_init(void) ...@@ -1188,10 +1188,10 @@ static int powernowk8_init(void)
} }
if (supported_cpus != num_online_cpus()) { if (supported_cpus != num_online_cpus()) {
put_online_cpus(); cpus_read_unlock();
return -ENODEV; return -ENODEV;
} }
put_online_cpus(); cpus_read_unlock();
ret = cpufreq_register_driver(&cpufreq_amd64_driver); ret = cpufreq_register_driver(&cpufreq_amd64_driver);
if (ret) if (ret)
......
...@@ -918,7 +918,7 @@ static void powernv_cpufreq_work_fn(struct work_struct *work) ...@@ -918,7 +918,7 @@ static void powernv_cpufreq_work_fn(struct work_struct *work)
unsigned int cpu; unsigned int cpu;
cpumask_t mask; cpumask_t mask;
get_online_cpus(); cpus_read_lock();
cpumask_and(&mask, &chip->mask, cpu_online_mask); cpumask_and(&mask, &chip->mask, cpu_online_mask);
smp_call_function_any(&mask, smp_call_function_any(&mask,
powernv_cpufreq_throttle_check, NULL, 0); powernv_cpufreq_throttle_check, NULL, 0);
...@@ -939,7 +939,7 @@ static void powernv_cpufreq_work_fn(struct work_struct *work) ...@@ -939,7 +939,7 @@ static void powernv_cpufreq_work_fn(struct work_struct *work)
cpufreq_cpu_put(policy); cpufreq_cpu_put(policy);
} }
out: out:
put_online_cpus(); cpus_read_unlock();
} }
static int powernv_cpufreq_occ_msg(struct notifier_block *nb, static int powernv_cpufreq_occ_msg(struct notifier_block *nb,
......
...@@ -537,9 +537,17 @@ static struct attribute *sugov_attrs[] = { ...@@ -537,9 +537,17 @@ static struct attribute *sugov_attrs[] = {
}; };
ATTRIBUTE_GROUPS(sugov); ATTRIBUTE_GROUPS(sugov);
static void sugov_tunables_free(struct kobject *kobj)
{
struct gov_attr_set *attr_set = container_of(kobj, struct gov_attr_set, kobj);
kfree(to_sugov_tunables(attr_set));
}
static struct kobj_type sugov_tunables_ktype = { static struct kobj_type sugov_tunables_ktype = {
.default_groups = sugov_groups, .default_groups = sugov_groups,
.sysfs_ops = &governor_sysfs_ops, .sysfs_ops = &governor_sysfs_ops,
.release = &sugov_tunables_free,
}; };
/********************** cpufreq governor interface *********************/ /********************** cpufreq governor interface *********************/
...@@ -639,12 +647,10 @@ static struct sugov_tunables *sugov_tunables_alloc(struct sugov_policy *sg_polic ...@@ -639,12 +647,10 @@ static struct sugov_tunables *sugov_tunables_alloc(struct sugov_policy *sg_polic
return tunables; return tunables;
} }
static void sugov_tunables_free(struct sugov_tunables *tunables) static void sugov_clear_global_tunables(void)
{ {
if (!have_governor_per_policy()) if (!have_governor_per_policy())
global_tunables = NULL; global_tunables = NULL;
kfree(tunables);
} }
static int sugov_init(struct cpufreq_policy *policy) static int sugov_init(struct cpufreq_policy *policy)
...@@ -707,7 +713,7 @@ static int sugov_init(struct cpufreq_policy *policy) ...@@ -707,7 +713,7 @@ static int sugov_init(struct cpufreq_policy *policy)
fail: fail:
kobject_put(&tunables->attr_set.kobj); kobject_put(&tunables->attr_set.kobj);
policy->governor_data = NULL; policy->governor_data = NULL;
sugov_tunables_free(tunables); sugov_clear_global_tunables();
stop_kthread: stop_kthread:
sugov_kthread_stop(sg_policy); sugov_kthread_stop(sg_policy);
...@@ -734,7 +740,7 @@ static void sugov_exit(struct cpufreq_policy *policy) ...@@ -734,7 +740,7 @@ static void sugov_exit(struct cpufreq_policy *policy)
count = gov_attr_set_put(&tunables->attr_set, &sg_policy->tunables_hook); count = gov_attr_set_put(&tunables->attr_set, &sg_policy->tunables_hook);
policy->governor_data = NULL; policy->governor_data = NULL;
if (!count) if (!count)
sugov_tunables_free(tunables); sugov_clear_global_tunables();
mutex_unlock(&global_tunables_lock); mutex_unlock(&global_tunables_lock);
......
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