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 3B710C636CC for ; Sat, 11 Feb 2023 12:53:30 +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=dHbFYq96l2KzbnjnRcE4KUxNO1BZSZ9DFYQwCfiwzbc=; b=wG+wvUdDBJWuVy AMq8ULH3/N/LRe/VXMyFE7X2PQsxBzP8RqeSj7gEBUVYqFZEDayk9e82gv+vjJ+yyO5Pf/zeOOn5U JQt0vFkk4ct8sy65Xf11D2B4V+RS5cJJEYtB6Z5kDBSRPKIWo089sJG3RbjM7OPiA9ao4ppO78T+X zK0quiqNeAixzfoUwc1On9wnuVpcpjUyW+8wwMxwUgUcIFmWJuP+op+l1o56A3RnvOInCYQfoNZfL PCm8+XIMda3d0s3Xf0U187DtuF0mG+wlTLzlEh6eo12n1diWkItnLordy1DNLwtOp0mGa6IsnnovA gAp920ZdzF6rBQTsivFg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQpMm-009U1F-Ff; Sat, 11 Feb 2023 12:52:32 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQpMj-009U03-3X for linux-arm-kernel@lists.infradead.org; Sat, 11 Feb 2023 12:52:31 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 60BE460C8A; Sat, 11 Feb 2023 12:52:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B674DC433D2; Sat, 11 Feb 2023 12:52:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676119947; bh=11MA0b6CpzloVrTiuOFhvwWnD9Pdb+4g/+U2RCMHG2A=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=fbRu3L8cmB7q4rXWF0tCpmE/CKfI0QX+ig4tTkTZK6YhIFvI780cK1ZGIYL9qD5sQ C3E4pWUoub+K05gL79enlHghQfGDpY9ZVUd7CyoDauwHczEDqi6uIvBwvSnnnLZ8pz yOVo2tpK182pOz6vAqNlmAh37WfhY2dIJRoLZnPDfhs/xz13WDcXh1lxu8j/JNzlTu /5F9Q/DcsZacFrpN+F7GQtlS6hbvrsWOh5znHIKHddN72WkS5PEPx4gXF2DFyVfw0P /czUTxBQU7lQ3kNXMYU0SLqNuKw0Bhi+rcoSB0SXafsbx/ZTwNxjVDZUOF+9imduHy A6Vl5CfEHmuaQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.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 1pQpMd-009Xqt-TT; Sat, 11 Feb 2023 12:52:25 +0000 Date: Sat, 11 Feb 2023 12:52:23 +0000 Message-ID: <867cwoz7nc.wl-maz@kernel.org> From: Marc Zyngier To: Johan Hovold Cc: Johan Hovold , Thomas Gleixner , x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Hsin-Yi Wang , Mark-PK Tsai Subject: Re: [PATCH v5 19/19] irqdomain: Switch to per-domain locking In-Reply-To: References: <20230209132323.4599-1-johan+linaro@kernel.org> <20230209132323.4599-20-johan+linaro@kernel.org> <86cz6izv48.wl-maz@kernel.org> <86bkm1zr59.wl-maz@kernel.org> <868rh5zhj6.wl-maz@kernel.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/28.2 (aarch64-unknown-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: johan@kernel.org, johan+linaro@kernel.org, tglx@linutronix.de, x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, hsinyi@chromium.org, mark-pk.tsai@mediatek.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-20230211_045229_315764_F6FC26AC X-CRM114-Status: GOOD ( 47.42 ) 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 AOn Sat, 11 Feb 2023 11:35:32 +0000, Johan Hovold wrote: > > On Fri, Feb 10, 2023 at 03:06:37PM +0000, Marc Zyngier wrote: > > On Fri, 10 Feb 2023 12:57:40 +0000, > > Johan Hovold wrote: > > > > > > On Fri, Feb 10, 2023 at 11:38:58AM +0000, Marc Zyngier wrote: > > > > On Fri, 10 Feb 2023 09:56:03 +0000, > > > > Johan Hovold wrote: > > > > > > > > @@ -1132,6 +1147,7 @@ struct irq_domain *irq_domain_create_hierarchy(struct irq_domain *parent, > > > > > > > else > > > > > > > domain = irq_domain_create_tree(fwnode, ops, host_data); > > > > > > > if (domain) { > > > > > > > + domain->root = parent->root; > > > > > > > domain->parent = parent; > > > > > > > domain->flags |= flags; > > > > > > > > > > > > So we still have a bug here, as we have published a domain that we > > > > > > keep updating. A parallel probing could find it in the interval and do > > > > > > something completely wrong. > > > > > > > > > > Indeed we do, even if device links should make this harder to hit these > > > > > days. > > > > > > > > > > > Splitting the work would help, as per the following patch. > > > > > > > > > > Looks good to me. Do you want to submit that as a patch that I'll rebase > > > > > on or should I submit it as part of a v6? > > > > > > > > Just take it directly. > > > > > > Ok, thanks. > > I've added a commit message and turned it into a patch to include in v6 > now: > > commit 3af395aa894c7df94ef2337e572e5e1710b4bbda (HEAD -> work) > Author: Marc Zyngier > Date: Thu Feb 9 16:00:55 2023 +0000 > > irqdomain: Fix domain registration race > > Hierarchical domains created using irq_domain_create_hierarchy() are > currently added to the domain list before having been fully initialised. > > This specifically means that a racing allocation request might fail to > allocate irq data for the inner domains of a hierarchy in case the > parent domain pointer has not yet been set up. > > Note that this is not really any issue for irqchip drivers that are > registered early via IRQCHIP_DECLARE() or IRQCHIP_ACPI_DECLARE(), but > could potentially cause trouble with drivers that are registered later > (e.g. when using IRQCHIP_PLATFORM_DRIVER_BEGIN(), gpiochip drivers, > etc.). > > Fixes: afb7da83b9f4 ("irqdomain: Introduce helper function irq_domain_add_hierarchy()") > Cc: stable@vger.kernel.org # 3.19 > ... > [ johan: add a commit message ] > Signed-off-by: Johan Hovold > > Could you just give your SoB for the diff here so I can credit you as > author? Thanks for that. Feel free to add: Signed-off-by: Marc Zyngier > > > > I guess this turns the "Use irq_domain_create_hierarchy()" patches into > > > fixes that should be backported as well. > > > > Maybe. Backports are not my immediate concern. > > Turns out all of those drivers are registered early via > IRQCHIP_DECLARE() or IRQCHIP_ACPI_DECLARE() so there shouldn't really be > any risk of hitting this race for those. > > > > But note that your proposed diff may not be sufficient to prevent > > > lookups from racing with domain registration generally. Many drivers > > > still update the bus token after the domain has been added (and > > > apparently some still set flags also after creating hierarchies I just > > > noticed, e.g. amd_iommu_create_irq_domain). > > > > The bus token should only rarely be a problem, as it is often set on > > an intermediate level which isn't directly looked-up by anything else. > > And if it did happen, it would probably result in a the domain not > > being found. > > > > Flags, on the other hand, are more problematic. But I consider this a > > driver bug which should be fixed independently. > > I agree. > > > > It seems we'd need to expose a separate allocation and registration > > > interface, or at least pass in the bus token to a new combined > > > interface. > > > > Potentially, yes. But this could come later down the line. I'm more > > concerned in getting this series into -next, as the merge window is > > fast approaching. > > I'll post a v6 first thing Monday if you can give me that SoB before > then. You should be all set. Please post the series at your earliest convenience, and I'll let i simmer in -next for a bit. Thanks, 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