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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57186C05027 for ; Mon, 20 Feb 2023 18:29:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232271AbjBTS3m (ORCPT ); Mon, 20 Feb 2023 13:29:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229885AbjBTS3k (ORCPT ); Mon, 20 Feb 2023 13:29:40 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36B42A5F6; Mon, 20 Feb 2023 10:29:37 -0800 (PST) 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 B528760F00; Mon, 20 Feb 2023 18:29:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13135C433D2; Mon, 20 Feb 2023 18:29:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676917776; bh=clAT3n/k8X8tP6cdwl4f2pTYp1TtDgAZr9dMJMVm6oY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=b9sn3KtIEpf9sndeVlU8BLTvB8JamyOUTD3dbtUs0EAqqO7dXHG0Gr3r5MZPVhsMo WW654PGhSniVmTCicvwAzutdcqW+yD/iFsXoEjYz7hnTQtQVZUYmSI6m+PEAjOB4mb Pz/ZuOftOQaMyntwzuwSirCWqWsIGDRPgawIGYXXXeWYQaL5qkPRWpR4EvFMvBNDzO KmSDtQcE3cjDZfLLYhN5eTNXAEYH2GeBnLL3cmtNSq+C3fDk6BtcOE9JpObLGpnbQr 7mj2DG0wQgs1ThNCERU0MPsUYM51hCcEEIHlRQjKt1++Dk1VMFj7c3s0YoKYCigX2b 9FaJ18qwJLW7g== 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 1pUAur-00BrsR-Fd; Mon, 20 Feb 2023 18:29:33 +0000 Date: Mon, 20 Feb 2023 18:29:33 +0000 Message-ID: <86fsb0xkaa.wl-maz@kernel.org> From: Marc Zyngier To: "Russell King (Oracle)" Cc: Thomas Gleixner , LKML , x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe Subject: Re: [REGRESSION] Re: [patch V3 09/33] genirq/msi: Add range checking to msi_insert_desc() In-Reply-To: References: <20221124230505.073418677@linutronix.de> <20221124232325.798556374@linutronix.de> 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") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux@armlinux.org.uk, tglx@linutronix.de, linux-kernel@vger.kernel.org, x86@kernel.org, joro@8bytes.org, will@kernel.org, linux-pci@vger.kernel.org, bhelgaas@google.com, lorenzo.pieralisi@arm.com, gregkh@linuxfoundation.org, jgg@mellanox.com, dave.jiang@intel.com, alex.williamson@redhat.com, kevin.tian@intel.com, dan.j.williams@intel.com, logang@deltatee.com, ashok.raj@intel.com, jdmason@kudzu.us, allenbh@gmail.com 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 Mon, 20 Feb 2023 17:11:23 +0000, "Russell King (Oracle)" wrote: > > On Fri, Nov 25, 2022 at 12:25:59AM +0100, Thomas Gleixner wrote: > > Per device domains provide the real domain size to the core code. This > > allows range checking on insertion of MSI descriptors and also paves the > > way for dynamic index allocations which are required e.g. for IMS. This > > avoids external mechanisms like bitmaps on the device side and just > > utilizes the core internal MSI descriptor storxe for it. > > > > Signed-off-by: Thomas Gleixner > > Hi Thomas, > > This patch appears to cause a regression on Macchiatobin, delaying the > boot by about ten seconds due to all the warnings the kernel now > produces. > > > @@ -136,11 +149,16 @@ static bool msi_desc_match(struct msi_de > > > > static bool msi_ctrl_valid(struct device *dev, struct msi_ctrl *ctrl) > > { > > + unsigned int hwsize; > > + > > if (WARN_ON_ONCE(ctrl->domid >= MSI_MAX_DEVICE_IRQDOMAINS || > > - !dev->msi.data->__domains[ctrl->domid].domain || > > - ctrl->first > ctrl->last || > > - ctrl->first > MSI_MAX_INDEX || > > - ctrl->last > MSI_MAX_INDEX)) > > + !dev->msi.data->__domains[ctrl->domid].domain)) > > + return false; > > + > > + hwsize = msi_domain_get_hwsize(dev, ctrl->domid); > > This calls msi_get_device_domain() without taking dev->msi.data->mutex, > resulting in the lockdep_assert_held() firing for what seems to be every > MSI created by the Armada 8040 ICU driver, which suggests something isn't > taking the lock as you expect. Please can you take a look and propose a > patch to fix this regression. Since you already worked it out, I only had to translate your words into the patch below, which solves it for me. Lockdep also reports[1] a possible circular locking dependency between phy_attach_direct() and rtnetlink_rcv_msg(), which looks interesting. Thanks, M. [1] https://paste.debian.net/1271454/ diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index 783a3e6a0b10..13d96495e6d0 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -1084,10 +1084,13 @@ int msi_domain_populate_irqs(struct irq_domain *domain, struct device *dev, struct xarray *xa; int ret, virq; - if (!msi_ctrl_valid(dev, &ctrl)) - return -EINVAL; - msi_lock_descs(dev); + + if (!msi_ctrl_valid(dev, &ctrl)) { + ret = -EINVAL; + goto unlock; + } + ret = msi_domain_add_simple_msi_descs(dev, &ctrl); if (ret) goto unlock; -- Without deviation from the norm, progress is not possible.