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: I778ab471cb075d4b3859c798f6e3ff72faf7edc0
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
Git-commit: c8b4bc552cef9e24427b12fee8763d1702f8d57a
Git-repo: https://android.googlesource.com/kernel/common.git
Signed-off-by: Vignesh Radhakrishnan <vigneshr@codeaurora.org>
This commit is contained in:
Ruchi Kandoi 2015-04-08 15:42:29 -07:00 committed by Vignesh Radhakrishnan
parent 3734b49d50
commit 14791c7a3b
1 changed files with 19 additions and 3 deletions

View File

@ -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 "power.h"
@ -661,16 +662,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);