diff mbox

ktime_to_us/ms debug patch

Message ID 1430414345-28639-1-git-send-email-john.stultz@linaro.org
State New
Headers show

Commit Message

John Stultz April 30, 2015, 5:19 p.m. UTC
Debug patch to try to sort out ktime_to_us/ms regressions

Mind running with this patch to see what it spits out, and
send me the resulting dmesg output?

Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 drivers/media/rc/ir-lirc-codec.c |  3 +++
 include/linux/ktime.h            | 33 +++++++++++++++++++++++++++++++--
 2 files changed, 34 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c
index 98893a8..3a75f58 100644
--- a/drivers/media/rc/ir-lirc-codec.c
+++ b/drivers/media/rc/ir-lirc-codec.c
@@ -173,6 +173,9 @@  static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf,
 	if (towait > 0) {
 		set_current_state(TASK_INTERRUPTIBLE);
 		schedule_timeout(usecs_to_jiffies(towait));
+	} else {
+		printk("JDB: ir_lirc_transmit_ir: towait is non-pos: %lld (start: %lld duration: %lld)\n",
+				towait, ktime_to_us(start), duration);
 	}
 
 out:
diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index c9d645a..647a598 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -171,14 +171,43 @@  extern u64 ktime_divns(const ktime_t kt, s64 div);
 # define ktime_divns(kt, div)		(u64)((kt).tv64 / (div))
 #endif
 
+
+static inline s64 _old_ktime_to_us(const ktime_t kt)
+{
+	struct timeval tv = ktime_to_timeval(kt);
+
+	return (s64) tv.tv_sec * USEC_PER_SEC + tv.tv_usec;
+}
+
+static inline s64 _old_ktime_to_ms(const ktime_t kt)
+{
+	struct timeval tv = ktime_to_timeval(kt);
+
+	return (s64) tv.tv_sec * MSEC_PER_SEC + tv.tv_usec / USEC_PER_MSEC;
+}
+
+
 static inline s64 ktime_to_us(const ktime_t kt)
 {
-	return ktime_divns(kt, NSEC_PER_USEC);
+	s64 ret = ktime_divns(kt, NSEC_PER_USEC);
+
+	if (ret != _old_ktime_to_us(kt)) {
+		printk("JDB: ktime_to_us: %lld -> divns %lld != old method: %lld\n",
+			ktime_to_ns(kt), ret, _old_ktime_to_us(kt));
+	}
+
+	return ret;
 }
 
 static inline s64 ktime_to_ms(const ktime_t kt)
 {
-	return ktime_divns(kt, NSEC_PER_MSEC);
+	s64 ret = ktime_divns(kt, NSEC_PER_MSEC);
+
+	if (ret != _old_ktime_to_ms(kt)) {
+		printk("JDB: ktime_to_ms: %lld -> divns %lld != old method: %lld\n",
+			ktime_to_ns(kt), ret, _old_ktime_to_ms(kt));
+	}
+	return ret;
 }
 
 static inline s64 ktime_us_delta(const ktime_t later, const ktime_t earlier)