From patchwork Tue Nov 15 13:36:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mason X-Patchwork-Id: 9429841 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6B32060469 for ; Tue, 15 Nov 2016 13:39:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 586B12874A for ; Tue, 15 Nov 2016 13:39:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D5942880B; Tue, 15 Nov 2016 13:39:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 56F37287AA for ; Tue, 15 Nov 2016 13:39:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c6dvR-0003F9-Q5; Tue, 15 Nov 2016 13:37:25 +0000 Received: from smtp5-g21.free.fr ([212.27.42.5]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c6dvM-00039x-ME for linux-arm-kernel@lists.infradead.org; Tue, 15 Nov 2016 13:37:21 +0000 Received: from [172.27.0.114] (unknown [92.154.11.170]) (Authenticated sender: slash.tmp) by smtp5-g21.free.fr (Postfix) with ESMTPSA id 69C895FE49; Tue, 15 Nov 2016 14:36:33 +0100 (CET) To: Linux ARM From: Mason Subject: [PATCH] arm: spin one more cycle in timer-based delays Message-ID: <582B0F61.6030903@free.fr> Date: Tue, 15 Nov 2016 14:36:33 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0 SeaMonkey/2.40 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161115_053720_933296_F139C996 X-CRM114-Status: GOOD ( 10.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Sebastian Frias , Russell King , Jonathan Austin , Arnd Bergmann , Kevin Hilman , Peter De Schrijver , Will Deacon Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When polling a tick counter in a busy loop, one might sample the counter just *before* it is updated, and then again just *after* it is updated. In that case, while mathematically v2-v1 equals 1, only epsilon has really passed. So, if a caller requests an N-cycle delay, we spin until v2-v1 is strictly greater than N to avoid these random corner cases. Signed-off-by: Mason Reviewed-by: Douglas Anderson --- arch/arm/lib/delay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c index 69aad80a3af4..3f1cd15ca102 100644 --- a/arch/arm/lib/delay.c +++ b/arch/arm/lib/delay.c @@ -60,7 +60,7 @@ static void __timer_delay(unsigned long cycles) { cycles_t start = get_cycles(); - while ((get_cycles() - start) < cycles) + while ((get_cycles() - start) <= cycles) cpu_relax(); }