Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 68b6254b authored by Ruchi Kandoi's avatar Ruchi Kandoi Committed by Dmitry Shmidt
Browse files

ANDROID: 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: default avatarRuchi Kandoi <kandoiruchi@google.com>
parent e2cc63fd
Loading
Loading
Loading
Loading
+19 −3
Original line number Original line Diff line number Diff line
@@ -15,6 +15,7 @@
#include <linux/seq_file.h>
#include <linux/seq_file.h>
#include <linux/debugfs.h>
#include <linux/debugfs.h>
#include <linux/pm_wakeirq.h>
#include <linux/pm_wakeirq.h>
#include <linux/types.h>
#include <trace/events/power.h>
#include <trace/events/power.h>


#include "power.h"
#include "power.h"
@@ -804,15 +805,30 @@ EXPORT_SYMBOL_GPL(pm_wakeup_event);


void pm_get_active_wakeup_sources(char *pending_wakeup_source, size_t max)
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;
	int len = 0;
	bool active = false;

	rcu_read_lock();
	rcu_read_lock();
	len += snprintf(pending_wakeup_source, max, "Pending Wakeup Sources: ");
	list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
	list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
		if (ws->active) {
		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);
				"%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();
	rcu_read_unlock();
}
}