Skip to content

Commit ba02050

Browse files
committed
Merge tag 'cpufreq-arm-updates-6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm
Merge CPUFreq updates for 6.17 from Viresh Kumar: "- tegra124: Allow building as a module (Aaron Kling). - Minor cleanups for Rust cpufreq and cpumask APIs and fix MAINTAINERS entry for cpu.rs (Abhinav Ananthu, Ritvik Gupta, and Lukas Bulwahn). - Minor cleanups for miscellaneous cpufreq drivers (Arnd Bergmann, Dan Carpenter, Krzysztof Kozlowski, Sven Peter, and Svyatoslav Ryhel)." * tag 'cpufreq-arm-updates-6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm: drivers: cpufreq: add Tegra114 support rust: cpumask: Replace `MaybeUninit` and `mem::zeroed` with `Opaque` APIs cpufreq: tegra124: Allow building as a module cpufreq: dt: Add register helper cpufreq: Export disable_cpufreq() cpufreq: armada-8k: Fix off by one in armada_8k_cpufreq_free_table() cpufreq: armada-8k: make both cpu masks static rust: cpufreq: use c_ types from kernel prelude rust: cpufreq: Ensure C ABI compatibility in all unsafe cpufreq: brcmstb-avs: Fully open-code compatible for grepping cpufreq: apple: drop default ARCH_APPLE in Kconfig MAINTAINERS: adjust file entry in CPU HOTPLUG
2 parents 4f95b5b + a7ce9ca commit ba02050

11 files changed

Lines changed: 86 additions & 64 deletions

File tree

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6256,7 +6256,7 @@ F: include/linux/cpuhotplug.h
62566256
F: include/linux/smpboot.h
62576257
F: kernel/cpu.c
62586258
F: kernel/smpboot.*
6259-
F: rust/helper/cpu.c
6259+
F: rust/helpers/cpu.c
62606260
F: rust/kernel/cpu.rs
62616261

62626262
CPU IDLE TIME MANAGEMENT FRAMEWORK

drivers/cpufreq/Kconfig.arm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ config ARM_APPLE_SOC_CPUFREQ
2828
tristate "Apple Silicon SoC CPUFreq support"
2929
depends on ARCH_APPLE || (COMPILE_TEST && 64BIT)
3030
select PM_OPP
31-
default ARCH_APPLE
3231
help
3332
This adds the CPUFreq driver for Apple Silicon machines
3433
(e.g. Apple M1).
@@ -238,7 +237,7 @@ config ARM_TEGRA20_CPUFREQ
238237
This adds the CPUFreq driver support for Tegra20/30 SOCs.
239238

240239
config ARM_TEGRA124_CPUFREQ
241-
bool "Tegra124 CPUFreq support"
240+
tristate "Tegra124 CPUFreq support"
242241
depends on ARCH_TEGRA || COMPILE_TEST
243242
depends on CPUFREQ_DT
244243
default ARCH_TEGRA

