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 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 8A1F5C77B7A for ; Thu, 25 May 2023 16:45:06 +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: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UX9UROIPdxDEk0bN0+XVwhp2o2mVHD/D1sd2+M0HjJw=; b=iqQeULPsncjDSG Ir9AapmkpAD6PlG+f44JCeXRUMfUjyNfvk0FacGMof4fCLEDml0lrZcoAf0tFO6Rbkhf/pORgbUJP Jdzqn+dYLBF62SfiEbKlRcKLqED+T5DdUSkn77MYjE1Ioz32uDIv2zYJh16xS67QpMnVXdJSRkn0e V965PjXQfQnWhttC8d9dVk8rnvPyiIdA2CdvWgntW1HFHQvWqTUsqFBPo79ep4d11WCXrnb7RKZVL 0MRFSjzE/w+y169zABEqJTgC2B5jnAkkb8q/QqSHzhW7VXq4W/z9oYPXoEPFnxorbKATfONEPGzEV KssPRsalpkVWYDbzc9mg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q2E4u-00H7lG-0J; Thu, 25 May 2023 16:44:40 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q2E4q-00H7kJ-0v for linux-arm-kernel@lists.infradead.org; Thu, 25 May 2023 16:44:38 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2F1DD60ADE; Thu, 25 May 2023 16:44:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C7EAC433EF; Thu, 25 May 2023 16:44:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685033074; bh=x2ehhytndM+N0YkKWG+7HE9EdElBfDgJezzgelgg1BM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=TfBiq/y/UOB0ph0+U1GENg/TWOYpiNgjtB01+CDeL+1aoxJbpcATLKiyRLG3CBgSm 37yS/2Jy54VsdYAMByvtW8g/AdYQFDOJF8IUJ29cUUhEOHREEzno/9iSF9LFudgWgL BpPJmnzlMgyh7Cng3pgGr6jS2Lj4oSxhha8MQQmO0QZbfCA/TR/1s79bRfUn7k7fEm K9AX5YjlhgtJrdAcXXto3OBFsXrEw5YKMItjn2gsg4t6fsQcoOJmnHRrpJ6U+I9wCI PvDBrzKymgsMFtCYTAf99Kbpk9fkdyhYTpb0MeEYh6Upvjz3lWC4ZEeTfQ+Q2hgCwv wc8M/BFI5DsMg== 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 1q2E4m-000M4F-6G; Thu, 25 May 2023 17:44:32 +0100 Date: Thu, 25 May 2023 17:44:31 +0100 Message-ID: <86mt1scqds.wl-maz@kernel.org> From: Marc Zyngier To: Ayan Kumar Halder Cc: stefano.stabellini@xilinx.com, sstabellini@kernel.org, julien@xen.org, bertrand.marquis@arm.com, mark.rutland@arm.com, daniel.lezcano@linaro.org, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1] arm: clocksource: Check if timer is enabled for timer irq In-Reply-To: <0c29756d-76ff-1fd5-09bb-0b13a5fddffd@amd.com> References: <20220811093620.16680-1-ayankuma@amd.com> <87pmh7un2o.wl-maz@kernel.org> <0c29756d-76ff-1fd5-09bb-0b13a5fddffd@amd.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") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: ayankuma@amd.com, stefano.stabellini@xilinx.com, sstabellini@kernel.org, julien@xen.org, bertrand.marquis@arm.com, mark.rutland@arm.com, daniel.lezcano@linaro.org, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230525_094436_428240_FBB9ED85 X-CRM114-Status: GOOD ( 32.72 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 25 May 2023 17:03:11 +0100, Ayan Kumar Halder wrote: > > Hi Marc, > > Apologies, this got lost in my mailbox. > > On 11/08/2022 10:49, Marc Zyngier wrote: > > On Thu, 11 Aug 2022 10:36:20 +0100, > > Ayan Kumar Halder wrote: > >> Refer ARM DDI 0487G.b, CNTP_CTL_EL0, > >> ISTATUS, bit [2] - When the value of the ENABLE bit is 1, ISTATUS > >> indicates whether the timer condition is met. > >> > >> Thus, one need to check ENABLE bit along with ISTATUS, to confirm > >> whether the timer condition is met. Further as the doc says, > >> "When the value of the ENABLE bit is 0, the ISTATUS field is UNKNOWN." > >> > >> Signed-off-by: Ayan Kumar Halder > >> --- > >> > >> Please refer to https://lore.kernel.org/all/6cfcd4fa-3afd-1c70-6a70-9df557ee1811@xen.org/T/ > >> for the previous discussion on this issue on xen-devel mailing list. > >> > >> 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 9ab8221ee3c6..96921772814c 100644 > >> --- a/drivers/clocksource/arm_arch_timer.c > >> +++ b/drivers/clocksource/arm_arch_timer.c > >> @@ -647,7 +647,7 @@ static __always_inline irqreturn_t timer_handler(const int access, > >> unsigned long ctrl; > >> ctrl = arch_timer_reg_read(access, ARCH_TIMER_REG_CTRL, evt); > >> - if (ctrl & ARCH_TIMER_CTRL_IT_STAT) { > >> + if ((ctrl & ARCH_TIMER_CTRL_IT_STAT) && (ctrl & ARCH_TIMER_CTRL_ENABLE)) { > >> ctrl |= ARCH_TIMER_CTRL_IT_MASK; > >> arch_timer_reg_write(access, ARCH_TIMER_REG_CTRL, ctrl, evt); > >> evt->event_handler(evt); > > And how can the timer be disabled if we're in the interrupt handler? > > I am not very sure about this. > > Is it possible for a pending interrupt to arrive just after the timer > has been disabled ? I can't see how. This is a level interrupt, so disabling it at the source also retires the pending bit from the GIC. And if what you describe actually happens, this is only a spurious interrupt and most probably a slightly broken interrupt controller implementation. Overall, this change doesn't make much sense, unless you can show me a HW implementation that is broken enough that this leads to actual problems. M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel