linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Patch v3 0/4] Introduce a mechanism to allocate PCI IRQ on demand
@ 2015-06-10  8:54 Jiang Liu
  2015-06-10  8:54 ` [Patch v3 1/4] PCI: Add hooks to allocate/free IRQ resources when binding/unbinding driver Jiang Liu
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Jiang Liu @ 2015-06-10  8:54 UTC (permalink / raw)
  To: Thomas Gleixner, Rafael J . Wysocki, Bjorn Helgaas
  Cc: Jiang Liu, LKML, linux-pci, linux-acpi, x86 @ kernel . org

Hi Bjorn,
	I have verified that this patch set could be applied to the
mainstream kernel without dependency on other patches, so could you
please help to merge it?

This patch set introduces a mechanism to allocate PCI IRQ on demand and
free it when not used anymore by hooking pci_device_probe() and
pci_device_remove().

It will be used to track IOAPIC pin usage on x86 so we could support
IOAPIC hot-removal.

The patch set passes Fengguang's 0day test suite.

V2->V3:
1) Change the default pcibios_alloc_irq() to always return 0, as
   suggested by Bjorn.
2) Refine comments.

V1->V2:
1) Refine pci_device_probe() to optimize for mainline code as suggested
   by Bjorn
2) Reorder patch set to put optional patch as the last (Patch 4)


Jiang Liu (4):
  PCI: Add hooks to allocate/free IRQ resources when binding/unbinding
    driver
  PCI, x86: Allocate PCI IRQ on demand and free it when not used
    anymore
  PCI: Add helpers to manage pci_dev->irq and pci_dev->irq_managed
  PCI, MSI: Free legacy PCI IRQ when enabling MSI/MSI-X

 arch/x86/include/asm/pci_x86.h |    2 --
 arch/x86/pci/common.c          |   20 +++++++++-----------
 arch/x86/pci/intel_mid_pci.c   |    9 ++++++---
 arch/x86/pci/irq.c             |   23 ++++-------------------
 drivers/acpi/pci_irq.c         |   17 ++++-------------
 drivers/pci/msi.c              |    6 +++++-
 drivers/pci/pci-driver.c       |   26 ++++++++++++++++++++------
 include/linux/pci.h            |   19 +++++++++++++++++++
 8 files changed, 67 insertions(+), 55 deletions(-)

-- 
1.7.10.4


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Patch v3 1/4] PCI: Add hooks to allocate/free IRQ resources when binding/unbinding driver
  2015-06-10  8:54 [Patch v3 0/4] Introduce a mechanism to allocate PCI IRQ on demand Jiang Liu
@ 2015-06-10  8:54 ` Jiang Liu
  2015-06-10  8:54 ` [Patch v3 2/4] PCI, x86: Allocate PCI IRQ on demand and free it when not used anymore Jiang Liu
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Jiang Liu @ 2015-06-10  8:54 UTC (permalink / raw)
  To: Thomas Gleixner, Rafael J . Wysocki, Bjorn Helgaas
  Cc: Jiang Liu, LKML, linux-pci, linux-acpi, x86 @ kernel . org

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 <jiang.liu@linux.intel.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
---
 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..52a880ca1768 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 0;
+}
+
+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


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Patch v3 2/4] PCI, x86: Allocate PCI IRQ on demand and free it when not used anymore
  2015-06-10  8:54 [Patch v3 0/4] Introduce a mechanism to allocate PCI IRQ on demand Jiang Liu
  2015-06-10  8:54 ` [Patch v3 1/4] PCI: Add hooks to allocate/free IRQ resources when binding/unbinding driver Jiang Liu
@ 2015-06-10  8:54 ` Jiang Liu
  2015-06-10  8:55 ` [Patch v3 3/4] PCI: Add helpers to manage pci_dev->irq and pci_dev->irq_managed Jiang Liu
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Jiang Liu @ 2015-06-10  8:54 UTC (permalink / raw)
  To: Thomas Gleixner, Rafael J . Wysocki, Bjorn Helgaas, Ingo Molnar,
	H. Peter Anvin, x86, Len Brown, Jiang Liu
  Cc: LKML, linux-pci, linux-acpi

