From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89DCDC001DE for ; Mon, 17 Jul 2023 09:19:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230059AbjGQJTP (ORCPT ); Mon, 17 Jul 2023 05:19:15 -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 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.