Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1584795pxb; Fri, 20 Aug 2021 08:56:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtb2xltYhUBq6UWRh3xC0vAFQm0lGeLQg6qnYmBdcAAwvFI58CdQXiwmqXF+DI7LiNRWxu X-Received: by 2002:aa7:df03:: with SMTP id c3mr22817428edy.348.1629474990863; Fri, 20 Aug 2021 08:56:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629474990; cv=none; d=google.com; s=arc-20160816; b=hr8OSqIVTV/8TaW0ieBoV2Pu8CxTBbNwYrilgTn+VW5Mt80nbNzRHvAw4TNhscpDdC LkHcIQcgVx/ZkWMHoxOFCmNcn4/QYaR4hYxJ9en+U0Qd8QaYHBKcBWZ9gNvruoLlCv9+ xQCEAaVJuhocWh7EYeEzUmIetN3uMg8hEer5JPnyMydsgg0pF3IFWQodnk1KMG+nvmLK pD1R4AEZgCXSIa0j0vnvvCUJGh661pZQ2O8VR53g1pHySpSfbvEZMvnnSAaeFuWndGmC 1rU3YOQ4A2yvSsfXckgmgBaiBHCls9JDWtbsUf7wR4mthAdMAtpKPGFoWjFH1p6L5wzA +k2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date; bh=HO7s+aF9yU0ZSpKNnR3NHntDi+O1aw/0iORuMONAwX0=; b=OyekdTxuD5W5nK4EcqZYeHBx0GS/3ZraVi0iCNi+4zhLxg67zmNF8gk+Gf7Qi77Ckx aA8IM3v630/2zJARiZfp/UBQ8mh+EDdmE5FCSCuB55YwaQnsw03WCfvL7aA0yS0eHYYF tGigCWw7saz8SmoXtyiYvEPCt1gMq4UBEQiE13lhE8qDUZ8RMuu0BiqnDRSznKmFh588 +hoNjZmALYLTvP5+zTJY3ZZqmGvYcdpVpE2pf8YM+H7OlkmLEwkcCmopc9vfz/Yvt+JE 8/V/RheHzfTJnFQF71ftiTdVAci4neoSmp7yMnmAF8HB2Wp3xv9DETuU2C/JJstl8lMD 7v7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j11si7481946edr.479.2021.08.20.08.56.07; Fri, 20 Aug 2021 08:56:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241250AbhHTPzC (ORCPT + 99 others); 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.