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 0F32CC4707B for ; Thu, 18 Jan 2024 14:01:02 +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=+wMlZt++ShKI2HMZdSb2/2zBkwJH8D3/BeqCUpEqNCM=; b=wDE+0GR9UoHRKQ LkPwsyqNSPqY/Bd29dB+lJqPvBMzybRNPcUXTz8zN9IDBOR2i8SxxPbCbFn0uw+pa1Psz28JhMFRQ 7SoMCYm53SwZCt1hHHhBCrvfPHdVzxuH42dTdgbJrAq2jpvrWrD0Hr1A71b66E7q7PL17J1RS+mxY mfIaOxpVm4TlNNchruJ37eIvdWFUweWjLC3lY5YaREaWt64C3AbZi+RCiZqh9nHuz1uG7iuKsM7in ZY4hNsuiSPZ697DkXHrM84yLiCo+Bdp/94za9iEYM1YcnHSmeqXkaHyho7px2D6vZ3ZnUfRZUfjL3 9lr5Mil5zbPScBWNQ/Qw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQSwV-002uBf-1x; Thu, 18 Jan 2024 14:00:27 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rQSwS-002uAl-16 for linux-arm-kernel@lists.infradead.org; Thu, 18 Jan 2024 14:00:26 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id AF3FACE1FAD; Thu, 18 Jan 2024 14:00:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1F62C433F1; Thu, 18 Jan 2024 14:00:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705586420; bh=oePAFFYODLX4qKuT+hCCpKcLhpD+k+lB3GJAV7/Ee3I=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=aeM1B0J20cbeQQNXCaZYaGpdGrfTjZA7w/rSw+wgQTLOMuEDK6L+Ukg+Sgb3/JSJA hAlpHZDyGPIdHRDRIBo6Y8L8FBJMdIG23sEdQugEWqb/NNDkMfRGbXkbWhlP0jIOsD bQybv1OQBW1JI2UKxQhzqqQdV85Z+DGLOMAn90i0vgwkOvvwSY0Uz7Ak9XS2lRrB68 nX3ZYqnozKJSFtyeYFQPI9pgP+twQv8aYRz3ft6IS9ELPy70t8WZz/Y3Wr+xIgOkb4 ukG9Fe24G9lyL4NQtl2qxxbMk9QuF0E9ubeHPHIYzmXYg0/nAj4LJmaDkGriiigjBj dNVpWXmcbYc5A== Received: from sofa.misterjones.org ([185.219.108.64] helo=wait-a-minute.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 1rQSwL-00CiGO-Bx; Thu, 18 Jan 2024 14:00:17 +0000 Date: Thu, 18 Jan 2024 14:00:15 +0000 Message-ID: <871qaeyc5s.wl-maz@kernel.org> From: Marc Zyngier To: Dawei Li Cc: tglx@linutronix.de, sdonthineni@nvidia.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, set_pte_at@outlook.com Subject: Re: [PATCH 1/4] irqchip/gic-v3: Implement read polling with dedicated API In-Reply-To: <20240118112739.2000497-2-dawei.li@shingroup.cn> References: <20240118112739.2000497-1-dawei.li@shingroup.cn> <20240118112739.2000497-2-dawei.li@shingroup.cn> 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 (x86_64-pc-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: dawei.li@shingroup.cn, tglx@linutronix.de, sdonthineni@nvidia.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, set_pte_at@outlook.com 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-20240118_060024_783407_FE8E6FF3 X-CRM114-Status: GOOD ( 25.53 ) 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, 18 Jan 2024 11:27:36 +0000, Dawei Li wrote: > > Kernel provide read*_poll_* API family to support looping based polling > code pattern like below: > while (...) > { > val = op(addr); > condition = cond(val); > if (condition) > break; > > /* Maybe some timeout handling stuff */ > > cpu_relax(); > udelay(); > } > > As such, use readl_relaxed_poll_timeout_atomic() to implement atomic > register polling logic in gic-v3. > > Signed-off-by: Dawei Li > --- > drivers/irqchip/irq-gic-v3.c | 27 ++++++++------------------- > 1 file changed, 8 insertions(+), 19 deletions(-) > > diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c > index 98b0329b7154..b9d9375a3434 100644 > --- a/drivers/irqchip/irq-gic-v3.c > +++ b/drivers/irqchip/irq-gic-v3.c > @@ -19,6 +19,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -251,17 +252,11 @@ static inline void __iomem *gic_dist_base(struct irq_data *d) > > static void gic_do_wait_for_rwp(void __iomem *base, u32 bit) > { > - u32 count = 1000000; /* 1s! */ > + u32 val; > > - while (readl_relaxed(base + GICD_CTLR) & bit) { > - count--; > - if (!count) { > - pr_err_ratelimited("RWP timeout, gone fishing\n"); > - return; > - } > - cpu_relax(); > - udelay(1); > - } > + if (readl_relaxed_poll_timeout_atomic(base + GICD_CTLR, > + val, !(val & bit), 1, 1000000) == -ETIMEDOUT) If you are doing this, please use a constant such as USEC_PER_SEC for the timeout. And fix the alignment of the second line so that the parameters are aligned vertically. > + pr_err_ratelimited("RWP timeout, gone fishing\n"); > } > > /* Wait for completion of a distributor change */ > @@ -279,7 +274,6 @@ static void gic_redist_wait_for_rwp(void) > static void gic_enable_redist(bool enable) > { > void __iomem *rbase; > - u32 count = 1000000; /* 1s! */ > u32 val; > > if (gic_data.flags & FLAGS_WORKAROUND_GICR_WAKER_MSM8996) > @@ -301,14 +295,9 @@ static void gic_enable_redist(bool enable) > return; /* No PM support in this redistributor */ > } > > - while (--count) { > - val = readl_relaxed(rbase + GICR_WAKER); > - if (enable ^ (bool)(val & GICR_WAKER_ChildrenAsleep)) > - break; > - cpu_relax(); > - udelay(1); > - } > - if (!count) > + if (readl_relaxed_poll_timeout_atomic(rbase + GICR_WAKER, > + val, enable ^ (bool)(val & GICR_WAKER_ChildrenAsleep), > + 1, 1000000) == -ETIMEDOUT) > pr_err_ratelimited("redistributor failed to %s...\n", > enable ? "wakeup" : "sleep"); > } Same thing here. 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