To support IOAPIC hotplug, we need to correctly manage IOAPIC pin usage,
which is to allocate IRQs on demand and free them when not used anymore.
So use pcibios_alloc_irq() and pcibios_free_irq() to dynamically allocate
and free PCI IRQs.

Also remove obseleted code mp_should_keep_irq().

Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/x86/include/asm/pci_x86.h |    2 --
 arch/x86/pci/common.c          |   20 +++++++++-----------
 arch/x86/pci/intel_mid_pci.c   |    7 +++++--
 arch/x86/pci/irq.c             |   15 +--------------
 drivers/acpi/pci_irq.c         |    9 +--------
 5 files changed, 16 insertions(+), 37 deletions(-)

diff --git a/arch/x86/include/asm/pci_x86.h b/arch/x86/include/asm/pci_x86.h
index 164e3f8d3c3d..fa1195dae425 100644
--- a/arch/x86/include/asm/pci_x86.h
+++ b/arch/x86/include/asm/pci_x86.h
@@ -93,8 +93,6 @@ extern raw_spinlock_t pci_config_lock;
 extern int (*pcibios_enable_irq)(struct pci_dev *dev);
 extern void (*pcibios_disable_irq)(struct pci_dev *dev);
 
-extern bool mp_should_keep_irq(struct device *dev);
-
 struct pci_raw_ops {
 	int (*read)(unsigned int domain, unsigned int bus, unsigned int devfn,
 						int reg, int len, u32 *val);
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 8fd6f44aee83..dc78a4a9a466 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -673,24 +673,22 @@ int pcibios_add_device(struct pci_dev *dev)
 	return 0;
 }
 
-int pcibios_enable_device(struct pci_dev *dev, int mask)
+int pcibios_alloc_irq(struct pci_dev *dev)
 {
-	int err;
-
-	if ((err = pci_enable_resources(dev, mask)) < 0)
-		return err;
-
-	if (!pci_dev_msi_enabled(dev))
-		return pcibios_enable_irq(dev);
-	return 0;
+	return pcibios_enable_irq(dev);
 }
 
-void pcibios_disable_device (struct pci_dev *dev)
+void pcibios_free_irq(struct pci_dev *dev)
 {
-	if (!pci_dev_msi_enabled(dev) && pcibios_disable_irq)
+	if (pcibios_disable_irq)
 		pcibios_disable_irq(dev);
 }
 
