PM: wakeup_reason: add 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>
Signed-off-by: Iliyan Malchev <malchev@google.com>
Change-Id: I3207f1844e3d87c706dfc298fb10e1c648814c5f
This commit is contained in:
Ruchi Kandoi 2014-10-29 10:36:27 -07:00 committed by Artem Borisov
parent c9816de694
commit 1154a48192
2 changed files with 37 additions and 8 deletions

View file

@ -20,7 +20,10 @@
#include <linux/types.h> #include <linux/types.h>
#define MAX_SUSPEND_ABORT_LEN 256
void log_wakeup_reason(int irq); void log_wakeup_reason(int irq);
void log_suspend_abort_reason(const char *fmt, ...);
const int* get_wakeup_reasons(size_t *len); const int* get_wakeup_reasons(size_t *len);
void clear_wakeup_reasons(void); void clear_wakeup_reasons(void);

View file

@ -31,6 +31,8 @@
#define MAX_WAKEUP_REASON_IRQS 32 #define MAX_WAKEUP_REASON_IRQS 32
static int irq_list[MAX_WAKEUP_REASON_IRQS]; static int irq_list[MAX_WAKEUP_REASON_IRQS];
static int irq_count; static int irq_count;
static bool suspend_abort;
static char abort_reason[MAX_SUSPEND_ABORT_LEN];
static struct kobject *wakeup_reason; static struct kobject *wakeup_reason;
static spinlock_t resume_reason_lock; static spinlock_t resume_reason_lock;
@ -45,6 +47,9 @@ static ssize_t last_resume_reason_show(struct kobject *kobj, struct kobj_attribu
int irq_no, buf_offset = 0; int irq_no, buf_offset = 0;
struct irq_desc *desc; struct irq_desc *desc;
spin_lock(&resume_reason_lock); spin_lock(&resume_reason_lock);
if (suspend_abort) {
buf_offset = sprintf(buf, "Abort: %s", abort_reason);
} else {
for (irq_no = 0; irq_no < irq_count; irq_no++) { for (irq_no = 0; irq_no < irq_count; irq_no++) {
desc = irq_to_desc(irq_list[irq_no]); desc = irq_to_desc(irq_list[irq_no]);
if (desc && desc->action && desc->action->name) if (desc && desc->action && desc->action->name)
@ -54,6 +59,7 @@ static ssize_t last_resume_reason_show(struct kobject *kobj, struct kobj_attribu
buf_offset += sprintf(buf + buf_offset, "%d\n", buf_offset += sprintf(buf + buf_offset, "%d\n",
irq_list[irq_no]); irq_list[irq_no]);
} }
}
spin_unlock(&resume_reason_lock); spin_unlock(&resume_reason_lock);
return buf_offset; return buf_offset;
} }
@ -116,6 +122,25 @@ void log_wakeup_reason(int irq)
spin_unlock(&resume_reason_lock); 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);
}
const int* get_wakeup_reasons(size_t *len) const int* get_wakeup_reasons(size_t *len)
{ {
*len = irq_count; *len = irq_count;
@ -126,6 +151,7 @@ void clear_wakeup_reasons(void)
{ {
spin_lock(&resume_reason_lock); spin_lock(&resume_reason_lock);
irq_count = 0; irq_count = 0;
suspend_abort = false;
spin_unlock(&resume_reason_lock); spin_unlock(&resume_reason_lock);
} }