From bfcc95d87abb2c89c84b1cae558217ce12cb6643 Mon Sep 17 00:00:00 2001 From: Ryan Lattrel Date: Tue, 7 Jul 2020 16:22:48 -0500 Subject: [PATCH] (CR): alarmtimer: add debug to identify alarmtimers Based on KBA-200505201040 Print out timer wake-up info to debug the sources of pm8xxx_rtc_alarm wake-ups. Change-Id: I39f24dad0613a08844eefcd25076831589256e52 Signed-off-by: Ryan Lattrel Reviewed-on: https://gerrit.mot.com/1668046 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Ling Jin Submit-Approved: Jira Key Reviewed-on: https://gerrit.mot.com/1778266 Reviewed-by: Huosheng Liao --- fs/timerfd.c | 6 ++++++ kernel/time/alarmtimer.c | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/fs/timerfd.c b/fs/timerfd.c index 48305ba41e3c..c2d289795686 100644 --- a/fs/timerfd.c +++ b/fs/timerfd.c @@ -238,6 +238,12 @@ static __poll_t timerfd_poll(struct file *file, poll_table *wait) spin_lock_irqsave(&ctx->wqh.lock, flags); if (ctx->ticks) events |= EPOLLIN; + + if (ctx->expired && isalarm(ctx)) + pr_info("%s: comm:%s pid:%d exp:%llu\n", __func__, + current->comm, current->pid, + ktime_to_ms(ctx->t.alarm.node.expires)); + spin_unlock_irqrestore(&ctx->wqh.lock, flags); return events; diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 9bd4e492823b..1e716c953fcd 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -60,6 +60,7 @@ static struct wakeup_source *ws; /* rtc timer and device for setting alarm wakeups at suspend */ static struct rtc_timer rtctimer; static struct rtc_device *rtcdev; +static int alarm_debug = 0; static DEFINE_SPINLOCK(rtcdev_lock); /** @@ -215,6 +216,12 @@ static enum hrtimer_restart alarmtimer_fired(struct hrtimer *timer) alarmtimer_dequeue(base, alarm); spin_unlock_irqrestore(&base->lock, flags); + if(alarm_debug & 0x1){ + pr_info("%s: type=%d, func=%pf, exp:%llu\n", __func__, + alarm->type, alarm->function, ktime_to_ms(alarm->node.expires)); + alarm_debug &= 0xFE; + } + if (alarm->function) restart = alarm->function(alarm, base->gettime()); @@ -255,6 +262,7 @@ static int alarmtimer_suspend(struct device *dev) struct rtc_device *rtc; unsigned long flags; struct rtc_time tm; + struct alarm* min_timer = NULL; spin_lock_irqsave(&freezer_delta_lock, flags); min = freezer_delta; @@ -281,6 +289,7 @@ static int alarmtimer_suspend(struct device *dev) continue; delta = ktime_sub(next->expires, base->gettime()); if (!min || (delta < min)) { + min_timer = container_of(next, struct alarm, node); expires = next->expires; min = delta; type = i; @@ -289,6 +298,14 @@ static int alarmtimer_suspend(struct device *dev) if (min == 0) return 0; + if (min_timer){ + pr_info("%s: [%p]type=%d, func=%pf, exp:%llu\n", __func__, + min_timer, min_timer->type, min_timer->function, + ktime_to_ms(min_timer->node.expires)); + min_timer = NULL; + } + alarm_debug = 0x1; + if (ktime_to_ns(min) < 2 * NSEC_PER_SEC) { __pm_wakeup_event(ws, 2 * MSEC_PER_SEC); return -EBUSY;