power: Print wakeup reason and suspend timestamp

Print the kerel wakeup reason and the time of suspend and resume

PM: suspend entry 2019-11-12 01:51:03.621354693 UTC
Suspended for 7.479 seconds
Resume caused by IRQ 28, pm8xxx_rtc_alarm
PM: suspend exit 2019-11-12 01:51:13.487683073 UTC

Bug: 144326354
Change-Id: Idfa9fb7caf205e97bf40a34f2b400a9d34f65ef4
Signed-off-by: hsinyitseng <hsinyitseng@google.com>
This commit is contained in:
hsinyitseng
2019-11-12 15:26:32 +08:00
parent dc18951e79
commit e4191b898f
3 changed files with 18 additions and 1 deletions

View File

@@ -10,6 +10,7 @@
#include <linux/interrupt.h>
#include <linux/suspend.h>
#include <linux/syscore_ops.h>
#include <linux/wakeup_reason.h>
#include "internals.h"
@@ -21,6 +22,7 @@ bool irq_pm_check_wakeup(struct irq_desc *desc)
desc->depth++;
irq_disable(desc);
pm_system_irq_wakeup(irq_desc_get_irq(desc));
log_wakeup_reason(irq_desc_get_irq(desc));
return true;
}
return false;

View File

@@ -29,6 +29,7 @@
#include <linux/syscore_ops.h>
#include <linux/swait.h>
#include <linux/ftrace.h>
#include <linux/rtc.h>
#include <trace/events/power.h>
#include <linux/compiler.h>
#include <linux/moduleparam.h>
@@ -769,6 +770,18 @@ static int enter_state(suspend_state_t state)
return error;
}
static void pm_suspend_marker(char *annotation)
{
struct timespec ts;
struct rtc_time tm;
getnstimeofday(&ts);
rtc_time_to_tm(ts.tv_sec, &tm);
pr_info("suspend %s %d-%02d-%02d %02d:%02d:%02d.%09lu UTC\n",
annotation, tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec, ts.tv_nsec);
}
/**
* pm_suspend - Externally visible function for suspending the system.
* @state: System sleep state to enter.
@@ -783,6 +796,7 @@ int pm_suspend(suspend_state_t state)
if (state <= PM_SUSPEND_ON || state >= PM_SUSPEND_MAX)
return -EINVAL;
pm_suspend_marker("entry");
pr_info("suspend entry (%s)\n", mem_sleep_labels[state]);
#ifdef CONFIG_PM_SLEEP_MONITOR
@@ -801,6 +815,7 @@ int pm_suspend(suspend_state_t state)
stop_suspend_mon();
#endif
pm_suspend_marker("exit");
pr_info("suspend exit\n");
return error;
}

View File

@@ -76,7 +76,7 @@ void tk_debug_account_sleep_time(const struct timespec64 *t)
int bin = min(fls(t->tv_sec), NUM_BINS-1);
sleep_time_bin[bin]++;
pm_deferred_pr_dbg("Timekeeping suspended for %lld.%03lu seconds\n",
pr_info("Suspended for %lld.%03lu seconds\n",
(s64)t->tv_sec, t->tv_nsec / NSEC_PER_MSEC);
}