Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1163827AbdDXAkv (ORCPT ); Sun, 23 Apr 2017 20:40:51 -0400 Received: from camailhost.cavium.com ([12.108.191.230]:18730 "EHLO camailhost.cavium.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163767AbdDXAkn (ORCPT ); Sun, 23 Apr 2017 20:40:43 -0400 X-Greylist: delayed 3191 seconds by postgrey-1.27 at vger.kernel.org; Sun, 23 Apr 2017 20:40:43 EDT From: Andrew Pinski To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Andrew Pinski Subject: [PATCH 2/2] arm64:vdso: Remove ISB from gettimeofday. Date: Sun, 23 Apr 2017 16:47:01 -0700 Message-Id: <1492991221-5156-2-git-send-email-apinski@cavium.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492991221-5156-1-git-send-email-apinski@cavium.com> References: <1492991221-5156-1-git-send-email-apinski@cavium.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1269 Lines: 40 ISB is normally required before mrs CNTVCT if we want the mrs to completed after the loads. In this case it is not. As we are taking the difference and if that difference was going to be negative, we just use the last counter value instead. Signed-off-by: Andrew Pinski --- arch/arm64/kernel/vdso/gettimeofday.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/vdso/gettimeofday.c b/arch/arm64/kernel/vdso/gettimeofday.c index a0ab8b1..cf3235a 100644 --- a/arch/arm64/kernel/vdso/gettimeofday.c +++ b/arch/arm64/kernel/vdso/gettimeofday.c @@ -117,10 +117,20 @@ static notrace u64 get_clock_shifted_nsec(u64 cycle_last, u64 mult) u64 res; /* Read the virtual counter. */ - isb(); + /* + * This normally requires an ISB but since we know the + * read of the last cycle will always be after the + * read of the values are valid word. + */ asm volatile("mrs %0, cntvct_el0" : "=r" (res) :: "memory"); - res = res - cycle_last; + /* + * If the current cycle is greater than the last, + * then get the difference. + */ + if (res > cycle_last) + res = res - cycle_last; + /* We can only guarantee 56 bits of precision. */ res &= ~(0xff00ul<<48); return res * mult; -- 2.7.4