Skip to content

Commit 9352ca5

Browse files
committed
Merge tag 'pm-5.1-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull more power management updates from Rafael Wysocki: "These are mostly fixes and cleanups on top of the previously merged power management material for 5.1-rc1 with one cpupower utility update that wasn't pushed earlier due to unfortunate timing. Specifics: - Fix registration of new cpuidle governors partially broken during the 5.0 development cycle by mistake (Rafael Wysocki). - Avoid integer overflows in the menu cpuidle governor by making it discard the overflowing data points upfront (Rafael Wysocki). - Fix minor mistake in the recent update of the iowait boost computation in the intel_pstate driver (Rafael Wysocki). - Drop incorrect __init annotation from one function in the pxa2xx cpufreq driver (Arnd Bergmann). - Fix the operating performance points (OPP) framework initialization for devices in multiple power domains if only one of them is scalable (Rajendra Nayak). - Fix mistake in dev_pm_opp_set_rate() which causes it to skip updating the performance state if the new frequency is the same as the old one (Viresh Kumar). - Rework the cancellation of wakeup source timers to avoid potential issues with it and do some cleanups unlocked by that change (Viresh Kumar, Rafael Wysocki). - Clean up the code computing the active/suspended time of devices in the PM-runtime framework after recent changes (Ulf Hansson). - Make the power management infrastructure code use pr_fmt() consistently (Joe Perches). - Clean up the generic power domains (genpd) framework somewhat (Aisheng Dong). - Improve kerneldoc comments for two functions in the cpufreq core (Rafael Wysocki). - Fix typo in a PM QoS file description comment (Aisheng Dong). - Update the handling of CPU boost frequencies in the cpupower utility (Abhishek Goel)" * tag 'pm-5.1-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: cpuidle: governor: Add new governors to cpuidle_governors again cpufreq: intel_pstate: Fix up iowait_boost computation PM / OPP: Update performance state when freq == old_freq PM / wakeup: Drop wakeup_source_drop() PM / wakeup: Rework wakeup source timer cancellation PM / domains: Remove one unnecessary blank line PM / Domains: Return early for all errors in _genpd_power_off() PM / Domains: Improve warn for multiple states but no governor OPP: Fix handling of multiple power domains PM / QoS: Fix typo in file description cpufreq: pxa2xx: remove incorrect __init annotation PM-runtime: Call pm_runtime_active|suspended_time() from sysfs PM-runtime: Consolidate code to get active/suspended time PM: Add and use pr_fmt() cpufreq: Improve kerneldoc comments for cpufreq_cpu_get/put() cpuidle: menu: Avoid overflows when computing variance tools/power/cpupower: Display boost frequency separately
2 parents 9bc4461 + b444e1a commit 9352ca5

File tree

21 files changed

+131
-112
lines changed

21 files changed

+131
-112
lines changed

drivers/base/power/domain.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* This file is released under the GPLv2.
77
*/
88

9+
#define pr_fmt(fmt) "PM: " fmt
10+
911
#include <linux/delay.h>
1012
#include <linux/kernel.h>
1113
#include <linux/io.h>
@@ -457,19 +459,19 @@ static int _genpd_power_off(struct generic_pm_domain *genpd, bool timed)
457459

458460
time_start = ktime_get();
459461
ret = genpd->power_off(genpd);
460-
if (ret == -EBUSY)
462+
if (ret)
461463
return ret;
462464

463465
elapsed_ns = ktime_to_ns(ktime_sub(ktime_get(), time_start));
464466
if (elapsed_ns <= genpd->states[state_idx].power_off_latency_ns)
465-
return ret;
467+
return 0;
466468

467469
genpd->states[state_idx].power_off_latency_ns = elapsed_ns;
468470
genpd->max_off_time_changed = true;
469471
pr_debug("%s: Power-%s latency exceeded, new value %lld ns\n",
470472
genpd->name, "off", elapsed_ns);
471473

472-
return ret;
474+
return 0;
473475
}
474476

