All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 2/4] time: Print wall time at die and reboot
@ 2017-07-19 19:45 Mark Salyzyn
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Salyzyn @ 2017-07-19 19:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: rjw, len.brown, pavel, linux-pm, a.zummo, alexandre.belloni,
	linux-rtc, Mark Salyzyn

Permits power state and battery life diagnosis.

Feature activated by CONFIG_RTC_SHOW_TIME.

Signed-off-by: Mark Salyzyn <salyzyn@android.com>

v2:
- react to implementation move to kernel timekeeping from rtc_lib
- use late_initcall to ensure rtc_lib driver(s) are loaded

---
 kernel/time/rtc_show_time.c | 59 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/kernel/time/rtc_show_time.c b/kernel/time/rtc_show_time.c
index 19a8a0cc94f0..6c7b8ae6be0c 100644
--- a/kernel/time/rtc_show_time.c
+++ b/kernel/time/rtc_show_time.c
@@ -6,6 +6,8 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/kdebug.h>
+#include <linux/reboot.h>
 #include <linux/rtc.h>
 
 void rtc_show_time(const char *prefix_msg)
@@ -27,3 +29,60 @@ void rtc_show_time(const char *prefix_msg)
 #endif
 }
 EXPORT_SYMBOL(rtc_show_time);
+
+static int rtc_show_time_die_notify(struct notifier_block *self,
+		unsigned long event, void *data)
+{
+	if (event != DIE_OOPS)
+		return NOTIFY_DONE;
+	rtc_show_time("Oops");
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block rtc_show_time_die_nb = {
+	.notifier_call = rtc_show_time_die_notify,
+	.priority = 0,
+};
+
+static int rtc_show_time_reboot_notify(struct notifier_block *self,
+		unsigned long event, void *data)
+{
+	const char *txt;
+
+	switch (event) {
+	case SYS_RESTART:
+		txt = "Restart";
+		break;
+	case SYS_HALT:
+		txt = "Halt";
+		break;
+	case SYS_POWER_OFF:
+		txt = "Power-Off";
+		break;
+	default:
+		return NOTIFY_DONE;
+	}
+	rtc_show_time(txt);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block rtc_show_time_reboot_nb = {
+	.notifier_call = rtc_show_time_reboot_notify,
+	.priority = 0,
+};
+
+static __init int init_rtc_show_time(void)
+{
+	int ret;
+
+	ret = register_die_notifier(&rtc_show_time_die_nb);
+	if (ret)
+		pr_warn("Failed to register rtc_show_time die notifier\n");
+	ret = register_reboot_notifier(&rtc_show_time_reboot_nb);
+	if (ret)
+		pr_warn("Failed to register rtc_show_time reboot notifier\n");
+
+	return ret;
+}
+/* rtc driver needs to be loaded before this is truly functional */
+late_initcall(init_rtc_show_time);
-- 
2.14.0.rc0.284.gd933b75aa4-goog

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 2/4] time: Print wall time at die and reboot
  2017-07-18 21:21 Mark Salyzyn
@ 2017-07-18 22:06 ` Thomas Gleixner
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Gleixner @ 2017-07-18 22:06 UTC (permalink / raw)
  To: Mark Salyzyn
  Cc: linux-kernel, rjw, len.brown, pavel, linux-pm, a.zummo,
	alexandre.belloni, linux-rtc, Mark Salyzyn, Thierry Strudel

On Tue, 18 Jul 2017, Mark Salyzyn wrote:

> Permits power state and battery life diagnosis.

This changelog is useless as long as you do not explain in which whay that
permits power state and battery life diagnosis.

I really have a hard time to figure out why you need to print RTC time on
oops or any of the other actions. That whole thing looks pretty
overengineered for a dubious value.

What kind of information is the current stuff missing and how are you using
this new information for better diagnosis?

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2 2/4] time: Print wall time at die and reboot
@ 2017-07-18 21:21 Mark Salyzyn
  2017-07-18 22:06 ` Thomas Gleixner
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Salyzyn @ 2017-07-18 21:21 UTC (permalink / raw)
  To: linux-kernel
  Cc: rjw, len.brown, pavel, linux-pm, a.zummo, alexandre.belloni,
	linux-rtc, Mark Salyzyn, Mark Salyzyn, Thierry Strudel

Permits power state and battery life diagnosis.

Feature activated by CONFIG_RTC_SHOW_TIME.

Signed-off-by: Mark Salyzyn <salyzyn@android.com>

v2:
- react to implementation move to kernel timekeeping from rtc_lib
- use late_initcall to ensure rtc_lib driver(s) are loaded
---
 kernel/time/rtc_show_time.c | 59 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/kernel/time/rtc_show_time.c b/kernel/time/rtc_show_time.c
index bbf4f92abf4f..d52e2a76cd00 100644
--- a/kernel/time/rtc_show_time.c
+++ b/kernel/time/rtc_show_time.c
@@ -6,6 +6,8 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/kdebug.h>
+#include <linux/reboot.h>
 #include <linux/rtc.h>
 
 void rtc_show_time(const char *prefix_msg)
@@ -21,3 +23,60 @@ void rtc_show_time(const char *prefix_msg)
 		tm.tm_hour, tm.tm_min, tm.tm_sec, ts.tv_nsec);
 }
 EXPORT_SYMBOL(rtc_show_time);
+
+static int rtc_show_time_die_notify(struct notifier_block *self,
+		unsigned long event, void *data)
+{
+	if (event != DIE_OOPS)
+		return NOTIFY_DONE;
+	rtc_show_time("Oops");
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block rtc_show_time_die_nb = {
+	.notifier_call = rtc_show_time_die_notify,
+	.priority = 0,
+};
+
+static int rtc_show_time_reboot_notify(struct notifier_block *self,
+		unsigned long event, void *data)
+{
+	const char *txt;
+
+	switch (event) {
+	case SYS_RESTART:
+		txt = "Restart";
+		break;
+	case SYS_HALT:
+		txt = "Halt";
+		break;
+	case SYS_POWER_OFF:
+		txt = "Power-Off";
+		break;
+	default:
+		return NOTIFY_DONE;
+	}
+	rtc_show_time(txt);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block rtc_show_time_reboot_nb = {
+	.notifier_call = rtc_show_time_reboot_notify,
+	.priority = 0,
+};
+
+static __init int init_rtc_show_time(void)
+{
+	int ret;
+
+	ret = register_die_notifier(&rtc_show_time_die_nb);
+	if (ret)
+		pr_warn("Failed to register rtc_show_time die notifier\n");
+	ret = register_reboot_notifier(&rtc_show_time_reboot_nb);
+	if (ret)
+		pr_warn("Failed to register rtc_show_time reboot notifier\n");
+
+	return ret;
+}
+/* rtc driver needs to be loaded before this is truly functional */
+late_initcall(init_rtc_show_time);
-- 
2.13.2.932.g7449e964c-goog

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-07-19 19:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-19 19:45 [PATCH v2 2/4] time: Print wall time at die and reboot Mark Salyzyn
  -- strict thread matches above, loose matches on Subject: below --
2017-07-18 21:21 Mark Salyzyn
2017-07-18 22:06 ` Thomas Gleixner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.