drivers/cpufreq/armada-8k-cpufreq.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static void armada_8k_cpufreq_free_table(struct freq_table *freq_tables)
103103
{
104104
int opps_index, nb_cpus = num_possible_cpus();
105105

106-
for (opps_index = 0 ; opps_index <= nb_cpus; opps_index++) {
106+
for (opps_index = 0 ; opps_index < nb_cpus; opps_index++) {
107107
int i;
108108

109109
/* If cpu_dev is NULL then we reached the end of the array */
@@ -132,7 +132,7 @@ static int __init armada_8k_cpufreq_init(void)
132132
int ret = 0, opps_index = 0, cpu, nb_cpus;
133133
struct freq_table *freq_tables;
134134
struct device_node *node;
135-
static struct cpumask cpus;
135+
static struct cpumask cpus, shared_cpus;
136136

137137
node = of_find_matching_node_and_match(NULL, armada_8k_cpufreq_of_match,
138138
NULL);
@@ -154,7 +154,6 @@ static int __init armada_8k_cpufreq_init(void)
154154
* divisions of it).
155155
*/
156156
for_each_cpu(cpu, &cpus) {
157-
struct cpumask shared_cpus;
158157
struct device *cpu_dev;
159158
struct clk *clk;
160159

drivers/cpufreq/brcmstb-avs-cpufreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ static void brcm_avs_cpufreq_remove(struct platform_device *pdev)
765765
}
766766

767767
static const struct of_device_id brcm_avs_cpufreq_match[] = {
768-
{ .compatible = BRCM_AVS_CPU_DATA },
768+
{ .compatible = "brcm,avs-cpu-data-mem" },
769769
{ }
770770
};
771771
MODULE_DEVICE_TABLE(of, brcm_avs_cpufreq_match);

drivers/cpufreq/cpufreq-dt-platdev.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ static const struct of_device_id blocklist[] __initconst = {
143143

144144
{ .compatible = "nvidia,tegra20", },
145145
{ .compatible = "nvidia,tegra30", },
146+
{ .compatible = "nvidia,tegra114", },
146147
{ .compatible = "nvidia,tegra124", },
147148
{ .compatible = "nvidia,tegra210", },
148149
{ .compatible = "nvidia,tegra234", },

drivers/cpufreq/cpufreq-dt.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,17 @@ static struct platform_driver dt_cpufreq_platdrv = {
329329
};
330330
module_platform_driver(dt_cpufreq_platdrv);
331331

332+
struct platform_device *cpufreq_dt_pdev_register(struct device *dev)
333+
{
334+
struct platform_device_info cpufreq_dt_devinfo = {};
335+
336+
cpufreq_dt_devinfo.name = "cpufreq-dt";
337+
cpufreq_dt_devinfo.parent = dev;
338+
339+
return platform_device_register_full(&cpufreq_dt_devinfo);
340+
}
341+
EXPORT_SYMBOL_GPL(cpufreq_dt_pdev_register);
342+
332343
MODULE_ALIAS("platform:cpufreq-dt");
333344
MODULE_AUTHOR("Viresh Kumar <viresh.kumar@linaro.org>");
334345
MODULE_AUTHOR("Shawn Guo <shawn.guo@linaro.org>");

drivers/cpufreq/cpufreq-dt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ struct cpufreq_dt_platform_data {
2222
int (*resume)(struct cpufreq_policy *policy);
2323
};
2424

25+
struct platform_device *cpufreq_dt_pdev_register(struct device *dev);
26+
2527
#endif /* __CPUFREQ_DT_H__ */

drivers/cpufreq/cpufreq.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ void disable_cpufreq(void)
109109
{
110110
off = 1;
111111
}
112+
EXPORT_SYMBOL_GPL(disable_cpufreq);
113+
112114
static DEFINE_MUTEX(cpufreq_governor_mutex);
113115

114116
bool have_governor_per_policy(void)

drivers/cpufreq/tegra124-cpufreq.c

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
#include <linux/pm_opp.h>
1717
#include <linux/types.h>
1818

19+
#include "cpufreq-dt.h"
20+
21+
static struct platform_device *tegra124_cpufreq_pdev;
22+
1923
struct tegra124_cpufreq_priv {
2024
struct clk *cpu_clk;
2125
struct clk *pllp_clk;
@@ -55,7 +59,6 @@ static int tegra124_cpufreq_probe(struct platform_device *pdev)
5559
struct device_node *np __free(device_node) = of_cpu_device_node_get(0);
5660
struct tegra124_cpufreq_priv *priv;
5761
struct device *cpu_dev;
58-
struct platform_device_info cpufreq_dt_devinfo = {};
5962
int ret;
6063

6164
if (!np)
@@ -95,11 +98,7 @@ static int tegra124_cpufreq_probe(struct platform_device *pdev)
9598
if (ret)
9699
goto out_put_pllp_clk;
97100

98-
cpufreq_dt_devinfo.name = "cpufreq-dt";
99-
cpufreq_dt_devinfo.parent = &pdev->dev;
100-
101-
priv->cpufreq_dt_pdev =
102-
platform_device_register_full(&cpufreq_dt_devinfo);
101+
priv->cpufreq_dt_pdev = cpufreq_dt_pdev_register(&pdev->dev);
103102
if (IS_ERR(priv->cpufreq_dt_pdev)) {
104103
ret = PTR_ERR(priv->cpufreq_dt_pdev);
105104
goto out_put_pllp_clk;
@@ -173,6 +172,21 @@ static int __maybe_unused tegra124_cpufreq_resume(struct device *dev)
173172
return err;
174173
}
175174

175+
static void tegra124_cpufreq_remove(struct platform_device *pdev)
176+
{
177+
struct tegra124_cpufreq_priv *priv = dev_get_drvdata(&pdev->dev);
178+
179+
if (!IS_ERR(priv->cpufreq_dt_pdev)) {
180+
platform_device_unregister(priv->cpufreq_dt_pdev);
181+
priv->cpufreq_dt_pdev = ERR_PTR(-ENODEV);
182+
}
183+
184+
clk_put(priv->pllp_clk);
185+
clk_put(priv->pllx_clk);
186+
clk_put(priv->dfll_clk);
187+
clk_put(priv->cpu_clk);
188+
}
189+
176190
static const struct dev_pm_ops tegra124_cpufreq_pm_ops = {
177191
SET_SYSTEM_SLEEP_PM_OPS(tegra124_cpufreq_suspend,
178192
tegra124_cpufreq_resume)
@@ -182,15 +196,16 @@ static struct platform_driver tegra124_cpufreq_platdrv = {
182196
.driver.name = "cpufreq-tegra124",
183197
.driver.pm = &tegra124_cpufreq_pm_ops,
184198
.probe = tegra124_cpufreq_probe,
199+
.remove = tegra124_cpufreq_remove,
185200
};
186201

187202
static int __init tegra_cpufreq_init(void)
188203
{
189204
int ret;
190-
struct platform_device *pdev;
191205

192-
if (!(of_machine_is_compatible("nvidia,tegra124") ||
193-
of_machine_is_compatible("nvidia,tegra210")))
206+
if (!(of_machine_is_compatible("nvidia,tegra114") ||
207+
of_machine_is_compatible("nvidia,tegra124") ||
208+
of_machine_is_compatible("nvidia,tegra210")))
194209
return -ENODEV;
195210

196211
/*
@@ -201,15 +216,25 @@ static int __init tegra_cpufreq_init(void)
201216
if (ret)
202217
return ret;
203218

204-
pdev = platform_device_register_simple("cpufreq-tegra124", -1, NULL, 0);
205-
if (IS_ERR(pdev)) {
219+
tegra124_cpufreq_pdev = platform_device_register_simple("cpufreq-tegra124", -1, NULL, 0);
220+
if (IS_ERR(tegra124_cpufreq_pdev)) {
206221
platform_driver_unregister(&tegra124_cpufreq_platdrv);
207-
return PTR_ERR(pdev);
222+
return PTR_ERR(tegra124_cpufreq_pdev);
208223
}
209224

210225
return 0;
211226
}
212227
module_init(tegra_cpufreq_init);
213228

229+
static void __exit tegra_cpufreq_module_exit(void)
230+
{
231+
if (!IS_ERR_OR_NULL(tegra124_cpufreq_pdev))
232+
platform_device_unregister(tegra124_cpufreq_pdev);
233+
234+
platform_driver_unregister(&tegra124_cpufreq_platdrv);
235+
}
236+
module_exit(tegra_cpufreq_module_exit);
237+
214238
MODULE_AUTHOR("Tuomas Tynkkynen <ttynkkynen@nvidia.com>");
215239
MODULE_DESCRIPTION("cpufreq driver for NVIDIA Tegra124");
240+
MODULE_LICENSE("GPL");

rust/kernel/cpufreq.rs

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ impl<T: Driver> Registration<T> {
10611061
///
10621062
/// - This function may only be called from the cpufreq C infrastructure.
10631063
/// - The pointer arguments must be valid pointers.
1064-
unsafe extern "C" fn init_callback(ptr: *mut bindings::cpufreq_policy) -> kernel::ffi::c_int {
1064+
unsafe extern "C" fn init_callback(ptr: *mut bindings::cpufreq_policy) -> c_int {
10651065
from_result(|| {
10661066
// SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the
10671067
// lifetime of `policy`.
@@ -1094,7 +1094,7 @@ impl<T: Driver> Registration<T> {
10941094
///
10951095
/// - This function may only be called from the cpufreq C infrastructure.
10961096
/// - The pointer arguments must be valid pointers.
1097-
unsafe extern "C" fn online_callback(ptr: *mut bindings::cpufreq_policy) -> kernel::ffi::c_int {
1097+
unsafe extern "C" fn online_callback(ptr: *mut bindings::cpufreq_policy) -> c_int {
10981098
from_result(|| {
10991099
// SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the
11001100
// lifetime of `policy`.
@@ -1109,9 +1109,7 @@ impl<T: Driver> Registration<T> {
11091109
///
11101110
/// - This function may only be called from the cpufreq C infrastructure.
11111111
/// - The pointer arguments must be valid pointers.
1112-
unsafe extern "C" fn offline_callback(
1113-
ptr: *mut bindings::cpufreq_policy,
1114-
) -> kernel::ffi::c_int {
1112+
unsafe extern "C" fn offline_callback(ptr: *mut bindings::cpufreq_policy) -> c_int {
11151113
from_result(|| {
11161114
// SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the
11171115
// lifetime of `policy`.
@@ -1126,9 +1124,7 @@ impl<T: Driver> Registration<T> {
11261124
///
11271125
/// - This function may only be called from the cpufreq C infrastructure.
11281126
/// - The pointer arguments must be valid pointers.
1129-
unsafe extern "C" fn suspend_callback(
1130-
ptr: *mut bindings::cpufreq_policy,
1131-
) -> kernel::ffi::c_int {
1127+
unsafe extern "C" fn suspend_callback(ptr: *mut bindings::cpufreq_policy) -> c_int {
11321128
from_result(|| {
11331129
// SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the
11341130
// lifetime of `policy`.
@@ -1143,7 +1139,7 @@ impl<T: Driver> Registration<T> {
11431139
///
11441140
/// - This function may only be called from the cpufreq C infrastructure.
11451141
/// - The pointer arguments must be valid pointers.
1146-
unsafe extern "C" fn resume_callback(ptr: *mut bindings::cpufreq_policy) -> kernel::ffi::c_int {
1142+
unsafe extern "C" fn resume_callback(ptr: *mut bindings::cpufreq_policy) -> c_int {
11471143
from_result(|| {
11481144
// SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the
11491145
// lifetime of `policy`.
@@ -1171,9 +1167,7 @@ impl<T: Driver> Registration<T> {
11711167
///
11721168
/// - This function may only be called from the cpufreq C infrastructure.
11731169
/// - The pointer arguments must be valid pointers.
1174-
unsafe extern "C" fn verify_callback(
1175-
ptr: *mut bindings::cpufreq_policy_data,
1176-
) -> kernel::ffi::c_int {
1170+
unsafe extern "C" fn verify_callback(ptr: *mut bindings::cpufreq_policy_data) -> c_int {
11771171
from_result(|| {
11781172
// SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the
11791173
// lifetime of `policy`.
@@ -1188,9 +1182,7 @@ impl<T: Driver> Registration<T> {
11881182
///
11891183
/// - This function may only be called from the cpufreq C infrastructure.
11901184
/// - The pointer arguments must be valid pointers.
1191-
unsafe extern "C" fn setpolicy_callback(
1192-
ptr: *mut bindings::cpufreq_policy,
1193-
) -> kernel::ffi::c_int {
1185+
unsafe extern "C" fn setpolicy_callback(ptr: *mut bindings::cpufreq_policy) -> c_int {
11941186
from_result(|| {
11951187
// SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the
11961188
// lifetime of `policy`.
@@ -1207,9 +1199,9 @@ impl<T: Driver> Registration<T> {
12071199
/// - The pointer arguments must be valid pointers.
12081200
unsafe extern "C" fn target_callback(
12091201
ptr: *mut bindings::cpufreq_policy,
1210-
target_freq: u32,
1211-
relation: u32,
1212-
) -> kernel::ffi::c_int {
1202+
target_freq: c_uint,
1203+
relation: c_uint,
1204+
) -> c_int {
12131205
from_result(|| {
12141206
// SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the
12151207
// lifetime of `policy`.
@@ -1226,8 +1218,8 @@ impl<T: Driver> Registration<T> {
12261218
/// - The pointer arguments must be valid pointers.
12271219
unsafe extern "C" fn target_index_callback(
12281220
ptr: *mut bindings::cpufreq_policy,
1229-
index: u32,
1230-
) -> kernel::ffi::c_int {
1221+
index: c_uint,
1222+
) -> c_int {
12311223
from_result(|| {
12321224
// SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the
12331225
// lifetime of `policy`.
@@ -1249,8 +1241,8 @@ impl<T: Driver> Registration<T> {
12491241
/// - The pointer arguments must be valid pointers.
12501242
unsafe extern "C" fn fast_switch_callback(
12511243
ptr: *mut bindings::cpufreq_policy,
1252-
target_freq: u32,
1253-
) -> kernel::ffi::c_uint {
1244+
target_freq: c_uint,
1245+
) -> c_uint {
12541246
// SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the
12551247
// lifetime of `policy`.
12561248
let policy = unsafe { Policy::from_raw_mut(ptr) };
@@ -1263,10 +1255,10 @@ impl<T: Driver> Registration<T> {
12631255
///
12641256
/// - This function may only be called from the cpufreq C infrastructure.
12651257
unsafe extern "C" fn adjust_perf_callback(
1266-
cpu: u32,
1267-
min_perf: usize,
1268-
target_perf: usize,
1269-
capacity: usize,
1258+
cpu: c_uint,
1259+
min_perf: c_ulong,
1260+
target_perf: c_ulong,
1261+
capacity: c_ulong,
12701262
) {
12711263
// SAFETY: The C API guarantees that `cpu` refers to a valid CPU number.
12721264
let cpu_id = unsafe { CpuId::from_u32_unchecked(cpu) };
@@ -1284,8 +1276,8 @@ impl<T: Driver> Registration<T> {
12841276
/// - The pointer arguments must be valid pointers.
12851277
unsafe extern "C" fn get_intermediate_callback(
12861278
ptr: *mut bindings::cpufreq_policy,
1287-
index: u32,
1288-
) -> kernel::ffi::c_uint {
1279+
index: c_uint,
1280+
) -> c_uint {
12891281
// SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the
12901282
// lifetime of `policy`.
12911283
let policy = unsafe { Policy::from_raw_mut(ptr) };
@@ -1305,8 +1297,8 @@ impl<T: Driver> Registration<T> {
13051297
/// - The pointer arguments must be valid pointers.
13061298
unsafe extern "C" fn target_intermediate_callback(
13071299
ptr: *mut bindings::cpufreq_policy,
1308-
index: u32,
1309-
) -> kernel::ffi::c_int {
1300+
index: c_uint,
1301+
) -> c_int {
13101302
from_result(|| {
13111303
// SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the
13121304
// lifetime of `policy`.
@@ -1325,7 +1317,7 @@ impl<T: Driver> Registration<T> {
13251317
/// # Safety
13261318
///
13271319
/// - This function may only be called from the cpufreq C infrastructure.
1328-
unsafe extern "C" fn get_callback(cpu: u32) -> kernel::ffi::c_uint {
1320+
unsafe extern "C" fn get_callback(cpu: c_uint) -> c_uint {
13291321
// SAFETY: The C API guarantees that `cpu` refers to a valid CPU number.
13301322
let cpu_id = unsafe { CpuId::from_u32_unchecked(cpu) };
13311323

@@ -1351,7 +1343,7 @@ impl<T: Driver> Registration<T> {
13511343
///
13521344
/// - This function may only be called from the cpufreq C infrastructure.
13531345
/// - The pointer arguments must be valid pointers.
1354-
unsafe extern "C" fn bios_limit_callback(cpu: i32, limit: *mut u32) -> kernel::ffi::c_int {
1346+
unsafe extern "C" fn bios_limit_callback(cpu: c_int, limit: *mut c_uint) -> c_int {
13551347
// SAFETY: The C API guarantees that `cpu` refers to a valid CPU number.
13561348
let cpu_id = unsafe { CpuId::from_i32_unchecked(cpu) };
13571349

@@ -1371,8 +1363,8 @@ impl<T: Driver> Registration<T> {
13711363
/// - The pointer arguments must be valid pointers.
13721364
unsafe extern "C" fn set_boost_callback(
13731365
ptr: *mut bindings::cpufreq_policy,
1374-
state: i32,
1375-
) -> kernel::ffi::c_int {
1366+
state: c_int,
1367+
) -> c_int {
13761368
from_result(|| {
13771369
// SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the
13781370
// lifetime of `policy`.

0 commit comments

Comments
 (0)