Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932396AbbFEVRl (ORCPT ); Fri, 5 Jun 2015 17:17:41 -0400 Received: from mail-ig0-f174.google.com ([209.85.213.174]:33164 "EHLO mail-ig0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752449AbbFEVRh (ORCPT ); Fri, 5 Jun 2015 17:17:37 -0400 Date: Fri, 5 Jun 2015 16:17:32 -0500 From: Bjorn Helgaas To: Jiang Liu Cc: Thomas Gleixner , "Rafael J . Wysocki" , LKML , linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, "x86 @ kernel . org" Subject: Re: [Patch v2 1/4] PCI: Add hooks to allocate/free IRQ resources when binding/unbinding driver Message-ID: <20150605211732.GR3631@google.com> References: <1433213360-3700-1-git-send-email-jiang.liu@linux.intel.com> <1433213360-3700-2-git-send-email-jiang.liu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1433213360-3700-2-git-send-email-jiang.liu@linux.intel.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2764 Lines: 87 On Tue, Jun 02, 2015 at 10:49:16AM +0800, Jiang Liu wrote: > Add two hook points pcibios_{alloc|free}_irq() into PCI core, which will > be called when binding/unbinding PCI device drivers. Then PCI arch code > may hook into these two points to allocate IRQ resources on demand and > free them when not used anymore. > > Signed-off-by: Jiang Liu > --- > drivers/pci/pci-driver.c | 26 ++++++++++++++++++++------ > include/linux/pci.h | 2 ++ > 2 files changed, 22 insertions(+), 6 deletions(-) > > diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c > index 3cb2210de553..450ad36ffc77 100644 > --- a/drivers/pci/pci-driver.c > +++ b/drivers/pci/pci-driver.c > @@ -388,18 +388,31 @@ static int __pci_device_probe(struct pci_driver *drv, struct pci_dev *pci_dev) > return error; > } > > +int __weak pcibios_alloc_irq(struct pci_dev *dev) > +{ > + return dev->irq; Based on your usage, pcibios_alloc_irq() returns either zero or a negative errno. So I think you should return 0 here. > +} > + > +void __weak pcibios_free_irq(struct pci_dev *dev) > +{ > +} > + > static int pci_device_probe(struct device *dev) > { > - int error = 0; > - struct pci_driver *drv; > - struct pci_dev *pci_dev; > + int error; > + struct pci_dev *pci_dev = to_pci_dev(dev); > + struct pci_driver *drv = to_pci_driver(dev->driver); > + > + error = pcibios_alloc_irq(pci_dev); > + if (error < 0) > + return error; > > - drv = to_pci_driver(dev->driver); > - pci_dev = to_pci_dev(dev); > pci_dev_get(pci_dev); > error = __pci_device_probe(drv, pci_dev); > - if (error) > + if (error) { > + pcibios_free_irq(pci_dev); > pci_dev_put(pci_dev); > + } > > return error; > } > @@ -415,6 +428,7 @@ static int pci_device_remove(struct device *dev) > drv->remove(pci_dev); > pm_runtime_put_noidle(dev); > } > + pcibios_free_irq(pci_dev); > pci_dev->driver = NULL; > } > > diff --git a/include/linux/pci.h b/include/linux/pci.h > index 353db8dc4c6e..f50d16a04abc 100644 > --- a/include/linux/pci.h > +++ b/include/linux/pci.h > @@ -1656,6 +1656,8 @@ int pcibios_set_pcie_reset_state(struct pci_dev *dev, > int pcibios_add_device(struct pci_dev *dev); > void pcibios_release_device(struct pci_dev *dev); > void pcibios_penalize_isa_irq(int irq, int active); > +int pcibios_alloc_irq(struct pci_dev *dev); > +void pcibios_free_irq(struct pci_dev *dev); > > #ifdef CONFIG_HIBERNATE_CALLBACKS > extern struct dev_pm_ops pcibios_pm_ops; > -- > 1.7.10.4 > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/