From patchwork Sat May 15 02:14:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 12259353 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-22.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0AFC4C433ED for ; Sat, 15 May 2021 02:16:44 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8030261029 for ; Sat, 15 May 2021 02:16:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8030261029 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=VKpx0XwRJTzkf/APalcNiLftA/iaoWRitwTOGd/iHCo=; b=Esj2MicBq/p7NSYfDiYmALy6zL 3qld96n8TBHmuEngA90QZB9IudAgp77Q1Zebb9sMMZZg1H0sNGvuZjMDs2+14as8GSbZ2zrOua1dd sJkohBFpA5akmYMVftUNRavXGLoDWLePCcXdhTSQtSSCrBmxLsYF3qcZg3qiDcF+C5QbQIFtgU5ku 8k1ayJMiMkd/SXU4AsOtN7nr+glU0g/Pg5U3HQGyb312/8pqG5Va/toH+3kY6k9NXOXOpLmZ9iRke hMdKxanFjOs6Qb1IOQmOs5ZNYl+EwumEeOzmJEKLd2fwut5Rpau/yHfdNZPAbqyvF5g8Vn8q9CCbS 33vW6FHA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lhjpN-009UQl-E2; Sat, 15 May 2021 02:14:53 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lhjpJ-009UQf-SL for linux-arm-kernel@desiato.infradead.org; Sat, 15 May 2021 02:14:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=jGoXzPaLrTSMzrEWtvvGyydli2uRBq2EBIG4vZ4n6Zg=; b=QDHnHuWV24vrqdaCWe8GerL4FA d5PmHizSjZunUEnPoUazgjJ0XFrwkxgPz5n+PGZq8fnAQdZOZuX8aU2zaWtNEVReNIztw1WPYu2xj qvPKYv723f80uRttBlMOn3a9YHypV6abGv9sOTe5KvOROTGTfyB6llnoK8KhIdmbzj9lqWWV05E7L tgu7y2zMxuqkJUy0B4qLQ4NnxHLtzGEyGhI2suSHcRo6x1AUmLmplHEmAMXiMfAxI9gA/RFVvNRid ZsvwGEglz4sq1Yz65Fo87W9XxvB8/hi6IU3KC4cfpmHym0G4aHfbOjR8shdinc56ZXM/Ey8mV7iuI aUTpFfxw==; Received: from new3-smtp.messagingengine.com ([66.111.4.229]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lhjpF-00CM06-R0 for linux-arm-kernel@lists.infradead.org; Sat, 15 May 2021 02:14:47 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id D2ED9580A31; Fri, 14 May 2021 22:14:41 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 14 May 2021 22:14:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm2; bh=jGoXzPaLrTSMzrEWtvvGyydli2 uRBq2EBIG4vZ4n6Zg=; b=KErnfvg+jCMxthXD2KiR7t2nvj0CgfNLo2U+9Td3QC CXeLFGDKffF9iOKwbJ7blXYJUUPLqmDDBg1vxTXzHC8WVM80iAQZ/uEEwTVNF9PS dW+X/UyNJUUJDa2SeZ7tR7X4LTD3qWC+m99xuHOndDWqHxtEM5fAOgzUUjFX0OjB TW2qdRrmVMEQq4Gk+xHq58xpPFlmswHGEDd5Bc4/8QCE4JLxrnsHVhN8IzqmFET6 HYvE7khtaLKuVXedTeeFuZm+4Modtv6AUjtKv4yUoiCLeIDkEYTxiMaHlj5nbVja 3boDLntBJGgwNibk5/acK27FVdjoa7rAbm080+MDHJzw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=jGoXzPaLrTSMzrEWt vvGyydli2uRBq2EBIG4vZ4n6Zg=; b=ArAENFk73SO14+CczIfwVKHG4tH1MgnWI 6z0VGUX6GQjaUImiEx2zqg2qAqOWdueL+chYrrNEWULGHJUWubQkvSNLx6YAESPL hyMiFAec8FK8uvt3xOqYfEH1xSdAmNwNd7rGVdlzQyWLRWBYYDn1VElyDE8+uiPw FrCpVcjDp3N6rxbMJ4O2LSFSvCGw2OFdLPLtdffju/tKxIlLasUyTtBcQQjlZ2uZ p4N/4l2skAdm/qAwKre+7HWAwHtDiLKT3Jg64mJidm7hwp564C387kJ8YrJjd9hs smHf2eseDE/uRNZHDx/xW6uMcslsaesquc+j2LdGFxgaSGfmruEoQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdehkedguddvjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgggfestdekredtredttdenucfhrhhomhepufgrmhhuvghl ucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecuggftrf grthhtvghrnhepieffueefheeggffhveevgfdugeeujefgudekteegueelvefgfedujeek tdeiheelnecuffhomhgrihhnpehgihhthhhusgdrtghomhdpkhgvrhhnvghlrdhorhhgne cukfhppeejtddrudefhedrudegkedrudehudenucevlhhushhtvghrufhiiigvpedtnecu rfgrrhgrmhepmhgrihhlfhhrohhmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Received: from titanium.stl.sholland.net (70-135-148-151.lightspeed.stlsmo.sbcglobal.net [70.135.148.151]) by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 14 May 2021 22:14:40 -0400 (EDT) From: Samuel Holland To: Mark Rutland , Marc Zyngier , Daniel Lezcano , Thomas Gleixner Cc: Ondrej Jirman , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev, Samuel Holland , stable@vger.kernel.org, Roman Stratiienko Subject: [PATCH] clocksource/arm_arch_timer: Improve Allwinner A64 timer workaround Date: Fri, 14 May 2021 21:14:39 -0500 Message-Id: <20210515021439.55316-1-samuel@sholland.org> X-Mailer: git-send-email 2.26.3 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210514_191446_055408_DD1F48F3 X-CRM114-Status: GOOD ( 13.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Bad counter reads are experienced sometimes when bit 10 or greater rolls over. Originally, testing showed that at least 10 lower bits would be set to the same value during these bad reads. However, some users still reported time skips. Wider testing revealed that on some chips, occasionally only the lowest 9 bits would read as the anomalous value. During these reads (which still happen only when bit 10), bit 9 would read as the correct value. Reduce the mask by one bit to cover these cases as well. Cc: stable@vger.kernel.org Fixes: c950ca8c35ee ("clocksource/drivers/arch_timer: Workaround for Allwinner A64 timer instability") Reported-by: Roman Stratiienko Signed-off-by: Samuel Holland --- The tool used for testing is here: https://github.com/smaeul/timer-tools For examples of the 9-bit pattern, see the data here: https://github.com/8bitgc/timer-tools/tree/master/output I was able to reproduce the same pattern (although _extremely_ rarely) on 1 of the 8 A64 boards I currently have access to. This explanation is consistent with the earlier report here: https://lore.kernel.org/lkml/20200929111347.1967438-1-r.stratiienko@gmail.com/ In that report, the time went backward 20542 ns == 493 cycles @ 24 MHz, which matches the expected 2^9 == 512 cycles minus system call overhead. drivers/clocksource/arm_arch_timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index d0177824c518..f4881764bf8f 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -352,7 +352,7 @@ static u64 notrace arm64_858921_read_cntvct_el0(void) do { \ _val = read_sysreg(reg); \ _retries--; \ - } while (((_val + 1) & GENMASK(9, 0)) <= 1 && _retries); \ + } while (((_val + 1) & GENMASK(8, 0)) <= 1 && _retries); \ \ WARN_ON_ONCE(!_retries); \ _val; \