475477
/**
@@ -1657,8 +1659,8 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
16571659
genpd_lock_nested(genpd, SINGLE_DEPTH_NESTING);
16581660

16591661
if (!list_empty(&subdomain->master_links) || subdomain->device_count) {
1660-
pr_warn("%s: unable to remove subdomain %s\n", genpd->name,
1661-
subdomain->name);
1662+
pr_warn("%s: unable to remove subdomain %s\n",
1663+
genpd->name, subdomain->name);
16621664
ret = -EBUSY;
16631665
goto out;
16641666
}
@@ -1766,8 +1768,8 @@ int pm_genpd_init(struct generic_pm_domain *genpd,
17661768
ret = genpd_set_default_power_state(genpd);
17671769
if (ret)
17681770
return ret;
1769-
} else if (!gov) {
1770-
pr_warn("%s : no governor for states\n", genpd->name);
1771+
} else if (!gov && genpd->state_count > 1) {
1772+
pr_warn("%s: no governor for states\n", genpd->name);
17711773
}
17721774

17731775
device_initialize(&genpd->dev);
@@ -2514,15 +2516,15 @@ static int genpd_parse_state(struct genpd_power_state *genpd_state,
25142516
&entry_latency);
25152517
if (err) {
25162518
pr_debug(" * %pOF missing entry-latency-us property\n",
2517-
state_node);
2519+
state_node);
25182520
return -EINVAL;
25192521
}
25202522

25212523
err = of_property_read_u32(state_node, "exit-latency-us",
25222524
&exit_latency);
25232525
if (err) {
25242526
pr_debug(" * %pOF missing exit-latency-us property\n",
2525-
state_node);
2527+
state_node);
25262528
return -EINVAL;
25272529
}
25282530

drivers/base/power/domain_governor.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ static bool __default_power_down_ok(struct dev_pm_domain *pd,
128128
off_on_time_ns = genpd->states[state].power_off_latency_ns +
129129
genpd->states[state].power_on_latency_ns;
130130

131-
132131
min_off_time_ns = -1;
133132
/*
134133
* Check if subdomains can be off for enough time.

drivers/base/power/main.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
* subsystem list maintains.
1818
*/
1919

20+
#define pr_fmt(fmt) "PM: " fmt
21+
2022
#include <linux/device.h>
2123
#include <linux/export.h>
2224
#include <linux/mutex.h>
@@ -128,7 +130,7 @@ void device_pm_add(struct device *dev)
128130
if (device_pm_not_required(dev))
129131
return;
130132

