Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'pm-cpufreq'

Merge cpufreq updates for 6.17-rc1:

- Fix two initialization ordering issues in the cpufreq core and a
governor initialization error path in it, and clean it up (Lifeng
Zheng)

- Add Granite Rapids support in no-HWP mode to the intel_pstate cpufreq
driver (Li RongQing)

- Make intel_pstate always use HWP_DESIRED_PERF in passive mode (Rafael
Wysocki)

- Allow building the tegra124 cpufreq driver as a module (Aaron Kling)

- Do minor cleanups for Rust cpufreq and cpumask APIs and fix MAINTAINERS
entry for cpu.rs (Abhinav Ananthu, Ritvik Gupta, Lukas Bulwahn)

- Clean up assorted cpufreq drivers (Arnd Bergmann, Dan Carpenter,
Krzysztof Kozlowski, Sven Peter, Svyatoslav Ryhel, Lifeng Zheng)

- Add the NEED_UPDATE_LIMITS flag to the CPPC cpufreq driver (Prashant
Malani)

- Fix minimum performance state label error in the amd-pstate driver
documentation (Shouye Liu)

- Add the CPUFREQ_GOV_STRICT_TARGET flag to the userspace cpufreq
governor and explain HW coordination influence on it in the
documentation (Shashank Balaji)

* pm-cpufreq: (27 commits)
cpufreq: CPPC: Mark driver with NEED_UPDATE_LIMITS flag
Documentation: amd-pstate:fix minimum performance state label error
drivers: cpufreq: add Tegra114 support
rust: cpumask: Replace `MaybeUninit` and `mem::zeroed` with `Opaque` APIs
cpufreq: Exit governor when failed to start old governor
cpufreq: Move the check of cpufreq_driver->get into cpufreq_verify_current_freq()
cpufreq: Init policy->rwsem before it may be possibly used
cpufreq: Initialize cpufreq-based frequency-invariance later
cpufreq: Remove duplicate check in __cpufreq_offline()
cpufreq: Contain scaling_cur_freq.attr in cpufreq_attrs
cpufreq: intel_pstate: Add Granite Rapids support in no-HWP mode
cpufreq: intel_pstate: Always use HWP_DESIRED_PERF in passive mode
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
...

