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 C6D3CC47422 for ; Fri, 19 Jan 2024 01:49:59 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uomdjZPqKTcntzzu1exxGlCZVu7R6YBwnEN2DFA/R18=; b=NxAfSUGzTZh2Lq glP086eA36K98XLyfsq8ZK54oDxKSVCXtyW+LC+dAcywCFvOpZ5mhWOonBBubzPf5megV3PUFFzdO t2aeflbS0kJ0x/I+QZmHAwzYRkNmXH8lqkUBQLn0h/nDVYF4GkvhPm35NvF4AkRki4RguJy6BGJ+Y 6HeQ1wUE3+gs5/lYTj28ipb2blK0JcyI8Qc/TUdFTuAMWJ0RWnpYvuiuskHzaGH69P1c8/vzYC5Iz SFbsDwjWvEcsM41Bd1vcLQ65DDGGHFhAckU8n1m/orq+qz0L8pE22TKkO8AIZkVRkmp1V6oYQlSjl zBd3Lj2vLG7hN/VVp5jQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQe0h-004Fle-0C; Fri, 19 Jan 2024 01:49:31 +0000 Received: from smtpbgbr2.qq.com ([54.207.22.56]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rQe0c-004Fi4-1s for linux-arm-kernel@lists.infradead.org; Fri, 19 Jan 2024 01:49:29 +0000 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> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <871qaeyc5s.wl-maz@kernel.org> X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:shingroup.cn:qybglogicsvrgz:qybglogicsvrgz5a-1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240118_174927_417474_8D772244 X-CRM114-Status: GOOD ( 26.73 ) 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 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. > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel