From patchwork Tue Apr 23 15:46:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 2479741 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork1.kernel.org (Postfix) with ESMTP id 1A7FC3FCA5 for ; Tue, 23 Apr 2013 18:52:51 +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 1UUfUt-0007TN-C7; Tue, 23 Apr 2013 15:51:14 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UUfT6-0004Nc-QW; Tue, 23 Apr 2013 15:49:20 +0000 Received: from mailout4.samsung.com ([203.254.224.34]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UUfSx-0004Mk-5W for linux-arm-kernel@lists.infradead.org; Tue, 23 Apr 2013 15:49:12 +0000 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MLP00KPHT9O4980@mailout4.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 24 Apr 2013 00:49:10 +0900 (KST) X-AuditID: cbfee61b-b7f8e6d000000f44-a6-5176ad76af2d Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 7C.B0.03908.67DA6715; Wed, 24 Apr 2013 00:49:10 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MLP0032TT5SFQ80@mmp1.samsung.com>; Wed, 24 Apr 2013 00:49:10 +0900 (KST) From: Tomasz Figa To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 09/13] clocksource: samsung_pwm_timer: Work around rounding errors in clockevents core Date: Tue, 23 Apr 2013 17:46:30 +0200 Message-id: <1366731994-7478-10-git-send-email-t.figa@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1366731994-7478-1-git-send-email-t.figa@samsung.com> References: <1366731994-7478-1-git-send-email-t.figa@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrHLMWRmVeSWpSXmKPExsVy+t9jAd2ytWWBBi13eSz+TjrGbjFp3QEm iwOzH7JanPmta9G74CqbxdmmN+wWmx5fY7WYcX4fk8XaI3fZLU5d/8xmsX7GaxaLzZumMlsc m7GE0WLVrj+MDnwev39NYvT4u+oFs8fOWXfZPe5c28Pm8e7cOXaPzUvqPc7PWMjoceVEE6tH 35ZVjB6fN8kFcEVx2aSk5mSWpRbp2yVwZUyaeZ+54CZ3xaqz/1kbGC9ydjFycEgImEhcXJHW xcgJZIpJXLi3nq2LkYtDSGARo8SBZ7fZIZwuJol1s86wg1SxCahJfG54xAZiiwhoSEzpegxW xCxwiUli/q5NrCAJYYFsiSVb/rOA2CwCqhKrj94Ds3kFnCTmnljCCrFOXuLp/T6wQZxA8Z1H H4LZQgKOEkf/tjNNYORdwMiwilE0tSC5oDgpPddIrzgxt7g0L10vOT93EyM4lJ9J72Bc1WBx iFGAg1GJh/fFrLJAIdbEsuLK3EOMEhzMSiK81rOBQrwpiZVVqUX58UWlOanFhxilOViUxHkP tloHCgmkJ5akZqemFqQWwWSZODilGhgXsd/7NWO786MLKiseiPPPDD4vkNCd9PrWnbKWtNup j3/K7M9tlFMT5hAKMnj9b0+v5senhWEvPummdqrrFvsIbE33d1p8RIa3I7qhjrPh/wT5PXWx aZLbJsk3yV29JuR/Sn1n+9EJXh3tQiEWex9mVG4qty3awzHJVXRxZJ8dz5UHTCxdl5VYijMS DbWYi4oTAZ90fWphAgAA X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130423_114911_544694_B7C26869 X-CRM114-Status: GOOD ( 12.74 ) X-Spam-Score: -6.9 (------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-6.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [203.254.224.34 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: kgene.kim@samsung.com, arnd@arndb.de, devicetree-discuss@lists.ozlabs.org, tomasz.figa@gmail.com, kyungmin.park@samsung.com, linux-samsung-soc@vger.kernel.org, john.stultz@linaro.org, ben-linux@fluff.org, olof@lixom.net, thomas.abraham@linaro.org, tglx@linutronix.de, Tomasz Figa , m.szyprowski@samsung.com 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Due to rounding errors in clockevents core (in conversions between ticks and nsecs), it might happen that the set_next_event callback gets called with cycles = 0, causing the code to incorrectly program the PWM timer. This patch modifies the callback to program the timer for 1 tick, if received tick count value is 0. Signed-off-by: Tomasz Figa Signed-off-by: Kyungmin Park --- drivers/clocksource/samsung_pwm_timer.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/clocksource/samsung_pwm_timer.c b/drivers/clocksource/samsung_pwm_timer.c index 92b2f13..0234c8d 100644 --- a/drivers/clocksource/samsung_pwm_timer.c +++ b/drivers/clocksource/samsung_pwm_timer.c @@ -176,6 +176,19 @@ static void samsung_time_start(unsigned int channel, bool periodic) static int samsung_set_next_event(unsigned long cycles, struct clock_event_device *evt) { + /* + * This check is needed to account for internal rounding + * errors inside clockevents core, which might result in + * passing cycles = 0, which in turn would not generate any + * timer interrupt and hang the system. + * + * Another solution would be to set up the clockevent device + * with min_delta = 2, but this would unnecessarily increase + * the minimum sleep period. + */ + if (!cycles) + cycles = 1; + samsung_time_setup(pwm.event_id, cycles); samsung_time_start(pwm.event_id, false);