aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/power/power.h1
-rw-r--r--drivers/base/power/qos.c2
-rw-r--r--drivers/base/power/runtime.c16
-rw-r--r--drivers/base/power/sysfs.c12
-rw-r--r--drivers/base/power/wakeup.c26
5 files changed, 25 insertions, 32 deletions
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
index c511def48b48..ec33fbdb919b 100644
--- a/drivers/base/power/power.h
+++ b/drivers/base/power/power.h
@@ -21,6 +21,7 @@ static inline void pm_runtime_early_init(struct device *dev)
21extern void pm_runtime_init(struct device *dev); 21extern void pm_runtime_init(struct device *dev);
22extern void pm_runtime_reinit(struct device *dev); 22extern void pm_runtime_reinit(struct device *dev);
23extern void pm_runtime_remove(struct device *dev); 23extern void pm_runtime_remove(struct device *dev);
24extern u64 pm_runtime_active_time(struct device *dev);
24 25
25#define WAKE_IRQ_DEDICATED_ALLOCATED BIT(0) 26#define WAKE_IRQ_DEDICATED_ALLOCATED BIT(0)
26#define WAKE_IRQ_DEDICATED_MANAGED BIT(1) 27#define WAKE_IRQ_DEDICATED_MANAGED BIT(1)
diff --git a/drivers/base/power/qos.c b/drivers/base/power/qos.c
index 3382542b39b7..f80e402ef778 100644
--- a/drivers/base/power/qos.c
+++ b/drivers/base/power/qos.c
@@ -22,7 +22,7 @@
22 * per-device constraint data struct. 22 * per-device constraint data struct.
23 * 23 *
24 * Note about the per-device constraint data struct allocation: 24 * 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
26 * dev_pm_info. 26 * dev_pm_info.
27 * . To minimize the data usage by the per-device constraints, the data struct 27 * . To minimize the data usage by the per-device constraints, the data struct
28 * is only allocated at the first call to dev_pm_qos_add_request. 28 * is only allocated at the first call to dev_pm_qos_add_request.
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 78937c45278c..a2d22e3ecf3a 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -64,7 +64,7 @@ static int rpm_suspend(struct device *dev, int rpmflags);
64 * runtime_status field is updated, to account the time in the old state 64 * runtime_status field is updated, to account the time in the old state
65 * correctly. 65 * correctly.
66 */ 66 */
67void update_pm_runtime_accounting(struct device *dev) 67static void update_pm_runtime_accounting(struct device *dev)
68{ 68{
69 u64 now, last, delta; 69 u64 now, last, delta;
70 70
@@ -98,7 +98,7 @@ static void __update_runtime_status(struct device *dev, enum rpm_status status)
98 dev->power.runtime_status = status; 98 dev->power.runtime_status = status;
99} 99}
100 100
101u64 pm_runtime_suspended_time(struct device *dev) 101static u64 rpm_get_accounted_time(struct device *dev, bool suspended)
102{ 102{
103 u64 time; 103 u64 time;
104 unsigned long flags; 104 unsigned long flags;
@@ -106,12 +106,22 @@ u64 pm_runtime_suspended_time(struct device *dev)
106 spin_lock_irqsave(&dev->power.lock, flags); 106 spin_lock_irqsave(&dev->power.lock, flags);
107 107
108 update_pm_runtime_accounting(dev); 108 update_pm_runtime_accounting(dev);
109 time = dev->power.suspended_time; 109 time = suspended ? dev->power.suspended_time : dev->power.active_time;
110 110
111 spin_unlock_irqrestore(&dev->power.lock, flags); 111 spin_unlock_irqrestore(&dev->power.lock, flags);
112 112
113 return time; 113 return time;
114} 114}
115
116u64 pm_runtime_active_time(struct device *dev)
117{
118 return rpm_get_accounted_time(dev, false);
119}
120
121u64 pm_runtime_suspended_time(struct device *dev)
122{
123 return rpm_get_accounted_time(dev, true);
124}
115EXPORT_SYMBOL_GPL(pm_runtime_suspended_time); 125EXPORT_SYMBOL_GPL(pm_runtime_suspended_time);
116 126
117/** 127/**
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index c6bf76124184..1226e441ddfe 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -125,13 +125,9 @@ static ssize_t runtime_active_time_show(struct device *dev,
125 struct device_attribute *attr, char *buf) 125 struct device_attribute *attr, char *buf)
126{ 126{
127 int ret; 127 int ret;
128 u64 tmp; 128 u64 tmp = pm_runtime_active_time(dev);
129 spin_lock_irq(&dev->power.lock);
130 update_pm_runtime_accounting(dev);
131 tmp = dev->power.active_time;
132 do_div(tmp, NSEC_PER_MSEC); 129 do_div(tmp, NSEC_PER_MSEC);
133 ret = sprintf(buf, "%llu\n", tmp); 130 ret = sprintf(buf, "%llu\n", tmp);
134 spin_unlock_irq(&dev->power.lock);
135 return ret; 131 return ret;
136} 132}
137 133
@@ -141,13 +137,9 @@ static ssize_t runtime_suspended_time_show(struct device *dev,
141 struct device_attribute *attr, char *buf) 137 struct device_attribute *attr, char *buf)
142{ 138{
143 int ret; 139 int ret;
144 u64 tmp; 140 u64 tmp = pm_runtime_suspended_time(dev);
145 spin_lock_irq(&dev->power.lock);
146 update_pm_runtime_accounting(dev);
147 tmp = dev->power.suspended_time;
148 do_div(tmp, NSEC_PER_MSEC); 141 do_div(tmp, NSEC_PER_MSEC);
149 ret = sprintf(buf, "%llu\n", tmp); 142 ret = sprintf(buf, "%llu\n", tmp);
150 spin_unlock_irq(&dev->power.lock);
151 return ret; 143 return ret;
152} 144}
153 145
diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
index d0e77d56c1d9..bb1ae175fae1 100644
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -108,23 +108,6 @@ struct wakeup_source *wakeup_source_create(const char *name)
108} 108}
109EXPORT_SYMBOL_GPL(wakeup_source_create); 109EXPORT_SYMBOL_GPL(wakeup_source_create);
110 110
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 */
118void 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}
126EXPORT_SYMBOL_GPL(wakeup_source_drop);
127
128/* 111/*
129 * Record wakeup_source statistics being deleted into a dummy wakeup_source. 112 * Record wakeup_source statistics being deleted into a dummy wakeup_source.
130 */ 113 */
@@ -164,7 +147,7 @@ void wakeup_source_destroy(struct wakeup_source *ws)
164 if (!ws) 147 if (!ws)
165 return; 148 return;
166 149
167 wakeup_source_drop(ws); 150 __pm_relax(ws);
168 wakeup_source_record(ws); 151 wakeup_source_record(ws);
169 kfree_const(ws->name); 152 kfree_const(ws->name);
170 kfree(ws); 153 kfree(ws);
@@ -207,6 +190,13 @@ void wakeup_source_remove(struct wakeup_source *ws)
207 list_del_rcu(&ws->entry); 190 list_del_rcu(&ws->entry);
208 raw_spin_unlock_irqrestore(&events_lock, flags); 191 raw_spin_unlock_irqrestore(&events_lock, flags);
209 synchronize_srcu(&wakeup_srcu); 192 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;
210} 200}
211EXPORT_SYMBOL_GPL(wakeup_source_remove); 201EXPORT_SYMBOL_GPL(wakeup_source_remove);
212 202