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 15853C021B8 for ; Sat, 1 Mar 2025 12:19:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0GR5xCMp1dYppmKer4FyU9W5VDeR263wQ+Fyh/GcmfY=; b=xAV5S7+TYE723Jw7Y5ELUlJwv7 1pLbXi1twzMN8cCWehYqHzHDnJt+kmW48xJy53cHEdYpHjK4Fe2RsAKZuRfNKSytPdseW9bOr5ne9 PxgnnawSg/NQawc4xfDQYlnlMiMPh/q0eMewqAIjyN9mNnoFepTBgXCt5QRsWkQMp5Bs7bZatOlXC luf/7dtCE4Aa2FyW0+QtiGr74s98G6Meax3Mrywbl3Bjvbi20+5R+sunBcr+e3ePFds+RfMJ1+ekD HOIg0C+9ldECY3P1t1L71imOacpnyWhhcQeJiL5db0V7XOmYJELtUJczqWffCA3gfddnyTUnii1jz SKwXbmaw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1toLoW-0000000DudG-0OYj; Sat, 01 Mar 2025 12:19:28 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1toLmy-0000000DuSb-1zMs for linux-arm-kernel@lists.infradead.org; Sat, 01 Mar 2025 12:17:52 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id A857C61170; Sat, 1 Mar 2025 12:17:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38D36C4CEDD; Sat, 1 Mar 2025 12:17:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740831471; bh=A8PdxtCizk6PgunyHAGQsWVRlwM9EY3+12Tc6z3znSM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=nhPy5+fOugQVe9poY7fQwjki9+P9S5nAFF7/0COxLPJun7AgwHNF1TsOHcKCUswYj UKVBh311X/Qk27ZtNHK3Tehk193k3QgTaCn5jQ3M2X6JXObmTolINnm2sYP/28HImG +oX+sz5e+NfyVqK0jK8c2+4f5uPYOx9Hxn6uVdx7NyV2eSQirUq8oOgrPLE8rL/vwS /O+CaBOIXSBZA05VOfTXyj9iNLyad0/43WHOcEBCWq4PGn/nCLeYnV7yoAz54teeWE /RUxG/sphEsuVn3x0lOlKMXtIZVJ0h3FR1Un1qjr0MrofAosyShEgeeQVTRkFG0SGi VphvI9rWcvJbw== 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 1toLmu-009Ltj-1q; Sat, 01 Mar 2025 12:17:48 +0000 Date: Sat, 01 Mar 2025 12:17:47 +0000 Message-ID: <86jz99osgk.wl-maz@kernel.org> From: Marc Zyngier To: Frank Li Cc: Kishon Vijay Abraham I , "Rafael J. Wysocki" , Thomas Gleixner , Anup Patel , Greg Kroah-Hartman , Danilo Krummrich , Manivannan Sadhasivam , Krzysztof =?UTF-8?B?V2lsY3p5xYRza2k=?= , Bjorn Helgaas , Arnd Bergmann , Shuah Khan , Richard Zhu , Lucas Stach , Lorenzo Pieralisi , Rob Herring , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Krzysztof Kozlowski , Conor Dooley , Niklas Cassel , dlemoal@kernel.org, jdmason@kudzu.us, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-kselftest@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org Subject: Re: [PATCH v15 01/15] platform-msi: Add msi_remove_device_irq_domain() in platform_device_msi_free_irqs_all() In-Reply-To: <20250211-ep-msi-v15-1-bcacc1f2b1a9@nxp.com> References: <20250211-ep-msi-v15-0-bcacc1f2b1a9@nxp.com> <20250211-ep-msi-v15-1-bcacc1f2b1a9@nxp.com> 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/29.4 (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: Frank.Li@nxp.com, kishon@kernel.org, rafael@kernel.org, tglx@linutronix.de, apatel@ventanamicro.com, gregkh@linuxfoundation.org, dakr@kernel.org, manivannan.sadhasivam@linaro.org, kw@linux.com, bhelgaas@google.com, arnd@arndb.de, shuah@kernel.org, hongxing.zhu@nxp.com, l.stach@pengutronix.de, lpieralisi@kernel.org, robh@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, krzk+dt@kernel.org, conor+dt@kernel.org, cassel@kernel.org, dlemoal@kernel.org, jdmason@kudzu.us, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-kselftest@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 11 Feb 2025 19:21:54 +0000, Frank Li wrote: > > The follow steps trigger kernel dump warning and > platform_device_msi_init_and_alloc_irqs() return false. > > 1: platform_device_msi_init_and_alloc_irqs(); > 2: platform_device_msi_free_irqs_all(); > 3: platform_device_msi_init_and_alloc_irqs(); > > [ 76.713677] WARNING: CPU: 3 PID: 134 at kernel/irq/msi.c:1028 msi_create_device_irq_domain+0x1bc/0x22c > [ 76.723010] Modules linked in: > [ 76.726082] CPU: 3 UID: 0 PID: 134 Comm: kworker/3:1H Not tainted 6.13.0-rc1-00015-gd60b98003b43-dirty #57 > [ 76.735741] Hardware name: NXP i.MX95 19X19 board (DT) > [ 76.740883] Workqueue: kpcitest pci_epf_test_cmd_handler > [ 76.746212] pstate: a0400009 (NzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) > [ 76.753172] pc : msi_create_device_irq_domain+0x1bc/0x22c > [ 76.758586] lr : msi_create_device_irq_domain+0x104/0x22c > [ 76.763988] sp : ffff800083f43be0 > [ 76.767313] x29: ffff800083f43be0 x28: 0000000000000000 x27: ffff8000827a7000 > [ 76.774466] x26: ffff00008085f400 x25: ffff00008000b180 x24: ffff000080fc6410 > [ 76.781624] x23: ffff000085704cc0 x22: ffff8000811c8828 x21: ffff000085704cc0 > [ 76.788774] x20: ffff000082814000 x19: 0000000000000000 x18: ffffffffffffffff > [ 76.795933] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000 > [ 76.803083] x14: 0000000000000000 x13: 0000000f00000000 x12: 0000000000000000 > [ 76.810233] x11: 0000000000000000 x10: 000000000000002d x9 : ffff800083f43ba0 > [ 76.817383] x8 : 00000000ffffffff x7 : 0000000000000019 x6 : ffff0000857e443a > [ 76.824533] x5 : 0000000000000000 x4 : ffffffffffffffff x3 : ffff000085704ce8 > [ 76.831683] x2 : ffff000080835640 x1 : 0000000000000213 x0 : ffff0000877189c0 > [ 76.838840] Call trace: > [ 76.841287] msi_create_device_irq_domain+0x1bc/0x22c (P) > [ 76.846701] msi_create_device_irq_domain+0x104/0x22c (L) > [ 76.852118] platform_device_msi_init_and_alloc_irqs+0x6c/0xb8 > > Do below two things in platform_device_msi_init_and_alloc_irqs(). > - msi_create_device_irq_domain() > - msi_domain_alloc_irqs_range() > > But only call msi_domain_free_irqs_all() in > platform_device_msi_free_irqs_all(), which missed call > msi_remove_device_irq_domain(). This cause above kernel dump when call > platform_device_msi_init_and_alloc_irqs() again. I don't think this commit message makes much sense, and doesn't explain the essential problem, which is the lack of symmetry. I'd suggest something like: "platform_device_msi_init_and_alloc_irqs() performs two tasks: allocating the MSI domain for a platform device, and allocate a number of MSIs in that domain. platform_device_msi_free_irqs_all() only frees the MSIs, and leaves the MSI domain alive. Given that platform_device_msi_init_and_alloc_irqs() is the sole tool a platform device has to allocate platform MSIs, it would make sense for platform_device_msi_free_irqs_all() to teardown the MSI domain at the same time as the MSIs. This also avoids warnings and unexpected behaviours when a driver repeatedly allocates and frees MSIs." With that: Acked-by: Marc Zyngier M. -- Without deviation from the norm, progress is not possible.