aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuchi Kandoi <kandoiruchi@google.com>2015-04-08 15:42:29 -0700
committerMister Oyster <oysterized@gmail.com>2017-04-11 11:00:08 +0200
commit6673a3d5e192cb7f9461325f36080dcb0e03ecd5 (patch)
tree2a89af1cb01c967323b8d1fcfd7b79f43d8960a1
parent5722f02247f1b02b1b57241b8e1d62108b85c0e4 (diff)
downloadandroid_kernel_m2note-6673a3d5e192cb7f9461325f36080dcb0e03ecd5.tar.gz
wakeup: Add last wake up source logging for suspend abort reason.
There is a possibility that a wakeup source event is received after the device prepares to suspend which might cause the suspend to abort. This patch adds the functionality of reporting the last active wakeup source which is currently not active but caused the suspend to abort reason via the /sys/kernel/power/last_wakeup_reason file. Change-Id: I1760d462f497b33e425f5565cb6cff5973932ec3 Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
-rw-r--r--drivers/base/power/wakeup.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
index 9ae735df7..96ffdb24b 100644
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -14,6 +14,7 @@
#include <linux/suspend.h>
#include <linux/seq_file.h>
#include <linux/debugfs.h>
+#include <linux/types.h>
#include <trace/events/power.h>
#include <linux/moduleparam.h>
@@ -711,16 +712,31 @@ EXPORT_SYMBOL_GPL(pm_wakeup_event);
void pm_get_active_wakeup_sources(char *pending_wakeup_source, size_t max)
{
- struct wakeup_source *ws;
+ struct wakeup_source *ws, *last_active_ws = NULL;
int len = 0;
+ bool active = false;
+
rcu_read_lock();
- len += snprintf(pending_wakeup_source, max, "Pending Wakeup Sources: ");
list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
if (ws->active) {
- len += snprintf(pending_wakeup_source + len, max,
+ if (!active)
+ len += scnprintf(pending_wakeup_source, max,
+ "Pending Wakeup Sources: ");
+ len += scnprintf(pending_wakeup_source + len, max - len,
"%s ", ws->name);
+ active = true;
+ } else if (!active &&
+ (!last_active_ws ||
+ ktime_to_ns(ws->last_time) >
+ ktime_to_ns(last_active_ws->last_time))) {
+ last_active_ws = ws;
}
}
+ if (!active && last_active_ws) {
+ scnprintf(pending_wakeup_source, max,
+ "Last active Wakeup Source: %s",
+ last_active_ws->name);
+ }
rcu_read_unlock();
}
EXPORT_SYMBOL_GPL(pm_get_active_wakeup_sources);