From patchwork Thu Apr 30 17:19:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 47873 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4543A20553 for ; Thu, 30 Apr 2015 17:19:15 +0000 (UTC) Received: by lamp14 with SMTP id p14sf17759337lam.3 for ; Thu, 30 Apr 2015 10:19:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=uVA9UGpT9uDNGUYqPwGu81rUfbZ0Fw9AwLSrG7jFbFU=; b=ACgz5YkyBjoz9JxmmwzS47yxpxWAj3m1ke5V4yNj4DldZxfXLgSNa4RCKGjhHRvLXN d4mOzoRSNftzAtbFkFNg2fip4Nsok2Du+bDek/0vtoHv7W9sfdRiUsh6YmuAJxHc3n9V 2Om5TeXH1w01qLNPcO8eSQ7yufQ6kV9lYENS3s2HV54KxwCtb1RaXawQWTKBQt5r0mCJ eHic/utAk3dfejPnTmHO5QQwGzoMD9AFkrTqgdDBz4wemaQ64XLrj1cfIZ0LpN885U8J iVWSZ/dPuJE0ixETT5eeEsEwjGmeRzfjCyXwCaNEF81McjXYMhZ+8KXIqeSIzPnLkLUy 4r6g== X-Gm-Message-State: ALoCoQlPngP9Mq8Jl25hDWaXjnLTmGsj84mljPSqO2zKbX/hbPfTye3J+hcguv/H8IgW9E3FYm5L X-Received: by 10.180.10.136 with SMTP id i8mr2309357wib.7.1430414354214; Thu, 30 Apr 2015 10:19:14 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.179.232 with SMTP id dj8ls412741lac.74.gmail; Thu, 30 Apr 2015 10:19:14 -0700 (PDT) X-Received: by 10.112.40.9 with SMTP id t9mr4875362lbk.55.1430414354059; Thu, 30 Apr 2015 10:19:14 -0700 (PDT) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id j2si2198334lbd.98.2015.04.30.10.19.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Apr 2015 10:19:13 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by layy10 with SMTP id y10so49545553lay.0 for ; Thu, 30 Apr 2015 10:19:13 -0700 (PDT) X-Received: by 10.152.36.161 with SMTP id r1mr4829431laj.88.1430414353774; Thu, 30 Apr 2015 10:19:13 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.67.65 with SMTP id l1csp3243554lbt; Thu, 30 Apr 2015 10:19:13 -0700 (PDT) X-Received: by 10.66.229.9 with SMTP id sm9mr7166908pac.1.1430414351360; Thu, 30 Apr 2015 10:19:11 -0700 (PDT) Received: from mail-pa0-f44.google.com (mail-pa0-f44.google.com. [209.85.220.44]) by mx.google.com with ESMTPS id gl1si4369768pbd.121.2015.04.30.10.19.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Apr 2015 10:19:11 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.44 as permitted sender) client-ip=209.85.220.44; Received: by pabtp1 with SMTP id tp1so65682344pab.2 for ; Thu, 30 Apr 2015 10:19:10 -0700 (PDT) X-Received: by 10.68.131.196 with SMTP id oo4mr9976667pbb.119.1430414349922; Thu, 30 Apr 2015 10:19:09 -0700 (PDT) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id om4sm2709058pdb.68.2015.04.30.10.19.08 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 30 Apr 2015 10:19:09 -0700 (PDT) From: John Stultz To: Trevor Cordes Cc: John Stultz Subject: [PATCH] ktime_to_us/ms debug patch Date: Thu, 30 Apr 2015 10:19:05 -0700 Message-Id: <1430414345-28639-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- drivers/media/rc/ir-lirc-codec.c | 3 +++ include/linux/ktime.h | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) 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)