Skip to content

Commit fbd88dd

Browse files
committed
Merge tag 'pm-6.9-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull more power management updates from Rafael Wysocki: "These update the Energy Model to make it prevent errors due to power unit mismatches, fix a typo in power management documentation, convert one driver to using a platform remove callback returning void, address two cpufreq issues (one in the core and one in the DT driver), and enable boost support in the SCMI cpufreq driver. Specifics: - Modify the Energy Model code to bail out and complain if the unit of power is not uW to prevent errors due to unit mismatches (Lukasz Luba) - Make the intel_rapl platform driver use a remove callback returning void (Uwe Kleine-König) - Fix typo in the suspend and interrupts document (Saravana Kannan) - Make per-policy boost flags actually take effect on platforms using cpufreq_boost_set_sw() (Sibi Sankar) - Enable boost support in the SCMI cpufreq driver (Sibi Sankar) - Make the DT cpufreq driver use zalloc_cpumask_var() for allocating cpumasks to avoid using unitinialized memory (Marek Szyprowski)" * tag 'pm-6.9-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: cpufreq: scmi: Enable boost support firmware: arm_scmi: Add support for marking certain frequencies as turbo cpufreq: dt: always allocate zeroed cpumask cpufreq: Fix per-policy boost behavior on SoCs using cpufreq_boost_set_sw() Documentation: power: Fix typo in suspend and interrupts doc PM: EM: Force device drivers to provide power in uW powercap: intel_rapl: Convert to platform remove callback returning void
2 parents 6d37f7e + a6d6590 commit fbd88dd

File tree

8 files changed

+50
-13
lines changed

8 files changed

+50
-13
lines changed

Documentation/power/suspend-and-interrupts.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ handling the given IRQ as a system wakeup interrupt line and disable_irq_wake()
7878
turns that logic off.
7979

8080
Calling enable_irq_wake() causes suspend_device_irqs() to treat the given IRQ
81-
in a special way. Namely, the IRQ remains enabled, by on the first interrupt
81+
in a special way. Namely, the IRQ remains enabled, but on the first interrupt
8282
it will be disabled, marked as pending and "suspended" so that it will be
8383
re-enabled by resume_device_irqs() during the subsequent system resume. Also
8484
the PM core is notified about the event which causes the system suspend in

drivers/cpufreq/cpufreq-dt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ static int dt_cpufreq_early_init(struct device *dev, int cpu)
208208
if (!priv)
209209
return -ENOMEM;
210210

211-
if (!alloc_cpumask_var(&priv->cpus, GFP_KERNEL))
211+
if (!zalloc_cpumask_var(&priv->cpus, GFP_KERNEL))
212212
return -ENOMEM;
213213

214214
cpumask_set_cpu(cpu, priv->cpus);

drivers/cpufreq/cpufreq.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -653,14 +653,16 @@ static ssize_t store_local_boost(struct cpufreq_policy *policy,
653653
if (policy->boost_enabled == enable)
654654
return count;
655655

656+
policy->boost_enabled = enable;
657+
656658
cpus_read_lock();
657659
ret = cpufreq_driver->set_boost(policy, enable);
658660
cpus_read_unlock();
659661

660-
if (ret)
662+
if (ret) {
663+
policy->boost_enabled = !policy->boost_enabled;
661664
return ret;
662-
663-
policy->boost_enabled = enable;
665+
}
664666

665667
return count;
666668
}
@@ -1428,6 +1430,9 @@ static int cpufreq_online(unsigned int cpu)
14281430
goto out_free_policy;
14291431
}
14301432

