Skip to content

Commit ccf46d8

Browse files
committed
Merge tag 'pm-6.5-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull more power management updates from Rafael Wysocki: "These add support for new hardware (ap807 and AM62A7), fix several issues in cpufreq drivers and in the operating performance points (OPP) framework, fix up intel_idle after recent changes and add documentation. Specifics: - Add missing __init annotation to one function in the intel_idle drvier (Rafael Wysocki) - Make intel_pstate use a correct scaling factor when mapping HWP performance levels to frequency values on hybrid-capable systems with disabled E-cores (Srinivas Pandruvada) - Fix Kconfig dependencies of the cpufreq-dt-platform driver (Viresh Kumar) - Add support to build cpufreq-dt-platdev as a module (Zhipeng Wang) - Don't allocate Sparc's cpufreq_driver dynamically (Viresh Kumar) - Add support for TI's AM62A7 platform (Vibhore Vardhan) - Add support for Armada's ap807 platform (Russell King (Oracle)) - Add support for StarFive JH7110 SoC (Mason Huo) - Fix voltage selection for Mediatek Socs (Daniel Golle) - Fix error handling in Tegra's cpufreq driver (Christophe JAILLET) - Document Qualcomm's IPQ8074 in DT bindings (Robert Marko) - Don't warn for disabling a non-existing frequency for imx6q cpufreq driver (Christoph Niedermaier) - Use dev_err_probe() in Qualcomm's cpufreq driver (Andrew Halaney) - Simplify performance state related logic in the OPP core (Viresh Kumar) - Fix use-after-free and improve locking around lazy_opp_tables (Viresh Kumar, Stephan Gerhold) - Minor cleanups - using dev_err_probe() and rate-limiting debug messages (Andrew Halaney, Adrián Larumbe)" * tag 'pm-6.5-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (23 commits) cpufreq: intel_pstate: Fix scaling for hybrid-capable systems with disabled E-cores cpufreq: Make CONFIG_CPUFREQ_DT_PLATDEV depend on OF intel_idle: Add __init annotation to matchup_vm_state_with_baremetal() OPP: Properly propagate error along when failing to get icc_path OPP: Use dev_err_probe() when failing to get icc_path cpufreq: qcom-cpufreq-hw: Use dev_err_probe() when failing to get icc paths cpufreq: mediatek: correct voltages for MT7622 and MT7623 cpufreq: armada-8k: add ap807 support OPP: Simplify the over-designed pstate <-> level dance OPP: pstate is only valid for genpd OPP tables OPP: don't drop performance constraint on OPP table removal OPP: Protect `lazy_opp_tables` list with `opp_table_lock` OPP: Staticize `lazy_opp_tables` in of.c cpufreq: dt-platdev: Support building as module opp: Fix use-after-free in lazy_opp_tables after probe deferral dt-bindings: cpufreq: qcom-cpufreq-nvmem: document IPQ8074 cpufreq: dt-platdev: Blacklist ti,am62a7 SoC cpufreq: ti-cpufreq: Add support for AM62A7 OPP: rate-limit debug messages when no change in OPP is required cpufreq: imx6q: don't warn for disabling a non-existing frequency ...
2 parents b869e9f + 40c565a commit ccf46d8

17 files changed

+180
-164
lines changed

Documentation/devicetree/bindings/cpufreq/qcom-cpufreq-nvmem.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ select:
2828
- qcom,apq8064
2929
- qcom,apq8096
3030
- qcom,ipq8064
31+
- qcom,ipq8074
3132
- qcom,msm8939
3233
- qcom,msm8960
3334
- qcom,msm8974

drivers/cpufreq/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ config CPUFREQ_DT
218218
If in doubt, say N.
219219

220220
config CPUFREQ_DT_PLATDEV
221-
bool
221+
tristate "Generic DT based cpufreq platdev driver"
222+
depends on OF
222223
help
223224
This adds a generic DT based cpufreq platdev driver for frequency
224225
management. This creates a 'cpufreq-dt' platform device, on the

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@
2121
#include <linux/pm_opp.h>
2222
#include <linux/slab.h>
2323