+int pcibios_enable_device(struct pci_dev *dev, int mask)
+{
+	return pci_enable_resources(dev, mask);
+}
+
 int pci_ext_cfg_avail(void)
 {
 	if (raw_pci_ext_ops)
diff --git a/arch/x86/pci/intel_mid_pci.c b/arch/x86/pci/intel_mid_pci.c
index 27062303c881..fb7a1f96d80c 100644
--- a/arch/x86/pci/intel_mid_pci.c
+++ b/arch/x86/pci/intel_mid_pci.c
@@ -234,10 +234,13 @@ static int intel_mid_pci_irq_enable(struct pci_dev *dev)
 
 static void intel_mid_pci_irq_disable(struct pci_dev *dev)
 {
-	if (!mp_should_keep_irq(&dev->dev) && dev->irq_managed &&
-	    dev->irq > 0) {
+	if (dev->irq_managed && dev->irq > 0) {
 		mp_unmap_irq(dev->irq);
 		dev->irq_managed = 0;
+		/*
+		 * Don't reset dev->irq here, otherwise
+		 * intel_mid_pci_irq_enable() will fail on next call.
+		 */
 	}
 }
 
diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
index 9bd115484745..72108f0b66b1 100644
--- a/arch/x86/pci/irq.c
+++ b/arch/x86/pci/irq.c
@@ -1257,22 +1257,9 @@ static int pirq_enable_irq(struct pci_dev *dev)
 	return 0;
 }
 
-bool mp_should_keep_irq(struct device *dev)
-{
-	if (dev->power.is_prepared)
-		return true;
-#ifdef CONFIG_PM
-	if (dev->power.runtime_status == RPM_SUSPENDING)
-		return true;
-#endif
-
-	return false;
-}
-
 static void pirq_disable_irq(struct pci_dev *dev)
 {
-	if (io_apic_assign_pci_irqs && !mp_should_keep_irq(&dev->dev) &&
-	    dev->irq_managed && dev->irq) {
+	if (io_apic_assign_pci_irqs && dev->irq_managed && dev->irq) {
 		mp_unmap_irq(dev->irq);
 		dev->irq = 0;
 		dev->irq_managed = 0;
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index b1def411c0b8..e7f718d6918a 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -485,14 +485,6 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
 	if (!pin || !dev->irq_managed || dev->irq <= 0)
 		return;
 
-	/* Keep IOAPIC pin configuration when suspending */
-	if (dev->dev.power.is_prepared)
-		return;
-#ifdef	CONFIG_PM
-	if (dev->dev.power.runtime_status == RPM_SUSPENDING)
-		return;
-#endif
-
 	entry = acpi_pci_irq_lookup(dev, pin);
 	if (!entry)
 		return;
@@ -513,5 +505,6 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
 	if (gsi >= 0) {
 		acpi_unregister_gsi(gsi);
 		dev->irq_managed = 0;
+		dev->irq = 0;
 	}
 }
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Patch v3 3/4] PCI: Add helpers to manage pci_dev->irq and pci_dev->irq_managed
  2015-06-10  8:54 [Patch v3 0/4] Introduce a mechanism to allocate PCI IRQ on demand Jiang Liu
  2015-06-10  8:54 ` [Patch v3 1/4] PCI: Add hooks to allocate/free IRQ resources when binding/unbinding driver Jiang Liu
  2015-06-10  8:54 ` [Patch v3 2/4] PCI, x86: Allocate PCI IRQ on demand and free it when not used anymore Jiang Liu
@ 2015-06-10  8:55 ` Jiang Liu
  2015-06-10  8:55 ` [Patch v3 4/4] PCI, MSI: Free legacy PCI IRQ when enabling MSI/MSI-X Jiang Liu
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Jiang Liu @ 2015-06-10  8:55 UTC (permalink / raw)
  To: Thomas Gleixner, Rafael J . Wysocki, Bjorn Helgaas, Ingo Molnar,
	H. Peter Anvin, x86, Len Brown
  Cc: Jiang Liu, LKML, linux-pci, linux-acpi

Add three helpers to manage pci_dev->irq and pci_dev->irq_managed,
which helps to improve maintenance.

Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/x86/pci/intel_mid_pci.c |    4 ++--
 arch/x86/pci/irq.c           |   10 ++++------
 drivers/acpi/pci_irq.c       |   10 ++++------
 include/linux/pci.h          |   17 +++++++++++++++++
 4 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/arch/x86/pci/intel_mid_pci.c b/arch/x86/pci/intel_mid_pci.c
index fb7a1f96d80c..22aaefb4f1ca 100644
--- a/arch/x86/pci/intel_mid_pci.c
+++ b/arch/x86/pci/intel_mid_pci.c
@@ -211,7 +211,7 @@ static int intel_mid_pci_irq_enable(struct pci_dev *dev)
 	struct irq_alloc_info info;
 	int polarity;
 
-	if (dev->irq_managed && dev->irq > 0)
+	if (pci_has_managed_irq(dev))
 		return 0;
 
 	if (intel_mid_identify_cpu() == INTEL_MID_CPU_CHIP_TANGIER)
@@ -234,7 +234,7 @@ static int intel_mid_pci_irq_enable(struct pci_dev *dev)
 
 static void intel_mid_pci_irq_disable(struct pci_dev *dev)
 {
-	if (dev->irq_managed && dev->irq > 0) {
+	if (pci_has_managed_irq(dev)) {
 		mp_unmap_irq(dev->irq);
 		dev->irq_managed = 0;
 		/*
diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
index 72108f0b66b1..32e70343e6fd 100644
--- a/arch/x86/pci/irq.c
+++ b/arch/x86/pci/irq.c
@@ -1202,7 +1202,7 @@ static int pirq_enable_irq(struct pci_dev *dev)
 			struct pci_dev *temp_dev;
 			int irq;
 
-			if (dev->irq_managed && dev->irq > 0)
+			if (pci_has_managed_irq(dev))
 				return 0;
 
 			irq = IO_APIC_get_PCI_irq_vector(dev->bus->number,
@@ -1230,8 +1230,7 @@ static int pirq_enable_irq(struct pci_dev *dev)
 			}
 			dev = temp_dev;
 			if (irq >= 0) {
-				dev->irq_managed = 1;
-				dev->irq = irq;
+				pci_set_managed_irq(dev, irq);
 				dev_info(&dev->dev, "PCI->APIC IRQ transform: "
 					 "INT %c -> IRQ %d\n", 'A' + pin - 1, irq);
 				return 0;
@@ -1259,9 +1258,8 @@ static int pirq_enable_irq(struct pci_dev *dev)
 
 static void pirq_disable_irq(struct pci_dev *dev)
 {
-	if (io_apic_assign_pci_irqs && dev->irq_managed && dev->irq) {
+	if (io_apic_assign_pci_irqs && pci_has_managed_irq(dev)) {
 		mp_unmap_irq(dev->irq);
-		dev->irq = 0;
-		dev->irq_managed = 0;
+		pci_reset_managed_irq(dev);
 	}
 }
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index e7f718d6918a..9d6343d02f7e 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -413,7 +413,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
 		return 0;
 	}
 
-	if (dev->irq_managed && dev->irq > 0)
+	if (pci_has_managed_irq(dev))
 		return 0;
 
 	entry = acpi_pci_irq_lookup(dev, pin);
@@ -458,8 +458,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
 		kfree(entry);
 		return rc;
 	}
-	dev->irq = rc;
-	dev->irq_managed = 1;
+	pci_set_managed_irq(dev, rc);
 
 	if (link)
 		snprintf(link_desc, sizeof(link_desc), " -> Link[%s]", link);
@@ -482,7 +481,7 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
 	u8 pin;
 
 	pin = dev->pin;
-	if (!pin || !dev->irq_managed || dev->irq <= 0)
+	if (!pin || !pci_has_managed_irq(dev))
 		return;
 
 	entry = acpi_pci_irq_lookup(dev, pin);
@@ -504,7 +503,6 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
 	dev_dbg(&dev->dev, "PCI INT %c disabled\n", pin_name(pin));
 	if (gsi >= 0) {
 		acpi_unregister_gsi(gsi);
-		dev->irq_managed = 0;
-		dev->irq = 0;
+		pci_reset_managed_irq(dev);
 	}
 }
diff --git a/include/linux/pci.h b/include/linux/pci.h
index f50d16a04abc..4bc640eef76f 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -958,6 +958,23 @@ static inline int pci_is_managed(struct pci_dev *pdev)
 	return pdev->is_managed;
 }
 
+static inline void pci_set_managed_irq(struct pci_dev *pdev, unsigned int irq)
+{
+	pdev->irq = irq;
+	pdev->irq_managed = 1;
+}
+
+static inline void pci_reset_managed_irq(struct pci_dev *pdev)
+{
+	pdev->irq = 0;
+	pdev->irq_managed = 0;
+}
+
+static inline bool pci_has_managed_irq(struct pci_dev *pdev)
+{
+	return pdev->irq_managed && pdev->irq > 0;
+}
+
 void pci_disable_device(struct pci_dev *dev);
 
 extern unsigned int pcibios_max_latency;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Patch v3 4/4] PCI, MSI: Free legacy PCI IRQ when enabling MSI/MSI-X
  2015-06-10  8:54 [Patch v3 0/4] Introduce a mechanism to allocate PCI IRQ on demand Jiang Liu
                   ` (2 preceding siblings ...)
  2015-06-10  8:55 ` [Patch v3 3/4] PCI: Add helpers to manage pci_dev->irq and pci_dev->irq_managed Jiang Liu
@ 2015-06-10  8:55 ` Jiang Liu
  2015-06-19 16:10 ` [Patch v3 0/4] Introduce a mechanism to allocate PCI IRQ on demand Bjorn Helgaas
  2015-07-30 19:23 ` Bjorn Helgaas
  5 siblings, 0 replies; 10+ messages in thread
From: Jiang Liu @ 2015-06-10  8:55 UTC (permalink / raw)
  To: Thomas Gleixner, Rafael J . Wysocki, Bjorn Helgaas
  Cc: Jiang Liu, LKML, linux-pci, linux-acpi, x86 @ kernel . org

Once PCI MSI/MSI-X is enabled by the device driver, PCI device won't
make use of legacy PCI IRQ until PCI MSI/MSI-X is disabled again.
This patch enhances the PCI MSI core to call pcibios_free_irq() when
enabling MSI/MSI-X and to call pcibios_alloc_irq() when disabling
MSI/MSI-X. So legacy PCI IRQ will released when enabling MSI/MSI-X
and reallocated when disabling MSI/MSI-X if pcibios_alloc_irq() and
pcibios_free_irq() are implemented by arch specific PCI code.

Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/msi.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index c3e7dfcf9ff5..47cf72c669f0 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -686,6 +686,7 @@ static int msi_capability_init(struct pci_dev *dev, int nvec)
 	msi_set_enable(dev, 1);
 	dev->msi_enabled = 1;
 
+	pcibios_free_irq(dev);
 	dev->irq = entry->irq;
 	return 0;
 }
@@ -813,9 +814,10 @@ static int msix_capability_init(struct pci_dev *dev,
 	/* Set MSI-X enabled bits and unmask the function */
 	pci_intx_for_msi(dev, 0);
 	dev->msix_enabled = 1;
-
 	msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_MASKALL, 0);
 
+	pcibios_free_irq(dev);
+
 	return 0;
 
 out_avail:
@@ -930,6 +932,7 @@ void pci_msi_shutdown(struct pci_dev *dev)
 
 	/* Restore dev->irq to its default pin-assertion irq */
 	dev->irq = desc->msi_attrib.default_irq;
+	pcibios_alloc_irq(dev);
 }
 
 void pci_disable_msi(struct pci_dev *dev)
@@ -1030,6 +1033,7 @@ void pci_msix_shutdown(struct pci_dev *dev)
 	msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_ENABLE, 0);
 	pci_intx_for_msi(dev, 1);
 	dev->msix_enabled = 0;
+	pcibios_alloc_irq(dev);
 }
 
 void pci_disable_msix(struct pci_dev *dev)
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [Patch v3 0/4] Introduce a mechanism to allocate PCI IRQ on demand
  2015-06-10  8:54 [Patch v3 0/4] Introduce a mechanism to allocate PCI IRQ on demand Jiang Liu
                   ` (3 preceding siblings ...)
  2015-06-10  8:55 ` [Patch v3 4/4] PCI, MSI: Free legacy PCI IRQ when enabling MSI/MSI-X Jiang Liu
@ 2015-06-19 16:10 ` Bjorn Helgaas
  2015-07-08  7:31   ` Jiang Liu
  2015-07-30 19:23 ` Bjorn Helgaas
  5 siblings, 1 reply; 10+ messages in thread
From: Bjorn Helgaas @ 2015-06-19 16:10 UTC (permalink / raw)
  To: Jiang Liu
  Cc: Thomas Gleixner, Rafael J . Wysocki, LKML, linux-pci, linux-acpi,
	x86 @ kernel . org

On Wed, Jun 10, 2015 at 04:54:57PM +0800, Jiang Liu wrote:
> Hi Bjorn,
> 	I have verified that this patch set could be applied to the
> mainstream kernel without dependency on other patches, so could you
> please help to merge it?

I already acked these and said I was willing to merge them and that I was
hoping for an ack from Thomas.

Any thoughts, Thomas?

> This patch set introduces a mechanism to allocate PCI IRQ on demand and
> free it when not used anymore by hooking pci_device_probe() and
> pci_device_remove().
> 
> It will be used to track IOAPIC pin usage on x86 so we could support
> IOAPIC hot-removal.
> 
> The patch set passes Fengguang's 0day test suite.
> 
> V2->V3:
> 1) Change the default pcibios_alloc_irq() to always return 0, as
>    suggested by Bjorn.
> 2) Refine comments.
> 
> V1->V2:
> 1) Refine pci_device_probe() to optimize for mainline code as suggested
>    by Bjorn
> 2) Reorder patch set to put optional patch as the last (Patch 4)
> 
> 
> Jiang Liu (4):
>   PCI: Add hooks to allocate/free IRQ resources when binding/unbinding
>     driver
>   PCI, x86: Allocate PCI IRQ on demand and free it when not used
>     anymore
>   PCI: Add helpers to manage pci_dev->irq and pci_dev->irq_managed
>   PCI, MSI: Free legacy PCI IRQ when enabling MSI/MSI-X
> 
>  arch/x86/include/asm/pci_x86.h |    2 --
>  arch/x86/pci/common.c          |   20 +++++++++-----------
>  arch/x86/pci/intel_mid_pci.c   |    9 ++++++---
>  arch/x86/pci/irq.c             |   23 ++++-------------------
>  drivers/acpi/pci_irq.c         |   17 ++++-------------
>  drivers/pci/msi.c              |    6 +++++-
>  drivers/pci/pci-driver.c       |   26 ++++++++++++++++++++------
>  include/linux/pci.h            |   19 +++++++++++++++++++
>  8 files changed, 67 insertions(+), 55 deletions(-)
> 
> -- 
> 1.7.10.4
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Patch v3 0/4] Introduce a mechanism to allocate PCI IRQ on demand
  2015-06-19 16:10 ` [Patch v3 0/4] Introduce a mechanism to allocate PCI IRQ on demand Bjorn Helgaas
@ 2015-07-08  7:31   ` Jiang Liu
  2015-07-08  7:40     ` Thomas Gleixner
  0 siblings, 1 reply; 10+ messages in thread
From: Jiang Liu @ 2015-07-08  7:31 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Thomas Gleixner, Rafael J . Wysocki, LKML, linux-pci, linux-acpi,
	x86 @ kernel . org

On 2015/6/20 0:10, Bjorn Helgaas wrote:
> On Wed, Jun 10, 2015 at 04:54:57PM +0800, Jiang Liu wrote:
>> Hi Bjorn,
>> 	I have verified that this patch set could be applied to the
>> mainstream kernel without dependency on other patches, so could you
>> please help to merge it?
> 
> I already acked these and said I was willing to merge them and that I was
> hoping for an ack from Thomas.
> 
> Any thoughts, Thomas?

Hi Thomas,
	Any comments about this bugfix series?
Thanks!
Gerry

> 
>> This patch set introduces a mechanism to allocate PCI IRQ on demand and
>> free it when not used anymore by hooking pci_device_probe() and
>> pci_device_remove().
>>
>> It will be used to track IOAPIC pin usage on x86 so we could support
>> IOAPIC hot-removal.
>>
>> The patch set passes Fengguang's 0day test suite.
>>
>> V2->V3:
>> 1) Change the default pcibios_alloc_irq() to always return 0, as
>>    suggested by Bjorn.
>> 2) Refine comments.
>>
>> V1->V2:
>> 1) Refine pci_device_probe() to optimize for mainline code as suggested
>>    by Bjorn
>> 2) Reorder patch set to put optional patch as the last (Patch 4)
>>
>>
>> Jiang Liu (4):
>>   PCI: Add hooks to allocate/free IRQ resources when binding/unbinding
>>     driver
>>   PCI, x86: Allocate PCI IRQ on demand and free it when not used
>>     anymore
>>   PCI: Add helpers to manage pci_dev->irq and pci_dev->irq_managed
>>   PCI, MSI: Free legacy PCI IRQ when enabling MSI/MSI-X
>>
>>  arch/x86/include/asm/pci_x86.h |    2 --
>>  arch/x86/pci/common.c          |   20 +++++++++-----------
>>  arch/x86/pci/intel_mid_pci.c   |    9 ++++++---
>>  arch/x86/pci/irq.c             |   23 ++++-------------------
>>  drivers/acpi/pci_irq.c         |   17 ++++-------------
>>  drivers/pci/msi.c              |    6 +++++-
>>  drivers/pci/pci-driver.c       |   26 ++++++++++++++++++++------
>>  include/linux/pci.h            |   19 +++++++++++++++++++
>>  8 files changed, 67 insertions(+), 55 deletions(-)
>>
>> -- 
>> 1.7.10.4
>>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Patch v3 0/4] Introduce a mechanism to allocate PCI IRQ on demand
  2015-07-08  7:31   ` Jiang Liu
@ 2015-07-08  7:40     ` Thomas Gleixner
  2015-07-08  7:55       ` Jiang Liu
  0 siblings, 1 reply; 10+ messages in thread
From: Thomas Gleixner @ 2015-07-08  7:40 UTC (permalink / raw)
  To: Jiang Liu
  Cc: Bjorn Helgaas, Rafael J . Wysocki, LKML, linux-pci, linux-acpi,
	x86 @ kernel . org

On Wed, 8 Jul 2015, Jiang Liu wrote:
> On 2015/6/20 0:10, Bjorn Helgaas wrote:
> > On Wed, Jun 10, 2015 at 04:54:57PM +0800, Jiang Liu wrote:
> >> Hi Bjorn,
> >> 	I have verified that this patch set could be applied to the
> >> mainstream kernel without dependency on other patches, so could you
> >> please help to merge it?
> > 
> > I already acked these and said I was willing to merge them and that I was
> > hoping for an ack from Thomas.
> > 
> > Any thoughts, Thomas?
> 
> Hi Thomas,
> 	Any comments about this bugfix series?

How is these a bugfix series? It looks like preparation for ioapic
hotplug.

But other than that, Acked-by-me.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Patch v3 0/4] Introduce a mechanism to allocate PCI IRQ on demand
  2015-07-08  7:40     ` Thomas Gleixner
