Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5371591rwp; Mon, 17 Jul 2023 03:01:03 -0700 (PDT) X-Google-Smtp-Source: APBJJlHjcrlAi8EHC5BJ25FbZLLmaFygQQts/TOCavyyuGR7XebS63WT+WWdYVnNl4skb15C87Bq X-Received: by 2002:a17:902:bd43:b0:1b3:c7c1:8ded with SMTP id b3-20020a170902bd4300b001b3c7c18dedmr9871834plx.27.1689588063157; Mon, 17 Jul 2023 03:01:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689588063; cv=none; d=google.com; s=arc-20160816; b=Rg4qAQf/Sk8u6nJo1EjV3i4GvKSwMUO/7XwejFiWON0L/Nr5EOvC/wryO3l7AqAUKH DSbcZdV9G/Nf6MD4p4QG+4DPt+Fr/WIyakq5GJibx1WKGTTwkDwAKg0vLbv/51pqkdZK n3b2e4I/ikhukCXj1rzs+WST/OEtrR0VmsEucXrV9gfQQ1LiLckx0MlAyBen8dU3AnOJ VQu8imhnw7H9Z6+lYM5807G7W93lVCLiUu3+QjNdJnYHGLRSsL3GucBNXc3jW+7rJyXl Sc+N62ovLgy7Ba6wCgs8i7McSbKFDElX2Su5uWm2HYAWJaWnj4lPAcYX1Nsqa4CRenH3 ljKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=oYA0HF5Pd/wFB5gdmfnpdRI1magtBtsMK5ptlpbkcUc=; fh=Sf8hp/bJdotUJhlaq5GTJYBexteZl6BpRsFRA2tF9cc=; b=K5f+mG7lvIzCJaz6VaUYDbb5v4AVYq58A2xKPR6BpFAxhMi6/HuY4FyLTwpQXX1z5S LlP7kMCqW5RWgiKUbuu9C7CyizrWp8b0qwzT/R33feEIeQ719jfVcS4gBXsj22jlO7HG Z533jjwbWHz3u8P/EfQxy68evB0GqB1WtDhjJvq4avbqYzbXR1HhmeKNLwNF9PFwboHN 5gfhqQAJBhzlCZI+fzJ2QAEjXbUPMqpGXCOGyl/8zBjA9MMtgZ/FW+s+E7OAMzA7Odu3 7Xsl6P7E1IdLJQKPqNwn4h2aDyLKPKRPlaWsckSD/idmRKPCpQQel+aMDqPeYQecVrI5 ItpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NufQfd26; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j8-20020a170903024800b001b8a56b9895si12040557plh.616.2023.07.17.03.00.50; Mon, 17 Jul 2023 03:01:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NufQfd26; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230027AbjGQJTO (ORCPT + 99 others); Mon, 17 Jul 2023 05:19:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229789AbjGQJTN (ORCPT ); Mon, 17 Jul 2023 05:19:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99DB9C7; Mon, 17 Jul 2023 02:19:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 311B260FE8; Mon, 17 Jul 2023 09:19:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 904A8C433C7; Mon, 17 Jul 2023 09:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689585550; bh=Wcib1LBx/BBld2MqJZG8YvcGDBjuhQ5mqQ4ubkArBbo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=NufQfd26YhM+kP3RPN7b0dUmAvYSYSJSRaNWpFSP3pbj+5P+dHhns8NR6tZX2LYkD FchQxUJD6Zug001eWkKE9s1P4FiFBqO0tJ5fROUUVK38J46FZKAe6/5gyxsBXnjjTP BDB6nIp4ue34sR8qTdNjXMJUn1vH52jGvcQpbCyp0BMwxp3vbRWQtF/DYeOVAZdGCh KSugYL4/g0Mhd1foZ7ZqmKhsaTxYNbVIBVha3/gfHjsBhkkdwJ3kcnPyWOvvOuFt14 9uTvSZr6WhcMNWUec73HCoSv7Lqk/sNzp0UJ93UDhqbxSU4VxvpCmGbgp1zZPlezXC wgRczdbAhKvyw== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1qLKNo-00DgDR-F1; Mon, 17 Jul 2023 10:19:08 +0100 Date: Mon, 17 Jul 2023 10:19:08 +0100 Message-ID: <867cqyvqsz.wl-maz@kernel.org> From: Marc Zyngier To: Cc: Mark Rutland , "Daniel Lezcano" , Thomas Gleixner , Matthias Brugger , AngeloGioacchino Del Regno , , , , , , , , Subject: Re: [PATCH] clocksource/drivers/arm_arch_timer: Disable timer before programming CVAL In-Reply-To: <20230717090735.19370-1-walter.chang@mediatek.com> References: <20230717090735.19370-1-walter.chang@mediatek.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: walter.chang@mediatek.com, mark.rutland@arm.com, daniel.lezcano@linaro.org, tglx@linutronix.de, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, wsd_upstream@mediatek.com, stanley.chu@mediatek.com, Chun-hung.Wu@mediatek.com, Freddy.Hsin@mediatek.com, stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 17 Jul 2023 10:07:34 +0100, wrote: > > From: Walter Chang > > Due to the fact that the use of `writeq_relaxed()` to program CVAL is > not guaranteed to be atomic, it is necessary to disable the timer before > programming CVAL. > > However, if the MMIO timer is already enabled and has not yet expired, > there is a possibility of unexpected behavior occurring: when the CPU > enters the idle state during this period, and if the CPU's local event > is earlier than the broadcast event, the following process occurs: > > tick_broadcast_enter() > tick_broadcast_oneshot_control(TICK_BROADCAST_ENTER) > __tick_broadcast_oneshot_control() > ___tick_broadcast_oneshot_control() > tick_broadcast_set_event() > clockevents_program_event() > set_next_event_mem() > > During this process, the MMIO timer remains enabled while programming > CVAL. To prevent such behavior, disable timer explicitly prior to > programming CVAL. > > Fixes: 8b82c4f883a7 ("clocksource/drivers/arm_arch_timer: Move MMIO timer programming over to CVAL") > Cc: stable@vger.kernel.org > Signed-off-by: Walter Chang Acked-by: Marc Zyngier M. -- Without deviation from the norm, progress is not possible.