Skip to content

Commit 43dde64

Browse files
committed
Merge back cpufreq changes for v5.15.
2 parents a87a109 + e5c6b31 commit 43dde64

File tree

7 files changed

+25
-19
lines changed

7 files changed

+25
-19
lines changed

drivers/cpufreq/acpi-cpufreq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ static ssize_t store_cpb(struct cpufreq_policy *policy, const char *buf,
163163
if (ret || val > 1)
164164
return -EINVAL;
165165

166-
get_online_cpus();
166+
cpus_read_lock();
167167
set_boost(policy, val);
168-
put_online_cpus();
168+
cpus_read_unlock();
169169

170170
return count;
171171
}

drivers/cpufreq/cpufreq.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2654,18 +2654,18 @@ int cpufreq_boost_trigger_state(int state)
26542654
cpufreq_driver->boost_enabled = state;
26552655
write_unlock_irqrestore(&cpufreq_driver_lock, flags);
26562656

2657-
get_online_cpus();
2657+
cpus_read_lock();
26582658
for_each_active_policy(policy) {
26592659
ret = cpufreq_driver->set_boost(policy, state);
26602660
if (ret)
26612661
goto err_reset_state;
26622662
}
2663-
put_online_cpus();
2663+
cpus_read_unlock();
26642664

26652665
return 0;
26662666

26672667
err_reset_state:
2668-
put_online_cpus();
2668+
cpus_read_unlock();
26692669

26702670
write_lock_irqsave(&cpufreq_driver_lock, flags);
26712671
cpufreq_driver->boost_enabled = !state;

drivers/cpufreq/cpufreq_ondemand.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ static void od_set_powersave_bias(unsigned int powersave_bias)
418418
default_powersave_bias = powersave_bias;
419419
cpumask_clear(&done);
420420

421-
get_online_cpus();
421+
cpus_read_lock();
422422
for_each_online_cpu(cpu) {
423423
struct cpufreq_policy *policy;
424424
struct policy_dbs_info *policy_dbs;
@@ -442,7 +442,7 @@ static void od_set_powersave_bias(unsigned int powersave_bias)
442442
od_tuners = dbs_data->tuners;
443443
od_tuners->powersave_bias = default_powersave_bias;
444444
}
445-
put_online_cpus();
445+
cpus_read_unlock();
446446
}
447447

448448
void od_register_powersave_bias_handler(unsigned int (*f)

drivers/cpufreq/intel_pstate.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2969,7 +2969,7 @@ static void intel_pstate_driver_cleanup(void)
29692969
{
29702970
unsigned int cpu;
29712971

2972-
get_online_cpus();
2972+
cpus_read_lock();
29732973
for_each_online_cpu(cpu) {
29742974
if (all_cpu_data[cpu]) {
29752975
if (intel_pstate_driver == &intel_pstate)
@@ -2979,7 +2979,7 @@ static void intel_pstate_driver_cleanup(void)
29792979
all_cpu_data[cpu] = NULL;
29802980
}
29812981
}
2982-
put_online_cpus();
2982+
cpus_read_unlock();
29832983

29842984
intel_pstate_driver = NULL;
29852985
}

drivers/cpufreq/powernow-k8.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,18 +1180,18 @@ static int powernowk8_init(void)
11801180
if (!x86_match_cpu(powernow_k8_ids))
11811181
return -ENODEV;
11821182

1183-
get_online_cpus();
1183+
cpus_read_lock();
11841184
for_each_online_cpu(i) {
11851185
smp_call_function_single(i, check_supported_cpu, &ret, 1);
11861186
if (!ret)
11871187
supported_cpus++;
11881188
}
11891189

11901190
if (supported_cpus != num_online_cpus()) {
1191-
put_online_cpus();
1191+
cpus_read_unlock();
11921192
return -ENODEV;
11931193
}
1194-
put_online_cpus();
1194+
cpus_read_unlock();
11951195

11961196
ret = cpufreq_register_driver(&cpufreq_amd64_driver);
11971197
if (ret)

drivers/cpufreq/powernv-cpufreq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ static void powernv_cpufreq_work_fn(struct work_struct *work)
918918
unsigned int cpu;
919919
cpumask_t mask;
920920

921-
get_online_cpus();
921+
cpus_read_lock();
922922
cpumask_and(&mask, &chip->mask, cpu_online_mask);
923923
smp_call_function_any(&mask,
924924
powernv_cpufreq_throttle_check, NULL, 0);
@@ -939,7 +939,7 @@ static void powernv_cpufreq_work_fn(struct work_struct *work)
939939
cpufreq_cpu_put(policy);
940940
}
941941
out:
942-
put_online_cpus();
942+
cpus_read_unlock();
943943
}
944944

945945
static int powernv_cpufreq_occ_msg(struct notifier_block *nb,

kernel/sched/cpufreq_schedutil.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -537,9 +537,17 @@ static struct attribute *sugov_attrs[] = {
537537
};
538538
ATTRIBUTE_GROUPS(sugov);
539539

540+
static void sugov_tunables_free(struct kobject *kobj)
541+
{
542+
struct gov_attr_set *attr_set = container_of(kobj, struct gov_attr_set, kobj);
543+
544+
kfree(to_sugov_tunables(attr_set));
545+
}
546+
540547
static struct kobj_type sugov_tunables_ktype = {
541548
.default_groups = sugov_groups,
542549
.sysfs_ops = &governor_sysfs_ops,
550+
.release = &sugov_tunables_free,
543551
};
544552

545553
/********************** cpufreq governor interface *********************/
@@ -639,12 +647,10 @@ static struct sugov_tunables *sugov_tunables_alloc(struct sugov_policy *sg_polic
639647
return tunables;
640648
}
641649

642-
static void sugov_tunables_free(struct sugov_tunables *tunables)
650+
static void sugov_clear_global_tunables(void)
643651
{
644652
if (!have_governor_per_policy())
645653
global_tunables = NULL;
646-
647-
kfree(tunables);
648654
}
649655

650656
static int sugov_init(struct cpufreq_policy *policy)
@@ -707,7 +713,7 @@ static int sugov_init(struct cpufreq_policy *policy)
707713
fail:
708714
kobject_put(&tunables->attr_set.kobj);
709715
policy->governor_data = NULL;
710-
sugov_tunables_free(tunables);
716+
sugov_clear_global_tunables();
711717

712718
stop_kthread:
713719
sugov_kthread_stop(sg_policy);
@@ -734,7 +740,7 @@ static void sugov_exit(struct cpufreq_policy *policy)
734740
count = gov_attr_set_put(&tunables->attr_set, &sg_policy->tunables_hook);
735741
policy->governor_data = NULL;
736742
if (!count)
737-
sugov_tunables_free(tunables);
743+
sugov_clear_global_tunables();
738744

739745
mutex_unlock(&global_tunables_lock);
740746

0 commit comments

Comments
 (0)