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 X-Spam-Level: X-Spam-Status: No, score=-14.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF297C4320A for ; Fri, 20 Aug 2021 15:54:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA05161152 for ; Fri, 20 Aug 2021 15:54:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241269AbhHTPzC (ORCPT ); Fri, 20 Aug 2021 11:55:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:37778 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238296AbhHTPzB (ORCPT ); Fri, 20 Aug 2021 11:55:01 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 750F36113E; Fri, 20 Aug 2021 15:54:23 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mH6qb-006E0Q-Gi; Fri, 20 Aug 2021 16:54:21 +0100 Date: Fri, 20 Aug 2021 16:54:21 +0100 Message-ID: <87im00qfgy.wl-maz@kernel.org> From: Marc Zyngier To: Maulik Shah Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-gpio@vger.kernel.org, bjorn.andersson@linaro.org, linus.walleij@linaro.org, tkjos@google.com, lsrao@codeaurora.org Subject: Re: [PATCH v2 2/3] irqdomain: Fix irq_domain_trim_hierarchy() In-Reply-To: <1629373993-13370-3-git-send-email-mkshah@codeaurora.org> References: <1629373993-13370-1-git-send-email-mkshah@codeaurora.org> <1629373993-13370-3-git-send-email-mkshah@codeaurora.org> 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/27.1 (x86_64-pc-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: mkshah@codeaurora.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-gpio@vger.kernel.org, bjorn.andersson@linaro.org, linus.walleij@linaro.org, tkjos@google.com, lsrao@codeaurora.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 Thu, 19 Aug 2021 12:53:12 +0100, Maulik Shah wrote: > > Currently tail marker is moving along with parent domain > irq data. Fix this to initialize only once from where all > parent domain needs trimming. > > Also correct the valid irq chip check. > > Signed-off-by: Maulik Shah > --- > kernel/irq/irqdomain.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c > index 19e83e9..9f6187b 100644 > --- a/kernel/irq/irqdomain.c > +++ b/kernel/irq/irqdomain.c > @@ -1235,7 +1235,7 @@ static int irq_domain_trim_hierarchy(unsigned int virq) > */ > for (irqd = irq_data->parent_data; irqd; irq_data = irqd, irqd = irqd->parent_data) { > /* Can't have a valid irqchip after a trim marker */ > - if (irqd->chip && tail) > + if (!IS_ERR(irqd->chip) && tail) > return -EINVAL; > > /* Can't have an empty irqchip before a trim marker */ > @@ -1247,7 +1247,8 @@ static int irq_domain_trim_hierarchy(unsigned int virq) > if (PTR_ERR(irqd->chip) != -ENOTCONN) > return -EINVAL; > > - tail = irq_data; > + if (!tail) > + tail = irq_data; > } > } I think you have the wrong end of the stick. 'tail' represent the *unique* point in the hierarchy where you can have a trim marker: (1) If there is a valid irqchip after a trim marker, this is wrong (2) If there is a trim marker after another trim marker, this is wrong (3) If there is a NULL irqchip before a trim marker, this is wrong (4) If there is an error that isn't a trim marker, this is wrong (1) and (2) are captured by: if (irqd->chip && tail) (3) is captured by: if (!irqd->chip && !tail) (4) is captured by: if (IS_ERR(irqd->chip)) { /* Only -ENOTCONN is a valid trim marker */ if (PTR_ERR(irqd->chip) != -ENOTCONN) The expected usage is that: - there is a single potential trim marker in the hierarchy - all the irqd->chip pointers below the marker are NULL - all the irqd->chip before the marker are neither NULL nor an error I don't see any bug here. Thanks, M. -- Without deviation from the norm, progress is not possible.