From patchwork Tue Sep 17 09:56:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ludovic Desroches X-Patchwork-Id: 2901681 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 94BC9BFF05 for ; Tue, 17 Sep 2013 09:58:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5696D20300 for ; Tue, 17 Sep 2013 09:58:22 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AA40E202CF for ; Tue, 17 Sep 2013 09:58:20 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VLs2y-0003qq-8R; Tue, 17 Sep 2013 09:58:16 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VLs2w-0000Zn-1t; Tue, 17 Sep 2013 09:58:14 +0000 Received: from eusmtp01.atmel.com ([212.144.249.242]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VLs2t-0000VN-Ch for linux-arm-kernel@lists.infradead.org; Tue, 17 Sep 2013 09:58:12 +0000 Received: from localhost (10.161.101.13) by eusmtp01.atmel.com (10.161.101.30) with Microsoft SMTP Server id 14.2.347.0; Tue, 17 Sep 2013 11:55:45 +0200 Date: Tue, 17 Sep 2013 11:56:00 +0200 From: Ludovic Desroches To: Marc Kleine-Budde Subject: Re: [PATCH] [PATCH] clocksource: tcb: fix min_delta calculation Message-ID: <20130917095600.GJ26819@ludovic.desroches@atmel.com> Mail-Followup-To: Marc Kleine-Budde , linux-kernel@vger.kernel.org, nicolas.ferre@atmel.com, Marc Pignat , john.stultz@linaro.org, kernel@pengutronix.de, Ronald Wahl , linux-arm-kernel@lists.infradead.org References: <1379077365-18458-1-git-send-email-mkl@pengutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1379077365-18458-1-git-send-email-mkl@pengutronix.de> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130917_055811_662927_2DFE0D09 X-CRM114-Status: GOOD ( 18.72 ) X-Spam-Score: -1.6 (-) Cc: nicolas.ferre@atmel.com, linux-kernel@vger.kernel.org, Marc Pignat , Ludovic Desroches , john.stultz@linaro.org, kernel@pengutronix.de, Ronald Wahl , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00, MSGID_MULTIPLE_AT, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hello Marc, On Fri, Sep 13, 2013 at 03:02:45PM +0200, Marc Kleine-Budde wrote: > The commit > > 77cc982 clocksource: use clockevents_config_and_register() where possible > > switches from manually calculating min_delta_ns (and others) and > clockevents_register_device() to automatic calculation via > clockevents_config_and_register(). During this conversation the "+ 1" in > > min_delta_ns = clockevent_delta2ns(1, &clkevt.clkevt) + 1; > > was lost. This leads to problems when programming clock events, resuling in > e.g. a sleep(2) sleeping more than 3 seconds. The "+ 1" was added in the > original code to fix a rounding problem in clockevent_delta2ns(), see > http://permalink.gmane.org/gmane.linux.kernel/549744 for background > information. > > This patch fixes the problem by increasing the min_delta to "2" ticks. Any reason to not do this: /* go go gadget! */ Then we can keep the same min_delta. One more question why doing the correction here and not in the delta2ns conversion function? Regards Ludovic > > Cc: Marc Pignat > Cc: Ronald Wahl > Acked-by: Shawn Guo > Signed-off-by: Marc Kleine-Budde > --- > Changes since v1: > - Improved description. Thanks to Ronald Wahl. > > drivers/clocksource/tcb_clksrc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/clocksource/tcb_clksrc.c b/drivers/clocksource/tcb_clksrc.c > index 8a61872..7cf6dc7 100644 > --- a/drivers/clocksource/tcb_clksrc.c > +++ b/drivers/clocksource/tcb_clksrc.c > @@ -197,7 +197,7 @@ static void __init setup_clkevents(struct atmel_tc *tc, int clk32k_divisor_idx) > > clkevt.clkevt.cpumask = cpumask_of(0); > > - clockevents_config_and_register(&clkevt.clkevt, 32768, 1, 0xffff); > + clockevents_config_and_register(&clkevt.clkevt, 32768, 2, 0xffff); > > setup_irq(irq, &tc_irqaction); > } > -- > 1.8.4.rc3 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --- a/drivers/clocksource/tcb_clksrc.c +++ b/drivers/clocksource/tcb_clksrc.c @@ -144,6 +144,9 @@ static void tc_mode(enum clock_event_mode m, struct clock_event_device *d) static int tc_next_event(unsigned long delta, struct clock_event_device *d) { + if (delta < d->min_delta_ticks) + delta = d->min_delta_ticks; + __raw_writel(delta, tcaddr + ATMEL_TC_REG(2, RC));