From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753629AbdCAXLr (ORCPT ); Wed, 1 Mar 2017 18:11:47 -0500 Received: from ale.deltatee.com ([207.54.116.67]:57269 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753547AbdCAXLl (ORCPT ); Wed, 1 Mar 2017 18:11:41 -0500 To: Keith Busch , Bjorn Helgaas References: <1488091997-12843-1-git-send-email-logang@deltatee.com> <20170301214120.GA30451@bhelgaas-glaptop.roam.corp.google.com> <20170301222651.GA14852@localhost.localdomain> Cc: Myron Stowe , Greg Kroah-Hartman , Bjorn Helgaas , Geert Uytterhoeven , Jonathan Corbet , "David S. Miller" , Andrew Morton , Emil Velikov , Mauro Carvalho Chehab , Guenter Roeck , Jarkko Sakkinen , Linus Walleij , Ryusuke Konishi , Stefan Berger , Wei Zhang , Kurt Schwemmer , Stephen Bates , linux-pci@vger.kernel.org, linux-doc@vger.kernel.org, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org From: Logan Gunthorpe Message-ID: <84556478-c01c-0925-be75-13a61d4c8f4f@deltatee.com> Date: Wed, 1 Mar 2017 15:37:03 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0 MIME-Version: 1.0 In-Reply-To: <20170301222651.GA14852@localhost.localdomain> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 172.16.1.111 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-doc@vger.kernel.org, linux-pci@vger.kernel.org, stephen.bates@microsemi.com, kurt.schwemmer@microsemi.com, wzhang@fb.com, stefanb@linux.vnet.ibm.com, konishi.ryusuke@lab.ntt.co.jp, linus.walleij@linaro.org, jarkko.sakkinen@linux.intel.com, linux@roeck-us.net, mchehab@kernel.org, emil.l.velikov@gmail.com, akpm@linux-foundation.org, davem@davemloft.net, corbet@lwn.net, geert+renesas@glider.be, bhelgaas@google.com, gregkh@linuxfoundation.org, myron.stowe@gmail.com, helgaas@kernel.org, keith.busch@intel.com X-SA-Exim-Mail-From: logang@deltatee.com Subject: Re: [PATCH v5 0/4] New Microsemi PCI Switch Management Driver X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/03/17 03:26 PM, Keith Busch wrote: > I think this is from using the managed device resource API to request the > irq actions. The scope of the resource used to be tied to the pci_dev's > dev, but now it's the new switchec class dev, which has a different > lifetime while open references exist, so it's not releasing the irq's. The scope of the IRQ was originally tied to the pci_dev. Then in v4 I tied it to the switchtec device in order to try and keep using the pci device after unbind. This didn't work, so I switched it back to using the pci_dev. (This seems to be the way most drivers work anyway.) > One thing about the BUG_ON that is confusing me is how it's getting > to free_msi_irq's BUG in v4 or v5. I don't see any part releasing the > allocated ones. Maybe the devres API is harder to use than having the > driver manage all the resources... free_msi_irqs seems to be called via pci_disable_device in pcim_release which devres will call during release of the PCI device and before all the references to the pci_dev are freed (I tried adding an extra get_device which gets put in the child devices release -- this didn't work): [ 1079.845616] Call Trace: [ 1079.845652] ? pcim_release+0x35/0x96 [ 1079.845691] ? release_nodes+0x15b/0x17c [ 1079.845730] ? device_release_driver_internal+0x12d/0x1cb [ 1079.845771] ? unbind_store+0x59/0x89 [ 1079.845809] ? kernfs_fop_write+0xe7/0x129 [ 1079.845847] ? __vfs_write+0x1c/0xa2 [ 1079.845885] ? kmem_cache_alloc+0xc5/0x131 [ 1079.845923] ? fput+0xd/0x7d [ 1079.845958] ? filp_close+0x5a/0x61 [ 1079.845993] ? vfs_write+0xa2/0xe4 [ 1079.846028] ? SyS_write+0x48/0x73 [ 1079.846066] ? entry_SYSCALL_64_fastpath+0x13/0x94 v5 is correct because it registers the irqs against the pci_dev (with devm_request_irq) and thus they get freed in time as part of the devres unwind. Logan