Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp719610rdb; Thu, 18 Jan 2024 17:49:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IFcu2zG7H1CVTvlloZEy3sbE6dMkmtMKGyygUszddi1iLdwKBw/2PIWMDVUkoW9n075mBtF X-Received: by 2002:ac8:5a0a:0:b0:429:e003:4197 with SMTP id n10-20020ac85a0a000000b00429e0034197mr1829209qta.32.1705628992536; Thu, 18 Jan 2024 17:49:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705628992; cv=pass; d=google.com; s=arc-20160816; b=gNIF1iSEFd+P+y0Lq4iXvSk/mWjSBW2F3N2BKd3G30/dck/9k38JTntEEesje3RS4Z pbCEaua+32q/GSbqzSsfG0Dgppy5k/P3wNaC7N38X+x5iby0LdPQYhdE6W+Vp7F5th/O 2F6I4WG2PqPP2vCRGmhaTPvzsKmHLENkeTu/Aqye9WRjnRhVgNoZMe0UmMUKQa+qNsMI VWW7yiivNYpcnbzNmuM9BrLG9ZEMmS2I//Lg2ZrUcCm09RyncILYaiUVqJfqktmiL39X LF8rbfZOlBcKFhfeiCAXIOub1OKlmZi4xErI0CwfSN8zml2KJPaFTzHy7tRTTSt4G8k8 CIsg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=feedback-id:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date; bh=6LBeBHeKjbHVfxywqeWNRz9nseGRSd4wgMMYNGOl3H4=; fh=xOdvY+/2e+PsPpd6z57MTJDdHhTP053mda2Awa60DvE=; b=SZmf4zNmvDtr93JYKcXpHHUi5j0w0QTMYr++qBixNlcf2oU8Pg3tiqcsds8RNJ3Y2I jLveeAVOnt/URF3awJh4ZFBsE/dENrUNc/nyOZ9slgvjZyVjteAmd6DjsiOPpzrqd4XT skse0+DOiPBrbPQtcapZLL1orGScjsULS1qLwswEoC9vnT4PlQH/JVr6xLFpahz+9XlY dZC5uqAgQJLtC2ziMPxeK83K36lh2sGTa6GyQ8Tjnqiw3nyV3LIVpNvU66/HvKj7nWpN R0BHhShgsM+POLdlzNJWx0AN9N4flrakjdtMP30n5JLdJ4CIcpE/or0qlQ4A87+fMPh8 Qj9w== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=shingroup.cn dmarc=pass fromdomain=shingroup.cn); spf=pass (google.com: domain of linux-kernel+bounces-30694-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30694-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=shingroup.cn Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id q10-20020a05622a04ca00b0042993049221si14938593qtx.253.2024.01.18.17.49.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 17:49:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30694-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=shingroup.cn dmarc=pass fromdomain=shingroup.cn); spf=pass (google.com: domain of linux-kernel+bounces-30694-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30694-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=shingroup.cn Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4C1BC1C22AD3 for ; Fri, 19 Jan 2024 01:49:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F10A120FD; Fri, 19 Jan 2024 01:49:45 +0000 (UTC) Received: from smtpbg151.qq.com (smtpbg151.qq.com [18.169.211.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7CAE1C30 for ; Fri, 19 Jan 2024 01:49:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=18.169.211.239 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705628985; cv=none; b=LP+I4OeNGv9+j++65VYLGtcw3FSDsPPtZS9+ezqM1tbBO8rdQB+VErr4LohENrboudtLIWHVU2GbQwJMAVgqm4Oa4CtOADFya2TyGmjUZ0nhuIPvg9u3CwcqIBwsxkzcqwZky62NsbyHJ4/gLDz3POUT0WIMjkiVkTMs8Q6iUv0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705628985; c=relaxed/simple; bh=T86wVEWIFt2hySqd2k7s7zDxzFY9oLKJqje1Rbam5oo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=RGw/zn3S7pRoZxlZwMzaoA8Ne67xeWBGE5Vd0nNZafpS6QGv8pl5OxFP6A2yr0MFvG0M6ZqFajiXwFYuODQ1XduHiHNJrsw+IS65efvBIJ4OmabedMLyA9hECRAWPl1mKijkekkrQWVQ7ls2wv4HR3IfEb6FwI2uzAxq4Qa5CLI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=shingroup.cn; spf=pass smtp.mailfrom=shingroup.cn; arc=none smtp.client-ip=18.169.211.239 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=shingroup.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shingroup.cn X-QQ-mid: bizesmtp87t1705628947tj4q10jx X-QQ-Originating-IP: j27BpN+p7rOsbd3ZNiDoHJmA3RCz0FD/Ud+l+7UNIYk= Received: from localhost ( [183.209.108.228]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 19 Jan 2024 09:49:06 +0800 (CST) X-QQ-SSF: 01400000000000504000000A0000000 X-QQ-FEAT: 1eRl5/SlfYPzYDWzAzOoN3fvsYciMkk4LPFMnXBW6M4C5F+GLp+GrljY2IaW2 uRPKsOdp4F3vT6wzGqPYwbFG7Erdvkm+UG6Gn0MlNZig+djbzibMlup3u5b6kBD75ZlR5SP cTO0/IwyZd4D2+C5DDtjK9ktRlaHD2wGCk4iGFUeGyuvXxVeBgxiBlRJmxOuD4mBM0qe2TG 35HWC/O8PRhzvYzD+BSir6mZ8zsbEE16WCaMtJEWykIHb/we+Vc55vJOg5qIgOFwCVTRl9D BP4Fa6bRgLBp4bnW+mqf9YSHCjDi+OWC37ywc7afTctTXtrdTRP2tz6URg/srZXcm5+Yg5j EcsDi0X3PgO/K2sxUyXQonMNpH3XHEXlPbgDdQYPAY5nmTlu+U1kEEcrBvH53xIOKZ0uhdM X-QQ-GoodBg: 2 X-BIZMAIL-ID: 7786004939020553288 Date: Fri, 19 Jan 2024 09:49:06 +0800 From: Dawei Li To: Marc Zyngier 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 Message-ID: References: <20240118112739.2000497-1-dawei.li@shingroup.cn> <20240118112739.2000497-2-dawei.li@shingroup.cn> <871qaeyc5s.wl-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <871qaeyc5s.wl-maz@kernel.org> X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:shingroup.cn:qybglogicsvrgz:qybglogicsvrgz5a-1 Hi Marc, Thanks for the quick review. On Thu, Jan 18, 2024 at 02:00:15PM +0000, Marc Zyngier wrote: > 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. Agreed, well defined constant is always preferable than magic number; And yes, alignment is for better readability. > > > + 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. Ack. I will address two issues above and send respin of V2. Thanks, Dawei > > M. > > -- > Without deviation from the norm, progress is not possible. >