24+
static const struct of_device_id __maybe_unused armada_8k_cpufreq_of_match[] = {
25+
{ .compatible = "marvell,ap806-cpu-clock" },
26+
{ .compatible = "marvell,ap807-cpu-clock" },
27+
{ },
28+
};
29+
MODULE_DEVICE_TABLE(of, armada_8k_cpufreq_of_match);
30+
2431
/*
2532
* Setup the opps list with the divider for the max frequency, that
2633
* will be filled at runtime.
@@ -127,7 +134,8 @@ static int __init armada_8k_cpufreq_init(void)
127134
struct device_node *node;
128135
struct cpumask cpus;
129136

130-
node = of_find_compatible_node(NULL, NULL, "marvell,ap806-cpu-clock");
137+
node = of_find_matching_node_and_match(NULL, armada_8k_cpufreq_of_match,
138+
NULL);
131139
if (!node || !of_device_is_available(node)) {
132140
of_node_put(node);
133141
return -ENODEV;
@@ -204,12 +212,6 @@ static void __exit armada_8k_cpufreq_exit(void)
204212
}
205213
module_exit(armada_8k_cpufreq_exit);
206214

207-
static const struct of_device_id __maybe_unused armada_8k_cpufreq_of_match[] = {
208-
{ .compatible = "marvell,ap806-cpu-clock" },
209-
{ },
210-
};
211-
MODULE_DEVICE_TABLE(of, armada_8k_cpufreq_of_match);
212-
213215
MODULE_AUTHOR("Gregory Clement <gregory.clement@bootlin.com>");
214216
MODULE_DESCRIPTION("Armada 8K cpufreq driver");
215217
MODULE_LICENSE("GPL");

drivers/cpufreq/cpufreq-dt-platdev.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
#include <linux/err.h>
8+
#include <linux/module.h>
89
#include <linux/of.h>
910
#include <linux/platform_device.h>
1011

@@ -85,6 +86,8 @@ static const struct of_device_id allowlist[] __initconst = {
8586
{ .compatible = "st-ericsson,u9500", },
8687
{ .compatible = "st-ericsson,u9540", },
8788

89+
{ .compatible = "starfive,jh7110", },
90+
8891
{ .compatible = "ti,omap2", },
8992
{ .compatible = "ti,omap4", },
9093
{ .compatible = "ti,omap5", },
@@ -165,6 +168,7 @@ static const struct of_device_id blocklist[] __initconst = {
165168
{ .compatible = "ti,dra7", },
166169
{ .compatible = "ti,omap3", },
167170
{ .compatible = "ti,am625", },
171+
{ .compatible = "ti,am62a7", },
168172

169173
{ .compatible = "qcom,ipq8064", },
170174
{ .compatible = "qcom,apq8064", },
@@ -214,3 +218,4 @@ static int __init cpufreq_dt_platdev_init(void)
214218
sizeof(struct cpufreq_dt_platform_data)));
215219
}
216220
core_initcall(cpufreq_dt_platdev_init);
221+
MODULE_LICENSE("GPL");

drivers/cpufreq/imx6q-cpufreq.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,14 @@ static struct cpufreq_driver imx6q_cpufreq_driver = {
209209
.suspend = cpufreq_generic_suspend,
210210
};
211211

212+
static void imx6x_disable_freq_in_opp(struct device *dev, unsigned long freq)
213+
{
214+
int ret = dev_pm_opp_disable(dev, freq);
215+
216+
if (ret < 0 && ret != -ENODEV)
217+
dev_warn(dev, "failed to disable %ldMHz OPP\n", freq / 1000000);
218+
}
219+
212220
#define OCOTP_CFG3 0x440
213221
#define OCOTP_CFG3_SPEED_SHIFT 16
214222
#define OCOTP_CFG3_SPEED_1P2GHZ 0x3
@@ -254,17 +262,15 @@ static int imx6q_opp_check_speed_grading(struct device *dev)
254262
val &= 0x3;
255263

256264
if (val < OCOTP_CFG3_SPEED_996MHZ)
257-
if (dev_pm_opp_disable(dev, 996000000))
258-
dev_warn(dev, "failed to disable 996MHz OPP\n");
265+
imx6x_disable_freq_in_opp(dev, 996000000);
259266

260267
if (of_machine_is_compatible("fsl,imx6q") ||
261268
of_machine_is_compatible("fsl,imx6qp")) {
262269
if (val != OCOTP_CFG3_SPEED_852MHZ)
263-
if (dev_pm_opp_disable(dev, 852000000))
264-
dev_warn(dev, "failed to disable 852MHz OPP\n");
270+
imx6x_disable_freq_in_opp(dev, 852000000);
271+
265272
if (val != OCOTP_CFG3_SPEED_1P2GHZ)
266-
if (dev_pm_opp_disable(dev, 1200000000))
267-
dev_warn(dev, "failed to disable 1.2GHz OPP\n");
273+
imx6x_disable_freq_in_opp(dev, 1200000000);
268274
}
269275

270276
return 0;
@@ -316,20 +322,16 @@ static int imx6ul_opp_check_speed_grading(struct device *dev)
316322
val >>= OCOTP_CFG3_SPEED_SHIFT;
317323
val &= 0x3;
318324

319-
if (of_machine_is_compatible("fsl,imx6ul")) {
325+
if (of_machine_is_compatible("fsl,imx6ul"))
320326
if (val != OCOTP_CFG3_6UL_SPEED_696MHZ)
321-
if (dev_pm_opp_disable(dev, 696000000))
322-
dev_warn(dev, "failed to disable 696MHz OPP\n");
323-
}
327+
imx6x_disable_freq_in_opp(dev, 696000000);
324328

325329
if (of_machine_is_compatible("fsl,imx6ull")) {
326330
if (val != OCOTP_CFG3_6ULL_SPEED_792MHZ)
327-
if (dev_pm_opp_disable(dev, 792000000))
328-
dev_warn(dev, "failed to disable 792MHz OPP\n");
331+
imx6x_disable_freq_in_opp(dev, 792000000);
329332

330333
if (val != OCOTP_CFG3_6ULL_SPEED_900MHZ)
331-
if (dev_pm_opp_disable(dev, 900000000))
332-
dev_warn(dev, "failed to disable 900MHz OPP\n");
334+
imx6x_disable_freq_in_opp(dev, 900000000);
333335
}
334336

335337
return ret;

drivers/cpufreq/intel_pstate.c

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,13 @@ static bool hwp_forced __read_mostly;
302302

303303
static struct cpufreq_driver *intel_pstate_driver __read_mostly;
304304

305+
#define HYBRID_SCALING_FACTOR 78741
306+
307+
static inline int core_get_scaling(void)
308+
{
309+
return 100000;
310+
}
311+
305312
#ifdef CONFIG_ACPI
306313
static bool acpi_ppc;
307314
#endif
@@ -400,6 +407,26 @@ static int intel_pstate_get_cppc_guaranteed(int cpu)
400407

401408
return cppc_perf.nominal_perf;
402409
}
410+
411+
static int intel_pstate_cppc_get_scaling(int cpu)
412+
{
413+
struct cppc_perf_caps cppc_perf;
414+
int ret;
415+
416+
ret = cppc_get_perf_caps(cpu, &cppc_perf);
417+
418+
/*
419+
* If the nominal frequency and the nominal performance are not
420+
* zero and the ratio between them is not 100, return the hybrid
421+
* scaling factor.
422+
*/
423+
if (!ret && cppc_perf.nominal_perf && cppc_perf.nominal_freq &&
424+
cppc_perf.nominal_perf * 100 != cppc_perf.nominal_freq)
425+
return HYBRID_SCALING_FACTOR;
426+
427+
return core_get_scaling();
428+
}
429+
403430
#else /* CONFIG_ACPI_CPPC_LIB */
404431
static inline void intel_pstate_set_itmt_prio(int cpu)
405432
{
@@ -492,6 +519,11 @@ static inline int intel_pstate_get_cppc_guaranteed(int cpu)
492519
{
493520
return -ENOTSUPP;
494521
}
522+
523+
static int intel_pstate_cppc_get_scaling(int cpu)
524+
{
525+
return core_get_scaling();
526+
}
495527
#endif /* CONFIG_ACPI_CPPC_LIB */
496528

497529
/**
@@ -1897,11 +1929,6 @@ static int core_get_turbo_pstate(int cpu)
18971929
return ret;
18981930
}
18991931

1900-
static inline int core_get_scaling(void)
1901-
{
1902-
return 100000;
1903-
}
1904-
19051932
static u64 core_get_val(struct cpudata *cpudata, int pstate)
19061933
{
19071934
u64 val;
@@ -1938,16 +1965,28 @@ static void hybrid_get_type(void *data)
19381965
*cpu_type = get_this_hybrid_cpu_type();
19391966
}
19401967

1941-
static int hybrid_get_cpu_scaling(int cpu)
1968+
static int hwp_get_cpu_scaling(int cpu)
19421969
{
19431970
u8 cpu_type = 0;
19441971

19451972
smp_call_function_single(cpu, hybrid_get_type, &cpu_type, 1);
19461973
/* P-cores have a smaller perf level-to-freqency scaling factor. */
19471974
if (cpu_type == 0x40)
1948-
return 78741;
1975+
return HYBRID_SCALING_FACTOR;
19491976

1950-
return core_get_scaling();
1977+
/* Use default core scaling for E-cores */
1978+
if (cpu_type == 0x20)
1979+
return core_get_scaling();
1980+
1981+
/*
1982+
* If reached here, this system is either non-hybrid (like Tiger
1983+
* Lake) or hybrid-capable (like Alder Lake or Raptor Lake) with
1984+
* no E cores (in which case CPUID for hybrid support is 0).
1985+
*
1986+
* The CPPC nominal_frequency field is 0 for non-hybrid systems,
1987+
* so the default core scaling will be used for them.
1988+
*/
1989+
return intel_pstate_cppc_get_scaling(cpu);
19511990
}
19521991