@ 2015-07-08  7:55       ` Jiang Liu
  0 siblings, 0 replies; 10+ messages in thread
From: Jiang Liu @ 2015-07-08  7:55 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Bjorn Helgaas, Rafael J . Wysocki, LKML, linux-pci, linux-acpi,
	x86 @ kernel . org

On 2015/7/8 15:40, Thomas Gleixner wrote:
> On Wed, 8 Jul 2015, Jiang Liu wrote:
>> On 2015/6/20 0:10, Bjorn Helgaas wrote:
>>> On Wed, Jun 10, 2015 at 04:54:57PM +0800, Jiang Liu wrote:
>>>> Hi Bjorn,
>>>> 	I have verified that this patch set could be applied to the
>>>> mainstream kernel without dependency on other patches, so could you
>>>> please help to merge it?
>>>
>>> I already acked these and said I was willing to merge them and that I was
>>> hoping for an ack from Thomas.
>>>
>>> Any thoughts, Thomas?
>>
>> Hi Thomas,
>> 	Any comments about this bugfix series?
> 
> How is these a bugfix series? It looks like preparation for ioapic
> hotplug.
> 
> But other than that, Acked-by-me.
Thanks! The IOAPIC hotplug driver has been merged into mainstream
kernel, so treat them as bugfix:)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Patch v3 0/4] Introduce a mechanism to allocate PCI IRQ on demand
  2015-06-10  8:54 [Patch v3 0/4] Introduce a mechanism to allocate PCI IRQ on demand Jiang Liu
                   ` (4 preceding siblings ...)
  2015-06-19 16:10 ` [Patch v3 0/4] Introduce a mechanism to allocate PCI IRQ on demand Bjorn Helgaas
@ 2015-07-30 19:23 ` Bjorn Helgaas
  5 siblings, 0 replies; 10+ messages in thread