1433+
/* Let the per-policy boost flag mirror the cpufreq_driver boost during init */
1434+
policy->boost_enabled = cpufreq_boost_enabled() && policy_has_boost_freq(policy);
1435+
14311436
/*
14321437
* The initialization has succeeded and the policy is online.
14331438
* If there is a problem with its frequency table, take it
@@ -2769,11 +2774,12 @@ int cpufreq_boost_trigger_state(int state)
27692774

27702775
cpus_read_lock();
27712776
for_each_active_policy(policy) {
2777+
policy->boost_enabled = state;
27722778
ret = cpufreq_driver->set_boost(policy, state);
2773-
if (ret)
2779+
if (ret) {
2780+
policy->boost_enabled = !policy->boost_enabled;
27742781
goto err_reset_state;
2775-
2776-
policy->boost_enabled = state;
2782+
}
27772783
}
27782784
cpus_read_unlock();
27792785

drivers/cpufreq/freq_table.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
4040
cpufreq_for_each_valid_entry(pos, table) {
4141
freq = pos->frequency;
4242

43-
if (!cpufreq_boost_enabled()
43+
if ((!cpufreq_boost_enabled() || !policy->boost_enabled)
4444
&& (pos->flags & CPUFREQ_BOOST_FREQ))
4545
continue;
4646

drivers/cpufreq/scmi-cpufreq.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ struct scmi_data {
3030

3131
static struct scmi_protocol_handle *ph;
3232
static const struct scmi_perf_proto_ops *perf_ops;
33+
static struct cpufreq_driver scmi_cpufreq_driver;
3334

3435
static unsigned int scmi_cpufreq_get_rate(unsigned int cpu)
3536
{
@@ -167,6 +168,12 @@ scmi_get_rate_limit(u32 domain, bool has_fast_switch)
167168
return rate_limit;
168169
}
169170

171+
static struct freq_attr *scmi_cpufreq_hw_attr[] = {
172+
&cpufreq_freq_attr_scaling_available_freqs,
173+
NULL,
174+
NULL,
175+
};
176+
170177
static int scmi_cpufreq_init(struct cpufreq_policy *policy)
171178
{
172179
int ret, nr_opp, domain;
@@ -276,6 +283,17 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy)
276283
policy->transition_delay_us =
277284
scmi_get_rate_limit(domain, policy->fast_switch_possible);
278285

286+
if (policy_has_boost_freq(policy)) {
287+
ret = cpufreq_enable_boost_support();
288+
if (ret) {
289+
dev_warn(cpu_dev, "failed to enable boost: %d\n", ret);
290+
goto out_free_opp;
291+
} else {
292+
scmi_cpufreq_hw_attr[1] = &cpufreq_freq_attr_scaling_boost_freqs;
293+
scmi_cpufreq_driver.boost_enabled = true;
294+
}
295+
}
296+
279297
return 0;
280298

281299
out_free_opp:
@@ -334,7 +352,7 @@ static struct cpufreq_driver scmi_cpufreq_driver = {
334352
CPUFREQ_NEED_INITIAL_FREQ_CHECK |
335353
CPUFREQ_IS_COOLING_DEV,
336354
.verify = cpufreq_generic_frequency_table_verify,
337-
.attr = cpufreq_generic_attr,
355+
.attr = scmi_cpufreq_hw_attr,
338356
.target_index = scmi_cpufreq_set_target,
339357
.fast_switch = scmi_cpufreq_fast_switch,
340358
.get = scmi_cpufreq_get_rate,

drivers/firmware/arm_scmi/perf.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,9 @@ static int scmi_dvfs_device_opps_add(const struct scmi_protocol_handle *ph,
871871
else
872872
freq = dom->opp[idx].indicative_freq * dom->mult_factor;
873873

874+
/* All OPPs above the sustained frequency are treated as turbo */
875+
data.turbo = freq > dom->sustained_freq_khz * 1000;
876+
874877
data.level = dom->opp[idx].perf;
875878
data.freq = freq;
876879

drivers/powercap/intel_rapl_msr.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,10 @@ static int rapl_msr_probe(struct platform_device *pdev)
197197
return ret;
198198
}
199199

200-
static int rapl_msr_remove(struct platform_device *pdev)
200+
static void rapl_msr_remove(struct platform_device *pdev)
201201
{
202202
cpuhp_remove_state(rapl_msr_priv->pcap_rapl_online);
203203
powercap_unregister_control_type(rapl_msr_priv->control_type);
204-
return 0;
205204
}
206205

207206
static const struct platform_device_id rapl_msr_ids[] = {
@@ -212,7 +211,7 @@ MODULE_DEVICE_TABLE(platform, rapl_msr_ids);
212211

213212
static struct platform_driver intel_rapl_msr_driver = {
214213
.probe = rapl_msr_probe,
215-
.remove = rapl_msr_remove,
214+
.remove_new = rapl_msr_remove,
216215
.id_table = rapl_msr_ids,
217216
.driver = {
218217
.name = "intel_rapl_msr",

kernel/power/energy_model.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,17 @@ int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
612612
else if (cb->get_cost)
613613
flags |= EM_PERF_DOMAIN_ARTIFICIAL;
614614

615+
/*
616+
* EM only supports uW (exception is artificial EM).
617+
* Therefore, check and force the drivers to provide
618+
* power in uW.
619+
*/
620+
if (!microwatts && !(flags & EM_PERF_DOMAIN_ARTIFICIAL)) {
621+
dev_err(dev, "EM: only supports uW power values\n");
622+
ret = -EINVAL;
623+
goto unlock;
624+
}
625+
615626
ret = em_create_pd(dev, nr_states, cb, cpus, flags);
616627
if (ret)
617628
goto unlock;

0 commit comments

Comments
 (0)