19531992
static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate)
@@ -3395,8 +3434,7 @@ static int __init intel_pstate_init(void)
33953434
if (!default_driver)
33963435
default_driver = &intel_pstate;
33973436

3398-
if (boot_cpu_has(X86_FEATURE_HYBRID_CPU))
3399-
pstate_funcs.get_cpu_scaling = hybrid_get_cpu_scaling;
3437+
pstate_funcs.get_cpu_scaling = hwp_get_cpu_scaling;
34003438

34013439
goto hwp_cpu_matched;
34023440
}

drivers/cpufreq/mediatek-cpufreq.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -696,9 +696,16 @@ static const struct mtk_cpufreq_platform_data mt2701_platform_data = {
696696
static const struct mtk_cpufreq_platform_data mt7622_platform_data = {
697697
.min_volt_shift = 100000,
698698
.max_volt_shift = 200000,
699-
.proc_max_volt = 1360000,
699+
.proc_max_volt = 1350000,
700700
.sram_min_volt = 0,
701-
.sram_max_volt = 1360000,
701+
.sram_max_volt = 1350000,
702+
.ccifreq_supported = false,
703+
};
704+
705+
static const struct mtk_cpufreq_platform_data mt7623_platform_data = {
706+
.min_volt_shift = 100000,
707+
.max_volt_shift = 200000,
708+
.proc_max_volt = 1300000,
702709
.ccifreq_supported = false,
703710
};
704711

@@ -734,7 +741,7 @@ static const struct of_device_id mtk_cpufreq_machines[] __initconst = {
734741
{ .compatible = "mediatek,mt2701", .data = &mt2701_platform_data },
735742
{ .compatible = "mediatek,mt2712", .data = &mt2701_platform_data },
736743
{ .compatible = "mediatek,mt7622", .data = &mt7622_platform_data },
737-
{ .compatible = "mediatek,mt7623", .data = &mt7622_platform_data },
744+
{ .compatible = "mediatek,mt7623", .data = &mt7623_platform_data },
738745
{ .compatible = "mediatek,mt8167", .data = &mt8516_platform_data },
739746
{ .compatible = "mediatek,mt817x", .data = &mt2701_platform_data },
740747
{ .compatible = "mediatek,mt8173", .data = &mt2701_platform_data },

drivers/cpufreq/qcom-cpufreq-hw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev)
661661

662662
ret = dev_pm_opp_of_find_icc_paths(cpu_dev, NULL);
663663
if (ret)
664-
return ret;
664+
return dev_err_probe(dev, ret, "Failed to find icc paths\n");
665665

666666
for (num_domains = 0; num_domains < MAX_FREQ_DOMAINS; num_domains++)
667667
if (!platform_get_resource(pdev, IORESOURCE_MEM, num_domains))

drivers/cpufreq/sparc-us2e-cpufreq.c

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
#include <asm/asi.h>
2121
#include <asm/timer.h>
2222

23-
static struct cpufreq_driver *cpufreq_us2e_driver;
24-
2523
struct us2e_freq_percpu_info {
2624
struct cpufreq_frequency_table table[6];
2725
};
@@ -300,12 +298,19 @@ static int __init us2e_freq_cpu_init(struct cpufreq_policy *policy)
300298

301299
static int us2e_freq_cpu_exit(struct cpufreq_policy *policy)
302300
{
303-
if (cpufreq_us2e_driver)
304-
us2e_freq_target(policy, 0);
305-
301+
us2e_freq_target(policy, 0);
306302
return 0;
307303
}
308304

305+
static struct cpufreq_driver cpufreq_us2e_driver = {
306+
.name = "UltraSPARC-IIe",
307+
.init = us2e_freq_cpu_init,
308+
.verify = cpufreq_generic_frequency_table_verify,
309+
.target_index = us2e_freq_target,
310+
.get = us2e_freq_get,
311+
.exit = us2e_freq_cpu_exit,
312+
};
313+
309314
static int __init us2e_freq_init(void)
310315
{
311316
unsigned long manuf, impl, ver;
@@ -319,39 +324,15 @@ static int __init us2e_freq_init(void)
319324
impl = ((ver >> 32) & 0xffff);
320325

321326
if (manuf == 0x17 && impl == 0x13) {
322-
struct cpufreq_driver *driver;
323-
324-
ret = -ENOMEM;
325-
driver = kzalloc(sizeof(*driver), GFP_KERNEL);
326-
if (!driver)
327-
goto err_out;
328-
329-
us2e_freq_table = kzalloc((NR_CPUS * sizeof(*us2e_freq_table)),
330-
GFP_KERNEL);
327+
us2e_freq_table = kzalloc(NR_CPUS * sizeof(*us2e_freq_table),
328+
GFP_KERNEL);
331329
if (!us2e_freq_table)
332-
goto err_out;
333-
334-
driver->init = us2e_freq_cpu_init;
335-
driver->verify = cpufreq_generic_frequency_table_verify;
336-
driver->target_index = us2e_freq_target;
337-
driver->get = us2e_freq_get;
338-
driver->exit = us2e_freq_cpu_exit;
339-
strcpy(driver->name, "UltraSPARC-IIe");
330+
return -ENOMEM;
340331

341-
cpufreq_us2e_driver = driver;
342-
ret = cpufreq_register_driver(driver);
332+
ret = cpufreq_register_driver(&cpufreq_us2e_driver);
343333
if (ret)
344-
goto err_out;
334+
kfree(us2e_freq_table);
345335

346-
return 0;
347-
348-
err_out:
349-
if (driver) {
350-
kfree(driver);
351-
cpufreq_us2e_driver = NULL;
352-
}
353-
kfree(us2e_freq_table);
354-
us2e_freq_table = NULL;
355336
return ret;
356337
}
357338

@@ -360,13 +341,8 @@ static int __init us2e_freq_init(void)
360341

361342
static void __exit us2e_freq_exit(void)
362343
{
363-
if (cpufreq_us2e_driver) {
364-
cpufreq_unregister_driver(cpufreq_us2e_driver);
365-
kfree(cpufreq_us2e_driver);
366-
cpufreq_us2e_driver = NULL;
367-
kfree(us2e_freq_table);
368-
us2e_freq_table = NULL;
369-
}
344+
cpufreq_unregister_driver(&cpufreq_us2e_driver);
345+
kfree(us2e_freq_table);
370346
}
371347

372348
MODULE_AUTHOR("David S. Miller <davem@redhat.com>");

0 commit comments

Comments
 (0)