From: Bjorn Helgaas @ 2015-07-30 19:23 UTC (permalink / raw)
  To: Jiang Liu
  Cc: Thomas Gleixner, Rafael J . Wysocki, LKML, linux-pci, linux-acpi,
	x86 @ kernel . org

On Wed, Jun 10, 2015 at 04:54:57PM +0800, Jiang Liu wrote:
> Hi Bjorn,
> 	I have verified that this patch set could be applied to the
> mainstream kernel without dependency on other patches, so could you
> please help to merge it?
> 
> This patch set introduces a mechanism to allocate PCI IRQ on demand and
> free it when not used anymore by hooking pci_device_probe() and
> pci_device_remove().
> 
> It will be used to track IOAPIC pin usage on x86 so we could support
> IOAPIC hot-removal.
> 
> The patch set passes Fengguang's 0day test suite.
> 
> V2->V3:
> 1) Change the default pcibios_alloc_irq() to always return 0, as
>    suggested by Bjorn.
> 2) Refine comments.
> 
> V1->V2:
> 1) Refine pci_device_probe() to optimize for mainline code as suggested
>    by Bjorn
> 2) Reorder patch set to put optional patch as the last (Patch 4)
> 
> 
> Jiang Liu (4):
>   PCI: Add hooks to allocate/free IRQ resources when binding/unbinding
>     driver
>   PCI, x86: Allocate PCI IRQ on demand and free it when not used
>     anymore
>   PCI: Add helpers to manage pci_dev->irq and pci_dev->irq_managed
>   PCI, MSI: Free legacy PCI IRQ when enabling MSI/MSI-X

