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

Commit c425eda2 authored by Ruchi Kandoi's avatar Ruchi Kandoi Committed by Amit Pundir
Browse files

power: Adds functionality to log the last suspend abort reason.



Extends the last_resume_reason to log suspend abort reason. The abort
reasons will have "Abort:" appended at the start to distinguish itself
from the resume reason.

Signed-off-by: default avatarRuchi Kandoi <kandoiruchi@google.com>
Change-Id: I3207f1844e3d87c706dfc298fb10e1c648814c5f
parent 44ab52b8
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
#include <linux/cpufreq.h>
#include <linux/cpuidle.h>
#include <linux/timer.h>
#include <linux/wakeup_reason.h>

#include "../base.h"
#include "power.h"
@@ -1353,6 +1354,7 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
	pm_callback_t callback = NULL;
	char *info = NULL;
	int error = 0;
	char suspend_abort[MAX_SUSPEND_ABORT_LEN];
	DECLARE_DPM_WATCHDOG_ON_STACK(wd);

	TRACE_DEVICE(dev);
@@ -1373,6 +1375,9 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
		pm_wakeup_event(dev, 0);

	if (pm_wakeup_pending()) {
		pm_get_active_wakeup_sources(suspend_abort,
			MAX_SUSPEND_ABORT_LEN);
		log_suspend_abort_reason(suspend_abort);
		async_error = -EBUSY;
		goto Complete;
	}
+16 −0
Original line number Diff line number Diff line
@@ -802,6 +802,22 @@ void pm_wakeup_event(struct device *dev, unsigned int msec)
}
EXPORT_SYMBOL_GPL(pm_wakeup_event);

void pm_get_active_wakeup_sources(char *pending_wakeup_source, size_t max)
{
	struct wakeup_source *ws;
	int len = 0;
	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,
				"%s ", ws->name);
		}
	}
	rcu_read_unlock();
}
EXPORT_SYMBOL_GPL(pm_get_active_wakeup_sources);

void pm_print_active_wakeup_sources(void)
{
	struct wakeup_source *ws;
+3 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@
#include <linux/module.h>
#include <linux/suspend.h>
#include <trace/events/power.h>
#include <linux/wakeup_reason.h>

static LIST_HEAD(syscore_ops_list);
static DEFINE_MUTEX(syscore_ops_lock);
@@ -75,6 +76,8 @@ int syscore_suspend(void)
	return 0;

 err_out:
	log_suspend_abort_reason("System core suspend callback %pF failed",
		ops->suspend);
	pr_err("PM: System core suspend callback %pF failed.\n", ops->suspend);

	list_for_each_entry_continue(ops, &syscore_ops_list, node)
+1 −0
Original line number Diff line number Diff line
@@ -434,6 +434,7 @@ extern bool pm_get_wakeup_count(unsigned int *count, bool block);
extern bool pm_save_wakeup_count(unsigned int count);
extern void pm_wakep_autosleep_enabled(bool set);
extern void pm_print_active_wakeup_sources(void);
extern void pm_get_active_wakeup_sources(char *pending_sources, size_t max);

static inline void lock_system_sleep(void)
{
+3 −1
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@
#ifndef _LINUX_WAKEUP_REASON_H
#define _LINUX_WAKEUP_REASON_H

void log_wakeup_reason(int irq);
#define MAX_SUSPEND_ABORT_LEN 256

void log_wakeup_reason(int irq);
void log_suspend_abort_reason(const char *fmt, ...);
#endif /* _LINUX_WAKEUP_REASON_H */
Loading