+137 -142
+1 -1
Documentation/admin-guide/pm/amd-pstate.rst
··· 72 72 Lowest non- | | | | 73 73 linear perf ------>+-----------------------+ +-----------------------+ 74 74 | | | | 75 - | | Lowest perf ---->| | 75 + | | Min perf ---->| | 76 76 | | | | 77 77 Lowest perf ------>+-----------------------+ +-----------------------+ 78 78 | | | |
+3 -1
Documentation/admin-guide/pm/cpufreq.rst
··· 398 398 399 399 This governor does not do anything by itself. Instead, it allows user space 400 400 to set the CPU frequency for the policy it is attached to by writing to the 401 - ``scaling_setspeed`` attribute of that policy. 401 + ``scaling_setspeed`` attribute of that policy. Though the intention may be to 402 + set an exact frequency for the policy, the actual frequency may vary depending 403 + on hardware coordination, thermal and power limits, and other factors. 402 404 403 405 ``schedutil`` 404 406 -------------
+1 -1
MAINTAINERS
··· 6256 6256 F: include/linux/smpboot.h 6257 6257 F: kernel/cpu.c 6258 6258 F: kernel/smpboot.* 6259 - F: rust/helper/cpu.c 6259 + F: rust/helpers/cpu.c 6260 6260 F: rust/kernel/cpu.rs 6261 6261 6262 6262 CPU IDLE TIME MANAGEMENT FRAMEWORK
+1 -2
drivers/cpufreq/Kconfig.arm
··· 28 28 tristate "Apple Silicon SoC CPUFreq support" 29 29 depends on ARCH_APPLE || (COMPILE_TEST && 64BIT) 30 30 select PM_OPP 31 - default ARCH_APPLE 32 31 help 33 32 This adds the CPUFreq driver for Apple Silicon machines 34 33 (e.g. Apple M1). ··· 237 238 This adds the CPUFreq driver support for Tegra20/30 SOCs. 238 239 239 240 config ARM_TEGRA124_CPUFREQ 240 - bool "Tegra124 CPUFreq support" 241 + tristate "Tegra124 CPUFreq support" 241 242 depends on ARCH_TEGRA || COMPILE_TEST 242 243 depends on CPUFREQ_DT 243 244 default ARCH_TEGRA
+2 -3
drivers/cpufreq/armada-8k-cpufreq.c
··· 103 103 { 104 104 int opps_index, nb_cpus = num_possible_cpus(); 105 105 106 - for (opps_index = 0 ; opps_index <= nb_cpus; opps_index++) { 106 + for (opps_index = 0 ; opps_index < nb_cpus; opps_index++) { 107 107 int i; 108 108 109 109 /* If cpu_dev is NULL then we reached the end of the array */ ··· 132 132 int ret = 0, opps_index = 0, cpu, nb_cpus; 133 133 struct freq_table *freq_tables; 134 134 struct device_node *node; 135 - static struct cpumask cpus; 135 + static struct cpumask cpus, shared_cpus; 136 136 137 137 node = of_find_matching_node_and_match(NULL, armada_8k_cpufreq_of_match, 138 138 NULL); ··· 154 154 * divisions of it). 155 155 */ 156 156 for_each_cpu(cpu, &cpus) { 157 - struct cpumask shared_cpus; 158 157 struct device *cpu_dev; 159 158 struct clk *clk; 160 159
+1 -1
drivers/cpufreq/brcmstb-avs-cpufreq.c
··· 765 765 } 766 766 767 767 static const struct of_device_id brcm_avs_cpufreq_match[] = { 768 - { .compatible = BRCM_AVS_CPU_DATA }, 768 + { .compatible = "brcm,avs-cpu-data-mem" }, 769 769 { } 770 770 }; 771 771 MODULE_DEVICE_TABLE(of, brcm_avs_cpufreq_match);
+16 -45
drivers/cpufreq/cppc_cpufreq.c
··· 26 26 27 27 #include <acpi/cppc_acpi.h> 28 28 29 - /* 30 - * This list contains information parsed from per CPU ACPI _CPC and _PSD 31 - * structures: e.g. the highest and lowest supported performance, capabilities, 32 - * desired performance, level requested etc. Depending on the share_type, not 33 - * all CPUs will have an entry in the list. 34 - */ 35 - static LIST_HEAD(cpu_data_list); 36 - 37 29 static struct cpufreq_driver cppc_cpufreq_driver; 38 30 39 31 #ifdef CONFIG_ACPI_CPPC_CPUFREQ_FIE ··· 344 352 #if defined(CONFIG_ARM64) && defined(CONFIG_ENERGY_MODEL) 345 353 346 354 static DEFINE_PER_CPU(unsigned int, efficiency_class); 347 - static void cppc_cpufreq_register_em(struct cpufreq_policy *policy); 348 355 349 356 /* Create an artificial performance state every CPPC_EM_CAP_STEP capacity unit. */ 350 357 #define CPPC_EM_CAP_STEP (20) ··· 479 488 return 0; 480 489 } 481 490 482 - static int populate_efficiency_class(void) 491 + static void cppc_cpufreq_register_em(struct cpufreq_policy *policy) 492 + { 493 + struct cppc_cpudata *cpu_data; 494 + struct em_data_callback em_cb = 495 + EM_ADV_DATA_CB(cppc_get_cpu_power, cppc_get_cpu_cost); 496 + 497 + cpu_data = policy->driver_data; 498 + em_dev_register_perf_domain(get_cpu_device(policy->cpu), 499 + get_perf_level_count(policy), &em_cb, 500 + cpu_data->shared_cpu_map, 0); 501 + } 502 + 503 + static void populate_efficiency_class(void) 483 504 { 484 505 struct acpi_madt_generic_interrupt *gicc; 485 506 DECLARE_BITMAP(used_classes, 256) = {}; ··· 506 503 if (bitmap_weight(used_classes, 256) <= 1) { 507 504 pr_debug("Efficiency classes are all equal (=%d). " 508 505 "No EM registered", class); 509 - return -EINVAL; 506 + return; 510 507 } 511 508 512 509 /* ··· 523 520 index++; 524 521 } 525 522 cppc_cpufreq_driver.register_em = cppc_cpufreq_register_em; 526 - 527 - return 0; 528 - } 529 - 530 - static void cppc_cpufreq_register_em(struct cpufreq_policy *policy) 531 - { 532 - struct cppc_cpudata *cpu_data; 533 - struct em_data_callback em_cb = 534 - EM_ADV_DATA_CB(cppc_get_cpu_power, cppc_get_cpu_cost); 535 - 536 - cpu_data = policy->driver_data; 537 - em_dev_register_perf_domain(get_cpu_device(policy->cpu), 538 - get_perf_level_count(policy), &em_cb, 539 - cpu_data->shared_cpu_map, 0); 540 523 } 541 524 542 525 #else 543 - static int populate_efficiency_class(void) 526 + static void populate_efficiency_class(void) 544 527 { 545 - return 0; 546 528 } 547 529 #endif 548 530 ··· 555 567 goto free_mask; 556 568 } 557 569 558 - list_add(&cpu_data->node, &cpu_data_list); 559 - 560 570 return cpu_data; 561 571 562 572 free_mask: ··· 569 583 { 570 584 struct cppc_cpudata *cpu_data = policy->driver_data; 571 585 572 - list_del(&cpu_data->node); 573 586 free_cpumask_var(cpu_data->shared_cpu_map); 574 587 kfree(cpu_data); 575 588 policy->driver_data = NULL; ··· 910 925 }; 911 926 912 927 static struct cpufreq_driver cppc_cpufreq_driver = { 913 - .flags = CPUFREQ_CONST_LOOPS, 928 + .flags = CPUFREQ_CONST_LOOPS | CPUFREQ_NEED_UPDATE_LIMITS, 914 929 .verify = cppc_verify_policy, 915 930 .target = cppc_cpufreq_set_target, 916 931 .get = cppc_cpufreq_get_rate, ··· 939 954 return ret; 940 955 } 941 956 942 - static inline void free_cpu_data(void) 943 - { 944 - struct cppc_cpudata *iter, *tmp; 945 - 946 - list_for_each_entry_safe(iter, tmp, &cpu_data_list, node) { 947 - free_cpumask_var(iter->shared_cpu_map); 948 - list_del(&iter->node); 949 - kfree(iter); 950 - } 951 - 952 - } 953 - 954 957 static void __exit cppc_cpufreq_exit(void) 955 958 { 956 959 cpufreq_unregister_driver(&cppc_cpufreq_driver); 957 960 cppc_freq_invariance_exit(); 958 - 959 - free_cpu_data(); 960 961 } 961 962 962 963 module_exit(cppc_cpufreq_exit);
+1
drivers/cpufreq/cpufreq-dt-platdev.c
··· 143 143 144 144 { .compatible = "nvidia,tegra20", }, 145 145 { .compatible = "nvidia,tegra30", }, 146 + { .compatible = "nvidia,tegra114", }, 146 147 { .compatible = "nvidia,tegra124", }, 147 148 { .compatible = "nvidia,tegra210", }, 148 149 { .compatible = "nvidia,tegra234", },
+11
drivers/cpufreq/cpufreq-dt.c
··· 329 329 }; 330 330 module_platform_driver(dt_cpufreq_platdrv); 331 331 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 + 332 343 MODULE_ALIAS("platform:cpufreq-dt"); 333 344 MODULE_AUTHOR("Viresh Kumar <viresh.kumar@linaro.org>"); 334 345 MODULE_AUTHOR("Shawn Guo <shawn.guo@linaro.org>");
+2
drivers/cpufreq/cpufreq-dt.h
··· 22 22 int (*resume)(struct cpufreq_policy *policy); 23 23 }; 24 24 25 + struct platform_device *cpufreq_dt_pdev_register(struct device *dev); 26 + 25 27 #endif /* __CPUFREQ_DT_H__ */
+28 -28
drivers/cpufreq/cpufreq.c
··· 109 109 { 110 110 off = 1; 111 111 } 112 + EXPORT_SYMBOL_GPL(disable_cpufreq); 113 + 112 114 static DEFINE_MUTEX(cpufreq_governor_mutex); 113 115 114 116 bool have_governor_per_policy(void) ··· 969 967 &cpuinfo_min_freq.attr, 970 968 &cpuinfo_max_freq.attr, 971 969 &cpuinfo_transition_latency.attr, 970 + &scaling_cur_freq.attr, 972 971 &scaling_min_freq.attr, 973 972 &scaling_max_freq.attr, 974 973 &affected_cpus.attr, ··· 1097 1094 if (ret) 1098 1095 return ret; 1099 1096 } 1100 - 1101 - ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr); 1102 - if (ret) 1103 - return ret; 1104 1097 1105 1098 if (cpufreq_driver->bios_limit) { 1106 1099 ret = sysfs_create_file(&policy->kobj, &bios_limit.attr); ··· 1283 1284 goto err_free_real_cpus; 1284 1285 } 1285 1286 1287 + init_rwsem(&policy->rwsem); 1288 + 1286 1289 freq_constraints_init(&policy->constraints); 1287 1290 1288 1291 policy->nb_min.notifier_call = cpufreq_notifier_min; ··· 1307 1306 } 1308 1307 1309 1308 INIT_LIST_HEAD(&policy->policy_list); 1310 - init_rwsem(&policy->rwsem); 1311 1309 spin_lock_init(&policy->transition_lock); 1312 1310 init_waitqueue_head(&policy->transition_wait); 1313 1311 INIT_WORK(&policy->update, handle_update); ··· 1694 1694 return; 1695 1695 } 1696 1696 1697 - if (has_target()) 1697 + if (has_target()) { 1698 1698 strscpy(policy->last_governor, policy->governor->name, 1699 1699 CPUFREQ_NAME_LEN); 1700 - else 1701 - policy->last_policy = policy->policy; 1702 - 1703 - if (has_target()) 1704 1700 cpufreq_exit_governor(policy); 1701 + } else { 1702 + policy->last_policy = policy->policy; 1703 + } 1705 1704 1706 1705 /* 1707 1706 * Perform the ->offline() during light-weight tear-down, as ··· 1801 1802 static unsigned int cpufreq_verify_current_freq(struct cpufreq_policy *policy, bool update) 1802 1803 { 1803 1804 unsigned int new_freq; 1805 + 1806 + if (!cpufreq_driver->get) 1807 + return 0; 1804 1808 1805 1809 new_freq = cpufreq_driver->get(policy->cpu); 1806 1810 if (!new_freq) ··· 1927 1925 1928 1926 guard(cpufreq_policy_read)(policy); 1929 1927 1930 - if (cpufreq_driver->get) 1931 - return __cpufreq_get(policy); 1932 - 1933 - return 0; 1928 + return __cpufreq_get(policy); 1934 1929 } 1935 1930 EXPORT_SYMBOL(cpufreq_get); 1936 1931 ··· 2481 2482 2482 2483 pr_debug("%s: for CPU %u\n", __func__, policy->cpu); 2483 2484 2484 - if (cpufreq_driver->get) 2485 - cpufreq_verify_current_freq(policy, false); 2485 + cpufreq_verify_current_freq(policy, false); 2486 2486 2487 2487 if (policy->governor->start) { 2488 2488 ret = policy->governor->start(policy); ··· 2713 2715 pr_debug("starting governor %s failed\n", policy->governor->name); 2714 2716 if (old_gov) { 2715 2717 policy->governor = old_gov; 2716 - if (cpufreq_init_governor(policy)) 2718 + if (cpufreq_init_governor(policy)) { 2717 2719 policy->governor = NULL; 2718 - else 2719 - cpufreq_start_governor(policy); 2720 + } else if (cpufreq_start_governor(policy)) { 2721 + cpufreq_exit_governor(policy); 2722 + policy->governor = NULL; 2723 + } 2720 2724 } 2721 2725 2722 2726 return ret; ··· 2944 2944 cpufreq_driver = driver_data; 2945 2945 write_unlock_irqrestore(&cpufreq_driver_lock, flags); 2946 2946 2947 - /* 2948 - * Mark support for the scheduler's frequency invariance engine for 2949 - * drivers that implement target(), target_index() or fast_switch(). 2950 - */ 2951 - if (!cpufreq_driver->setpolicy) { 2952 - static_branch_enable_cpuslocked(&cpufreq_freq_invariance); 2953 - pr_debug("supports frequency invariance"); 2954 - } 2955 - 2956 2947 if (driver_data->setpolicy) 2957 2948 driver_data->flags |= CPUFREQ_CONST_LOOPS; 2958 2949 ··· 2973 2982 goto err_if_unreg; 2974 2983 hp_online = ret; 2975 2984 ret = 0; 2985 + 2986 + /* 2987 + * Mark support for the scheduler's frequency invariance engine for 2988 + * drivers that implement target(), target_index() or fast_switch(). 2989 + */ 2990 + if (!cpufreq_driver->setpolicy) { 2991 + static_branch_enable_cpuslocked(&cpufreq_freq_invariance); 2992 + pr_debug("supports frequency invariance"); 2993 + } 2976 2994 2977 2995 pr_debug("driver %s up and running\n", driver_data->name); 2978 2996 goto out;
+1
drivers/cpufreq/cpufreq_userspace.c
··· 134 134 .store_setspeed = cpufreq_set, 135 135 .show_setspeed = show_speed, 136 136 .owner = THIS_MODULE, 137 + .flags = CPUFREQ_GOV_STRICT_TARGET, 137 138 }; 138 139 139 140 MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>, "
+4 -2
drivers/cpufreq/intel_pstate.c
··· 2775 2775 X86_MATCH(INTEL_TIGERLAKE, core_funcs), 2776 2776 X86_MATCH(INTEL_SAPPHIRERAPIDS_X, core_funcs), 2777 2777 X86_MATCH(INTEL_EMERALDRAPIDS_X, core_funcs), 2778 + X86_MATCH(INTEL_GRANITERAPIDS_D, core_funcs), 2779 + X86_MATCH(INTEL_GRANITERAPIDS_X, core_funcs), 2778 2780 {} 2779 2781 }; 2780 2782 MODULE_DEVICE_TABLE(x86cpu, intel_pstate_cpu_ids); ··· 3251 3249 int max_pstate = policy->strict_target ? 3252 3250 target_pstate : cpu->max_perf_ratio; 3253 3251 3254 - intel_cpufreq_hwp_update(cpu, target_pstate, max_pstate, 0, 3255 - fast_switch); 3252 + intel_cpufreq_hwp_update(cpu, target_pstate, max_pstate, 3253 + target_pstate, fast_switch); 3256 3254 } else if (target_pstate != old_pstate) { 3257 3255 intel_cpufreq_perf_ctl_update(cpu, target_pstate, fast_switch); 3258 3256 }
+37 -12
drivers/cpufreq/tegra124-cpufreq.c
··· 16 16 #include <linux/pm_opp.h> 17 17 #include <linux/types.h> 18 18 19 + #include "cpufreq-dt.h" 20 + 21 + static struct platform_device *tegra124_cpufreq_pdev; 22 + 19 23 struct tegra124_cpufreq_priv { 20 24 struct clk *cpu_clk; 21 25 struct clk *pllp_clk; ··· 59 55 struct device_node *np __free(device_node) = of_cpu_device_node_get(0); 60 56 struct tegra124_cpufreq_priv *priv; 61 57 struct device *cpu_dev; 62 - struct platform_device_info cpufreq_dt_devinfo = {}; 63 58 int ret; 64 59 65 60 if (!np) ··· 98 95 if (ret) 99 96 goto out_put_pllp_clk; 100 97 101 - cpufreq_dt_devinfo.name = "cpufreq-dt"; 102 - cpufreq_dt_devinfo.parent = &pdev->dev; 103 - 104 - priv->cpufreq_dt_pdev = 105 - platform_device_register_full(&cpufreq_dt_devinfo); 98 + priv->cpufreq_dt_pdev = cpufreq_dt_pdev_register(&pdev->dev); 106 99 if (IS_ERR(priv->cpufreq_dt_pdev)) { 107 100 ret = PTR_ERR(priv->cpufreq_dt_pdev); 108 101 goto out_put_pllp_clk; ··· 172 173 return err; 173 174 } 174 175 176 + static void tegra124_cpufreq_remove(struct platform_device *pdev) 177 + { 178 + struct tegra124_cpufreq_priv *priv = dev_get_drvdata(&pdev->dev); 179 + 180 + if (!IS_ERR(priv->cpufreq_dt_pdev)) { 181 + platform_device_unregister(priv->cpufreq_dt_pdev); 182 + priv->cpufreq_dt_pdev = ERR_PTR(-ENODEV); 183 + } 184 + 185 + clk_put(priv->pllp_clk); 186 + clk_put(priv->pllx_clk); 187 + clk_put(priv->dfll_clk); 188 + clk_put(priv->cpu_clk); 189 + } 190 + 175 191 static const struct dev_pm_ops tegra124_cpufreq_pm_ops = { 176 192 SET_SYSTEM_SLEEP_PM_OPS(tegra124_cpufreq_suspend, 177 193 tegra124_cpufreq_resume) ··· 196 182 .driver.name = "cpufreq-tegra124", 197 183 .driver.pm = &tegra124_cpufreq_pm_ops, 198 184 .probe = tegra124_cpufreq_probe, 185 + .remove = tegra124_cpufreq_remove, 199 186 }; 200 187 201 188 static int __init tegra_cpufreq_init(void) 202 189 { 203 190 int ret; 204 - struct platform_device *pdev; 205 191 206 - if (!(of_machine_is_compatible("nvidia,tegra124") || 207 - of_machine_is_compatible("nvidia,tegra210"))) 192 + if (!(of_machine_is_compatible("nvidia,tegra114") || 193 + of_machine_is_compatible("nvidia,tegra124") || 194 + of_machine_is_compatible("nvidia,tegra210"))) 208 195 return -ENODEV; 209 196 210 197 /* ··· 216 201 if (ret) 217 202 return ret; 218 203 219 - pdev = platform_device_register_simple("cpufreq-tegra124", -1, NULL, 0); 220 - if (IS_ERR(pdev)) { 204 + tegra124_cpufreq_pdev = platform_device_register_simple("cpufreq-tegra124", -1, NULL, 0); 205 + if (IS_ERR(tegra124_cpufreq_pdev)) { 221 206 platform_driver_unregister(&tegra124_cpufreq_platdrv); 222 - return PTR_ERR(pdev); 207 + return PTR_ERR(tegra124_cpufreq_pdev); 223 208 } 224 209 225 210 return 0; 226 211 } 227 212 module_init(tegra_cpufreq_init); 228 213 214 + static void __exit tegra_cpufreq_module_exit(void) 215 + { 216 + if (!IS_ERR_OR_NULL(tegra124_cpufreq_pdev)) 217 + platform_device_unregister(tegra124_cpufreq_pdev); 218 + 219 + platform_driver_unregister(&tegra124_cpufreq_platdrv); 220 + } 221 + module_exit(tegra_cpufreq_module_exit); 222 + 229 223 MODULE_AUTHOR("Tuomas Tynkkynen <ttynkkynen@nvidia.com>"); 230 224 MODULE_DESCRIPTION("cpufreq driver for NVIDIA Tegra124"); 225 + MODULE_LICENSE("GPL");
-1
include/acpi/cppc_acpi.h
··· 139 139 140 140 /* Per CPU container for runtime CPPC management. */ 141 141 struct cppc_cpudata { 142 - struct list_head node; 143 142 struct cppc_perf_caps perf_caps; 144 143 struct cppc_perf_ctrls perf_ctrls; 145 144 struct cppc_perf_fb_ctrs perf_fb_ctrs;
+26 -34
rust/kernel/cpufreq.rs
··· 1061 1061 /// 1062 1062 /// - This function may only be called from the cpufreq C infrastructure. 1063 1063 /// - 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 { 1065 1065 from_result(|| { 1066 1066 // SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the 1067 1067 // lifetime of `policy`. ··· 1094 1094 /// 1095 1095 /// - This function may only be called from the cpufreq C infrastructure. 1096 1096 /// - 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 { 1098 1098 from_result(|| { 1099 1099 // SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the 1100 1100 // lifetime of `policy`. ··· 1109 1109 /// 1110 1110 /// - This function may only be called from the cpufreq C infrastructure. 1111 1111 /// - 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 { 1115 1113 from_result(|| { 1116 1114 // SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the 1117 1115 // lifetime of `policy`. ··· 1124 1126 /// 1125 1127 /// - This function may only be called from the cpufreq C infrastructure. 1126 1128 /// - The pointer arguments must be valid pointers. 1127 - unsafe extern "C" fn suspend_callback( 1128 - ptr: *mut bindings::cpufreq_policy, 1129 - ) -> kernel::ffi::c_int { 1129 + unsafe extern "C" fn suspend_callback(ptr: *mut bindings::cpufreq_policy) -> c_int { 1130 1130 from_result(|| { 1131 1131 // SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the 1132 1132 // lifetime of `policy`. ··· 1139 1143 /// 1140 1144 /// - This function may only be called from the cpufreq C infrastructure. 1141 1145 /// - The pointer arguments must be valid pointers. 1142 - unsafe extern "C" fn resume_callback(ptr: *mut bindings::cpufreq_policy) -> kernel::ffi::c_int { 1146 + unsafe extern "C" fn resume_callback(ptr: *mut bindings::cpufreq_policy) -> c_int { 1143 1147 from_result(|| { 1144 1148 // SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the 1145 1149 // lifetime of `policy`. ··· 1167 1171 /// 1168 1172 /// - This function may only be called from the cpufreq C infrastructure. 1169 1173 /// - The pointer arguments must be valid pointers. 1170 - unsafe extern "C" fn verify_callback( 1171 - ptr: *mut bindings::cpufreq_policy_data, 1172 - ) -> kernel::ffi::c_int { 1174 + unsafe extern "C" fn verify_callback(ptr: *mut bindings::cpufreq_policy_data) -> c_int { 1173 1175 from_result(|| { 1174 1176 // SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the 1175 1177 // lifetime of `policy`. ··· 1182 1188 /// 1183 1189 /// - This function may only be called from the cpufreq C infrastructure. 1184 1190 /// - The pointer arguments must be valid pointers. 1185 - unsafe extern "C" fn setpolicy_callback( 1186 - ptr: *mut bindings::cpufreq_policy, 1187 - ) -> kernel::ffi::c_int { 1191 + unsafe extern "C" fn setpolicy_callback(ptr: *mut bindings::cpufreq_policy) -> c_int { 1188 1192 from_result(|| { 1189 1193 // SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the 1190 1194 // lifetime of `policy`. ··· 1199 1207 /// - The pointer arguments must be valid pointers. 1200 1208 unsafe extern "C" fn target_callback( 1201 1209 ptr: *mut bindings::cpufreq_policy, 1202 - target_freq: u32, 1203 - relation: u32, 1204 - ) -> kernel::ffi::c_int { 1210 + target_freq: c_uint, 1211 + relation: c_uint, 1212 + ) -> c_int { 1205 1213 from_result(|| { 1206 1214 // SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the 1207 1215 // lifetime of `policy`. ··· 1218 1226 /// - The pointer arguments must be valid pointers. 1219 1227 unsafe extern "C" fn target_index_callback( 1220 1228 ptr: *mut bindings::cpufreq_policy, 1221 - index: u32, 1222 - ) -> kernel::ffi::c_int { 1229 + index: c_uint, 1230 + ) -> c_int { 1223 1231 from_result(|| { 1224 1232 // SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the 1225 1233 // lifetime of `policy`. ··· 1241 1249 /// - The pointer arguments must be valid pointers. 1242 1250 unsafe extern "C" fn fast_switch_callback( 1243 1251 ptr: *mut bindings::cpufreq_policy, 1244 - target_freq: u32, 1245 - ) -> kernel::ffi::c_uint { 1252 + target_freq: c_uint, 1253 + ) -> c_uint { 1246 1254 // SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the 1247 1255 // lifetime of `policy`. 1248 1256 let policy = unsafe { Policy::from_raw_mut(ptr) }; ··· 1255 1263 /// 1256 1264 /// - This function may only be called from the cpufreq C infrastructure. 1257 1265 unsafe extern "C" fn adjust_perf_callback( 1258 - cpu: u32, 1259 - min_perf: usize, 1260 - target_perf: usize, 1261 - capacity: usize, 1266 + cpu: c_uint, 1267 + min_perf: c_ulong, 1268 + target_perf: c_ulong, 1269 + capacity: c_ulong, 1262 1270 ) { 1263 1271 // SAFETY: The C API guarantees that `cpu` refers to a valid CPU number. 1264 1272 let cpu_id = unsafe { CpuId::from_u32_unchecked(cpu) }; ··· 1276 1284 /// - The pointer arguments must be valid pointers. 1277 1285 unsafe extern "C" fn get_intermediate_callback( 1278 1286 ptr: *mut bindings::cpufreq_policy, 1279 - index: u32, 1280 - ) -> kernel::ffi::c_uint { 1287 + index: c_uint, 1288 + ) -> c_uint { 1281 1289 // SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the 1282 1290 // lifetime of `policy`. 1283 1291 let policy = unsafe { Policy::from_raw_mut(ptr) }; ··· 1297 1305 /// - The pointer arguments must be valid pointers. 1298 1306 unsafe extern "C" fn target_intermediate_callback( 1299 1307 ptr: *mut bindings::cpufreq_policy, 1300 - index: u32, 1301 - ) -> kernel::ffi::c_int { 1308 + index: c_uint, 1309 + ) -> c_int { 1302 1310 from_result(|| { 1303 1311 // SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the 1304 1312 // lifetime of `policy`. ··· 1317 1325 /// # Safety 1318 1326 /// 1319 1327 /// - This function may only be called from the cpufreq C infrastructure. 1320 - unsafe extern "C" fn get_callback(cpu: u32) -> kernel::ffi::c_uint { 1328 + unsafe extern "C" fn get_callback(cpu: c_uint) -> c_uint { 1321 1329 // SAFETY: The C API guarantees that `cpu` refers to a valid CPU number. 1322 1330 let cpu_id = unsafe { CpuId::from_u32_unchecked(cpu) }; 1323 1331 ··· 1343 1351 /// 1344 1352 /// - This function may only be called from the cpufreq C infrastructure. 1345 1353 /// - The pointer arguments must be valid pointers. 1346 - unsafe extern "C" fn bios_limit_callback(cpu: i32, limit: *mut u32) -> kernel::ffi::c_int { 1354 + unsafe extern "C" fn bios_limit_callback(cpu: c_int, limit: *mut c_uint) -> c_int { 1347 1355 // SAFETY: The C API guarantees that `cpu` refers to a valid CPU number. 1348 1356 let cpu_id = unsafe { CpuId::from_i32_unchecked(cpu) }; 1349 1357 ··· 1363 1371 /// - The pointer arguments must be valid pointers. 1364 1372 unsafe extern "C" fn set_boost_callback( 1365 1373 ptr: *mut bindings::cpufreq_policy, 1366 - state: i32, 1367 - ) -> kernel::ffi::c_int { 1374 + state: c_int, 1375 + ) -> c_int { 1368 1376 from_result(|| { 1369 1377 // SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the 1370 1378 // lifetime of `policy`.
+2 -11
rust/kernel/cpumask.rs
··· 14 14 #[cfg(CONFIG_CPUMASK_OFFSTACK)] 15 15 use core::ptr::{self, NonNull}; 16 16 17 - #[cfg(not(CONFIG_CPUMASK_OFFSTACK))] 18 - use core::mem::MaybeUninit; 19 - 20 17 use core::ops::{Deref, DerefMut}; 21 18 22 19 /// A CPU Mask. ··· 236 239 }, 237 240 238 241 #[cfg(not(CONFIG_CPUMASK_OFFSTACK))] 239 - // SAFETY: FFI type is valid to be zero-initialized. 240 - // 241 - // INVARIANT: The associated memory is freed when the `CpumaskVar` goes out of scope. 242 - mask: unsafe { core::mem::zeroed() }, 242 + mask: Cpumask(Opaque::zeroed()), 243 243 }) 244 244 } 245 245 ··· 260 266 NonNull::new(ptr.cast()).ok_or(AllocError)? 261 267 }, 262 268 #[cfg(not(CONFIG_CPUMASK_OFFSTACK))] 263 - // SAFETY: Guaranteed by the safety requirements of the function. 264 - // 265 - // INVARIANT: The associated memory is freed when the `CpumaskVar` goes out of scope. 266 - mask: unsafe { MaybeUninit::uninit().assume_init() }, 269 + mask: Cpumask(Opaque::uninit()), 267 270 }) 268 271 } 269 272