From patchwork Tue Jul 18 17:25:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Salyzyn X-Patchwork-Id: 9849217 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D787B60392 for ; Tue, 18 Jul 2017 17:25:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA695285CB for ; Tue, 18 Jul 2017 17:25:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF2C9285CD; Tue, 18 Jul 2017 17:25:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3911285CC for ; Tue, 18 Jul 2017 17:25:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751725AbdGRRZk (ORCPT ); Tue, 18 Jul 2017 13:25:40 -0400 Received: from mail-pg0-f53.google.com ([74.125.83.53]:36556 "EHLO mail-pg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751676AbdGRRZh (ORCPT ); Tue, 18 Jul 2017 13:25:37 -0400 Received: by mail-pg0-f53.google.com with SMTP id u5so16157571pgq.3 for ; Tue, 18 Jul 2017 10:25:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=8KD7+oaq9RWXndd9muNWwIiFbgRXhrxIDg/pv4+J6Dw=; b=pPdYpe5/HLSbAwl7nXyoebXsqLVyxwvVdPDWzHpdgMRhGvuNQtrm9FN+4zFAjol1v6 z8qigYuTBd1emD/wOzaB1+DCmCuPCf4nORnpacuvEQPwc9ImLo7aP/VuogUjwPgMCID6 wbOxxDqTyvgCWL3Kszn3I4WCGULZv+z1ge5KWr3lBNPMdqkQIdBI05hPeMTQuIx7vmrI 73b+X52UincwEjqDr6ENiX7hAclZgKlki2YkTpF8dfH0WciTmnBklMi/jVcmcs3JnMxT c6y7pCIH6NAX5OJogWtmJOoparEm0wTDg1mb8ySh3G0WVrzf7u7j2HcbkQBQkZsTow7h eE2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=8KD7+oaq9RWXndd9muNWwIiFbgRXhrxIDg/pv4+J6Dw=; b=Y4Y6sdIFX2u7uuwsI8Sq9gpEg4Q21KnuGFVUd3Prki2aDXQwgekNGdbBIMVmz1V89D f2t4uvi4yffTakOrmEpKmBOoyUaWWVODC7Sf6hmWBbIJp/v0iZK0vgQMmKtY/9WS4Puy S8ZhC//CG35pTbj1iHI1oB504yZsZ4IWgWZO4Jm6aB1chN6+mChmAfa4Q0yC8OKg5Dle Dt/ERvXjSsHfn+EzyUA8MWw2eyQcwDxOGYWx96Ara8ggrMxoqRgwq1XUb7GWqhGaLDLz S/kUn79JJI8cXiqPKWE8wpAR55KvAx4eUNpfAy8noGsYQlFK9DRIgRZJnKOkWGEDoCW3 XNew== X-Gm-Message-State: AIVw111N+ABvbzKQXdMwwUvB8QqVj9ua+uPy465iBD8KIsU9CK5eJkuR S+8sG6XVakJFR2Kr X-Received: by 10.98.68.76 with SMTP id r73mr2813055pfa.152.1500398736813; Tue, 18 Jul 2017 10:25:36 -0700 (PDT) Received: from nebulus.mtv.corp.google.com ([100.98.120.17]) by smtp.gmail.com with ESMTPSA id u6sm4470722pgb.12.2017.07.18.10.25.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Jul 2017 10:25:36 -0700 (PDT) From: Mark Salyzyn To: linux-kernel@vger.kernel.org Cc: rjw@rjwysocki.net, len.brown@intel.com, pavel@ucw.cz, linux-pm@vger.kernel.org, a.zummo@towertech.it, alexandre.belloni@free-electrons.com, linux-rtc@vger.kernel.org, Mark Salyzyn Subject: [PATCH 1/4] rtc-lib: Add rtc_show_time(const char *prefix_msg) Date: Tue, 18 Jul 2017 10:25:23 -0700 Message-Id: <20170718172525.114514-1-salyzyn@android.com> X-Mailer: git-send-email 2.13.2.932.g7449e964c-goog Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Go directly to the rtc for persistent wall clock time and print. Useful if REALTIME is required to be logged in a low level power management function or when clock activities are suspended. An aid to permit user space alignment of kernel activities. Feature activated by CONFIG_RTC_SHOW_TIME. Signed-off-by: Mark Salyzyn --- drivers/rtc/Kconfig | 11 +++++++++++ drivers/rtc/rtc-lib.c | 16 ++++++++++++++++ include/linux/rtc.h | 5 +++++ 3 files changed, 32 insertions(+) diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 72419ac2c52a..7c308605bf42 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -5,6 +5,17 @@ config RTC_LIB bool +config RTC_SHOW_TIME + bool "rtc_show_time instrumentation" + select RTC_LIB + help + Activate rtc_show_time(const char *msg) wall clock time + instrumentation. + + The instrumentation is used to help triage and synchronize + kernel logs using CLOCK_MONOTONIC and user space activity + logs utilizing CLOCK_REALTIME references. + config RTC_MC146818_LIB bool select RTC_LIB diff --git a/drivers/rtc/rtc-lib.c b/drivers/rtc/rtc-lib.c index 1ae7da5cfc60..676d6a83e843 100644 --- a/drivers/rtc/rtc-lib.c +++ b/drivers/rtc/rtc-lib.c @@ -94,6 +94,22 @@ void rtc_time64_to_tm(time64_t time, struct rtc_time *tm) } EXPORT_SYMBOL(rtc_time64_to_tm); +#ifdef CONFIG_RTC_SHOW_TIME +void rtc_show_time(const char *prefix_msg) +{ + struct timespec ts; + struct rtc_time tm; + + getnstimeofday(&ts); + rtc_time_to_tm(ts.tv_sec, &tm); + pr_info("%s %d-%02d-%02d %02d:%02d:%02d.%09lu UTC\n", + prefix_msg ? prefix_msg : "Time:", + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec, ts.tv_nsec); +} +EXPORT_SYMBOL(rtc_show_time); +#endif + /* * Does the rtc_time represent a valid date/time? */ diff --git a/include/linux/rtc.h b/include/linux/rtc.h index 0a0f0d14a5fb..bf625e023799 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h @@ -22,6 +22,11 @@ extern int rtc_year_days(unsigned int day, unsigned int month, unsigned int year extern int rtc_valid_tm(struct rtc_time *tm); extern time64_t rtc_tm_to_time64(struct rtc_time *tm); extern void rtc_time64_to_tm(time64_t time, struct rtc_time *tm); +#ifdef CONFIG_RTC_SHOW_TIME +extern void rtc_show_time(const char *prefix_msg); +#else +#define rtc_show_time(prefix_msg) +#endif ktime_t rtc_tm_to_ktime(struct rtc_time tm); struct rtc_time rtc_ktime_to_tm(ktime_t kt);