From patchwork Sun Dec 4 00:51:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Brown X-Patchwork-Id: 13063700 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0B0F6C4332F for ; Sun, 4 Dec 2022 00:53:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: 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: List-Owner; bh=2Bu01Q6y/qI/isKYRxJqVxw08HrzuHRz008NXle2S/Y=; b=SzqMji4BlETyOF +m27GufzMlq55gLbSkChEK1UtO/0/EgqRV3IYHkpU51KyhUQwoIx6OrcJg1ERS91CYwSBSj3qzZ0/ Av5K6sMNCeL8sdXMn9wsHsiqPC+n2Jq798bcLvz2wCaC+GHyOct+IhU5E9OHkQt8GbGPuHMoZUiKM SYyAb88GNNibtVEht8SHVzHeEsMcxu1bqFjmn/pelfXXLcPci4OrggCyoyvJcMsskx8EpEIphl3VT YqM7S+MX8ggU0UyuuQIU1ZQbPUuvG0ab9SoeGdV9IYYHsY26VYukWen85N6tNgCpm7oFFKVkrbT3B djMjt00n5fieHahZl3WA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p1dEj-005xVo-Uj; Sun, 04 Dec 2022 00:52:06 +0000 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p1dEg-005xUK-Ip for linux-arm-kernel@lists.infradead.org; Sun, 04 Dec 2022 00:52:03 +0000 Received: by mail-pj1-x1033.google.com with SMTP id l22-20020a17090a3f1600b00212fbbcfb78so11642583pjc.3 for ; Sat, 03 Dec 2022 16:51:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schmorgal.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NMKDlQK6w5vM05cXeYbQoGa5PaT/kmzZOsaTUxGIqfw=; b=h04sl9uqFP4yjV+BzAe/1I6f4E74BUDWAxauN4tiRzlfYJPedxIKaPzEuIKqAan0lm NESPULc7hwRVj6zyICBZD/5Ur7C71H4XFZ2n/THytNgNX+F1+hZUA/FubuxOer9aRxUn 9NuwwRpdnvrIDh06KRn73YWOfzVQ63R6DIdSI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NMKDlQK6w5vM05cXeYbQoGa5PaT/kmzZOsaTUxGIqfw=; b=6GJkwiEEwKyx3dBNZiNWT0ZeplJ5T14ISYIvVLiEsxVbyPVDj4BUBWkIvRmZtK86kN v1oRGDoIiU9gmLGRBzUwGDbtlAc9PQQHrV8hd5c6NaI6PWdo1qOoLBb60yEZaPmBnVkn LCQBE3fKM2pXSEdQfeH1r+W5w5t2IrH7qaPsniLvsrHYXR3RFRiHOHLzltrNCzXcHe+d zsqajuwOrka9MPnEv8XQBZ9aGgzsxxRItMVX/aFVb7+ygZTIz+vre1EHWZjIDrEDAL/u 2+UkRHD9VfCFTkVZF4cbOyj3JYrQguuB3fKLlpiPinC0t99hV5IbQN8Ge9qbK/ufe1x3 aXSQ== X-Gm-Message-State: ANoB5plzL1NbPZiIVAGC24WaLfPfU3MZNI0qCjJNdZU5tLr+6G7dTPDU I2iEYTBGD5AgJBe3tGMXArSrPw== X-Google-Smtp-Source: AA0mqf6J3qV2CKsySZYd8rDtLINBQW/HTYZN+JEgB2qymluBQMwEw31K6Hi9ZlDjFbsA11bMunpWrA== X-Received: by 2002:a17:90a:67c4:b0:213:ba14:3032 with SMTP id g4-20020a17090a67c400b00213ba143032mr89152676pjm.111.1670115119242; Sat, 03 Dec 2022 16:51:59 -0800 (PST) Received: from doug-ryzen-5700G.. ([192.183.212.197]) by smtp.gmail.com with ESMTPSA id 24-20020a631358000000b004393f60db36sm6058977pgt.32.2022.12.03.16.51.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Dec 2022 16:51:58 -0800 (PST) From: Doug Brown To: Russell King , Lubomir Rintel Cc: soc@kernel.org, Rob Herring , Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Doug Brown Subject: [PATCH 2/2] ARM: mmp: fix timer_read delay Date: Sat, 3 Dec 2022 16:51:17 -0800 Message-Id: <20221204005117.53452-3-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221204005117.53452-1-doug@schmorgal.com> References: <20221204005117.53452-1-doug@schmorgal.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221203_165202_651842_B278542E X-CRM114-Status: GOOD ( 15.17 ) 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 timer_read() was using an empty 100-iteration loop to wait for the TMR_CVWR register to capture the latest timer counter value. The delay wasn't long enough. This resulted in CPU idle time being extremely underreported on PXA168 with CONFIG_NO_HZ_IDLE=y. Switch to the approach used in the vendor kernel, which implements the capture delay by reading TMR_CVWR a few times instead. Fixes: 49cbe78637eb ("[ARM] pxa: add base support for Marvell's PXA168 processor line") Signed-off-by: Doug Brown --- arch/arm/mach-mmp/time.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-mmp/time.c b/arch/arm/mach-mmp/time.c index 41b2e8abc9e6..708816caf859 100644 --- a/arch/arm/mach-mmp/time.c +++ b/arch/arm/mach-mmp/time.c @@ -43,18 +43,21 @@ static void __iomem *mmp_timer_base = TIMERS_VIRT_BASE; /* - * FIXME: the timer needs some delay to stablize the counter capture + * Read the timer through the CVWR register. Delay is required after requesting + * a read. The CR register cannot be directly read due to metastability issues + * documented in the PXA168 software manual. */ static inline uint32_t timer_read(void) { - int delay = 100; + uint32_t val; + int delay = 3; __raw_writel(1, mmp_timer_base + TMR_CVWR(1)); while (delay--) - cpu_relax(); + val = __raw_readl(mmp_timer_base + TMR_CVWR(1)); - return __raw_readl(mmp_timer_base + TMR_CVWR(1)); + return val; } static u64 notrace mmp_read_sched_clock(void)