Applied to pci/irq with the following changelogs for v4.3, thanks!

commit 890e4847587fcff5eb0438e90992ad7d2a261f33
Author: Jiang Liu <jiang.liu@linux.intel.com>
Date:   Wed Jun 10 16:54:58 2015 +0800

    PCI: Add pcibios_alloc_irq() and pcibios_free_irq()
    
    Add pcibios_alloc_irq() and pcibios_free_irq(), which are called when
    binding/unbinding PCI device drivers.
    
    PCI arch code may implement these to manage IRQ resources for hotplugged
    devices.
    
    [bhelgaas: changelog]
    Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Acked-by: Thomas Gleixner <tglx@linutronix.de>

commit 991de2e59090e55c65a7f59a049142e3c480f7bd
Author: Jiang Liu <jiang.liu@linux.intel.com>
Date:   Wed Jun 10 16:54:59 2015 +0800

    PCI, x86: Implement pcibios_alloc_irq() and pcibios_free_irq()
    
    To support IOAPIC hotplug, we need to allocate PCI IRQ resources on demand
    and free them when not used anymore.
    
    Implement pcibios_alloc_irq() and pcibios_free_irq() to dynamically
    allocate and free PCI IRQs.
    
    Remove mp_should_keep_irq(), which is no longer used.
    
    [bhelgaas: changelog]
    Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Acked-by: Thomas Gleixner <tglx@linutronix.de>

