Skip to content

Commit c79e6fa

Browse files
committed
Merge tag 'pm-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull power management updates from Rafael Wysocki: "These add support for some new hardware, extend the existing hardware support, fix some issues and clean up code Specifics: - Add isupport for Tiger Lake in no-HWP mode to intel_pstate (Doug Smythies) - Update the AMD P-state driver (Perry Yuan): - Fix wrong lowest perf fetch - Map desired perf into pstate scope for powersave governor - Update pstate frequency transition delay time - Fix initial highest_perf value - Clean up - Move max CPU capacity to sugov_policy in the schedutil cpufreq governor (Lukasz Luba) - Add SM6115 to cpufreq-dt blocklist (Adam Skladowski) - Add support for Tegra239 and minor cleanups (Sumit Gupta, ye xingchen, and Yang Yingliang) - Add freq qos for qcom cpufreq driver and minor cleanups (Xuewen Yan, and Viresh Kumar) - Minor cleanups around functions called at module_init() (Xiu Jianfeng) - Use module_init and add module_exit for bmips driver (Zhang Jianhua) - Add AlderLake-N support to intel_idle (Zhang Rui) - Replace strlcpy() with unused retval with strscpy() in intel_idle (Wolfram Sang) - Remove redundant check from cpuidle_switch_governor() (Yu Liao) - Replace strlcpy() with unused retval with strscpy() in the powernv cpuidle driver (Wolfram Sang) - Drop duplicate word from a comment in the coupled cpuidle driver (Jason Wang) - Make rpm_resume() return -EINPROGRESS if RPM_NOWAIT is passed to it in the flags and the device is about to resume (Rafael Wysocki) - Add extra debugging statement for multiple active IRQs to system wakeup handling code (Mario Limonciello) - Replace strlcpy() with unused retval with strscpy() in the core system suspend support code (Wolfram Sang) - Update the intel_rapl power capping driver: - Use standard Energy Unit for SPR Dram RAPL domain (Zhang Rui). - Add support for RAPTORLAKE_S (Zhang Rui). - Fix UBSAN shift-out-of-bounds issue (Chao Qin) - Handle -EPROBE_DEFER when regulator is not probed on mtk-ci-devfreq.c (AngeloGioacchino Del Regno) - Fix message typo and use dev_err_probe() in rockchip-dfi.c (Christophe JAILLET)" * tag 'pm-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (29 commits) cpufreq: qcom-cpufreq-hw: Add cpufreq qos for LMh cpufreq: Add __init annotation to module init funcs cpufreq: tegra194: change tegra239_cpufreq_soc to static PM / devfreq: rockchip-dfi: Fix an error message PM / devfreq: mtk-cci: Handle sram regulator probe deferral powercap: intel_rapl: Use standard Energy Unit for SPR Dram RAPL domain PM: runtime: Return -EINPROGRESS from rpm_resume() in the RPM_NOWAIT case intel_idle: Add AlderLake-N support powercap: intel_rapl: fix UBSAN shift-out-of-bounds issue cpufreq: tegra194: Add support for Tegra239 cpufreq: qcom-cpufreq-hw: Fix uninitialized throttled_freq warning cpufreq: intel_pstate: Add Tigerlake support in no-HWP mode powercap: intel_rapl: Add support for RAPTORLAKE_S cpufreq: amd-pstate: Fix initial highest_perf value cpuidle: Remove redundant check in cpuidle_switch_governor() PM: wakeup: Add extra debugging statement for multiple active IRQs cpufreq: tegra194: Remove the unneeded result variable PM: suspend: move from strlcpy() with unused retval to strscpy() intel_idle: move from strlcpy() with unused retval to strscpy() cpuidle: powernv: move from strlcpy() with unused retval to strscpy() ...
2 parents 9388076 + ac73ce3 commit c79e6fa

20 files changed

+165
-82
lines changed

drivers/base/power/runtime.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,10 +792,13 @@ static int rpm_resume(struct device *dev, int rpmflags)
792792
DEFINE_WAIT(wait);
793793

794794
if (rpmflags & (RPM_ASYNC | RPM_NOWAIT)) {
795-
if (dev->power.runtime_status == RPM_SUSPENDING)
795+
if (dev->power.runtime_status == RPM_SUSPENDING) {
796796
dev->power.deferred_resume = true;
797-
else
797+
if (rpmflags & RPM_NOWAIT)
798+
retval = -EINPROGRESS;
799+
} else {
798800
retval = -EINPROGRESS;
801+
}
799802
goto out;
800803
}
801804