131-
pr_debug("PM: Adding info for %s:%s\n",
133+
pr_debug("Adding info for %s:%s\n",
132134
dev->bus ? dev->bus->name : "No Bus", dev_name(dev));
133135
device_pm_check_callbacks(dev);
134136
mutex_lock(&dpm_list_mtx);
@@ -149,7 +151,7 @@ void device_pm_remove(struct device *dev)
149151
if (device_pm_not_required(dev))
150152
return;
151153

152-
pr_debug("PM: Removing info for %s:%s\n",
154+
pr_debug("Removing info for %s:%s\n",
153155
dev->bus ? dev->bus->name : "No Bus", dev_name(dev));
154156
complete_all(&dev->power.completion);
155157
mutex_lock(&dpm_list_mtx);
@@ -168,7 +170,7 @@ void device_pm_remove(struct device *dev)
168170
*/
169171
void device_pm_move_before(struct device *deva, struct device *devb)
170172
{
171-
pr_debug("PM: Moving %s:%s before %s:%s\n",
173+
pr_debug("Moving %s:%s before %s:%s\n",
172174
deva->bus ? deva->bus->name : "No Bus", dev_name(deva),
173175
devb->bus ? devb->bus->name : "No Bus", dev_name(devb));
174176
/* Delete deva from dpm_list and reinsert before devb. */
@@ -182,7 +184,7 @@ void device_pm_move_before(struct device *deva, struct device *devb)
182184
*/
183185
void device_pm_move_after(struct device *deva, struct device *devb)
184186
{
185-
pr_debug("PM: Moving %s:%s after %s:%s\n",
187+
pr_debug("Moving %s:%s after %s:%s\n",
186188
deva->bus ? deva->bus->name : "No Bus", dev_name(deva),
187189
devb->bus ? devb->bus->name : "No Bus", dev_name(devb));
188190
/* Delete deva from dpm_list and reinsert after devb. */
@@ -195,7 +197,7 @@ void device_pm_move_after(struct device *deva, struct device *devb)
195197
*/
196198
void device_pm_move_last(struct device *dev)
197199
{
198-
pr_debug("PM: Moving %s:%s to end of list\n",
200+
pr_debug("Moving %s:%s to end of list\n",
199201
dev->bus ? dev->bus->name : "No Bus", dev_name(dev));
200202
list_move_tail(&dev->power.entry, &dpm_list);
201203
}
@@ -418,8 +420,8 @@ static void pm_dev_dbg(struct device *dev, pm_message_t state, const char *info)
418420
static void pm_dev_err(struct device *dev, pm_message_t state, const char *info,
419421
int error)
420422
{
421-
printk(KERN_ERR "PM: Device %s failed to %s%s: error %d\n",
422-
dev_name(dev), pm_verb(state.event), info, error);
423+
pr_err("Device %s failed to %s%s: error %d\n",
424+
dev_name(dev), pm_verb(state.event), info, error);
423425
}
424426

425427
static void dpm_show_time(ktime_t starttime, pm_message_t state, int error,
@@ -2022,8 +2024,7 @@ int dpm_prepare(pm_message_t state)
20222024
error = 0;
20232025
continue;
20242026
}
2025-
printk(KERN_INFO "PM: Device %s not prepared "
2026-
"for power transition: code %d\n",
2027+
pr_info("Device %s not prepared for power transition: code %d\n",
20272028
dev_name(dev), error);
20282029
put_device(dev);
20292030
break;
@@ -2062,7 +2063,7 @@ EXPORT_SYMBOL_GPL(dpm_suspend_start);
20622063
void __suspend_report_result(const char *function, void *fn, int ret)
20632064
{
20642065
if (ret)
2065-
printk(KERN_ERR "%s(): %pF returns %d\n", function, fn, ret);
2066+
pr_err("%s(): %pF returns %d\n", function, fn, ret);
20662067
}
20672068
EXPORT_SYMBOL_GPL(__suspend_report_result);
20682069

drivers/base/power/power.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ static inline void pm_runtime_early_init(struct device *dev)
2121
extern void pm_runtime_init(struct device *dev);
2222
extern void pm_runtime_reinit(struct device *dev);
2323
extern void pm_runtime_remove(struct device *dev);
24+
extern u64 pm_runtime_active_time(struct device *dev);
2425

2526
#define WAKE_IRQ_DEDICATED_ALLOCATED BIT(0)
2627
#define WAKE_IRQ_DEDICATED_MANAGED BIT(1)

drivers/base/power/qos.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* per-device constraint data struct.
2323
*
2424
* Note about the per-device constraint data struct allocation:
25-
* . The per-device constraints data struct ptr is tored into the device
25+
* . The per-device constraints data struct ptr is stored into the device
2626
* dev_pm_info.
2727
* . To minimize the data usage by the per-device constraints, the data struct
2828
* is only allocated at the first call to dev_pm_qos_add_request.

drivers/base/power/runtime.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static int rpm_suspend(struct device *dev, int rpmflags);
6464
* runtime_status field is updated, to account the time in the old state
6565
* correctly.
6666
*/
67-
void update_pm_runtime_accounting(struct device *dev)
67+
static void update_pm_runtime_accounting(struct device *dev)
6868
{
6969
u64 now, last, delta;
7070

@@ -98,20 +98,30 @@ static void __update_runtime_status(struct device *dev, enum rpm_status status)
9898
dev->power.runtime_status = status;
9999
}
100100

101-
u64 pm_runtime_suspended_time(struct device *dev)
101+
static u64 rpm_get_accounted_time(struct device *dev, bool suspended)
102102
{
103103
u64 time;
104104
unsigned long flags;
105105

106106
spin_lock_irqsave(&dev->power.lock, flags);
107107

108108
update_pm_runtime_accounting(dev);
109-
time = dev->power.suspended_time;
109+
time = suspended ? dev->power.suspended_time : dev->power.active_time;
110110

111111
spin_unlock_irqrestore(&dev->power.lock, flags);
112112

113113
return time;
114114
}
115+
116+
u64 pm_runtime_active_time(struct device *dev)
117+
{
118+
return rpm_get_accounted_time(dev, false);
119+
}
120+
121+
u64 pm_runtime_suspended_time(struct device *dev)
122+
{
123+
return rpm_get_accounted_time(dev, true);
124+
}
115125
EXPORT_SYMBOL_GPL(pm_runtime_suspended_time);
116126

117127
/**

drivers/base/power/sysfs.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,9 @@ static ssize_t runtime_active_time_show(struct device *dev,
125125
struct device_attribute *attr, char *buf)
126126
{
127127
int ret;
128-
u64 tmp;
129-
spin_lock_irq(&dev->power.lock);
130-
update_pm_runtime_accounting(dev);
131-
tmp = dev->power.active_time;
128+
u64 tmp = pm_runtime_active_time(dev);
132129
do_div(tmp, NSEC_PER_MSEC);
133130
ret = sprintf(buf, "%llu\n", tmp);
134-
spin_unlock_irq(&dev->power.lock);
135131
return ret;
136132
}
137133

@@ -141,13 +137,9 @@ static ssize_t runtime_suspended_time_show(struct device *dev,
141137
struct device_attribute *attr, char *buf)
142138
{
143139
int ret;
144-
u64 tmp;
145-
spin_lock_irq(&dev->power.lock);
146-
update_pm_runtime_accounting(dev);
147-
tmp = dev->power.suspended_time;
140+
u64 tmp = pm_runtime_suspended_time(dev);
148141
do_div(tmp, NSEC_PER_MSEC);
149142
ret = sprintf(buf, "%llu\n", tmp);
150-
spin_unlock_irq(&dev->power.lock);
151143
return ret;
152144
}
153145

drivers/base/power/trace.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
* devices may be working.
88
*/
99

10+
#define pr_fmt(fmt) "PM: " fmt
11+
1012
#include <linux/pm-trace.h>
1113
#include <linux/export.h>
1214
#include <linux/rtc.h>

drivers/base/power/wakeup.c

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* This file is released under the GPLv2.
77
*/
88

9+
#define pr_fmt(fmt) "PM: " fmt
10+
911
#include <linux/device.h>
1012
#include <linux/slab.h>
1113
#include <linux/sched/signal.h>
@@ -106,23 +108,6 @@ struct wakeup_source *wakeup_source_create(const char *name)
106108
}
107109
EXPORT_SYMBOL_GPL(wakeup_source_create);
108110

109-
/**
110-
* wakeup_source_drop - Prepare a struct wakeup_source object for destruction.
111-
* @ws: Wakeup source to prepare for destruction.
112-
*
113-
* Callers must ensure that __pm_stay_awake() or __pm_wakeup_event() will never
114-
* be run in parallel with this function for the same wakeup source object.
115-
*/
116-
void wakeup_source_drop(struct wakeup_source *ws)
117-
{
118-
if (!ws)
119-
return;
120-
121-
del_timer_sync(&ws->timer);
122-
__pm_relax(ws);
123-
}
124-
EXPORT_SYMBOL_GPL(wakeup_source_drop);
125-
126111
/*
127112
* Record wakeup_source statistics being deleted into a dummy wakeup_source.
128113
*/
@@ -162,7 +147,7 @@ void wakeup_source_destroy(struct wakeup_source *ws)
162147
if (!ws)
163148
return;
164149

165-
wakeup_source_drop(ws);
150+
__pm_relax(ws);
166151
wakeup_source_record(ws);
167152
kfree_const(ws->name);
168153
kfree(ws);
@@ -205,6 +190,13 @@ void wakeup_source_remove(struct wakeup_source *ws)
205190
list_del_rcu(&ws->entry);
206191
raw_spin_unlock_irqrestore(&events_lock, flags);
207192
synchronize_srcu(&wakeup_srcu);
193+
194+
del_timer_sync(&ws->timer);
195+
/*
196+
* Clear timer.function to make wakeup_source_not_registered() treat
197+
* this wakeup source as not registered.
198+
*/
199+
ws->timer.function = NULL;
208200
}
209201
EXPORT_SYMBOL_GPL(wakeup_source_remove);
210202

@@ -853,7 +845,7 @@ bool pm_wakeup_pending(void)
853845
raw_spin_unlock_irqrestore(&events_lock, flags);
854846

855847
if (ret) {
856-
pr_debug("PM: Wakeup pending, aborting suspend\n");
848+
pr_debug("Wakeup pending, aborting suspend\n");
857849
pm_print_active_wakeup_sources();
858850
}
859851

drivers/cpufreq/cpufreq.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -206,17 +206,15 @@ unsigned int cpufreq_generic_get(unsigned int cpu)
206206
EXPORT_SYMBOL_GPL(cpufreq_generic_get);
207207

208208
/**
209-
* cpufreq_cpu_get: returns policy for a cpu and marks it busy.
209+
* cpufreq_cpu_get - Return policy for a CPU and mark it as busy.
210+
* @cpu: CPU to find the policy for.
210211
*
211-
* @cpu: cpu to find policy for.
212+
* Call cpufreq_cpu_get_raw() to obtain a cpufreq policy for @cpu and increment
213+
* the kobject reference counter of that policy. Return a valid policy on
214+
* success or NULL on failure.
212215
*
213-
* This returns policy for 'cpu', returns NULL if it doesn't exist.
214-
* It also increments the kobject reference count to mark it busy and so would
215-
* require a corresponding call to cpufreq_cpu_put() to decrement it back.
216-
* If corresponding call cpufreq_cpu_put() isn't made, the policy wouldn't be
217-
* freed as that depends on the kobj count.
218-
*
219-
* Return: A valid policy on success, otherwise NULL on failure.
216+
* The policy returned by this function has to be released with the help of
217+
* cpufreq_cpu_put() to balance its kobject reference counter properly.
220218
*/
221219
struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
222220
{
@@ -243,12 +241,8 @@ struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
243241
EXPORT_SYMBOL_GPL(cpufreq_cpu_get);
244242

245243
/**
246-
* cpufreq_cpu_put: Decrements the usage count of a policy
247-
*
248-
* @policy: policy earlier returned by cpufreq_cpu_get().
249-
*
250-
* This decrements the kobject reference count incremented earlier by calling
251-
* cpufreq_cpu_get().
244+
* cpufreq_cpu_put - Decrement kobject usage counter for cpufreq policy.
245+
* @policy: cpufreq policy returned by cpufreq_cpu_get().
252246
*/
253247
void cpufreq_cpu_put(struct cpufreq_policy *policy)
254248
{

drivers/cpufreq/intel_pstate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1762,7 +1762,7 @@ static void intel_pstate_update_util(struct update_util_data *data, u64 time,
17621762
/* Start over if the CPU may have been idle. */
17631763
if (delta_ns > TICK_NSEC) {
17641764
cpu->iowait_boost = ONE_EIGHTH_FP;
1765-
} else if (cpu->iowait_boost) {
1765+
} else if (cpu->iowait_boost >= ONE_EIGHTH_FP) {
17661766
cpu->iowait_boost <<= 1;
17671767
if (cpu->iowait_boost > int_tofp(1))
17681768
cpu->iowait_boost = int_tofp(1);

drivers/cpufreq/pxa2xx-cpufreq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static int pxa_cpufreq_change_voltage(const struct pxa_freqs *pxa_freq)
143143
return ret;
144144
}
145145

146-
static void __init pxa_cpufreq_init_voltages(void)
146+
static void pxa_cpufreq_init_voltages(void)
147147
{
148148
vcc_core = regulator_get(NULL, "vcc_core");
149149
if (IS_ERR(vcc_core)) {
@@ -159,7 +159,7 @@ static int pxa_cpufreq_change_voltage(const struct pxa_freqs *pxa_freq)
159159
return 0;
160160
}
161161

162-
static void __init pxa_cpufreq_init_voltages(void) { }
162+
static void pxa_cpufreq_init_voltages(void) { }
163163
#endif
164164

165165
static void find_freq_tables(struct cpufreq_frequency_table **freq_table,

0 commit comments

Comments
 (0)