mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-10 21:07:02 +09:00
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: Ruchi Kandoi <kandoiruchi@google.com> Change-Id: I3207f1844e3d87c706dfc298fb10e1c648814c5f
This commit is contained in:
committed by
John Stultz
parent
1adb5b4034
commit
57caa2ad5c
@@ -18,6 +18,7 @@
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/kmod.h>
|
||||
#include <trace/events/power.h>
|
||||
#include <linux/wakeup_reason.h>
|
||||
|
||||
/*
|
||||
* Timeout for stopping processes
|
||||
@@ -35,6 +36,7 @@ static int try_to_freeze_tasks(bool user_only)
|
||||
unsigned int elapsed_msecs;
|
||||
bool wakeup = false;
|
||||
int sleep_usecs = USEC_PER_MSEC;
|
||||
char suspend_abort[MAX_SUSPEND_ABORT_LEN];
|
||||
|
||||
do_gettimeofday(&start);
|
||||
|
||||
@@ -64,6 +66,9 @@ static int try_to_freeze_tasks(bool user_only)
|
||||
break;
|
||||
|
||||
if (pm_wakeup_pending()) {
|
||||
pm_get_active_wakeup_sources(suspend_abort,
|
||||
MAX_SUSPEND_ABORT_LEN);
|
||||
log_suspend_abort_reason(suspend_abort);
|
||||
wakeup = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <trace/events/power.h>
|
||||
#include <linux/compiler.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/wakeup_reason.h>
|
||||
|
||||
#include "power.h"
|
||||
|
||||
@@ -313,7 +314,8 @@ void __weak arch_suspend_enable_irqs(void)
|
||||
*/
|
||||
static int suspend_enter(suspend_state_t state, bool *wakeup)
|
||||
{
|
||||
int error;
|
||||
char suspend_abort[MAX_SUSPEND_ABORT_LEN];
|
||||
int error, last_dev;
|
||||
|
||||
error = platform_suspend_prepare(state);
|
||||
if (error)
|
||||
@@ -321,7 +323,11 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
|
||||
|
||||
error = dpm_suspend_late(PMSG_SUSPEND);
|
||||
if (error) {
|
||||
last_dev = suspend_stats.last_failed_dev + REC_FAILED_NUM - 1;
|
||||
last_dev %= REC_FAILED_NUM;
|
||||
printk(KERN_ERR "PM: late suspend of devices failed\n");
|
||||
log_suspend_abort_reason("%s device failed to power down",
|
||||
suspend_stats.failed_devs[last_dev]);
|
||||
goto Platform_finish;
|
||||
}
|
||||
error = platform_suspend_prepare_late(state);
|
||||
@@ -330,7 +336,11 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
|
||||
|
||||
error = dpm_suspend_noirq(PMSG_SUSPEND);
|
||||
if (error) {
|
||||
last_dev = suspend_stats.last_failed_dev + REC_FAILED_NUM - 1;
|
||||
last_dev %= REC_FAILED_NUM;
|
||||
printk(KERN_ERR "PM: noirq suspend of devices failed\n");
|
||||
log_suspend_abort_reason("noirq suspend of %s device failed",
|
||||
suspend_stats.failed_devs[last_dev]);
|
||||
goto Platform_early_resume;
|
||||
}
|
||||
error = platform_suspend_prepare_noirq(state);
|
||||
@@ -354,8 +364,10 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
|
||||
}
|
||||
|
||||
error = disable_nonboot_cpus();
|
||||
if (error || suspend_test(TEST_CPUS))
|
||||
if (error || suspend_test(TEST_CPUS)) {
|
||||
log_suspend_abort_reason("Disabling non-boot cpus failed");
|
||||
goto Enable_cpus;
|
||||
}
|
||||
|
||||
arch_suspend_disable_irqs();
|
||||
BUG_ON(!irqs_disabled());
|
||||
@@ -371,6 +383,9 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
|
||||
state, false);
|
||||
events_check_enabled = false;
|
||||
} else if (*wakeup) {
|
||||
pm_get_active_wakeup_sources(suspend_abort,
|
||||
MAX_SUSPEND_ABORT_LEN);
|
||||
log_suspend_abort_reason(suspend_abort);
|
||||
error = -EBUSY;
|
||||
}
|
||||
syscore_resume();
|
||||
@@ -418,6 +433,7 @@ int suspend_devices_and_enter(suspend_state_t state)
|
||||
error = dpm_suspend_start(PMSG_SUSPEND);
|
||||
if (error) {
|
||||
pr_err("PM: Some devices failed to suspend, or early wake event detected\n");
|
||||
log_suspend_abort_reason("Some devices failed to suspend, or early wake event detected");
|
||||
goto Recover_platform;
|
||||
}
|
||||
suspend_test_finish("suspend devices");
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#define MAX_WAKEUP_REASON_IRQS 32
|
||||
static int irq_list[MAX_WAKEUP_REASON_IRQS];
|
||||
static int irqcount;
|
||||
static bool suspend_abort;
|
||||
static char abort_reason[MAX_SUSPEND_ABORT_LEN];
|
||||
static struct kobject *wakeup_reason;
|
||||
static spinlock_t resume_reason_lock;
|
||||
|
||||
@@ -40,14 +42,18 @@ static ssize_t last_resume_reason_show(struct kobject *kobj, struct kobj_attribu
|
||||
int irq_no, buf_offset = 0;
|
||||
struct irq_desc *desc;
|
||||
spin_lock(&resume_reason_lock);
|
||||
for (irq_no = 0; irq_no < irqcount; irq_no++) {
|
||||
desc = irq_to_desc(irq_list[irq_no]);
|
||||
if (desc && desc->action && desc->action->name)
|
||||
buf_offset += sprintf(buf + buf_offset, "%d %s\n",
|
||||
irq_list[irq_no], desc->action->name);
|
||||
else
|
||||
buf_offset += sprintf(buf + buf_offset, "%d\n",
|
||||
irq_list[irq_no]);
|
||||
if (suspend_abort) {
|
||||
buf_offset = sprintf(buf, "Abort: %s", abort_reason);
|
||||
} else {
|
||||
for (irq_no = 0; irq_no < irqcount; irq_no++) {
|
||||
desc = irq_to_desc(irq_list[irq_no]);
|
||||
if (desc && desc->action && desc->action->name)
|
||||
buf_offset += sprintf(buf + buf_offset, "%d %s\n",
|
||||
irq_list[irq_no], desc->action->name);
|
||||
else
|
||||
buf_offset += sprintf(buf + buf_offset, "%d\n",
|
||||
irq_list[irq_no]);
|
||||
}
|
||||
}
|
||||
spin_unlock(&resume_reason_lock);
|
||||
return buf_offset;
|
||||
@@ -89,6 +95,25 @@ void log_wakeup_reason(int irq)
|
||||
spin_unlock(&resume_reason_lock);
|
||||
}
|
||||
|
||||
void log_suspend_abort_reason(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
spin_lock(&resume_reason_lock);
|
||||
|
||||
//Suspend abort reason has already been logged.
|
||||
if (suspend_abort) {
|
||||
spin_unlock(&resume_reason_lock);
|
||||
return;
|
||||
}
|
||||
|
||||
suspend_abort = true;
|
||||
va_start(args, fmt);
|
||||
snprintf(abort_reason, MAX_SUSPEND_ABORT_LEN, fmt, args);
|
||||
va_end(args);
|
||||
spin_unlock(&resume_reason_lock);
|
||||
}
|
||||
|
||||
/* Detects a suspend and clears all the previous wake up reasons*/
|
||||
static int wakeup_reason_pm_event(struct notifier_block *notifier,
|
||||
unsigned long pm_event, void *unused)
|
||||
@@ -97,6 +122,7 @@ static int wakeup_reason_pm_event(struct notifier_block *notifier,
|
||||
case PM_SUSPEND_PREPARE:
|
||||
spin_lock(&resume_reason_lock);
|
||||
irqcount = 0;
|
||||
suspend_abort = false;
|
||||
spin_unlock(&resume_reason_lock);
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user