Skip to content

Commit e603525

Browse files
committed
Merge branches 'pm-core', 'pm-sleep' and 'pm-qos'
* pm-core: PM-runtime: Call pm_runtime_active|suspended_time() from sysfs PM-runtime: Consolidate code to get active/suspended time * pm-sleep: PM / wakeup: Drop wakeup_source_drop() PM / wakeup: Rework wakeup source timer cancellation * pm-qos: PM / QoS: Fix typo in file description
4 parents 7a5bd12 + 0996584 + 623217a + 07a6c71 commit e603525

File tree

7 files changed

+25
-42
lines changed

7 files changed

+25
-42
lines changed

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/wakeup.c

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -108,23 +108,6 @@ struct wakeup_source *wakeup_source_create(const char *name)
108108
}
109109
EXPORT_SYMBOL_GPL(wakeup_source_create);
110110

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

167-
wakeup_source_drop(ws);
150+
__pm_relax(ws);
168151
wakeup_source_record(ws);
169152
kfree_const(ws->name);
170153
kfree(ws);
@@ -207,6 +190,13 @@ void wakeup_source_remove(struct wakeup_source *ws)
207190
list_del_rcu(&ws->entry);
208191
raw_spin_unlock_irqrestore(&events_lock, flags);
209192
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;
210200
}
211201
EXPORT_SYMBOL_GPL(wakeup_source_remove);
212202

include/linux/pm.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,6 @@ struct dev_pm_info {
643643
struct dev_pm_qos *qos;
644644
};
645645

646-
extern void update_pm_runtime_accounting(struct device *dev);
647646
extern int dev_pm_get_subsys_data(struct device *dev);
648647
extern void dev_pm_put_subsys_data(struct device *dev);
649648

include/linux/pm_wakeup.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ static inline void device_set_wakeup_path(struct device *dev)
9696
/* drivers/base/power/wakeup.c */
9797
extern void wakeup_source_prepare(struct wakeup_source *ws, const char *name);
9898
extern struct wakeup_source *wakeup_source_create(const char *name);
99-
extern void wakeup_source_drop(struct wakeup_source *ws);
10099
extern void wakeup_source_destroy(struct wakeup_source *ws);
101100
extern void wakeup_source_add(struct wakeup_source *ws);
102101
extern void wakeup_source_remove(struct wakeup_source *ws);
@@ -134,8 +133,6 @@ static inline struct wakeup_source *wakeup_source_create(const char *name)
134133
return NULL;
135134
}
136135

137-
static inline void wakeup_source_drop(struct wakeup_source *ws) {}
138-
139136
static inline void wakeup_source_destroy(struct wakeup_source *ws) {}
140137

141138
static inline void wakeup_source_add(struct wakeup_source *ws) {}
@@ -204,12 +201,6 @@ static inline void wakeup_source_init(struct wakeup_source *ws,
204201
wakeup_source_add(ws);
205202
}
206203

207-
static inline void wakeup_source_trash(struct wakeup_source *ws)
208-
{
209-
wakeup_source_remove(ws);
210-
wakeup_source_drop(ws);
211-
}
212-
213204
static inline void __pm_wakeup_event(struct wakeup_source *ws, unsigned int msec)
214205
{
215206
return pm_wakeup_ws_event(ws, msec, false);

0 commit comments

Comments
 (0)