drivers/base/power/wakeup.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,8 @@ void pm_system_irq_wakeup(unsigned int irq_number)
944944
else
945945
irq_number = 0;
946946

947+
pm_pr_dbg("Triggering wakeup from IRQ %d\n", irq_number);
948+
947949
raw_spin_unlock_irqrestore(&wakeup_irq_lock, flags);
948950

949951
if (irq_number)

drivers/cpufreq/amd-pstate.c

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
#include <asm/cpu_device_id.h>
4747
#include "amd-pstate-trace.h"
4848

49-
#define AMD_PSTATE_TRANSITION_LATENCY 0x20000
50-
#define AMD_PSTATE_TRANSITION_DELAY 500
49+
#define AMD_PSTATE_TRANSITION_LATENCY 20000
50+
#define AMD_PSTATE_TRANSITION_DELAY 1000
5151

5252
/*
5353
* TODO: We need more time to fine tune processors with shared memory solution
@@ -120,7 +120,7 @@ struct amd_cpudata {
120120
struct amd_aperf_mperf cur;
121121
struct amd_aperf_mperf prev;
122122

123-
u64 freq;
123+
u64 freq;
124124
bool boost_supported;
125125
};
126126

@@ -152,6 +152,7 @@ static inline int amd_pstate_enable(bool enable)
152152
static int pstate_init_perf(struct amd_cpudata *cpudata)
153153
{
154154
u64 cap1;
155+
u32 highest_perf;
155156

156157
int ret = rdmsrl_safe_on_cpu(cpudata->cpu, MSR_AMD_CPPC_CAP1,
157158
&cap1);
@@ -163,7 +164,11 @@ static int pstate_init_perf(struct amd_cpudata *cpudata)
163164
*
164165
* CPPC entry doesn't indicate the highest performance in some ASICs.
165166
*/
166-
WRITE_ONCE(cpudata->highest_perf, amd_get_highest_perf());
167+
highest_perf = amd_get_highest_perf();
168+
if (highest_perf > AMD_CPPC_HIGHEST_PERF(cap1))
169+
highest_perf = AMD_CPPC_HIGHEST_PERF(cap1);
170+
171+
WRITE_ONCE(cpudata->highest_perf, highest_perf);
167172

168173
WRITE_ONCE(cpudata->nominal_perf, AMD_CPPC_NOMINAL_PERF(cap1));
169174
WRITE_ONCE(cpudata->lowest_nonlinear_perf, AMD_CPPC_LOWNONLIN_PERF(cap1));
@@ -175,12 +180,17 @@ static int pstate_init_perf(struct amd_cpudata *cpudata)
175180
static int cppc_init_perf(struct amd_cpudata *cpudata)
176181
{
177182
struct cppc_perf_caps cppc_perf;
183+
u32 highest_perf;
178184

179185
int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf);
180186
if (ret)
181187
return ret;
182188

183-
WRITE_ONCE(cpudata->highest_perf, amd_get_highest_perf());
189+
highest_perf = amd_get_highest_perf();
190+
if (highest_perf > cppc_perf.highest_perf)
191+
highest_perf = cppc_perf.highest_perf;
192+
193+
WRITE_ONCE(cpudata->highest_perf, highest_perf);
184194

