提交 bb177fed 编写于 作者: J Julius Werner 提交者: Rafael J. Wysocki

PM / Sleep: Print last wakeup source on failed wakeup_count write

Commit a938da06 introduced a useful little log message to tell
users/debuggers which wakeup source aborted a suspend.  However,
this message is only printed if the abort happens during the
in-kernel suspend path (after writing /sys/power/state).

The full specification of the /sys/power/wakeup_count facility
allows user-space power managers to double-check if wakeups have
already happened before it actually tries to suspend (e.g. while it
was running user-space pre-suspend hooks), by writing the last known
wakeup_count value to /sys/power/wakeup_count.  This patch changes
the sysfs handler for that node to also print said log message if
that write fails, so that we can figure out the offending wakeup
source for both kinds of suspend aborts.
Signed-off-by: NJulius Werner <jwerner@chromium.org>
Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
上级 d24c2a4f
...@@ -659,7 +659,7 @@ void pm_wakeup_event(struct device *dev, unsigned int msec) ...@@ -659,7 +659,7 @@ void pm_wakeup_event(struct device *dev, unsigned int msec)
} }
EXPORT_SYMBOL_GPL(pm_wakeup_event); EXPORT_SYMBOL_GPL(pm_wakeup_event);
static void print_active_wakeup_sources(void) void pm_print_active_wakeup_sources(void)
{ {
struct wakeup_source *ws; struct wakeup_source *ws;
int active = 0; int active = 0;
...@@ -683,6 +683,7 @@ static void print_active_wakeup_sources(void) ...@@ -683,6 +683,7 @@ static void print_active_wakeup_sources(void)
last_activity_ws->name); last_activity_ws->name);
rcu_read_unlock(); rcu_read_unlock();
} }
EXPORT_SYMBOL_GPL(pm_print_active_wakeup_sources);
/** /**
* pm_wakeup_pending - Check if power transition in progress should be aborted. * pm_wakeup_pending - Check if power transition in progress should be aborted.
...@@ -709,7 +710,7 @@ bool pm_wakeup_pending(void) ...@@ -709,7 +710,7 @@ bool pm_wakeup_pending(void)
if (ret) { if (ret) {
pr_info("PM: Wakeup pending, aborting suspend\n"); pr_info("PM: Wakeup pending, aborting suspend\n");
print_active_wakeup_sources(); pm_print_active_wakeup_sources();
} }
return ret; return ret;
......
...@@ -363,6 +363,7 @@ extern bool pm_wakeup_pending(void); ...@@ -363,6 +363,7 @@ extern bool pm_wakeup_pending(void);
extern bool pm_get_wakeup_count(unsigned int *count, bool block); extern bool pm_get_wakeup_count(unsigned int *count, bool block);
extern bool pm_save_wakeup_count(unsigned int count); extern bool pm_save_wakeup_count(unsigned int count);
extern void pm_wakep_autosleep_enabled(bool set); extern void pm_wakep_autosleep_enabled(bool set);
extern void pm_print_active_wakeup_sources(void);
static inline void lock_system_sleep(void) static inline void lock_system_sleep(void)
{ {
......
...@@ -424,6 +424,8 @@ static ssize_t wakeup_count_store(struct kobject *kobj, ...@@ -424,6 +424,8 @@ static ssize_t wakeup_count_store(struct kobject *kobj,
if (sscanf(buf, "%u", &val) == 1) { if (sscanf(buf, "%u", &val) == 1) {
if (pm_save_wakeup_count(val)) if (pm_save_wakeup_count(val))
error = n; error = n;
else
pm_print_active_wakeup_sources();
} }
out: out:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册