Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3746539pxk; Tue, 29 Sep 2020 05:22:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTLyh2m+Dbbw3kE1tyg/AQntUCnTXUgGLyPn0bWiKHcGNrOPFeW3bSTFtDTN9w2b1iaIWc X-Received: by 2002:a17:906:b784:: with SMTP id dt4mr3820551ejb.376.1601382178642; Tue, 29 Sep 2020 05:22:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601382178; cv=none; d=google.com; s=arc-20160816; b=d9eLnBy2/KHbo7UZIm4Vb8UwyIZRXKQRJTkX648nUPIEICTJVucEPEh5D3vbJMOvrN xzGokAkhwsCOpPv7SLK/DnV6S0c/G2kamMYs89Jl1i7pxpQltTStUgmNdeA9bCDydwZy 3Seae9zMO3fDfO0nVtgcbUXSfqizMXdexmTFnvJYGI60huZqH/GugoEU7W1eJEZRBZJj 7/5Pgz7H/fSKYlzJww6H0W7YJ835lMQvBkwE/tSgiuT0yZRlK755OKcbbT5NhpzdyZnL whtlbtQPI/W8Gyw9G+irQpg3Mohz9etwTHLoHs75pctNiJtHnJynvM7pAFjp6/bzFmei imAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=2MUnuYHY3oV7EyFwhMCZ7MQn1p4XGm2QgvaBdCasgNk=; b=qF1odh2kyG+NyMQCgeGYDgx0A9gbC/d+HpvEswoykG+zc1O3liCi9NPuyOhQ70FtAR Q63aEgpW2dkS11Nb1ukxrIl/ckkCvVqaSIoJWPGuNZAP/DypqioQJo+JWrWGMva8FHxb GaVZLhtBJcww1C25g6flcbi/kNZIlISrykdUh/eNoR8mq7Sj+gzLm7s+q2vVwR0Q6Ksx gltXLa1VxpSqqKd4FwosBj6wbz2X4WOagyTTqKOtOsh5GBRgNywqILn/KVCAkag3IHOq C1AkHJTl8eE79rI+q5V75lA4ufnPYpXOg+gftF3GPts9+xTNEHe1qMGKoVzQT2qfhcVZ Oq8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@megous.com header.s=mail header.b=BXPssIoL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=megous.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i7si1841781ejo.472.2020.09.29.05.22.35; Tue, 29 Sep 2020 05:22:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@megous.com header.s=mail header.b=BXPssIoL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=megous.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732537AbgI2MVg (ORCPT + 99 others); Tue, 29 Sep 2020 08:21:36 -0400 Received: from vps.xff.cz ([195.181.215.36]:51274 "EHLO vps.xff.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729822AbgI2LfW (ORCPT ); Tue, 29 Sep 2020 07:35:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megous.com; s=mail; t=1601379320; bh=NYesYDM0ZLiT5Nd37jm/2orVxg1+VI1tpstJHtB2iwc=; h=Date:From:To:Cc:Subject:References:X-My-GPG-KeyId:From; b=BXPssIoLK58jxGGdh3oWBFqmOG0oAUyMMFee7FzK7Pu/QztXqe05NKQJrYh/WoLjn vDN8Kjnhi6zYRRuGUcAkdQN4y9t9/oCzXXv/nXdLUxYK6DAZA7YdPfRf+MEe1WRxZe omGBFLhJSsKQfeSvkqfTFanXdGik98nq9QVznuIk= Date: Tue, 29 Sep 2020 13:35:19 +0200 From: =?utf-8?Q?Ond=C5=99ej?= Jirman To: Roman Stratiienko Cc: linux-sunxi@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] RFC: arm64: arch_timer: Fix timer inconsistency test for A64 Message-ID: <20200929113519.b2vydqmhcivvbwom@core.my.home> Mail-Followup-To: =?utf-8?Q?Ond=C5=99ej?= Jirman , Roman Stratiienko , linux-sunxi@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20200929111347.1967438-1-r.stratiienko@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200929111347.1967438-1-r.stratiienko@gmail.com> X-My-GPG-KeyId: EBFBDDE11FB918D44D1F56C1F9F0A873BE9777ED Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Roman, On Tue, Sep 29, 2020 at 02:13:47PM +0300, Roman Stratiienko wrote: > Fixes linux_kselftest:timers_inconsistency-check_arm_64 > > Test logs without the fix: > ''' > binary returned non-zero. Exit code: 1, stderr: , stdout: > Consistent CLOCK_REALTIME > 1601335525:467086804 > 1601335525:467087554 > 1601335525:467088345 > 1601335525:467089095 > 1601335525:467089887 > 1601335525:467090637 > 1601335525:467091429 > 1601335525:467092179 > 1601335525:467092929 > 1601335525:467093720 > 1601335525:467094470 > 1601335525:467095262 > 1601335525:467096012 > 1601335525:467096804 > -------------------- > 1601335525:467097554 > 1601335525:467077012 > -------------------- > 1601335525:467099095 > 1601335525:467099845 > 1601335525:467100637 > 1601335525:467101387 > 1601335525:467102179 > 1601335525:467102929 > ''' Can you reproduce the issue with a fixed CPU frequency. I suspect the root cause is around CPU frequency scaling code on A64, and timer jumps happen when the kernel is changing CPU frequency. I fixed a similar issue on H3 SoC just by changing the CPU frequency scaling code, without having to touch the timer readout code. https://megous.com/git/linux/commit/?h=ths-5.9&id=51ff1a6d80126f678efca42555f93efa611f50c4 regards, o. > Signed-off-by: Roman Stratiienko > CC: linux-arm-kernel@lists.infradead.org > CC: linux-kernel@vger.kernel.org > CC: linux-sunxi@googlegroups.com > CC: megous@megous.com > --- > drivers/clocksource/arm_arch_timer.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c > index 6c3e841801461..d50aa43cb654b 100644 > --- a/drivers/clocksource/arm_arch_timer.c > +++ b/drivers/clocksource/arm_arch_timer.c > @@ -346,16 +346,17 @@ static u64 notrace arm64_858921_read_cntvct_el0(void) > * number of CPU cycles in 3 consecutive 24 MHz counter periods. > */ > #define __sun50i_a64_read_reg(reg) ({ \ > - u64 _val; \ > + u64 _val1, _val2; \ > int _retries = 150; \ > \ > do { \ > - _val = read_sysreg(reg); \ > + _val1 = read_sysreg(reg); \ > + _val2 = read_sysreg(reg); \ > _retries--; \ > - } while (((_val + 1) & GENMASK(9, 0)) <= 1 && _retries); \ > + } while (((_val2 - _val1) > 0x10) && _retries); \ > \ > WARN_ON_ONCE(!_retries); \ > - _val; \ > + _val2; \ > }) > > static u64 notrace sun50i_a64_read_cntpct_el0(void) > -- > 2.25.1 >