185195
WRITE_ONCE(cpudata->nominal_perf, cppc_perf.nominal_perf);
186196
WRITE_ONCE(cpudata->lowest_nonlinear_perf,
@@ -269,6 +279,7 @@ static void amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf,
269279
u64 prev = READ_ONCE(cpudata->cppc_req_cached);
270280
u64 value = prev;
271281

282+
des_perf = clamp_t(unsigned long, des_perf, min_perf, max_perf);
272283
value &= ~AMD_CPPC_MIN_PERF(~0L);
273284
value |= AMD_CPPC_MIN_PERF(min_perf);
274285

@@ -312,7 +323,7 @@ static int amd_pstate_target(struct cpufreq_policy *policy,
312323
return -ENODEV;
313324

314325
cap_perf = READ_ONCE(cpudata->highest_perf);
315-
min_perf = READ_ONCE(cpudata->lowest_nonlinear_perf);
326+
min_perf = READ_ONCE(cpudata->lowest_perf);
316327
max_perf = cap_perf;
317328

318329
freqs.old = policy->cur;
@@ -357,8 +368,6 @@ static void amd_pstate_adjust_perf(unsigned int cpu,
357368
if (max_perf < min_perf)
358369
max_perf = min_perf;
359370

360-
des_perf = clamp_t(unsigned long, des_perf, min_perf, max_perf);
361-
362371
amd_pstate_update(cpudata, min_perf, des_perf, max_perf, true);
363372
}
364373

@@ -555,9 +564,7 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy)
555564

556565
static int amd_pstate_cpu_exit(struct cpufreq_policy *policy)
557566
{
558-
struct amd_cpudata *cpudata;
559-
560-
cpudata = policy->driver_data;
567+
struct amd_cpudata *cpudata = policy->driver_data;
561568

562569
freq_qos_remove_request(&cpudata->req[1]);
563570
freq_qos_remove_request(&cpudata->req[0]);
@@ -599,9 +606,7 @@ static ssize_t show_amd_pstate_max_freq(struct cpufreq_policy *policy,
599606
char *buf)
600607
{
601608
int max_freq;
602-
struct amd_cpudata *cpudata;
603-
604-
cpudata = policy->driver_data;
609+
struct amd_cpudata *cpudata = policy->driver_data;
605610

606611
max_freq = amd_get_max_freq(cpudata);
607612
if (max_freq < 0)
@@ -614,9 +619,7 @@ static ssize_t show_amd_pstate_lowest_nonlinear_freq(struct cpufreq_policy *poli
614619
char *buf)
615620
{
616621
int freq;
617-
struct amd_cpudata *cpudata;
618-
619-
cpudata = policy->driver_data;
622+
struct amd_cpudata *cpudata = policy->driver_data;
620623

621624
freq = amd_get_lowest_nonlinear_freq(cpudata);
622625
if (freq < 0)
@@ -662,7 +665,7 @@ static struct cpufreq_driver amd_pstate_driver = {
662665
.resume = amd_pstate_cpu_resume,
663666
.set_boost = amd_pstate_set_boost,
664667
.name = "amd-pstate",
665-
.attr = amd_pstate_attr,
668+
.attr = amd_pstate_attr,
666669
};
667670

668671
static int __init amd_pstate_init(void)

drivers/cpufreq/bmips-cpufreq.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ static struct cpufreq_driver bmips_cpufreq_driver = {
156156
.name = BMIPS_CPUFREQ_PREFIX,
157157
};
158158

159-
static int __init bmips_cpufreq_probe(void)
159+
static int __init bmips_cpufreq_driver_init(void)
160160
{
161161
struct cpufreq_compat *cc;
162162
struct device_node *np;
@@ -176,7 +176,13 @@ static int __init bmips_cpufreq_probe(void)
176176

177177
return cpufreq_register_driver(&bmips_cpufreq_driver);
178178
}
179-
device_initcall(bmips_cpufreq_probe);
179+
module_init(bmips_cpufreq_driver_init);
180+
181+
static void __exit bmips_cpufreq_driver_exit(void)
182+
{
183+
cpufreq_unregister_driver(&bmips_cpufreq_driver);
184+
}
185+
module_exit(bmips_cpufreq_driver_exit);
180186

181187
MODULE_AUTHOR("Markus Mayer <[email protected]>");
182188
MODULE_DESCRIPTION("CPUfreq driver for Broadcom BMIPS SoCs");

drivers/cpufreq/cpufreq-dt-platdev.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ static const struct of_device_id blocklist[] __initconst = {
146146
{ .compatible = "qcom,sc8180x", },
147147
{ .compatible = "qcom,sc8280xp", },
148148
{ .compatible = "qcom,sdm845", },
149+
{ .compatible = "qcom,sm6115", },
149150
{ .compatible = "qcom,sm6350", },
150151
{ .compatible = "qcom,sm8150", },
151152
{ .compatible = "qcom,sm8250", },

drivers/cpufreq/highbank-cpufreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static struct notifier_block hb_cpufreq_clk_nb = {
5555
.notifier_call = hb_cpufreq_clk_notify,
5656
};
5757

58-
static int hb_cpufreq_driver_init(void)
58+
static int __init hb_cpufreq_driver_init(void)
5959
{
6060
struct platform_device_info devinfo = { .name = "cpufreq-dt", };
6161
struct device *cpu_dev;

drivers/cpufreq/intel_pstate.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,6 +2416,7 @@ static const struct x86_cpu_id intel_pstate_cpu_ids[] = {
24162416
X86_MATCH(SKYLAKE_X, core_funcs),
24172417
X86_MATCH(COMETLAKE, core_funcs),
24182418
X86_MATCH(ICELAKE_X, core_funcs),
2419+
X86_MATCH(TIGERLAKE, core_funcs),
24192420
{}
24202421
};
24212422
MODULE_DEVICE_TABLE(x86cpu, intel_pstate_cpu_ids);

drivers/cpufreq/qcom-cpufreq-hw.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/of_address.h>
1414
#include <linux/of_platform.h>
1515
#include <linux/pm_opp.h>
16+
#include <linux/pm_qos.h>
1617
#include <linux/slab.h>
1718
#include <linux/spinlock.h>
1819
#include <linux/units.h>
@@ -56,6 +57,8 @@ struct qcom_cpufreq_data {
5657
struct cpufreq_policy *policy;
5758

5859
bool per_core_dcvs;
60+
61+
struct freq_qos_request throttle_freq_req;
5962
};
6063

6164
static unsigned long cpu_hw_rate, xo_rate;
@@ -316,14 +319,16 @@ static void qcom_lmh_dcvs_notify(struct qcom_cpufreq_data *data)
316319
if (IS_ERR(opp)) {
317320
dev_warn(dev, "Can't find the OPP for throttling: %pe!\n", opp);
318321
} else {
319-
throttled_freq = freq_hz / HZ_PER_KHZ;
320-
321-
/* Update thermal pressure (the boost frequencies are accepted) */
322-
arch_update_thermal_pressure(policy->related_cpus, throttled_freq);
323-
324322
dev_pm_opp_put(opp);
325323
}
326324

325+
throttled_freq = freq_hz / HZ_PER_KHZ;
326+
327+
freq_qos_update_request(&data->throttle_freq_req, throttled_freq);
328+
329+
/* Update thermal pressure (the boost frequencies are accepted) */
330+
arch_update_thermal_pressure(policy->related_cpus, throttled_freq);
331+
327332
/*
328333
* In the unlikely case policy is unregistered do not enable
329334
* polling or h/w interrupt
@@ -413,6 +418,14 @@ static int qcom_cpufreq_hw_lmh_init(struct cpufreq_policy *policy, int index)
413418
if (data->throttle_irq < 0)
414419
return data->throttle_irq;
415420

421+
ret = freq_qos_add_request(&policy->constraints,
422+
&data->throttle_freq_req, FREQ_QOS_MAX,
423+
FREQ_QOS_MAX_DEFAULT_VALUE);
424+
if (ret < 0) {
425+
dev_err(&pdev->dev, "Failed to add freq constraint (%d)\n", ret);
426+
return ret;
427+
}
428+
416429
data->cancel_throttle = false;
417430
data->policy = policy;
418431

@@ -479,6 +492,7 @@ static void qcom_cpufreq_hw_lmh_exit(struct qcom_cpufreq_data *data)
479492
if (data->throttle_irq <= 0)
480493
return;
481494

495+
freq_qos_remove_request(&data->throttle_freq_req);
482496
free_irq(data->throttle_irq, data);
483497
}
484498

drivers/cpufreq/sti-cpufreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ static int sti_cpufreq_fetch_syscon_registers(void)
252252
return 0;
253253
}
254254

255-
static int sti_cpufreq_init(void)
255+
static int __init sti_cpufreq_init(void)
256256
{
257257
int ret;
258258

drivers/cpufreq/tegra194-cpufreq.c

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@
3838
/* cpufreq transisition latency */
3939
#define TEGRA_CPUFREQ_TRANSITION_LATENCY (300 * 1000) /* unit in nanoseconds */
4040

41-
enum cluster {
42-
CLUSTER0,
43-
CLUSTER1,
44-
CLUSTER2,
45-
CLUSTER3,
46-
MAX_CLUSTERS,
47-
};
48-
4941
struct tegra_cpu_ctr {
5042
u32 cpu;
5143
u32 coreclk_cnt, last_coreclk_cnt;
@@ -67,12 +59,12 @@ struct tegra_cpufreq_ops {
6759
struct tegra_cpufreq_soc {
6860
struct tegra_cpufreq_ops *ops;
6961
int maxcpus_per_cluster;
62+
unsigned int num_clusters;
7063
phys_addr_t actmon_cntr_base;
7164
};
7265

7366
struct tegra194_cpufreq_data {
7467
void __iomem *regs;
75-
size_t num_clusters;
7668
struct cpufreq_frequency_table **tables;
7769
const struct tegra_cpufreq_soc *soc;
7870
};
@@ -166,6 +158,14 @@ static const struct tegra_cpufreq_soc tegra234_cpufreq_soc = {
166158
.ops = &tegra234_cpufreq_ops,
167159
.actmon_cntr_base = 0x9000,
168160
.maxcpus_per_cluster = 4,
161+
.num_clusters = 3,
162+
};
163+
164+
static const struct tegra_cpufreq_soc tegra239_cpufreq_soc = {
165+
.ops = &tegra234_cpufreq_ops,
166+
.actmon_cntr_base = 0x4000,
167+
.maxcpus_per_cluster = 8,
168+
.num_clusters = 1,
169169
};
170170

171171
static void tegra194_get_cpu_cluster_id(u32 cpu, u32 *cpuid, u32 *clusterid)
@@ -314,11 +314,7 @@ static void tegra194_get_cpu_ndiv_sysreg(void *ndiv)
314314

315315
static int tegra194_get_cpu_ndiv(u32 cpu, u32 cpuid, u32 clusterid, u64 *ndiv)
316316
{
317-
int ret;
318-
319-
ret = smp_call_function_single(cpu, tegra194_get_cpu_ndiv_sysreg, &ndiv, true);
320-
321-
return ret;
317+
return smp_call_function_single(cpu, tegra194_get_cpu_ndiv_sysreg, &ndiv, true);
322318
}
323319

324320
static void tegra194_set_cpu_ndiv_sysreg(void *data)
@@ -382,7 +378,7 @@ static int tegra194_cpufreq_init(struct cpufreq_policy *policy)
382378

383379
data->soc->ops->get_cpu_cluster_id(policy->cpu, NULL, &clusterid);
384380

385-
if (clusterid >= data->num_clusters || !data->tables[clusterid])
381+
if (clusterid >= data->soc->num_clusters || !data->tables[clusterid])
386382
return -EINVAL;
387383

388384
start_cpu = rounddown(policy->cpu, maxcpus_per_cluster);
@@ -433,6 +429,7 @@ static struct tegra_cpufreq_ops tegra194_cpufreq_ops = {
433429
static const struct tegra_cpufreq_soc tegra194_cpufreq_soc = {
434430
.ops = &tegra194_cpufreq_ops,
435431
.maxcpus_per_cluster = 2,
432+
.num_clusters = 4,
436433
};
437434

438435
static void tegra194_cpufreq_free_resources(void)
@@ -525,15 +522,14 @@ static int tegra194_cpufreq_probe(struct platform_device *pdev)
525522

526523
soc = of_device_get_match_data(&pdev->dev);
527524

528-
if (soc->ops && soc->maxcpus_per_cluster) {
525+
if (soc->ops && soc->maxcpus_per_cluster && soc->num_clusters) {
529526
data->soc = soc;
530527
} else {
531528
dev_err(&pdev->dev, "soc data missing\n");
532529
return -EINVAL;
533530
}
534531

535-
data->num_clusters = MAX_CLUSTERS;
536-
data->tables = devm_kcalloc(&pdev->dev, data->num_clusters,
532+
data->tables = devm_kcalloc(&pdev->dev, data->soc->num_clusters,
537533
sizeof(*data->tables), GFP_KERNEL);
538534
if (!data->tables)
539535
return -ENOMEM;
@@ -558,7 +554,7 @@ static int tegra194_cpufreq_probe(struct platform_device *pdev)
558554
goto put_bpmp;
559555
}
560556

561-
for (i = 0; i < data->num_clusters; i++) {
557+
for (i = 0; i < data->soc->num_clusters; i++) {
562558
data->tables[i] = init_freq_table(pdev, bpmp, i);
563559
if (IS_ERR(data->tables[i])) {
564560
err = PTR_ERR(data->tables[i]);
@@ -590,6 +586,7 @@ static int tegra194_cpufreq_remove(struct platform_device *pdev)
590586
static const struct of_device_id tegra194_cpufreq_of_match[] = {
591587
{ .compatible = "nvidia,tegra194-ccplex", .data = &tegra194_cpufreq_soc },
592588
{ .compatible = "nvidia,tegra234-ccplex-cluster", .data = &tegra234_cpufreq_soc },
589+
{ .compatible = "nvidia,tegra239-ccplex-cluster", .data = &tegra239_cpufreq_soc },
593590
{ /* sentinel */ }
594591
};
595592

drivers/cpufreq/ti-cpufreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ static int ti_cpufreq_probe(struct platform_device *pdev)
398398
return ret;
399399
}
400400

401-
static int ti_cpufreq_init(void)
401+
static int __init ti_cpufreq_init(void)
402402
{
403403
const struct of_device_id *match;
404404

drivers/cpuidle/coupled.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
* variable is not locked. It is only written from the cpu that
5555
* it stores (or by the on/offlining cpu if that cpu is offline),
5656
* and only read after all the cpus are ready for the coupled idle
57-
* state are are no longer updating it.
57+
* state are no longer updating it.
5858
*
5959
* Three atomic counters are used. alive_count tracks the number
6060
* of cpus in the coupled set that are currently or soon will be

0 commit comments

Comments
 (0)