commit 811a4e6fce09bc9239c664c6a1a53645a678c303
Author: Jiang Liu <jiang.liu@linux.intel.com>
Date:   Wed Jun 10 16:55:00 2015 +0800

    PCI: Add helpers to manage pci_dev->irq and pci_dev->irq_managed
    
    Add pci_has_managed_irq(), pci_set_managed_irq(), and
    pci_reset_managed_irq() to simplify code.  No functional change.
    
    [bhelgaas: changelog]
    Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Acked-by: Thomas Gleixner <tglx@linutronix.de>

commit 5f2269916b0e509f2926346b58209abfa8316143
Author: Jiang Liu <jiang.liu@linux.intel.com>
Date:   Thu Jul 30 14:00:08 2015 -0500

    PCI/MSI: Free legacy IRQ when enabling MSI/MSI-X
    
    Once MSI/MSI-X is enabled by the device driver, a PCI device won't use
    legacy IRQs again until MSI/MSI-X is disabled.
    
    Call pcibios_free_irq() when enabling MSI/MSI-X and pcibios_alloc_irq()
    when disabling MSI/MSI-X.  This allows arch code to manage resources
    associated with the legacy IRQ.
    
    [bhelgaas: changelog]
    Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Acked-by: Thomas Gleixner <tglx@linutronix.de>

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-07-30 19:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-10  8:54 [Patch v3 0/4] Introduce a mechanism to allocate PCI IRQ on demand Jiang Liu
2015-06-10  8:54 ` [Patch v3 1/4] PCI: Add hooks to allocate/free IRQ resources when binding/unbinding driver Jiang Liu
2015-06-10  8:54 ` [Patch v3 2/4] PCI, x86: Allocate PCI IRQ on demand and free it when not used anymore Jiang Liu
2015-06-10  8:55 ` [Patch v3 3/4] PCI: Add helpers to manage pci_dev->irq and pci_dev->irq_managed Jiang Liu
2015-06-10  8:55 ` [Patch v3 4/4] PCI, MSI: Free legacy PCI IRQ when enabling MSI/MSI-X Jiang Liu
2015-06-19 16:10 ` [Patch v3 0/4] Introduce a mechanism to allocate PCI IRQ on demand Bjorn Helgaas
2015-07-08  7:31   ` Jiang Liu
2015-07-08  7:40     ` Thomas Gleixner
2015-07-08  7:55       ` Jiang Liu
2015-07-30 19:23 ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).