linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 00/32] genirq: Another round of tree wide cleanups
@ 2014-05-07 15:44 Thomas Gleixner
  2014-05-07 15:44 ` [patch 01/32] arm: iop13xx: Use sparse irqs for MSI Thomas Gleixner
                   ` (32 more replies)
  0 siblings, 33 replies; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra

This cleanup series addresses a few histerical leftovers:

1) irq_reserve_irq()

   The remaining callsites are pointless except s390, but we have a
   better way to protect the lower interrupt space there.

   It's gone for good and it will never come back. Use irq domains, if
   you want hot pluggable irq chips.

2) create/destroy_irq and their variants

   Designed in different circles of hell we have an incompatible zoo
   of those.

   Three different implementations with different semantics vs. the
   return values. Two use cases which are just reusing the global
   namespace. And they come along with four different flavours of
   dynamic irq allocation.

   I created a core implementation for that and put it under
   GENERIC_IRQ_LEGACY_ALLOC_HWIRQ to make clear that this is not for
   new code. That implementation is used by x86 and tile. I gave up on
   converting ia64 over, so I moved the create/destroy_irq prototypes
   into ia64 headers and provided a wrapper for the shared dmar driver.

   The core implementation is a very basic allocator and that's
   deliberately so. I don't want more users and every more complex
   than that wants to use irq domains.

3) dynamic_irq_init/cleanup

   Another leftover from the past. By moving tile and iop13xx to
   sparse irq there is only ia64 left. I simplified the code and made
   this available only under a legacy config option to avoid that more
   people think they need this.

Full diffstat below.

Thanks,

	tglx
---
 arch/arm/Kconfig                          |    1 
 arch/arm/mach-iop13xx/include/mach/irqs.h |    2 
 arch/arm/mach-iop13xx/include/mach/time.h |    3 
 arch/arm/mach-iop13xx/iq81340mc.c         |    1 
 arch/arm/mach-iop13xx/iq81340sc.c         |    1 
 arch/arm/mach-iop13xx/msi.c               |   51 ++---------
 arch/arm/mach-iop13xx/setup.c             |    1 
 arch/arm/mach-iop13xx/tpmi.c              |    1 
 arch/ia64/Kconfig                         |    1 
 arch/ia64/include/asm/hw_irq.h            |    1 
 arch/ia64/include/asm/irq.h               |    3 
 arch/ia64/include/asm/irq_remapping.h     |    2 
 arch/ia64/kernel/iosapic.c                |    2 
 arch/ia64/kernel/irq_ia64.c               |   15 ---
 arch/mips/pci/msi-xlp.c                   |   10 --
 arch/mips/pci/pci-xlr.c                   |   10 --
 arch/s390/kernel/irq.c                    |    5 -
 arch/s390/pci/pci.c                       |    6 -
 arch/tile/Kconfig                         |    2 
 arch/tile/include/asm/irq.h               |    6 -
 arch/tile/kernel/irq.c                    |   40 ---------
 arch/tile/kernel/pci_gx.c                 |   17 +--
 arch/x86/Kconfig                          |    1 
 arch/x86/include/asm/io_apic.h            |    2 
 arch/x86/include/asm/irq_remapping.h      |    3 
 arch/x86/kernel/apic/io_apic.c            |  130 +++++-------------------------
 arch/x86/kernel/hpet.c                    |    5 -
 arch/x86/platform/uv/uv_irq.c             |   10 --
 drivers/iommu/dmar.c                      |    8 -
 drivers/iommu/irq_remapping.c             |   12 +-
 drivers/net/ethernet/tile/tilegx.c        |    6 -
 drivers/pci/htirq.c                       |   13 ---
 drivers/sh/intc/core.c                    |    6 -
 drivers/tty/hvc/hvc_tile.c                |    8 -
 drivers/tty/serial/tilegx.c               |    8 -
 drivers/usb/host/ehci-tilegx.c            |    8 -
 drivers/usb/host/ohci-tilegx.c            |    8 -
 drivers/xen/events/events_base.c          |   17 ---
 include/linux/irq.h                       |   38 +++-----
 kernel/irq/Kconfig                        |    9 ++
 kernel/irq/chip.c                         |    5 -
 kernel/irq/internals.h                    |    6 +
 kernel/irq/irqdesc.c                      |   95 ++++++++++++++-------
 43 files changed, 216 insertions(+), 363 deletions(-)




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

* [patch 01/32] arm: iop13xx: Use sparse irqs for MSI
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-16 13:31   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 02/32] mips: Kill pointless destroy_irq() Thomas Gleixner
                   ` (31 subsequent siblings)
  32 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML
  Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra,
	Dan Williams, Russell King

[-- Attachment #1: arm-iop13xx-use-sparse-irq.patch --]
[-- Type: text/plain, Size: 5460 bytes --]

No need for a private allocator. The core code handles it
already. 

Allocate the non MSI irqs right at boot time via machine_desc->nr_irqs
and let the sparse core handle the MSI space.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
---
 arch/arm/Kconfig                          |    1 
 arch/arm/mach-iop13xx/include/mach/irqs.h |    2 -
 arch/arm/mach-iop13xx/include/mach/time.h |    3 +
 arch/arm/mach-iop13xx/iq81340mc.c         |    1 
 arch/arm/mach-iop13xx/iq81340sc.c         |    1 
 arch/arm/mach-iop13xx/msi.c               |   51 ++++++------------------------
 arch/arm/mach-iop13xx/setup.c             |    1 
 arch/arm/mach-iop13xx/tpmi.c              |    1 
 8 files changed, 19 insertions(+), 42 deletions(-)

Index: tip/arch/arm/Kconfig
===================================================================
--- tip.orig/arch/arm/Kconfig
+++ tip/arch/arm/Kconfig
@@ -480,6 +480,7 @@ config ARCH_IOP13XX
 	select PCI
 	select PLAT_IOP
 	select VMSPLIT_1G
+	select SPARSE_IRQ
 	help
 	  Support for Intel's IOP13XX (XScale) family of processors.
 
Index: tip/arch/arm/mach-iop13xx/include/mach/irqs.h
===================================================================
--- tip.orig/arch/arm/mach-iop13xx/include/mach/irqs.h
+++ tip/arch/arm/mach-iop13xx/include/mach/irqs.h
@@ -191,6 +191,4 @@ static inline u32 read_intpnd_3(void)
 #define NR_IOP13XX_IRQS	(IRQ_IOP13XX_HPI + 1)
 #endif
 
-#define NR_IRQS		NR_IOP13XX_IRQS
-
 #endif /* _IOP13XX_IRQ_H_ */
Index: tip/arch/arm/mach-iop13xx/include/mach/time.h
===================================================================
--- tip.orig/arch/arm/mach-iop13xx/include/mach/time.h
+++ tip/arch/arm/mach-iop13xx/include/mach/time.h
@@ -1,5 +1,8 @@
 #ifndef _IOP13XX_TIME_H_
 #define _IOP13XX_TIME_H_
+
+#include <mach/irqs.h>
+
 #define IRQ_IOP_TIMER0 IRQ_IOP13XX_TIMER0
 
 #define IOP_TMR_EN	    0x02
Index: tip/arch/arm/mach-iop13xx/iq81340mc.c
===================================================================
--- tip.orig/arch/arm/mach-iop13xx/iq81340mc.c
+++ tip/arch/arm/mach-iop13xx/iq81340mc.c
@@ -93,4 +93,5 @@ MACHINE_START(IQ81340MC, "Intel IQ81340M
 	.init_time	= iq81340mc_timer_init,
 	.init_machine   = iq81340mc_init,
 	.restart	= iop13xx_restart,
+	.nr_irqs	= NR_IOP13XX_IRQS,
 MACHINE_END
Index: tip/arch/arm/mach-iop13xx/iq81340sc.c
===================================================================
--- tip.orig/arch/arm/mach-iop13xx/iq81340sc.c
+++ tip/arch/arm/mach-iop13xx/iq81340sc.c
@@ -95,4 +95,5 @@ MACHINE_START(IQ81340SC, "Intel IQ81340S
 	.init_time	= iq81340sc_timer_init,
 	.init_machine   = iq81340sc_init,
 	.restart	= iop13xx_restart,
+	.nr_irqs	= NR_IOP13XX_IRQS,
 MACHINE_END
Index: tip/arch/arm/mach-iop13xx/msi.c
===================================================================
--- tip.orig/arch/arm/mach-iop13xx/msi.c
+++ tip/arch/arm/mach-iop13xx/msi.c
@@ -24,10 +24,6 @@
 #include <asm/mach/irq.h>
 #include <asm/irq.h>
 
-
-#define IOP13XX_NUM_MSI_IRQS 128
-static DECLARE_BITMAP(msi_irq_in_use, IOP13XX_NUM_MSI_IRQS);
-
 /* IMIPR0 CP6 R8 Page 1
  */
 static u32 read_imipr_0(void)
@@ -121,41 +117,6 @@ void __init iop13xx_msi_init(void)
 	irq_set_chained_handler(IRQ_IOP13XX_INBD_MSI, iop13xx_msi_handler);
 }
 
-/*
- * Dynamic irq allocate and deallocation
- */
-int create_irq(void)
-{
-	int irq, pos;
-
-again:
-	pos = find_first_zero_bit(msi_irq_in_use, IOP13XX_NUM_MSI_IRQS);
-	irq = IRQ_IOP13XX_MSI_0 + pos;
-	if (irq > NR_IRQS)
-		return -ENOSPC;
-	/* test_and_set_bit operates on 32-bits at a time */
-	if (test_and_set_bit(pos, msi_irq_in_use))
-		goto again;
-
-	dynamic_irq_init(irq);
-
-	return irq;
-}
-
-void destroy_irq(unsigned int irq)
-{
-	int pos = irq - IRQ_IOP13XX_MSI_0;
-
-	dynamic_irq_cleanup(irq);
-
-	clear_bit(pos, msi_irq_in_use);
-}
-
-void arch_teardown_msi_irq(unsigned int irq)
-{
-	destroy_irq(irq);
-}
-
 static void iop13xx_msi_nop(struct irq_data *d)
 {
 	return;
@@ -172,12 +133,17 @@ static struct irq_chip iop13xx_msi_chip
 
 int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
 {
-	int id, irq = create_irq();
+	int id, irq = irq_alloc_desc_from(IRQ_IOP13XX_MSI_0, -1);
 	struct msi_msg msg;
 
 	if (irq < 0)
 		return irq;
 
+	if (irq >= NR_IOP13XX_IRQS) {
+		irq_free_desc(irq);
+		return -ENOSPC;
+	}
+
 	irq_set_msi_desc(irq, desc);
 
 	msg.address_hi = 0x0;
@@ -191,3 +157,8 @@ int arch_setup_msi_irq(struct pci_dev *p
 
 	return 0;
 }
+
+void arch_teardown_msi_irq(unsigned int irq)
+{
+	irq_free_desc(irq);
+}
Index: tip/arch/arm/mach-iop13xx/setup.c
===================================================================
--- tip.orig/arch/arm/mach-iop13xx/setup.c
+++ tip/arch/arm/mach-iop13xx/setup.c
@@ -27,6 +27,7 @@
 #include <mach/hardware.h>
 #include <asm/irq.h>
 #include <asm/hardware/iop_adma.h>
+#include <mach/irqs.h>
 
 #define IOP13XX_UART_XTAL 33334000
 #define IOP13XX_SETUP_DEBUG 0
Index: tip/arch/arm/mach-iop13xx/tpmi.c
===================================================================
--- tip.orig/arch/arm/mach-iop13xx/tpmi.c
+++ tip/arch/arm/mach-iop13xx/tpmi.c
@@ -24,6 +24,7 @@
 #include <linux/io.h>
 #include <asm/irq.h>
 #include <asm/sizes.h>
+#include <mach/irqs.h>
 
 /* assumes CONTROLLER_ONLY# is never asserted in the ESSR register */
 #define IOP13XX_TPMI_MMR(dev) 	IOP13XX_REG_ADDR32_PHYS(0x48000 + (dev << 12))



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

* [patch 03/32] genirq: Provide generic hwirq allocation facility
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
  2014-05-07 15:44 ` [patch 01/32] arm: iop13xx: Use sparse irqs for MSI Thomas Gleixner
  2014-05-07 15:44 ` [patch 02/32] mips: Kill pointless destroy_irq() Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-07 20:37   ` Chris Metcalf
                     ` (3 more replies)
  2014-05-07 15:44 ` [patch 04/32] x86: Implement arch_setup/teardown_hwirq() Thomas Gleixner
                   ` (29 subsequent siblings)
  32 siblings, 4 replies; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML
  Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra,
	Chris Metcalf, Fenghua Yu

[-- Attachment #1: genirq-provide-generic-hwirq-allocation.patch --]
[-- Type: text/plain, Size: 4636 bytes --]

Not really the solution to the problem, but at least it confines the
mess in the core code and allows to get rid of the create/destroy_irq
variants from hell, i.e. 3 implementations with different semantics
plus the x86 specific variants __create_irqs and create_irq_nr
which have been invented in another circle of hell.

x86 : x86 should be converted to irq domains and I'm deliberately
      making it impossible to do the multi-vector MSI support by
      adding more crap to the current mess. It's not that hard to do
      and I'm really tired of the trainwrecks which have been invented
      by baindaid engineering so far. Any attempt to do multi-vector
      MSI or ioapic hotplug without converting to irq domains is NAKed
      hereby.

tile: Might use irq domains as well, but it has a very limited
      interrupt space, so handling it via this functionality might be
      the right thing to do even in the long run.

ia64: That's an hopeless case, as I doubt that anyone has the stomach
      to rewrite the homebrewn dynamic allocation facilities. I stared
      at it for a couple of hours and gave up. The create/destroy_irq
      mess could be made private to itanic right away if there
      wouldn't be the iommu/dmar driver being shared with x86. So to
      do that I'm going to add a separate ia64 specific implementation
      later in order not to deep-six itanic right away.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: x86@kernel.org
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>

---
 include/linux/irq.h  |   15 +++++++++++++++
 kernel/irq/Kconfig   |    5 +++++
 kernel/irq/irqdesc.c |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 71 insertions(+)

Index: tip/include/linux/irq.h
===================================================================
--- tip.orig/include/linux/irq.h
+++ tip/include/linux/irq.h
@@ -637,6 +637,21 @@ static inline int irq_reserve_irq(unsign
 	return irq_reserve_irqs(irq, 1);
 }
 
+#ifdef CONFIG_GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
+unsigned int irq_alloc_hwirqs(int cnt, int node);
+static inline unsigned int irq_alloc_hwirq(int node)
+{
+	return irq_alloc_hwirqs(1, node);
+}
+void irq_free_hwirqs(unsigned int from, int cnt);
+static inline void irq_free_hwirq(unsigned int irq)
+{
+	return irq_free_hwirqs(irq, 1);
+}
+int arch_setup_hwirq(unsigned int irq, int node);
+void arch_teardown_hwirq(unsigned int irq);
+#endif
+
 #ifndef irq_reg_writel
 # define irq_reg_writel(val, addr)	writel(val, addr)
 #endif
Index: tip/kernel/irq/Kconfig
===================================================================
--- tip.orig/kernel/irq/Kconfig
+++ tip/kernel/irq/Kconfig
@@ -17,6 +17,11 @@ config GENERIC_IRQ_SHOW
 config GENERIC_IRQ_SHOW_LEVEL
        bool
 
+# Facility to allocate an hardware interrupt. This is legacy support
+# and should not be used in new code. Use irq domains instead.
+config GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
+       bool
+
 # Support for delayed migration from interrupt context
 config GENERIC_PENDING_IRQ
 	bool
Index: tip/kernel/irq/irqdesc.c
===================================================================
--- tip.orig/kernel/irq/irqdesc.c
+++ tip/kernel/irq/irqdesc.c
@@ -396,6 +396,57 @@ err:
 }
 EXPORT_SYMBOL_GPL(__irq_alloc_descs);
 
+#ifdef CONFIG_GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
+/**
+ * irq_alloc_hwirqs - Allocate an irq descriptor and initialize the hardware
+ * @cnt:	number of interrupts to allocate
+ * @node:	node on which to allocate
+ *
+ * Returns an interrupt number > 0 or 0, if the allocation fails.
+ */
+unsigned int irq_alloc_hwirqs(int cnt, int node)
+{
+	int i, irq = __irq_alloc_descs(-1, 0, cnt, node, NULL);
+
+	if (irq < 0)
+		return 0;
+
+	for (i = irq; cnt > 0; i++, cnt--) {
+		if (arch_setup_hwirq(i, node))
+			goto err;
+		irq_clear_status_flags(i, _IRQ_NOREQUEST);
+	}
+	return irq;
+
+err:
+	for (i--; i >= irq; i--) {
+		irq_set_status_flags(i, _IRQ_NOREQUEST | _IRQ_NOPROBE);
+		arch_teardown_hwirq(i);
+	}
+	irq_free_descs(irq, cnt);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(irq_alloc_hwirqs);
+
+/**
+ * irq_free_hwirqs - Free irq descriptor and cleanup the hardware
+ * @from:	Free from irq number
+ * @cnt:	number of interrupts to free
+ *
+ */
+void irq_free_hwirqs(unsigned int from, int cnt)
+{
+	int i;
+
+	for (i = from; cnt > 0; i++, cnt--) {
+		irq_set_status_flags(i, _IRQ_NOREQUEST | _IRQ_NOPROBE);
+		arch_teardown_hwirq(i);
+	}
+	irq_free_descs(from, cnt);
+}
+EXPORT_SYMBOL_GPL(irq_free_hwirqs);
+#endif
+
 /**
  * irq_reserve_irqs - mark irqs allocated
  * @from:	mark from irq number



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

* [patch 02/32] mips: Kill pointless destroy_irq()
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
  2014-05-07 15:44 ` [patch 01/32] arm: iop13xx: Use sparse irqs for MSI Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-16 13:31   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 03/32] genirq: Provide generic hwirq allocation facility Thomas Gleixner
                   ` (30 subsequent siblings)
  32 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML
  Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra,
	Ralf Baechle, Jayachandran C

[-- Attachment #1: mips-kill-pointless-destroy-irq.patch --]
[-- Type: text/plain, Size: 1789 bytes --]

Copy and paste leftovers with no functionality at all.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Jayachandran C <jchandra@broadcom.com>
Cc: linux-mips@linux-mips.org
---
 arch/mips/pci/msi-xlp.c |   10 +---------
 arch/mips/pci/pci-xlr.c |   10 +---------
 2 files changed, 2 insertions(+), 18 deletions(-)

Index: tip/arch/mips/pci/msi-xlp.c
===================================================================
--- tip.orig/arch/mips/pci/msi-xlp.c
+++ tip/arch/mips/pci/msi-xlp.c
@@ -206,14 +206,8 @@ static struct irq_chip xlp_msix_chip = {
 	.irq_unmask	= unmask_msi_irq,
 };
 
-void destroy_irq(unsigned int irq)
-{
-	    /* nothing to do yet */
-}
-
 void arch_teardown_msi_irq(unsigned int irq)
 {
-	destroy_irq(irq);
 }
 
 /*
@@ -298,10 +292,8 @@ static int xlp_setup_msi(uint64_t lnkbas
 
 	xirq = xirq + msivec;		/* msi mapped to global irq space */
 	ret = irq_set_msi_desc(xirq, desc);
-	if (ret < 0) {
-		destroy_irq(xirq);
+	if (ret < 0)
 		return ret;
-	}
 
 	write_msi_msg(xirq, &msg);
 	return 0;
Index: tip/arch/mips/pci/pci-xlr.c
===================================================================
--- tip.orig/arch/mips/pci/pci-xlr.c
+++ tip/arch/mips/pci/pci-xlr.c
@@ -214,14 +214,8 @@ static int get_irq_vector(const struct p
 }
 
 #ifdef CONFIG_PCI_MSI
-void destroy_irq(unsigned int irq)
-{
-	    /* nothing to do yet */
-}
-
 void arch_teardown_msi_irq(unsigned int irq)
 {
-	destroy_irq(irq);
 }
 
 int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc)
@@ -263,10 +257,8 @@ int arch_setup_msi_irq(struct pci_dev *d
 		MSI_DATA_DELIVERY_FIXED;
 
 	ret = irq_set_msi_desc(irq, desc);
-	if (ret < 0) {
-		destroy_irq(irq);
+	if (ret < 0)
 		return ret;
-	}
 
 	write_msi_msg(irq, &msg);
 	return 0;



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

* [patch 04/32] x86: Implement arch_setup/teardown_hwirq()
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (2 preceding siblings ...)
  2014-05-07 15:44 ` [patch 03/32] genirq: Provide generic hwirq allocation facility Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-16 13:31   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 06/32] x86: hpet: Use irq_alloc/free_hwirq() Thomas Gleixner
                   ` (28 subsequent siblings)
  32 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra

[-- Attachment #1: x86-implement-setup-teardown-hwirqs.patch --]
[-- Type: text/plain, Size: 2113 bytes --]

This is just a cleanup to get rid of the create/destroy_irq variants
which were designed in hell.

The long term solution for x86 is to switch over to irq domains and
cleanup the whole vector allocation mess.

The generic irq_alloc_hwirqs() interface deliberately prevents
multi-MSI vector allocation to further enforce the irq domain
conversion (aside of the desire to support ioapic hotplug).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: x86@kernel.org
---
 arch/x86/Kconfig               |    1 +
 arch/x86/kernel/apic/io_apic.c |   33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)

Index: tip/arch/x86/Kconfig
===================================================================
--- tip.orig/arch/x86/Kconfig
+++ tip/arch/x86/Kconfig
@@ -831,6 +831,7 @@ config X86_LOCAL_APIC
 config X86_IO_APIC
 	def_bool y
 	depends on X86_64 || SMP || X86_32_NON_STANDARD || X86_UP_IOAPIC || PCI_MSI
+	select GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
 
 config X86_REROUTE_FOR_BROKEN_BOOT_IRQS
 	bool "Reroute for broken boot IRQs"
Index: tip/arch/x86/kernel/apic/io_apic.c
===================================================================
--- tip.orig/arch/x86/kernel/apic/io_apic.c
+++ tip/arch/x86/kernel/apic/io_apic.c
@@ -3010,6 +3010,39 @@ void destroy_irqs(unsigned int irq, unsi
 		destroy_irq(irq + i);
 }
 
+int arch_setup_hwirq(unsigned int irq, int node)
+{
+	struct irq_cfg *cfg;
+	unsigned long flags;
+	int ret;
+
+	cfg = alloc_irq_cfg(irq, node);
+	if (!cfg)
+		return -ENOMEM;
+
+	raw_spin_lock_irqsave(&vector_lock, flags);
+	ret = __assign_irq_vector(irq, cfg, apic->target_cpus());
+	raw_spin_unlock_irqrestore(&vector_lock, flags);
+
+	if (!ret)
+		irq_set_chip_data(irq, cfg);
+	else
+		free_irq_cfg(irq, cfg);
+	return ret;
+}
+
+void arch_teardown_hwirq(unsigned int irq)
+{
+	struct irq_cfg *cfg = irq_get_chip_data(irq);
+	unsigned long flags;
+
+	free_remapped_irq(irq);
+	raw_spin_lock_irqsave(&vector_lock, flags);
+	__clear_irq_vector(irq, cfg);
+	raw_spin_unlock_irqrestore(&vector_lock, flags);
+	free_irq_cfg(irq, cfg);
+}
+
 /*
  * MSI message composition
  */



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

* [patch 05/32] x86: irq_remapping: Use irq_alloc/free_hwirq()
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (4 preceding siblings ...)
  2014-05-07 15:44 ` [patch 06/32] x86: hpet: Use irq_alloc/free_hwirq() Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-14  9:32   ` Joerg Roedel
  2014-05-16 13:32   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 08/32] x86: htirq: Use irq_alloc/free_irq() Thomas Gleixner
                   ` (26 subsequent siblings)
  32 siblings, 2 replies; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra, Joerg Roedel

[-- Attachment #1: x86-irq-remap-use-irq-alloc-free-hwirq.patch --]
[-- Type: text/plain, Size: 1984 bytes --]

The create_irq variants are going away. Use the new interface. The
core and arch code already excludes the gsi interrupts from the
allocation, so no functional change.

This does not replace the requirement to move x86 to irq domains, but
it limits the mess to some degree.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: x86@kernel.org
Cc: Joerg Roedel <joro@8bytes.org>
Cc: iommu@lists.linux-foundation.org
---
 drivers/iommu/irq_remapping.c |   12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Index: tip/drivers/iommu/irq_remapping.c
===================================================================
--- tip.orig/drivers/iommu/irq_remapping.c
+++ tip/drivers/iommu/irq_remapping.c
@@ -51,7 +51,7 @@ static void irq_remapping_disable_io_api
 
 static int do_setup_msi_irqs(struct pci_dev *dev, int nvec)
 {
-	int node, ret, sub_handle, nvec_pow2, index = 0;
+	int ret, sub_handle, nvec_pow2, index = 0;
 	unsigned int irq;
 	struct msi_desc *msidesc;
 
@@ -61,8 +61,7 @@ static int do_setup_msi_irqs(struct pci_
 	WARN_ON(msidesc->msi_attrib.multiple);
 	WARN_ON(msidesc->nvec_used);
 
-	node = dev_to_node(&dev->dev);
-	irq = __create_irqs(get_nr_irqs_gsi(), nvec, node);
+	irq = irq_alloc_hwirqs(nvec, dev_to_node(&dev->dev));
 	if (irq == 0)
 		return -ENOSPC;
 
@@ -89,7 +88,7 @@ static int do_setup_msi_irqs(struct pci_
 	return 0;
 
 error:
-	destroy_irqs(irq, nvec);
+	irq_free_hwirqs(irq, nvec);
 
 	/*
 	 * Restore altered MSI descriptor fields and prevent just destroyed
@@ -109,12 +108,11 @@ static int do_setup_msix_irqs(struct pci
 	unsigned int irq;
 
 	node		= dev_to_node(&dev->dev);
-	irq		= get_nr_irqs_gsi();
 	sub_handle	= 0;
 
 	list_for_each_entry(msidesc, &dev->msi_list, list) {
 
-		irq = create_irq_nr(irq, node);
+		irq = irq_alloc_hwirq(node);
 		if (irq == 0)
 			return -1;
 
@@ -137,7 +135,7 @@ static int do_setup_msix_irqs(struct pci
 	return 0;
 
 error:
-	destroy_irq(irq);
+	irq_free_hwirq(irq);
 	return ret;
 }
 



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

* [patch 06/32] x86: hpet: Use irq_alloc/free_hwirq()
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (3 preceding siblings ...)
  2014-05-07 15:44 ` [patch 04/32] x86: Implement arch_setup/teardown_hwirq() Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-16 13:32   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 05/32] x86: irq_remapping: " Thomas Gleixner
                   ` (27 subsequent siblings)
  32 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra

[-- Attachment #1: x86-hpet-use-irq-alloc-free-hwirq.patch --]
[-- Type: text/plain, Size: 972 bytes --]

Use the new interfaces. No functional change.

This does not replace the requirement to move x86 to irq domains, but
it limits the mess to some degree.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: x86@kernel.org
---
 arch/x86/kernel/hpet.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Index: tip/arch/x86/kernel/hpet.c
===================================================================
--- tip.orig/arch/x86/kernel/hpet.c
+++ tip/arch/x86/kernel/hpet.c
@@ -479,7 +479,7 @@ static int hpet_msi_next_event(unsigned
 static int hpet_setup_msi_irq(unsigned int irq)
 {
 	if (x86_msi.setup_hpet_msi(irq, hpet_blockid)) {
-		destroy_irq(irq);
+		irq_free_hwirq(irq);
 		return -EINVAL;
 	}
 	return 0;
@@ -487,9 +487,8 @@ static int hpet_setup_msi_irq(unsigned i
 
 static int hpet_assign_irq(struct hpet_dev *dev)
 {
-	unsigned int irq;
+	unsigned int irq = irq_alloc_hwirq(-1);
 
-	irq = create_irq_nr(0, -1);
 	if (!irq)
 		return -EINVAL;
 



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

* [patch 08/32] x86: htirq: Use irq_alloc/free_irq()
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (5 preceding siblings ...)
  2014-05-07 15:44 ` [patch 05/32] x86: irq_remapping: " Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-07 16:03   ` Bjorn Helgaas
  2014-05-16 13:32   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 07/32] x86: uv: Use irq_alloc/free_hwirq() Thomas Gleixner
                   ` (25 subsequent siblings)
  32 siblings, 2 replies; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra, Bjorn Helgaas

[-- Attachment #1: x86-htirq-use-irq-alloc-hwirq.patch --]
[-- Type: text/plain, Size: 1430 bytes --]

No functional change, just cleaned up a bit.

This does not replace the requirement to move x86 to irq domains, but
it limits the mess to some degree.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: x86@kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org
---
 drivers/pci/htirq.c |   13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

Index: tip/drivers/pci/htirq.c
===================================================================
--- tip.orig/drivers/pci/htirq.c
+++ tip/drivers/pci/htirq.c
@@ -87,12 +87,9 @@ void unmask_ht_irq(struct irq_data *data
 int __ht_create_irq(struct pci_dev *dev, int idx, ht_irq_update_t *update)
 {
 	struct ht_irq_cfg *cfg;
+	int max_irq, pos, irq;
 	unsigned long flags;
 	u32 data;
-	int max_irq;
-	int pos;
-	int irq;
-	int node;
 
 	pos = pci_find_ht_capability(dev, HT_CAPTYPE_IRQ);
 	if (!pos)
@@ -120,10 +117,8 @@ int __ht_create_irq(struct pci_dev *dev,
 	cfg->msg.address_lo = 0xffffffff;
 	cfg->msg.address_hi = 0xffffffff;
 
-	node = dev_to_node(&dev->dev);
-	irq = create_irq_nr(0, node);
-
-	if (irq <= 0) {
+	irq = irq_alloc_hwirq(dev_to_node(&dev->dev));
+	if (!irq) {
 		kfree(cfg);
 		return -EBUSY;
 	}
@@ -166,7 +161,7 @@ void ht_destroy_irq(unsigned int irq)
 	cfg = irq_get_handler_data(irq);
 	irq_set_chip(irq, NULL);
 	irq_set_handler_data(irq, NULL);
-	destroy_irq(irq);
+	irq_free_hwirq(irq);
 
 	kfree(cfg);
 }



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

* [patch 07/32] x86: uv: Use irq_alloc/free_hwirq()
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (6 preceding siblings ...)
  2014-05-07 15:44 ` [patch 08/32] x86: htirq: Use irq_alloc/free_irq() Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-16 13:32   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 09/32] x86: ioapic: " Thomas Gleixner
                   ` (24 subsequent siblings)
  32 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra

[-- Attachment #1: x86-uv-use-irq-alloc-free-hwirq.patch --]
[-- Type: text/plain, Size: 1564 bytes --]

No functional change. The request to allocate the irq above
NR_IRQS_LEGACY is completely pointless as the implementation enforces
that the dynamic allocations are above the GSI interrupts, which
includes the legacy PIT irqs.

This does not replace the requirement to move x86 to irq domains, but
it limits the mess to some degree.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: x86@kernel.org
---
 arch/x86/platform/uv/uv_irq.c |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Index: tip/arch/x86/platform/uv/uv_irq.c
===================================================================
--- tip.orig/arch/x86/platform/uv/uv_irq.c
+++ tip/arch/x86/platform/uv/uv_irq.c
@@ -238,11 +238,9 @@ uv_set_irq_affinity(struct irq_data *dat
 int uv_setup_irq(char *irq_name, int cpu, int mmr_blade,
 		 unsigned long mmr_offset, int limit)
 {
-	int irq, ret;
+	int ret, irq = irq_alloc_hwirq(uv_blade_to_memory_nid(mmr_blade));
 
-	irq = create_irq_nr(NR_IRQS_LEGACY, uv_blade_to_memory_nid(mmr_blade));
-
-	if (irq <= 0)
+	if (!irq)
 		return -EBUSY;
 
 	ret = arch_enable_uv_irq(irq_name, irq, cpu, mmr_blade, mmr_offset,
@@ -250,7 +248,7 @@ int uv_setup_irq(char *irq_name, int cpu
 	if (ret == irq)
 		uv_set_irq_2_mmr_info(irq, mmr_offset, mmr_blade);
 	else
-		destroy_irq(irq);
+		irq_free_hwirq(irq);
 
 	return ret;
 }
@@ -285,6 +283,6 @@ void uv_teardown_irq(unsigned int irq)
 			n = n->rb_right;
 	}
 	spin_unlock_irqrestore(&uv_irq_lock, irqflags);
-	destroy_irq(irq);
+	irq_free_hwirq(irq);
 }
 EXPORT_SYMBOL_GPL(uv_teardown_irq);



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

* [patch 09/32] x86: ioapic: Use irq_alloc/free_hwirq()
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (7 preceding siblings ...)
  2014-05-07 15:44 ` [patch 07/32] x86: uv: Use irq_alloc/free_hwirq() Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-16 13:33   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 11/32] iommu: dmar: Fix return value check of create_irq() Thomas Gleixner
                   ` (23 subsequent siblings)
  32 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra

[-- Attachment #1: x86-ioapic-use-irq-alloc-hwirq.patch --]
[-- Type: text/plain, Size: 1510 bytes --]

No functional change just less crap.

This does not replace the requirement to move x86 to irq domains, but
it limits the mess to some degree.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: x86@kernel.org
---
 arch/x86/kernel/apic/io_apic.c |   23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

Index: tip/arch/x86/kernel/apic/io_apic.c
===================================================================
--- tip.orig/arch/x86/kernel/apic/io_apic.c
+++ tip/arch/x86/kernel/apic/io_apic.c
@@ -3169,8 +3169,8 @@ int setup_msi_irq(struct pci_dev *dev, s
 
 int native_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
 {
-	unsigned int irq, irq_want;
 	struct msi_desc *msidesc;
+	unsigned int irq;
 	int node, ret;
 
 	/* Multiple MSI vectors only supported with interrupt remapping */
@@ -3178,28 +3178,25 @@ int native_setup_msi_irqs(struct pci_dev
 		return 1;
 
 	node = dev_to_node(&dev->dev);
-	irq_want = nr_irqs_gsi;
+
 	list_for_each_entry(msidesc, &dev->msi_list, list) {
-		irq = create_irq_nr(irq_want, node);
-		if (irq == 0)
+		irq = irq_alloc_hwirq(node);
+		if (!irq)
 			return -ENOSPC;
 
-		irq_want = irq + 1;
-
 		ret = setup_msi_irq(dev, msidesc, irq, 0);
-		if (ret < 0)
-			goto error;
+		if (ret < 0) {
+			irq_free_hwirq(irq);
+			return ret;
+		}
+
 	}
 	return 0;
-
-error:
-	destroy_irq(irq);
-	return ret;
 }
 
 void native_teardown_msi_irq(unsigned int irq)
 {
-	destroy_irq(irq);
+	irq_free_hwirq(irq);
 }
 
 #ifdef CONFIG_DMAR_TABLE



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

* [patch 11/32] iommu: dmar: Fix return value check of create_irq()
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (8 preceding siblings ...)
  2014-05-07 15:44 ` [patch 09/32] x86: ioapic: " Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-16 13:33   ` [tip:irq/core] iommu: smar: Fix return value check of create_irq( ) tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 10/32] x86: Get rid of get_nr_irqs_gsi() Thomas Gleixner
                   ` (22 subsequent siblings)
  32 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML
  Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra, Fenghua Yu,
	Joerg Roedel

[-- Attachment #1: iommu-dmar-fix-return-value-check-of-create_irq.patch --]
[-- Type: text/plain, Size: 788 bytes --]

ia64 returns a negative error code when allocation fails andx86
returns 0. Make it handle both.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: x86@kernel.org
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
Cc: Joerg Roedel <joro@8bytes.org>
Cc: iommu@lists.linux-foundation.org
---
 drivers/iommu/dmar.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: tip/drivers/iommu/dmar.c
===================================================================
--- tip.orig/drivers/iommu/dmar.c
+++ tip/drivers/iommu/dmar.c
@@ -1551,7 +1551,7 @@ int dmar_set_interrupt(struct intel_iomm
 		return 0;
 
 	irq = create_irq();
-	if (!irq) {
+	if (irq <= 0) {
 		pr_err("IOMMU: no free vectors\n");
 		return -EINVAL;
 	}



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

* [patch 10/32] x86: Get rid of get_nr_irqs_gsi()
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (9 preceding siblings ...)
  2014-05-07 15:44 ` [patch 11/32] iommu: dmar: Fix return value check of create_irq() Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-16 13:33   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 13/32] ia64: Remove unused check_irq_used() Thomas Gleixner
                   ` (21 subsequent siblings)
  32 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML
  Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra,
	Konrad Rzeszutek Wilk

[-- Attachment #1: x86-get-rid-of-get-nr-irqs-gsi.patch --]
[-- Type: text/plain, Size: 2349 bytes --]

No need to expose this outside of the ioapic code. The dynamic
allocations are guaranteed not to happen in the gsi space. See commit
62a08ae2a.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: x86@kernel.org
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: xen-devel@lists.xenproject.org

---
 arch/x86/include/asm/io_apic.h   |    2 --
 arch/x86/kernel/apic/io_apic.c   |    5 -----
 drivers/xen/events/events_base.c |   17 +----------------
 3 files changed, 1 insertion(+), 23 deletions(-)

Index: tip/arch/x86/include/asm/io_apic.h
===================================================================
--- tip.orig/arch/x86/include/asm/io_apic.h
+++ tip/arch/x86/include/asm/io_apic.h
@@ -168,8 +168,6 @@ extern int save_ioapic_entries(void);
 extern void mask_ioapic_entries(void);
 extern int restore_ioapic_entries(void);
 
-extern int get_nr_irqs_gsi(void);
-
 extern void setup_ioapic_ids_from_mpc(void);
 extern void setup_ioapic_ids_from_mpc_nocheck(void);
 
Index: tip/arch/x86/kernel/apic/io_apic.c
===================================================================
--- tip.orig/arch/x86/kernel/apic/io_apic.c
+++ tip/arch/x86/kernel/apic/io_apic.c
@@ -3450,11 +3450,6 @@ static void __init probe_nr_irqs_gsi(voi
 	printk(KERN_DEBUG "nr_irqs_gsi: %d\n", nr_irqs_gsi);
 }
 
-int get_nr_irqs_gsi(void)
-{
-	return nr_irqs_gsi;
-}
-
 unsigned int arch_dynirq_lower_bound(unsigned int from)
 {
 	return from < nr_irqs_gsi ? nr_irqs_gsi : from;
Index: tip/drivers/xen/events/events_base.c
===================================================================
--- tip.orig/drivers/xen/events/events_base.c
+++ tip/drivers/xen/events/events_base.c
@@ -390,22 +390,7 @@ static void xen_irq_init(unsigned irq)
 
 static int __must_check xen_allocate_irqs_dynamic(int nvec)
 {
-	int first = 0;
-	int i, irq;
-
-#ifdef CONFIG_X86_IO_APIC
-	/*
-	 * For an HVM guest or domain 0 which see "real" (emulated or
-	 * actual respectively) GSIs we allocate dynamic IRQs
-	 * e.g. those corresponding to event channels or MSIs
-	 * etc. from the range above those "real" GSIs to avoid
-	 * collisions.
-	 */
-	if (xen_initial_domain() || xen_hvm_domain())
-		first = get_nr_irqs_gsi();
-#endif
-
-	irq = irq_alloc_descs_from(first, nvec, -1);
+	int i, irq = irq_alloc_descs(-1, 0, nvec, -1);
 
 	if (irq >= 0) {
 		for (i = 0; i < nvec; i++)



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

* [patch 13/32] ia64: Remove unused check_irq_used()
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (10 preceding siblings ...)
  2014-05-07 15:44 ` [patch 10/32] x86: Get rid of get_nr_irqs_gsi() Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-16 13:33   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 12/32] iommu: dmar: Provide arch specific irq allocation Thomas Gleixner
                   ` (20 subsequent siblings)
  32 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra, Fenghua Yu

[-- Attachment #1: ia64-remove-unused-check-irq-used.patch --]
[-- Type: text/plain, Size: 1405 bytes --]

Just stumbled over it when staring into ia64 irq handling.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
---
 arch/ia64/include/asm/hw_irq.h |    1 -
 arch/ia64/kernel/irq_ia64.c    |    8 --------
 2 files changed, 9 deletions(-)

Index: tip/arch/ia64/include/asm/hw_irq.h
===================================================================
--- tip.orig/arch/ia64/include/asm/hw_irq.h
+++ tip/arch/ia64/include/asm/hw_irq.h
@@ -132,7 +132,6 @@ extern int reserve_irq_vector (int vecto
 extern void __setup_vector_irq(int cpu);
 extern void ia64_send_ipi (int cpu, int vector, int delivery_mode, int redirect);
 extern void ia64_native_register_percpu_irq (ia64_vector vec, struct irqaction *action);
-extern int check_irq_used (int irq);
 extern void destroy_and_reserve_irq (unsigned int irq);
 
 #if defined(CONFIG_SMP) && (defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_DIG))
Index: tip/arch/ia64/kernel/irq_ia64.c
===================================================================
--- tip.orig/arch/ia64/kernel/irq_ia64.c
+++ tip/arch/ia64/kernel/irq_ia64.c
@@ -93,14 +93,6 @@ static int irq_status[NR_IRQS] = {
 	[0 ... NR_IRQS -1] = IRQ_UNUSED
 };
 
-int check_irq_used(int irq)
-{
-	if (irq_status[irq] == IRQ_USED)
-		return 1;
-
-	return -1;
-}
-
 static inline int find_unassigned_irq(void)
 {
 	int irq;



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

* [patch 12/32] iommu: dmar: Provide arch specific irq allocation
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (11 preceding siblings ...)
  2014-05-07 15:44 ` [patch 13/32] ia64: Remove unused check_irq_used() Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-16 13:33   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 14/32] x86: Remove create/dstroy_irq() Thomas Gleixner
                   ` (19 subsequent siblings)
  32 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML
  Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra, Fenghua Yu,
	Joerg Roedel

[-- Attachment #1: iommu-dmar-provide-arch-specific-irq-alloc.patch --]
[-- Type: text/plain, Size: 2415 bytes --]

ia64 and x86 share this driver. x86 is moving to a different irq
allocation and ia64 keeps its private irq_create/destroy stuff.

Use macros to redirect to one or the other. Yes, macros to avoid
include hell.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: x86@kernel.org
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
Cc: Joerg Roedel <joro@8bytes.org>
Cc: iommu@lists.linux-foundation.org
---
 arch/ia64/include/asm/irq_remapping.h |    2 ++
 arch/x86/include/asm/irq_remapping.h  |    3 +++
 drivers/iommu/dmar.c                  |    6 +++---
 3 files changed, 8 insertions(+), 3 deletions(-)

Index: tip/arch/ia64/include/asm/irq_remapping.h
===================================================================
--- tip.orig/arch/ia64/include/asm/irq_remapping.h
+++ tip/arch/ia64/include/asm/irq_remapping.h
@@ -1,4 +1,6 @@
 #ifndef __IA64_INTR_REMAPPING_H
 #define __IA64_INTR_REMAPPING_H
 #define irq_remapping_enabled 0
+#define dmar_alloc_hwirq	create_irq
+#define dmar_free_hwirq		destroy_irq
 #endif
Index: tip/arch/x86/include/asm/irq_remapping.h
===================================================================
--- tip.orig/arch/x86/include/asm/irq_remapping.h
+++ tip/arch/x86/include/asm/irq_remapping.h
@@ -58,6 +58,9 @@ extern bool setup_remapped_irq(int irq,
 
 void irq_remap_modify_chip_defaults(struct irq_chip *chip);
 
+#define dmar_alloc_hwirq()	irq_alloc_hwirq(-1)
+#define dmar_free_hwirq		irq_free_hwirq
+
 #else  /* CONFIG_IRQ_REMAP */
 
 static inline void setup_irq_remapping_ops(void) { }
Index: tip/drivers/iommu/dmar.c
===================================================================
--- tip.orig/drivers/iommu/dmar.c
+++ tip/drivers/iommu/dmar.c
@@ -994,7 +994,7 @@ static void free_iommu(struct intel_iomm
 	if (iommu->irq) {
 		free_irq(iommu->irq, iommu);
 		irq_set_handler_data(iommu->irq, NULL);
-		destroy_irq(iommu->irq);
+		dmar_free_hwirq(iommu->irq);
 	}
 
 	if (iommu->qi) {
@@ -1550,7 +1550,7 @@ int dmar_set_interrupt(struct intel_iomm
 	if (iommu->irq)
 		return 0;
 
-	irq = create_irq();
+	irq = dmar_alloc_hwirq();
 	if (irq <= 0) {
 		pr_err("IOMMU: no free vectors\n");
 		return -EINVAL;
@@ -1563,7 +1563,7 @@ int dmar_set_interrupt(struct intel_iomm
 	if (ret) {
 		irq_set_handler_data(irq, NULL);
 		iommu->irq = 0;
-		destroy_irq(irq);
+		dmar_free_hwirq(irq);
 		return ret;
 	}
 



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

* [patch 14/32] x86: Remove create/dstroy_irq()
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (12 preceding siblings ...)
  2014-05-07 15:44 ` [patch 12/32] iommu: dmar: Provide arch specific irq allocation Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-16 13:34   ` [tip:irq/core] x86: Remove create/destroy_irq() tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 16/32] tile: usb: Use irq_alloc/free_hwirq Thomas Gleixner
                   ` (18 subsequent siblings)
  32 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra

[-- Attachment #1: x86-remove-create-distroy-irq.patch --]
[-- Type: text/plain, Size: 3740 bytes --]

No more users. Remove the cruft

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: x86@kernel.org
---
 arch/x86/kernel/apic/io_apic.c |  106 -----------------------------------------
 include/linux/irq.h            |    4 -
 2 files changed, 1 insertion(+), 109 deletions(-)

Index: tip/arch/x86/kernel/apic/io_apic.c
===================================================================
--- tip.orig/arch/x86/kernel/apic/io_apic.c
+++ tip/arch/x86/kernel/apic/io_apic.c
@@ -281,18 +281,6 @@ static struct irq_cfg *alloc_irq_and_cfg
 	return cfg;
 }
 
-static int alloc_irqs_from(unsigned int from, unsigned int count, int node)
-{
-	return irq_alloc_descs_from(from, count, node);
-}
-
-static void free_irq_at(unsigned int at, struct irq_cfg *cfg)
-{
-	free_irq_cfg(at, cfg);
-	irq_free_desc(at);
-}
-
-
 struct io_apic {
 	unsigned int index;
 	unsigned int unused[3];
@@ -2916,100 +2904,8 @@ static int __init ioapic_init_ops(void)
 device_initcall(ioapic_init_ops);
 
 /*
- * Dynamic irq allocate and deallocation
+ * Dynamic irq allocate and deallocation. Should be replaced by irq domains!
  */
-unsigned int __create_irqs(unsigned int from, unsigned int count, int node)
-{
-	struct irq_cfg **cfg;
-	unsigned long flags;
-	int irq, i;
-
-	if (from < nr_irqs_gsi)
-		from = nr_irqs_gsi;
-
-	cfg = kzalloc_node(count * sizeof(cfg[0]), GFP_KERNEL, node);
-	if (!cfg)
-		return 0;
-
-	irq = alloc_irqs_from(from, count, node);
-	if (irq < 0)
-		goto out_cfgs;
-
-	for (i = 0; i < count; i++) {
-		cfg[i] = alloc_irq_cfg(irq + i, node);
-		if (!cfg[i])
-			goto out_irqs;
-	}
-
-	raw_spin_lock_irqsave(&vector_lock, flags);
-	for (i = 0; i < count; i++)
-		if (__assign_irq_vector(irq + i, cfg[i], apic->target_cpus()))
-			goto out_vecs;
-	raw_spin_unlock_irqrestore(&vector_lock, flags);
-
-	for (i = 0; i < count; i++) {
-		irq_set_chip_data(irq + i, cfg[i]);
-		irq_clear_status_flags(irq + i, IRQ_NOREQUEST);
-	}
-
-	kfree(cfg);
-	return irq;
-
-out_vecs:
-	for (i--; i >= 0; i--)
-		__clear_irq_vector(irq + i, cfg[i]);
-	raw_spin_unlock_irqrestore(&vector_lock, flags);
-out_irqs:
-	for (i = 0; i < count; i++)
-		free_irq_at(irq + i, cfg[i]);
-out_cfgs:
-	kfree(cfg);
-	return 0;
-}
-
-unsigned int create_irq_nr(unsigned int from, int node)
-{
-	return __create_irqs(from, 1, node);
-}
-
-int create_irq(void)
-{
-	int node = cpu_to_node(0);
-	unsigned int irq_want;
-	int irq;
-
-	irq_want = nr_irqs_gsi;
-	irq = create_irq_nr(irq_want, node);
-
-	if (irq == 0)
-		irq = -1;
-
-	return irq;
-}
-
-void destroy_irq(unsigned int irq)
-{
-	struct irq_cfg *cfg = irq_get_chip_data(irq);
-	unsigned long flags;
-
-	irq_set_status_flags(irq, IRQ_NOREQUEST|IRQ_NOPROBE);
-
-	free_remapped_irq(irq);
-
-	raw_spin_lock_irqsave(&vector_lock, flags);
-	__clear_irq_vector(irq, cfg);
-	raw_spin_unlock_irqrestore(&vector_lock, flags);
-	free_irq_at(irq, cfg);
-}
-
-void destroy_irqs(unsigned int irq, unsigned int count)
-{
-	unsigned int i;
-
-	for (i = 0; i < count; i++)
-		destroy_irq(irq + i);
-}
-
 int arch_setup_hwirq(unsigned int irq, int node)
 {
 	struct irq_cfg *cfg;
Index: tip/include/linux/irq.h
===================================================================
--- tip.orig/include/linux/irq.h
+++ tip/include/linux/irq.h
@@ -526,12 +526,8 @@ static inline void irq_set_percpu_devid_
 }
 
 /* Handle dynamic irq creation and destruction */
-extern unsigned int create_irq_nr(unsigned int irq_want, int node);
-extern unsigned int __create_irqs(unsigned int from, unsigned int count,
-				  int node);
 extern int create_irq(void);
 extern void destroy_irq(unsigned int irq);
-extern void destroy_irqs(unsigned int irq, unsigned int count);
 
 /*
  * Dynamic irq helper functions. Obsolete. Use irq_alloc_desc* and



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

* [patch 15/32] tile: Implement irq_alloc/free_hwirq() for migration
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (14 preceding siblings ...)
  2014-05-07 15:44 ` [patch 16/32] tile: usb: Use irq_alloc/free_hwirq Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-14 17:48   ` Chris Metcalf
                     ` (2 more replies)
  2014-05-07 15:44 ` [patch 17/32] tile: net: Use irq_alloc/free_hwirq Thomas Gleixner
                   ` (16 subsequent siblings)
  32 siblings, 3 replies; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra, Chris Metcalf

[-- Attachment #1: tile-implement-temporay-irq-alloc-free-hwirq.patch --]
[-- Type: text/plain, Size: 1251 bytes --]

We want to convert the drivers over to the new interface and finally
tile to sparse irqs. Implement irq_alloc/free_hwirq() for step by step
migration.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Chris Metcalf <cmetcalf@tilera.com>
---
 arch/tile/include/asm/irq.h |    3 +++
 arch/tile/kernel/irq.c      |   12 ++++++++++++
 2 files changed, 15 insertions(+)

Index: tip/arch/tile/include/asm/irq.h
===================================================================
--- tip.orig/arch/tile/include/asm/irq.h
+++ tip/arch/tile/include/asm/irq.h
@@ -76,4 +76,7 @@ void tile_irq_activate(unsigned int irq,
 
 void setup_irq_regs(void);
 
+unsigned int irq_alloc_hwirq(int node);
+void irq_free_hwirq(unsigned int irq);
+
 #endif /* _ASM_TILE_IRQ_H */
Index: tip/arch/tile/kernel/irq.c
===================================================================
--- tip.orig/arch/tile/kernel/irq.c
+++ tip/arch/tile/kernel/irq.c
@@ -312,4 +312,16 @@ void destroy_irq(unsigned int irq)
 	spin_unlock_irqrestore(&available_irqs_lock, flags);
 }
 EXPORT_SYMBOL(destroy_irq);
+
+unsigned int irq_alloc_hwirq(int node)
+{
+	int ret = create_irq();
+	return ret < 0 ? 0 : ret;
+}
+
+void irq_free_hwirq(unsigned int irq)
+{
+	destroy_irq();
+}
+
 #endif



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

* [patch 16/32] tile: usb: Use irq_alloc/free_hwirq
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (13 preceding siblings ...)
  2014-05-07 15:44 ` [patch 14/32] x86: Remove create/dstroy_irq() Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-16 13:34   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 15/32] tile: Implement irq_alloc/free_hwirq() for migration Thomas Gleixner
                   ` (17 subsequent siblings)
  32 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra, Chris Metcalf

[-- Attachment #1: tile-usb-use-alloc-free-irq.patch --]
[-- Type: text/plain, Size: 2100 bytes --]

No functional change. Just convert to the new interface.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Chris Metcalf <cmetcalf@tilera.com>
---
 drivers/usb/host/ehci-tilegx.c |    8 ++++----
 drivers/usb/host/ohci-tilegx.c |    8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

Index: tip/drivers/usb/host/ehci-tilegx.c
===================================================================
--- tip.orig/drivers/usb/host/ehci-tilegx.c
+++ tip/drivers/usb/host/ehci-tilegx.c
@@ -142,8 +142,8 @@ static int ehci_hcd_tilegx_drv_probe(str
 	ehci->hcs_params = readl(&ehci->caps->hcs_params);
 
 	/* Create our IRQs and register them. */
-	pdata->irq = create_irq();
-	if (pdata->irq < 0) {
+	pdata->irq = irq_alloc_hwirq(-1);
+	if (!pdata->irq) {
 		ret = -ENXIO;
 		goto err_no_irq;
 	}
@@ -175,7 +175,7 @@ static int ehci_hcd_tilegx_drv_probe(str
 	}
 
 err_have_irq:
-	destroy_irq(pdata->irq);
+	irq_free_hwirq(pdata->irq);
 err_no_irq:
 	tilegx_stop_ehc();
 	usb_put_hcd(hcd);
@@ -193,7 +193,7 @@ static int ehci_hcd_tilegx_drv_remove(st
 	usb_put_hcd(hcd);
 	tilegx_stop_ehc();
 	gxio_usb_host_destroy(&pdata->usb_ctx);
-	destroy_irq(pdata->irq);
+	irq_free_hwirq(pdata->irq);
 
 	return 0;
 }
Index: tip/drivers/usb/host/ohci-tilegx.c
===================================================================
--- tip.orig/drivers/usb/host/ohci-tilegx.c
+++ tip/drivers/usb/host/ohci-tilegx.c
@@ -129,8 +129,8 @@ static int ohci_hcd_tilegx_drv_probe(str
 	tilegx_start_ohc();
 
 	/* Create our IRQs and register them. */
-	pdata->irq = create_irq();
-	if (pdata->irq < 0) {
+	pdata->irq = irq_alloc_hwirq(-1);
+	if (!pdata->irq) {
 		ret = -ENXIO;
 		goto err_no_irq;
 	}
@@ -164,7 +164,7 @@ static int ohci_hcd_tilegx_drv_probe(str
 	}
 
 err_have_irq:
-	destroy_irq(pdata->irq);
+	irq_free_hwirq(pdata->irq);
 err_no_irq:
 	tilegx_stop_ohc();
 	usb_put_hcd(hcd);
@@ -182,7 +182,7 @@ static int ohci_hcd_tilegx_drv_remove(st
 	usb_put_hcd(hcd);
 	tilegx_stop_ohc();
 	gxio_usb_host_destroy(&pdata->usb_ctx);
-	destroy_irq(pdata->irq);
+	irq_free_hwirq(pdata->irq);
 
 	return 0;
 }



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

* [patch 17/32] tile: net: Use irq_alloc/free_hwirq
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (15 preceding siblings ...)
  2014-05-07 15:44 ` [patch 15/32] tile: Implement irq_alloc/free_hwirq() for migration Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-16 13:34   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 18/32] tile: serial: " Thomas Gleixner
                   ` (15 subsequent siblings)
  32 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra, Chris Metcalf

[-- Attachment #1: tile-net-use-alloc-free-irq.patch --]
[-- Type: text/plain, Size: 998 bytes --]

No functional change. Just convert to the new interface.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Chris Metcalf <cmetcalf@tilera.com>
---
 drivers/net/ethernet/tile/tilegx.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: tip/drivers/net/ethernet/tile/tilegx.c
===================================================================
--- tip.orig/drivers/net/ethernet/tile/tilegx.c
+++ tip/drivers/net/ethernet/tile/tilegx.c
@@ -1208,8 +1208,8 @@ static int tile_net_setup_interrupts(str
 
 	irq = md->ingress_irq;
 	if (irq < 0) {
-		irq = create_irq();
-		if (irq < 0) {
+		irq = irq_alloc_hwirq(-1);
+		if (!irq) {
 			netdev_err(dev,
 				   "create_irq failed: mpipe[%d] %d\n",
 				   instance, irq);
@@ -1223,7 +1223,7 @@ static int tile_net_setup_interrupts(str
 		if (rc != 0) {
 			netdev_err(dev, "request_irq failed: mpipe[%d] %d\n",
 				   instance, rc);
-			destroy_irq(irq);
+			irq_free_hwirq(irq);
 			return rc;
 		}
 		md->ingress_irq = irq;



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

* [patch 19/32] tile: hvc: Use irq_alloc/free_hwirq
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (17 preceding siblings ...)
  2014-05-07 15:44 ` [patch 18/32] tile: serial: " Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-16 13:35   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 20/32] tile: pci: Use irq_alloc/free_hwirq() Thomas Gleixner
                   ` (13 subsequent siblings)
  32 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra, Chris Metcalf

[-- Attachment #1: tile-hvc-use-alloc-free-irq.patch --]
[-- Type: text/plain, Size: 1124 bytes --]

No functional change. Just convert to the new interface.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Chris Metcalf <cmetcalf@tilera.com>
---
 drivers/tty/hvc/hvc_tile.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Index: tip/drivers/tty/hvc/hvc_tile.c
===================================================================
--- tip.orig/drivers/tty/hvc/hvc_tile.c
+++ tip/drivers/tty/hvc/hvc_tile.c
@@ -133,14 +133,14 @@ static int hvc_tile_probe(struct platfor
 	int tile_hvc_irq;
 
 	/* Create our IRQ and register it. */
-	tile_hvc_irq = create_irq();
-	if (tile_hvc_irq < 0)
+	tile_hvc_irq = irq_alloc_hwirq(-1);
+	if (!tile_hvc_irq)
 		return -ENXIO;
 
 	tile_irq_activate(tile_hvc_irq, TILE_IRQ_PERCPU);
 	hp = hvc_alloc(0, tile_hvc_irq, &hvc_tile_get_put_ops, 128);
 	if (IS_ERR(hp)) {
-		destroy_irq(tile_hvc_irq);
+		irq_free_hwirq(tile_hvc_irq);
 		return PTR_ERR(hp);
 	}
 	dev_set_drvdata(&pdev->dev, hp);
@@ -155,7 +155,7 @@ static int hvc_tile_remove(struct platfo
 
 	rc = hvc_remove(hp);
 	if (rc == 0)
-		destroy_irq(hp->data);
+		irq_free_hwirq(hp->data);
 
 	return rc;
 }



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

* [patch 18/32] tile: serial: Use irq_alloc/free_hwirq
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (16 preceding siblings ...)
  2014-05-07 15:44 ` [patch 17/32] tile: net: Use irq_alloc/free_hwirq Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-16 13:34   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 19/32] tile: hvc: " Thomas Gleixner
                   ` (14 subsequent siblings)
  32 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra, Chris Metcalf

[-- Attachment #1: tile-serial-use-alloc-free-irq.patch --]
[-- Type: text/plain, Size: 1145 bytes --]

No functional change. Just convert to the new interface.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Chris Metcalf <cmetcalf@tilera.com>
---
 drivers/tty/serial/tilegx.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Index: tip/drivers/tty/serial/tilegx.c
===================================================================
--- tip.orig/drivers/tty/serial/tilegx.c
+++ tip/drivers/tty/serial/tilegx.c
@@ -359,8 +359,8 @@ static int tilegx_startup(struct uart_po
 		}
 
 		/* Create our IRQs. */
-		port->irq = create_irq();
-		if (port->irq < 0)
+		port->irq = irq_alloc_hwirq(-1);
+		if (!port->irq)
 			goto err_uart_dest;
 		tile_irq_activate(port->irq, TILE_IRQ_PERCPU);
 
@@ -395,7 +395,7 @@ static int tilegx_startup(struct uart_po
 err_free_irq:
 	free_irq(port->irq, port);
 err_dest_irq:
-	destroy_irq(port->irq);
+	irq_free_hwirq(port->irq);
 err_uart_dest:
 	gxio_uart_destroy(context);
 	ret = -ENXIO;
@@ -435,7 +435,7 @@ static void tilegx_shutdown(struct uart_
 
 	if (port->irq > 0) {
 		free_irq(port->irq, port);
-		destroy_irq(port->irq);
+		irq_free_hwirq(port->irq);
 		port->irq = 0;
 	}
 



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

* [patch 20/32] tile: pci: Use irq_alloc/free_hwirq()
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (18 preceding siblings ...)
  2014-05-07 15:44 ` [patch 19/32] tile: hvc: " Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-16 13:35   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 21/32] tile: Use SPARSE_IRQ Thomas Gleixner
                   ` (12 subsequent siblings)
  32 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra, Chris Metcalf

[-- Attachment #1: tile-core-use-alloc-free-irq.patch --]
[-- Type: text/plain, Size: 1528 bytes --]

No functional change. Just convert to the new interface.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Chris Metcalf <cmetcalf@tilera.com>
---
 arch/tile/kernel/pci_gx.c |   17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

Index: tip/arch/tile/kernel/pci_gx.c
===================================================================
--- tip.orig/arch/tile/kernel/pci_gx.c
+++ tip/arch/tile/kernel/pci_gx.c
@@ -350,10 +350,9 @@ static int tile_init_irqs(struct pci_con
 		int cpu;
 
 		/* Ask the kernel to allocate an IRQ. */
-		irq = create_irq();
-		if (irq < 0) {
+		irq = irq_alloc_hwirq(-1);
+		if (!irq) {
 			pr_err("PCI: no free irq vectors, failed for %d\n", i);
-
 			goto free_irqs;
 		}
 		controller->irq_intx_table[i] = irq;
@@ -382,7 +381,7 @@ static int tile_init_irqs(struct pci_con
 
 free_irqs:
 	for (j = 0; j < i; j++)
-		destroy_irq(controller->irq_intx_table[j]);
+		irq_free_hwirq(controller->irq_intx_table[j]);
 
 	return -1;
 }
@@ -1500,9 +1499,9 @@ int arch_setup_msi_irq(struct pci_dev *p
 	int irq;
 	int ret;
 
-	irq = create_irq();
-	if (irq < 0)
-		return irq;
+	irq = irq_alloc_hwirq(-1);
+	if (!irq)
+		return -ENOSPC;
 
 	/*
 	 * Since we use a 64-bit Mem-Map to accept the MSI write, we fail
@@ -1601,11 +1600,11 @@ hv_msi_config_failure:
 	/* Free mem-map */
 msi_mem_map_alloc_failure:
 is_64_failure:
-	destroy_irq(irq);
+	irq_free_hwirq(irq);
 	return ret;
 }
 
 void arch_teardown_msi_irq(unsigned int irq)
 {
-	destroy_irq(irq);
+	irq_free_hwirq(irq);
 }



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

* [patch 21/32] tile: Use SPARSE_IRQ
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (19 preceding siblings ...)
  2014-05-07 15:44 ` [patch 20/32] tile: pci: Use irq_alloc/free_hwirq() Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-16 13:35   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 22/32] genirq: Make create/destroy_irq() ia64 private Thomas Gleixner
                   ` (11 subsequent siblings)
  32 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra, Chris Metcalf

[-- Attachment #1: tile-use-sparse-irq.patch --]
[-- Type: text/plain, Size: 3330 bytes --]

Get rid of the private allocator and switch over to sparse IRQs.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Chris Metcalf <cmetcalf@tilera.com>
---
 arch/tile/Kconfig           |    2 +
 arch/tile/include/asm/irq.h |    9 +++----
 arch/tile/kernel/irq.c      |   52 ++------------------------------------------
 3 files changed, 9 insertions(+), 54 deletions(-)

Index: tip/arch/tile/Kconfig
===================================================================
--- tip.orig/arch/tile/Kconfig
+++ tip/arch/tile/Kconfig
@@ -125,6 +125,8 @@ config HVC_TILE
 
 config TILEGX
 	bool "Building for TILE-Gx (64-bit) processor"
+	select SPARSE_IRQ
+	select GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
 	select HAVE_FUNCTION_TRACER
 	select HAVE_FUNCTION_TRACE_MCOUNT_TEST
 	select HAVE_FUNCTION_GRAPH_TRACER
Index: tip/arch/tile/include/asm/irq.h
===================================================================
--- tip.orig/arch/tile/include/asm/irq.h
+++ tip/arch/tile/include/asm/irq.h
@@ -18,10 +18,12 @@
 #include <linux/hardirq.h>
 
 /* The hypervisor interface provides 32 IRQs. */
-#define NR_IRQS 32
+#define NR_IRQS			32
 
 /* IRQ numbers used for linux IPIs. */
-#define IRQ_RESCHEDULE 0
+#define IRQ_RESCHEDULE	0
+/* Interrupts for dynamic allocation start at 1. Let the core allocate irq0 */
+#define NR_IRQS_LEGACY	1
 
 #define irq_canonicalize(irq)   (irq)
 
@@ -76,7 +78,4 @@ void tile_irq_activate(unsigned int irq,
 
 void setup_irq_regs(void);
 
-unsigned int irq_alloc_hwirq(int node);
-void irq_free_hwirq(unsigned int irq);
-
 #endif /* _ASM_TILE_IRQ_H */
Index: tip/arch/tile/kernel/irq.c
===================================================================
--- tip.orig/arch/tile/kernel/irq.c
+++ tip/arch/tile/kernel/irq.c
@@ -54,13 +54,6 @@ static DEFINE_PER_CPU(unsigned long, irq
  */
 static DEFINE_PER_CPU(int, irq_depth);
 
-/* State for allocating IRQs on Gx. */
-#if CHIP_HAS_IPI()
-static unsigned long available_irqs = ((1UL << NR_IRQS) - 1) &
-				      (~(1UL << IRQ_RESCHEDULE));
-static DEFINE_SPINLOCK(available_irqs_lock);
-#endif
-
 #if CHIP_HAS_IPI()
 /* Use SPRs to manipulate device interrupts. */
 #define mask_irqs(irq_mask) __insn_mtspr(SPR_IPI_MASK_SET_K, irq_mask)
@@ -278,50 +271,11 @@ int arch_show_interrupts(struct seq_file
 	return 0;
 }
 
-/*
- * Generic, controller-independent functions:
- */
-
 #if CHIP_HAS_IPI()
-int create_irq(void)
-{
-	unsigned long flags;
-	int result;
-
-	spin_lock_irqsave(&available_irqs_lock, flags);
-	if (available_irqs == 0)
-		result = -ENOMEM;
-	else {
-		result = __ffs(available_irqs);
-		available_irqs &= ~(1UL << result);
-		dynamic_irq_init(result);
-	}
-	spin_unlock_irqrestore(&available_irqs_lock, flags);
-
-	return result;
-}
-EXPORT_SYMBOL(create_irq);
-
-void destroy_irq(unsigned int irq)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&available_irqs_lock, flags);
-	available_irqs |= (1UL << irq);
-	dynamic_irq_cleanup(irq);
-	spin_unlock_irqrestore(&available_irqs_lock, flags);
-}
-EXPORT_SYMBOL(destroy_irq);
-
-unsigned int irq_alloc_hwirq(int node)
-{
-	int ret = create_irq();
-	return ret < 0 ? 0 : ret;
-}
-
-void irq_free_hwirq(unsigned int irq)
+int arch_setup_hwirq(unsigned int irq, int node)
 {
-	destroy_irq();
+	return irq >= NR_IRQS ? -EINVAL : 0;
 }
 
+void arch_teardown_hwirq(unsigned int irq) { }
 #endif



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

* [patch 22/32] genirq: Make create/destroy_irq() ia64 private
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (20 preceding siblings ...)
  2014-05-07 15:44 ` [patch 21/32] tile: Use SPARSE_IRQ Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-16 13:35   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 23/32] x86, irq: Remove pointless irq_reserve_irqs() call Thomas Gleixner
                   ` (10 subsequent siblings)
  32 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra, Fenghua Yu

[-- Attachment #1: irq-make-create-destroy-irq-ia64-private.patch --]
[-- Type: text/plain, Size: 1200 bytes --]

No more users outside of itanic. Confine it.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
---
 arch/ia64/include/asm/irq.h |    3 +++
 include/linux/irq.h         |    4 ----
 2 files changed, 3 insertions(+), 4 deletions(-)

Index: tip/arch/ia64/include/asm/irq.h
===================================================================
--- tip.orig/arch/ia64/include/asm/irq.h
+++ tip/arch/ia64/include/asm/irq.h
@@ -31,4 +31,7 @@ bool is_affinity_mask_valid(const struct
 
 #define is_affinity_mask_valid is_affinity_mask_valid
 
+int create_irq(void);
+void destroy_irq(unsigned int irq);
+
 #endif /* _ASM_IA64_IRQ_H */
Index: tip/include/linux/irq.h
===================================================================
--- tip.orig/include/linux/irq.h
+++ tip/include/linux/irq.h
@@ -525,10 +525,6 @@ static inline void irq_set_percpu_devid_
 			     IRQ_NOPROBE | IRQ_PER_CPU_DEVID);
 }
 
-/* Handle dynamic irq creation and destruction */
-extern int create_irq(void);
-extern void destroy_irq(unsigned int irq);
-
 /*
  * Dynamic irq helper functions. Obsolete. Use irq_alloc_desc* and
  * irq_free_desc instead.



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

* [patch 24/32] sh: intc: Remove pointless irq_reserve_irqs() invocation
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (22 preceding siblings ...)
  2014-05-07 15:44 ` [patch 23/32] x86, irq: Remove pointless irq_reserve_irqs() call Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-11  0:53   ` Simon Horman
  2014-05-16 13:36   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 25/32] s390: pci: Check return value of alloc_irq_desc() proper Thomas Gleixner
                   ` (8 subsequent siblings)
  32 siblings, 2 replies; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra, Simon Horman

[-- Attachment #1: sh-remove-pointless-reserve-irq-call.patch --]
[-- Type: text/plain, Size: 900 bytes --]

The preceding call to irq_create_identity_mapping() marks the
interrupt as allocated already. Remove the leftover.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-sh@vger.kernel.org
Cc: Simon Horman <horms@verge.net.au>
---
 drivers/sh/intc/core.c |    6 ------
 1 file changed, 6 deletions(-)

Index: tip/drivers/sh/intc/core.c
===================================================================
--- tip.orig/drivers/sh/intc/core.c
+++ tip/drivers/sh/intc/core.c
@@ -80,12 +80,6 @@ static void __init intc_register_irq(str
 	unsigned int data[2], primary;
 	unsigned long flags;
 
-	/*
-	 * Register the IRQ position with the global IRQ map, then insert
-	 * it in to the radix tree.
-	 */
-	irq_reserve_irq(irq);
-
 	raw_spin_lock_irqsave(&intc_big_lock, flags);
 	radix_tree_insert(&d->tree, enum_id, intc_irq_xlate_get(irq));
 	raw_spin_unlock_irqrestore(&intc_big_lock, flags);



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

* [patch 23/32] x86, irq: Remove pointless irq_reserve_irqs() call
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (21 preceding siblings ...)
  2014-05-07 15:44 ` [patch 22/32] genirq: Make create/destroy_irq() ia64 private Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-16 13:36   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 24/32] sh: intc: Remove pointless irq_reserve_irqs() invocation Thomas Gleixner
                   ` (9 subsequent siblings)
  32 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra

[-- Attachment #1: x86-remove-pointless-reserve-irq-call.patch --]
[-- Type: text/plain, Size: 775 bytes --]

That's a leftover from the time where x86 supported SPARSE_IRQ=n.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: x86@kernel.org
---
 arch/x86/kernel/apic/io_apic.c |    3 ---
 1 file changed, 3 deletions(-)

Index: tip/arch/x86/kernel/apic/io_apic.c
===================================================================
--- tip.orig/arch/x86/kernel/apic/io_apic.c
+++ tip/arch/x86/kernel/apic/io_apic.c
@@ -206,9 +206,6 @@ int __init arch_early_irq_init(void)
 	count = ARRAY_SIZE(irq_cfgx);
 	node = cpu_to_node(0);
 
-	/* Make sure the legacy interrupts are marked in the bitmap */
-	irq_reserve_irqs(0, legacy_pic->nr_legacy_irqs);
-
 	for (i = 0; i < count; i++) {
 		irq_set_chip_data(i, &cfg[i]);
 		zalloc_cpumask_var_node(&cfg[i].domain, GFP_KERNEL, node);



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

* [patch 25/32] s390: pci: Check return value of alloc_irq_desc() proper
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (23 preceding siblings ...)
  2014-05-07 15:44 ` [patch 24/32] sh: intc: Remove pointless irq_reserve_irqs() invocation Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-16 13:36   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 26/32] s390: Remove pointless arch_show_interrupts() Thomas Gleixner
                   ` (7 subsequent siblings)
  32 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML
  Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra,
	Martin Schwidefsky, Heiko Carstens

[-- Attachment #1: s390-pci-check-alloc-irq-proper.patch --]
[-- Type: text/plain, Size: 1272 bytes --]

alloc_irq_desc() returns an integer and as documented either a valid
irq number or a negative error code. Checking for NO_IRQ is definitely
not the proper error handling.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux390@de.ibm.com
---
 arch/s390/pci/pci.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: tip/arch/s390/pci/pci.c
===================================================================
--- tip.orig/arch/s390/pci/pci.c
+++ tip/arch/s390/pci/pci.c
@@ -401,11 +401,11 @@ static void zpci_irq_handler(struct airq
 int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
 {
 	struct zpci_dev *zdev = get_zdev(pdev);
-	unsigned int hwirq, irq, msi_vecs;
+	unsigned int hwirq, msi_vecs;
 	unsigned long aisb;
 	struct msi_desc *msi;
 	struct msi_msg msg;
-	int rc;
+	int rc, irq;
 
 	if (type == PCI_CAP_ID_MSI && nvec > 1)
 		return 1;
@@ -433,7 +433,7 @@ int arch_setup_msi_irqs(struct pci_dev *
 	list_for_each_entry(msi, &pdev->msi_list, list) {
 		rc = -EIO;
 		irq = irq_alloc_desc(0);	/* Alloc irq on node 0 */
-		if (irq == NO_IRQ)
+		if (irq < 0)
 			goto out_msi;
 		rc = irq_set_msi_desc(irq, msi);
 		if (rc)



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

* [patch 26/32] s390: Remove pointless arch_show_interrupts()
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (24 preceding siblings ...)
  2014-05-07 15:44 ` [patch 25/32] s390: pci: Check return value of alloc_irq_desc() proper Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-16 13:36   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 27/32] s390: Avoid call to irq_reserve_irqs() Thomas Gleixner
                   ` (6 subsequent siblings)
  32 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML
  Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra,
	Martin Schwidefsky, Heiko Carstens

[-- Attachment #1: s390-remove-pointless-arch-show-interrupts.patch --]
[-- Type: text/plain, Size: 729 bytes --]

S390 is not using the generic show interrupts implementation so the
extra arch_show_interrupts() is just useless.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux390@de.ibm.com
---
 arch/s390/kernel/irq.c |    5 -----
 1 file changed, 5 deletions(-)

Index: tip/arch/s390/kernel/irq.c
===================================================================
--- tip.orig/arch/s390/kernel/irq.c
+++ tip/arch/s390/kernel/irq.c
@@ -151,11 +151,6 @@ out:
 	return 0;
 }
 
-int arch_show_interrupts(struct seq_file *p, int prec)
-{
-	return 0;
-}
-
 /*
  * Switch to the asynchronous interrupt stack for softirq execution.
  */



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

* [patch 27/32] s390: Avoid call to irq_reserve_irqs()
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (25 preceding siblings ...)
  2014-05-07 15:44 ` [patch 26/32] s390: Remove pointless arch_show_interrupts() Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-16 13:36   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 28/32] genirq: Replace reserve_irqs in core code Thomas Gleixner
                   ` (5 subsequent siblings)
  32 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML
  Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra,
	Martin Schwidefsky, Heiko Carstens

[-- Attachment #1: s390-avoid-call-to-reserve-irq.patch --]
[-- Type: text/plain, Size: 1055 bytes --]

There is no need to mark the lower interrupts as reserved in order to
exclude them from dynamic allocation.

Provide arch_dynirq_lower_bound() to exclude the lower space.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux390@de.ibm.com
---
 arch/s390/kernel/irq.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Index: tip/arch/s390/kernel/irq.c
===================================================================
--- tip.orig/arch/s390/kernel/irq.c
+++ tip/arch/s390/kernel/irq.c
@@ -92,7 +92,6 @@ static const struct irq_class irqclass_s
 
 void __init init_IRQ(void)
 {
-	irq_reserve_irqs(0, THIN_INTERRUPT);
 	init_cio_interrupts();
 	init_airq_interrupts();
 	init_ext_interrupts();
@@ -151,6 +150,11 @@ out:
 	return 0;
 }
 
+unsigned int arch_dynirq_lower_bound(unsigned int from)
+{
+	return from < THIN_INTERRUPT ? THIN_INTERRUPT : from;
+}
+
 /*
  * Switch to the asynchronous interrupt stack for softirq execution.
  */



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

* [patch 29/32] genirq: Remove irq_reserve_irq[s]
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (27 preceding siblings ...)
  2014-05-07 15:44 ` [patch 28/32] genirq: Replace reserve_irqs in core code Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-08 12:14   ` Grant Likely
  2014-05-16 13:37   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 30/32] genirq: Replace dynamic_irq_init/cleanup Thomas Gleixner
                   ` (3 subsequent siblings)
  32 siblings, 2 replies; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra

[-- Attachment #1: genirq-remove-irq-reserve.patch --]
[-- Type: text/plain, Size: 1920 bytes --]

No more users. And it's not going to come back. If you need
hotplugable irq chips, use irq domains.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/irq.h  |    7 -------
 kernel/irq/irqdesc.c |   25 -------------------------
 2 files changed, 32 deletions(-)

Index: tip/include/linux/irq.h
===================================================================
--- tip.orig/include/linux/irq.h
+++ tip/include/linux/irq.h
@@ -617,18 +617,11 @@ int __irq_alloc_descs(int irq, unsigned
 	irq_alloc_descs(-1, from, cnt, node)
 
 void irq_free_descs(unsigned int irq, unsigned int cnt);
-int irq_reserve_irqs(unsigned int from, unsigned int cnt);
-
 static inline void irq_free_desc(unsigned int irq)
 {
 	irq_free_descs(irq, 1);
 }
 
-static inline int irq_reserve_irq(unsigned int irq)
-{
-	return irq_reserve_irqs(irq, 1);
-}
-
 #ifdef CONFIG_GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
 unsigned int irq_alloc_hwirqs(int cnt, int node);
 static inline unsigned int irq_alloc_hwirq(int node)
Index: tip/kernel/irq/irqdesc.c
===================================================================
--- tip.orig/kernel/irq/irqdesc.c
+++ tip/kernel/irq/irqdesc.c
@@ -455,31 +455,6 @@ EXPORT_SYMBOL_GPL(irq_free_hwirqs);
 #endif
 
 /**
- * irq_reserve_irqs - mark irqs allocated
- * @from:	mark from irq number
- * @cnt:	number of irqs to mark
- *
- * Returns 0 on success or an appropriate error code
- */
-int irq_reserve_irqs(unsigned int from, unsigned int cnt)
-{
-	unsigned int start;
-	int ret = 0;
-
-	if (!cnt || (from + cnt) > nr_irqs)
-		return -EINVAL;
-
-	mutex_lock(&sparse_irq_lock);
-	start = bitmap_find_next_zero_area(allocated_irqs, nr_irqs, from, cnt, 0);
-	if (start == from)
-		bitmap_set(allocated_irqs, start, cnt);
-	else
-		ret = -EEXIST;
-	mutex_unlock(&sparse_irq_lock);
-	return ret;
-}
-
-/**
  * irq_get_next_irq - get next allocated irq number
  * @offset:	where to start the search
  *



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

* [patch 28/32] genirq: Replace reserve_irqs in core code
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (26 preceding siblings ...)
  2014-05-07 15:44 ` [patch 27/32] s390: Avoid call to irq_reserve_irqs() Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-16 13:37   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 29/32] genirq: Remove irq_reserve_irq[s] Thomas Gleixner
                   ` (4 subsequent siblings)
  32 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra

[-- Attachment #1: genirq-replace-irq-reserve.patch --]
[-- Type: text/plain, Size: 1876 bytes --]

We want to get rid of the public interface.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/irq/chip.c      |    5 ++---
 kernel/irq/internals.h |    6 ++++++
 kernel/irq/irqdesc.c   |    7 +++++++
 3 files changed, 15 insertions(+), 3 deletions(-)

Index: tip/kernel/irq/chip.c
===================================================================
--- tip.orig/kernel/irq/chip.c
+++ tip/kernel/irq/chip.c
@@ -40,10 +40,9 @@ int irq_set_chip(unsigned int irq, struc
 	irq_put_desc_unlock(desc, flags);
 	/*
 	 * For !CONFIG_SPARSE_IRQ make the irq show up in
-	 * allocated_irqs. For the CONFIG_SPARSE_IRQ case, it is
-	 * already marked, and this call is harmless.
+	 * allocated_irqs.
 	 */
-	irq_reserve_irq(irq);
+	irq_mark_irq(irq);
 	return 0;
 }
 EXPORT_SYMBOL(irq_set_chip);
Index: tip/kernel/irq/internals.h
===================================================================
--- tip.orig/kernel/irq/internals.h
+++ tip/kernel/irq/internals.h
@@ -76,6 +76,12 @@ extern void mask_irq(struct irq_desc *de
 extern void unmask_irq(struct irq_desc *desc);
 extern void unmask_threaded_irq(struct irq_desc *desc);
 
+#ifdef CONFIG_SPARSE_IRQ
+static inline void irq_mark_irq(unsigned int irq) { }
+#else
+extern void irq_mark_irq(unsigned int irq);
+#endif
+
 extern void init_kstat_irqs(struct irq_desc *desc, int node, int nr);
 
 irqreturn_t handle_irq_event_percpu(struct irq_desc *desc, struct irqaction *action);
Index: tip/kernel/irq/irqdesc.c
===================================================================
--- tip.orig/kernel/irq/irqdesc.c
+++ tip/kernel/irq/irqdesc.c
@@ -299,6 +299,13 @@ static int irq_expand_nr_irqs(unsigned i
 	return -ENOMEM;
 }
 
+void irq_mark_irq(unsigned int irq)
+{
+	mutex_lock(&sparse_irq_lock);
+	bitmap_set(allocated_irqs, irq, 1);
+	mutex_unlock(&sparse_irq_lock);
+}
+
 #endif /* !CONFIG_SPARSE_IRQ */
 
 /**



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

* [patch 31/32] ia64: Use irq_init_desc
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (29 preceding siblings ...)
  2014-05-07 15:44 ` [patch 30/32] genirq: Replace dynamic_irq_init/cleanup Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-07 20:06   ` Luck, Tony
  2014-05-16 13:37   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 32/32] genirq: Remove dynamic_irq mess Thomas Gleixner
  2014-05-08 12:17 ` [patch 00/32] genirq: Another round of tree wide cleanups Grant Likely
  32 siblings, 2 replies; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra, Fenghua Yu

[-- Attachment #1: ia64-use-irq-init-desc.patch --]
[-- Type: text/plain, Size: 1966 bytes --]

Switch over to the new interface. No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
---
 arch/ia64/Kconfig           |    1 +
 arch/ia64/kernel/iosapic.c  |    2 +-
 arch/ia64/kernel/irq_ia64.c |    7 +++----
 3 files changed, 5 insertions(+), 5 deletions(-)

Index: tip/arch/ia64/Kconfig
===================================================================
--- tip.orig/arch/ia64/Kconfig
+++ tip/arch/ia64/Kconfig
@@ -32,6 +32,7 @@ config IA64
 	select GENERIC_IRQ_PROBE
 	select GENERIC_PENDING_IRQ if SMP
 	select GENERIC_IRQ_SHOW
+	select GENERIC_IRQ_LEGACY
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	select GENERIC_IOMAP
Index: tip/arch/ia64/kernel/iosapic.c
===================================================================
--- tip.orig/arch/ia64/kernel/iosapic.c
+++ tip/arch/ia64/kernel/iosapic.c
@@ -735,7 +735,7 @@ iosapic_register_intr (unsigned int gsi,
 		rte = find_rte(irq, gsi);
 		if(iosapic_intr_info[irq].count == 0) {
 			assign_irq_vector(irq);
-			dynamic_irq_init(irq);
+			irq_init_desc(irq);
 		} else if (rte->refcnt != NO_REF_RTE) {
 			rte->refcnt++;
 			goto unlock_iosapic_lock;
Index: tip/arch/ia64/kernel/irq_ia64.c
===================================================================
--- tip.orig/arch/ia64/kernel/irq_ia64.c
+++ tip/arch/ia64/kernel/irq_ia64.c
@@ -382,8 +382,7 @@ void destroy_and_reserve_irq(unsigned in
 {
 	unsigned long flags;
 
-	dynamic_irq_cleanup(irq);
-
+	irq_init_desc(irq);
 	spin_lock_irqsave(&vector_lock, flags);
 	__clear_irq_vector(irq);
 	irq_status[irq] = IRQ_RSVD;
@@ -416,13 +415,13 @@ int create_irq(void)
  out:
 	spin_unlock_irqrestore(&vector_lock, flags);
 	if (irq >= 0)
-		dynamic_irq_init(irq);
+		irq_init_desc(irq);
 	return irq;
 }
 
 void destroy_irq(unsigned int irq)
 {
-	dynamic_irq_cleanup(irq);
+	irq_init_desc(irq);
 	clear_irq_vector(irq);
 }
 



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

* [patch 30/32] genirq: Replace dynamic_irq_init/cleanup
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (28 preceding siblings ...)
  2014-05-07 15:44 ` [patch 29/32] genirq: Remove irq_reserve_irq[s] Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-16 13:37   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-07 15:44 ` [patch 31/32] ia64: Use irq_init_desc Thomas Gleixner
                   ` (2 subsequent siblings)
  32 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra

[-- Attachment #1: genirq-replace-dynamic-irq-crap.patch --]
[-- Type: text/plain, Size: 1602 bytes --]

Create a new interface and confine it with a config switch which makes
clear that this is just legacy support and not to be used for new code.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/irq.h  |    4 ++++
 kernel/irq/Kconfig   |    4 ++++
 kernel/irq/irqdesc.c |    7 +++++++
 3 files changed, 15 insertions(+)

Index: tip/include/linux/irq.h
===================================================================
--- tip.orig/include/linux/irq.h
+++ tip/include/linux/irq.h
@@ -637,6 +637,10 @@ int arch_setup_hwirq(unsigned int irq, i
 void arch_teardown_hwirq(unsigned int irq);
 #endif
 
+#ifdef CONFIG_GENERIC_IRQ_LEGACY
+void irq_init_desc(unsigned int irq);
+#endif
+
 #ifndef irq_reg_writel
 # define irq_reg_writel(val, addr)	writel(val, addr)
 #endif
Index: tip/kernel/irq/Kconfig
===================================================================
--- tip.orig/kernel/irq/Kconfig
+++ tip/kernel/irq/Kconfig
@@ -5,6 +5,10 @@ menu "IRQ subsystem"
 config MAY_HAVE_SPARSE_IRQ
        bool
 
+# Legacy support, required for itanic
+config GENERIC_IRQ_LEGACY
+       bool
+
 # Enable the generic irq autoprobe mechanism
 config GENERIC_IRQ_PROBE
 	bool
Index: tip/kernel/irq/irqdesc.c
===================================================================
--- tip.orig/kernel/irq/irqdesc.c
+++ tip/kernel/irq/irqdesc.c
@@ -306,6 +306,13 @@ void irq_mark_irq(unsigned int irq)
 	mutex_unlock(&sparse_irq_lock);
 }
 
+#ifdef CONFIG_GENERIC_IRQ_LEGACY
+void irq_init_desc(unsigned int irq)
+{
+	dynamic_irq_cleanup(irq);
+}
+#endif
+
 #endif /* !CONFIG_SPARSE_IRQ */
 
 /**



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

* [patch 32/32] genirq: Remove dynamic_irq mess
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (30 preceding siblings ...)
  2014-05-07 15:44 ` [patch 31/32] ia64: Use irq_init_desc Thomas Gleixner
@ 2014-05-07 15:44 ` Thomas Gleixner
  2014-05-16 13:37   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-05-08 12:17 ` [patch 00/32] genirq: Another round of tree wide cleanups Grant Likely
  32 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 15:44 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra

[-- Attachment #1: genirq-remove-dynamic-irq-mess.patch --]
[-- Type: text/plain, Size: 2264 bytes --]

No more users. Get rid of the cruft.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/irq.h  |   10 ----------
 kernel/irq/irqdesc.c |   23 +++++++----------------
 2 files changed, 7 insertions(+), 26 deletions(-)

Index: tip/include/linux/irq.h
===================================================================
--- tip.orig/include/linux/irq.h
+++ tip/include/linux/irq.h
@@ -525,16 +525,6 @@ static inline void irq_set_percpu_devid_
 			     IRQ_NOPROBE | IRQ_PER_CPU_DEVID);
 }
 
-/*
- * Dynamic irq helper functions. Obsolete. Use irq_alloc_desc* and
- * irq_free_desc instead.
- */
-extern void dynamic_irq_cleanup(unsigned int irq);
-static inline void dynamic_irq_init(unsigned int irq)
-{
-	dynamic_irq_cleanup(irq);
-}
-
 /* Set/get chip/data for an IRQ: */
 extern int irq_set_chip(unsigned int irq, struct irq_chip *chip);
 extern int irq_set_handler_data(unsigned int irq, void *data);
Index: tip/kernel/irq/irqdesc.c
===================================================================
--- tip.orig/kernel/irq/irqdesc.c
+++ tip/kernel/irq/irqdesc.c
@@ -278,7 +278,12 @@ EXPORT_SYMBOL(irq_to_desc);
 
 static void free_desc(unsigned int irq)
 {
-	dynamic_irq_cleanup(irq);
+	struct irq_desc *desc = irq_to_desc(irq);
+	unsigned long flags;
+
+	raw_spin_lock_irqsave(&desc->lock, flags);
+	desc_set_defaults(irq, desc, desc_node(desc), NULL);
+	raw_spin_unlock_irqrestore(&desc->lock, flags);
 }
 
 static inline int alloc_descs(unsigned int start, unsigned int cnt, int node,
@@ -309,7 +314,7 @@ void irq_mark_irq(unsigned int irq)
 #ifdef CONFIG_GENERIC_IRQ_LEGACY
 void irq_init_desc(unsigned int irq)
 {
-	dynamic_irq_cleanup(irq);
+	free_desc(irq);
 }
 #endif
 
@@ -522,20 +527,6 @@ int irq_set_percpu_devid(unsigned int ir
 	return 0;
 }
 
-/**
- * dynamic_irq_cleanup - cleanup a dynamically allocated irq
- * @irq:	irq number to initialize
- */
-void dynamic_irq_cleanup(unsigned int irq)
-{
-	struct irq_desc *desc = irq_to_desc(irq);
-	unsigned long flags;
-
-	raw_spin_lock_irqsave(&desc->lock, flags);
-	desc_set_defaults(irq, desc, desc_node(desc), NULL);
-	raw_spin_unlock_irqrestore(&desc->lock, flags);
-}
-
 void kstat_incr_irq_this_cpu(unsigned int irq)
 {
 	kstat_incr_irqs_this_cpu(irq, irq_to_desc(irq));



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

* Re: [patch 08/32] x86: htirq: Use irq_alloc/free_irq()
  2014-05-07 15:44 ` [patch 08/32] x86: htirq: Use irq_alloc/free_irq() Thomas Gleixner
@ 2014-05-07 16:03   ` Bjorn Helgaas
  2014-05-07 16:30     ` Thomas Gleixner
  2014-05-16 13:32   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  1 sibling, 1 reply; 86+ messages in thread
From: Bjorn Helgaas @ 2014-05-07 16:03 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: LKML, Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra

On Wed, May 7, 2014 at 9:44 AM, Thomas Gleixner <tglx@linutronix.de> wrote:
> No functional change, just cleaned up a bit.
>
> This does not replace the requirement to move x86 to irq domains, but
> it limits the mess to some degree.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Acked-by: Bjorn Helgaas <bhelgaas@google.com>

I assume you'll merge this along with the rest of your series.  Let me
know if you need me to do anything.

> Cc: x86@kernel.org
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: linux-pci@vger.kernel.org
> ---
>  drivers/pci/htirq.c |   13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
>
> Index: tip/drivers/pci/htirq.c
> ===================================================================
> --- tip.orig/drivers/pci/htirq.c
> +++ tip/drivers/pci/htirq.c
> @@ -87,12 +87,9 @@ void unmask_ht_irq(struct irq_data *data
>  int __ht_create_irq(struct pci_dev *dev, int idx, ht_irq_update_t *update)
>  {
>         struct ht_irq_cfg *cfg;
> +       int max_irq, pos, irq;
>         unsigned long flags;
>         u32 data;
> -       int max_irq;
> -       int pos;
> -       int irq;
> -       int node;
>
>         pos = pci_find_ht_capability(dev, HT_CAPTYPE_IRQ);
>         if (!pos)
> @@ -120,10 +117,8 @@ int __ht_create_irq(struct pci_dev *dev,
>         cfg->msg.address_lo = 0xffffffff;
>         cfg->msg.address_hi = 0xffffffff;
>
> -       node = dev_to_node(&dev->dev);
> -       irq = create_irq_nr(0, node);
> -
> -       if (irq <= 0) {
> +       irq = irq_alloc_hwirq(dev_to_node(&dev->dev));
> +       if (!irq) {
>                 kfree(cfg);
>                 return -EBUSY;
>         }
> @@ -166,7 +161,7 @@ void ht_destroy_irq(unsigned int irq)
>         cfg = irq_get_handler_data(irq);
>         irq_set_chip(irq, NULL);
>         irq_set_handler_data(irq, NULL);
> -       destroy_irq(irq);
> +       irq_free_hwirq(irq);
>
>         kfree(cfg);
>  }
>
>

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

* Re: [patch 08/32] x86: htirq: Use irq_alloc/free_irq()
  2014-05-07 16:03   ` Bjorn Helgaas
@ 2014-05-07 16:30     ` Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 16:30 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: LKML, Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra

On Wed, 7 May 2014, Bjorn Helgaas wrote:

> On Wed, May 7, 2014 at 9:44 AM, Thomas Gleixner <tglx@linutronix.de> wrote:
> > No functional change, just cleaned up a bit.
> >
> > This does not replace the requirement to move x86 to irq domains, but
> > it limits the mess to some degree.
> >
> > Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> 
> Acked-by: Bjorn Helgaas <bhelgaas@google.com>
> 
> I assume you'll merge this along with the rest of your series.  Let me
> know if you need me to do anything.

Yes, I'll take the whole lot when nobody screams

Thanks,

	tglx

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

* RE: [patch 31/32] ia64: Use irq_init_desc
  2014-05-07 15:44 ` [patch 31/32] ia64: Use irq_init_desc Thomas Gleixner
@ 2014-05-07 20:06   ` Luck, Tony
  2014-05-16 13:37   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 86+ messages in thread
From: Luck, Tony @ 2014-05-07 20:06 UTC (permalink / raw)
  To: Thomas Gleixner, LKML
  Cc: Ingo Molnar, Peter Anvin, Peter Zijlstra, Yu, Fenghua

> Switch over to the new interface. No functional change.

ia64 parts:

Tested-by: Tony Luck <tony.luck@intel.com>

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

* Re: [patch 03/32] genirq: Provide generic hwirq allocation facility
  2014-05-07 15:44 ` [patch 03/32] genirq: Provide generic hwirq allocation facility Thomas Gleixner
@ 2014-05-07 20:37   ` Chris Metcalf
  2014-05-07 23:15     ` Thomas Gleixner
  2014-05-08 12:07   ` Grant Likely
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 86+ messages in thread
From: Chris Metcalf @ 2014-05-07 20:37 UTC (permalink / raw)
  To: Thomas Gleixner, LKML, Tony Lu
  Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra, Fenghua Yu

On 5/7/2014 11:44 AM, Thomas Gleixner wrote:
> Not really the solution to the problem, but at least it confines the
> mess in the core code and allows to get rid of the create/destroy_irq
> variants from hell, i.e. 3 implementations with different semantics
> plus the x86 specific variants __create_irqs and create_irq_nr
> which have been invented in another circle of hell.
>
> [...]
>
> tile: Might use irq domains as well, but it has a very limited
>       interrupt space, so handling it via this functionality might be
>       the right thing to do even in the long run.

We have an internal change that we haven't upstreamed yet that makes
irqs actually (cpu,ipi) pairs, so that more irqs can be allocated.
As a result we allocate some irqs as bound to a specific IPI on a single
cpu, and some irqs get bound to a particular IPI registered on every cpu.

I'll have to set aside a bit of time to look more closely at how your
change interacts with the work we've done internally.  I've appended the
per-cpu IRQ change from our internal tree here (and cc'ed the author).
The API change is in the <asm/irq.h> diff at the very start.

--
From: Tony Lu <zlu@tilera.com>
Subject: [PATCH] tile: per-cpu IRQ support

With the change, we are no longer limited to 32 IRQ resources.
We support up to NR_CPUS*32 IRQ resources. Note there are some
IRQ-related API changes.

- create_irq(). Create an IRQ that should happen on every core, such
as Linux IPI reschedule, and mPIPE network ingress IRQ.

- create_irq_on_any(). Create an IRQ that should happen on a single
core. It chooses the core from non-dataplanes.

- create_irq_on(cpu). Create an IRQ that should happen on a single
core. The core is specified if cpu ID is valid, else if cpu=-1, this
function choose a core from non-dataplane.

This change also makes irq_disable/irq_enable into no-ops.  They are
currently used only by request_irq/free_irq. And in the request_irq/
free_irq context during shim driver initialization, we call the gxio
routines to configure the IRQ binding/unbinding, so there is no need
to do irq_disable/irq_enable twice.

Signed-off-by: Tony Lu <zlu@tilera.com>
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
---
 arch/tile/include/asm/irq.h        |  48 +++++-
 arch/tile/kernel/irq.c             | 294 ++++++++++++++++++++++++++++++++-----
 arch/tile/kernel/pci_gx.c          |  91 ++++++------
 arch/tile/kernel/smp.c             |  18 ++-
 drivers/net/ethernet/tile/tilegx.c |   3 +-
 drivers/tty/hvc/hvc_tile.c         |   6 +-
 drivers/tty/serial/tilegx.c        |   9 +-
 drivers/usb/host/ehci-tilegx.c     |   9 +-
 drivers/usb/host/ohci-tilegx.c     |   9 +-
 9 files changed, 384 insertions(+), 103 deletions(-)

diff --git a/arch/tile/include/asm/irq.h b/arch/tile/include/asm/irq.h
index 33cff9a3058b..aa7577e80bc8 100644
--- a/arch/tile/include/asm/irq.h
+++ b/arch/tile/include/asm/irq.h
@@ -17,14 +17,33 @@
 
 #include <linux/hardirq.h>
 
-/* The hypervisor interface provides 32 IRQs. */
+/* The hypervisor interface provides 32 IPI events per core. */
+#define NR_IPI_EVENTS 32
+
+#if CHIP_HAS_IPI()
+/* 
+ * The number of supported IRQs. This can be set to a larger value
+ * (at most NR_CPUS*NR_IPI_EVENTS) that may be needed with more
+ * peripheral devices.
+ */
+#define NR_IRQS 256
+#else
 #define NR_IRQS 32
+#endif
 
-/* IRQ numbers used for linux IPIs. */
-#define IRQ_RESCHEDULE 0
+/* The IRQ number used for linux IPI reschedule. */
+extern int irq_reschedule;
+/* The IPI event used for irq_reschedule. */
+extern int irq_reschedule_event;
 
 #define irq_canonicalize(irq)   (irq)
 
+/* An IRQ number is bound to a core and an IPI event number. */
+struct irq_map {
+	int cpu;
+	int event;
+};
+
 void ack_bad_irq(unsigned int irq);
 
 /*
@@ -74,6 +93,29 @@ enum {
  */
 void tile_irq_activate(unsigned int irq, int tile_irq_type);
 
+/*
+ * Create an IRQ that is valid only on a single core. The core is
+ * specified by callers with the exception that this function will
+ * choose a core if cpu=-1.
+ */
+int create_irq_on(int cpu);
+
+/* 
+ * Create an IRQ that is valid only on a single core. The core is
+ * chosen from non-dataplanes by this function.
+ */
+static inline int create_irq_on_any(void)
+{
+	return create_irq_on(-1);
+}
+
+/* Create an IRQ that is valid on all cores. */
+int create_irq(void);
+
+/* Map an IRQ number to (cpu, event). For globally-valid IRQs, cpu=-1. */
+int tile_irq_get_cpu(int irq);
+int tile_irq_get_event(int irq);
+
 void setup_irq_regs(void);
 
 #endif /* _ASM_TILE_IRQ_H */
diff --git a/arch/tile/kernel/irq.c b/arch/tile/kernel/irq.c
index 906a76bdb31d..7fab97ae6f08 100644
--- a/arch/tile/kernel/irq.c
+++ b/arch/tile/kernel/irq.c
@@ -22,6 +22,7 @@
 #include <arch/spr_def.h>
 #include <asm/traps.h>
 #include <linux/perf_event.h>
+#include <linux/stddef.h>
 
 /* Bit-flag stored in irq_desc->chip_data to indicate HW-cleared irqs. */
 #define IS_HW_CLEARED 1
@@ -54,13 +55,39 @@ static DEFINE_PER_CPU(unsigned long, irq_disable_mask)
  */
 static DEFINE_PER_CPU(int, irq_depth);
 
-/* State for allocating IRQs on Gx. */
+#define IPI_EVENT_INVALID -1
+#define IRQ_INVALID -1
+#define IPI_CORE_INVALID -2
+
 #if CHIP_HAS_IPI()
-static unsigned long available_irqs = ((1UL << NR_IRQS) - 1) &
-				      (~(1UL << IRQ_RESCHEDULE));
-static DEFINE_SPINLOCK(available_irqs_lock);
+/* Mask of CPUs that should receive interrupts. */
+static struct cpumask intr_cpus_map;
+
+/* A global table mapping IRQ numbers to (cpu, event). */
+struct irq_map irq_map[NR_IRQS] = {
+	[0 ... NR_IRQS-1] = {
+		.cpu	= IPI_CORE_INVALID,
+		.event	= IPI_EVENT_INVALID,
+	}
+};
+
+/* A percpu array of IPI numbers for each core, mapping back to the IRQ. */
+static DEFINE_PER_CPU(int [NR_IPI_EVENTS], irq_event) = {
+	[0 ... NR_IPI_EVENTS - 1] = IRQ_INVALID,
+};
+
+static DEFINE_SPINLOCK(irq_events_lock);
+
 #endif
 
+static inline int tile_irq_get_irqnum(int event);
+int tile_irq_get_event(int irq);
+
+/* THe IRQ number used for Linux IPI reschedule. */
+int irq_reschedule;
+/* The IPI event used for irq_reschedule. */
+int irq_reschedule_event;
+
 #if CHIP_HAS_IPI()
 /* Use SPRs to manipulate device interrupts. */
 #define mask_irqs(irq_mask) __insn_mtspr(SPR_IPI_MASK_SET_K, irq_mask)
@@ -81,8 +108,8 @@ static DEFINE_SPINLOCK(available_irqs_lock);
 void tile_dev_intr(struct pt_regs *regs, int intnum)
 {
 	int depth = __get_cpu_var(irq_depth)++;
-	unsigned long original_irqs;
-	unsigned long remaining_irqs;
+	unsigned long original_events;
+	unsigned long remaining_events;
 	struct pt_regs *old_regs;
 
 #if CHIP_HAS_IPI()
@@ -93,17 +120,17 @@ void tile_dev_intr(struct pt_regs *regs, int intnum)
 	 * we're going to handle.
 	 */
 	unsigned long masked = __insn_mfspr(SPR_IPI_MASK_K);
-	original_irqs = __insn_mfspr(SPR_IPI_EVENT_K) & ~masked;
-	__insn_mtspr(SPR_IPI_MASK_SET_K, original_irqs);
+	original_events = __insn_mfspr(SPR_IPI_EVENT_K) & ~masked;
+	__insn_mtspr(SPR_IPI_MASK_SET_K, original_events);
 #else
 	/*
 	 * Hypervisor performs the equivalent of the Gx code above and
 	 * then puts the pending interrupt mask into a system save reg
 	 * for us to find.
 	 */
-	original_irqs = __insn_mfspr(SPR_SYSTEM_SAVE_K_3);
+	original_events = __insn_mfspr(SPR_SYSTEM_SAVE_K_3);
 #endif
-	remaining_irqs = original_irqs;
+	remaining_events = original_events;
 
 	/* Track time spent here in an interrupt context. */
 	old_regs = set_irq_regs(regs);
@@ -121,14 +148,17 @@ void tile_dev_intr(struct pt_regs *regs, int intnum)
 		}
 	}
 #endif
-	while (remaining_irqs) {
-		unsigned long irq = __ffs(remaining_irqs);
-		remaining_irqs &= ~(1UL << irq);
+	while (remaining_events) {
+		unsigned long irq, event = __ffs(remaining_events);
+		remaining_events &= ~(1UL << event);
 
 		/* Count device irqs; Linux IPIs are counted elsewhere. */
-		if (irq != IRQ_RESCHEDULE)
+		if (event != irq_reschedule_event)
 			__get_cpu_var(irq_stat).irq_dev_intr_count++;
 
+		/* Convert IPI event to irq number. */
+		irq = tile_irq_get_irqnum(event);
+
 		generic_handle_irq(irq);
 	}
 
@@ -150,6 +180,19 @@ void tile_dev_intr(struct pt_regs *regs, int intnum)
 	set_irq_regs(old_regs);
 }
 
+#if CHIP_HAS_IPI()
+/*
+ * Do nothing. We leave all IPI events unmasked on all cores by default.
+ */
+static void tile_irq_chip_enable(struct irq_data *d)
+{
+}
+
+static void tile_irq_chip_disable(struct irq_data *d)
+{
+}
+
+#else
 
 /*
  * Remove an irq from the disabled mask.  If we're in an interrupt
@@ -175,17 +218,18 @@ static void tile_irq_chip_disable(struct irq_data *d)
 	mask_irqs(1UL << d->irq);
 	put_cpu_var(irq_disable_mask);
 }
+#endif
 
 /* Mask an interrupt. */
 static void tile_irq_chip_mask(struct irq_data *d)
 {
-	mask_irqs(1UL << d->irq);
+	mask_irqs(1UL << tile_irq_get_event(d->irq));
 }
 
 /* Unmask an interrupt. */
 static void tile_irq_chip_unmask(struct irq_data *d)
 {
-	unmask_irqs(1UL << d->irq);
+	unmask_irqs(1UL << tile_irq_get_event(d->irq));
 }
 
 /*
@@ -195,7 +239,7 @@ static void tile_irq_chip_unmask(struct irq_data *d)
 static void tile_irq_chip_ack(struct irq_data *d)
 {
 	if ((unsigned long)irq_data_get_irq_chip_data(d) != IS_HW_CLEARED)
-		clear_irqs(1UL << d->irq);
+		clear_irqs(1UL << tile_irq_get_event(d->irq));
 }
 
 /*
@@ -204,8 +248,9 @@ static void tile_irq_chip_ack(struct irq_data *d)
  */
 static void tile_irq_chip_eoi(struct irq_data *d)
 {
-	if (!(__get_cpu_var(irq_disable_mask) & (1UL << d->irq)))
-		unmask_irqs(1UL << d->irq);
+	int event = tile_irq_get_event(d->irq);
+	if (!(__get_cpu_var(irq_disable_mask) & (1UL << event)))
+		unmask_irqs(1UL << event);
 }
 
 static struct irq_chip tile_irq_chip = {
@@ -283,33 +328,216 @@ int arch_show_interrupts(struct seq_file *p, int prec)
  */
 
 #if CHIP_HAS_IPI()
+
+int tile_irq_get_cpu(int irq)
+{
+	int cpu;
+
+	BUG_ON(irq < 0 || irq >= NR_IRQS);
+	cpu = irq_map[irq].cpu;
+	BUG_ON(cpu == IPI_CORE_INVALID);
+	return cpu;
+}
+EXPORT_SYMBOL(tile_irq_get_cpu);
+
+int tile_irq_get_event(int irq)
+{
+	int event;
+
+	BUG_ON(irq < 0 || irq >= NR_IRQS);
+	event = irq_map[irq].event;
+	BUG_ON(event < 0 || event >= NR_IPI_EVENTS);
+	return event;
+}
+EXPORT_SYMBOL(tile_irq_get_event);
+
+static inline int tile_irq_get_irqnum(int event)
+{
+	int irq;
+
+	BUG_ON(event >= NR_IPI_EVENTS);
+	irq = __get_cpu_var(irq_event)[event];
+	BUG_ON(irq < 0 || irq >= NR_IRQS);
+	return irq;
+}
+
+static bool global_event_available(int event)
+{
+	int cpu;
+
+	for_each_possible_cpu(cpu)
+		if (per_cpu(irq_event, cpu)[event] != IPI_EVENT_INVALID)
+			return false;
+
+	return true;
+}
+
 int create_irq(void)
 {
 	unsigned long flags;
-	int result;
-
-	spin_lock_irqsave(&available_irqs_lock, flags);
-	if (available_irqs == 0)
-		result = -ENOMEM;
-	else {
-		result = __ffs(available_irqs);
-		available_irqs &= ~(1UL << result);
-		dynamic_irq_init(result);
+	int irq, event, cpu;
+	int result = -ENOMEM;
+
+	spin_lock_irqsave(&irq_events_lock, flags);
+
+	/* Get an unused IRQ number. */
+	for (irq = 0; irq < NR_IRQS; irq++) {
+		if (irq_map[irq].event == IRQ_INVALID)
+			break;
 	}
-	spin_unlock_irqrestore(&available_irqs_lock, flags);
 
+	if (irq == NR_IRQS)
+		goto out;
+
+	/*
+	 * Get a global IPI event that is not used on every core.
+	 * Search from the low end of the IPI event space.
+	 */
+	for (event = 0; event < NR_IPI_EVENTS; event++) {
+		if (global_event_available(event))
+			break;
+	}
+
+	if (event == NR_IPI_EVENTS)
+		goto out;
+
+	/* Set the IPI event for each core. */
+	for_each_possible_cpu(cpu)
+		per_cpu(irq_event, cpu)[event] = irq;
+
+	/*
+ 	 * Record the core ID and event number for this irq. Core==-1 means
+ 	 * it is a global irq happening on every core.
+ 	 */
+	irq_map[irq].cpu = -1;
+	irq_map[irq].event = event;
+
+	result = irq;
+	dynamic_irq_init(result);
+
+out:
+	spin_unlock_irqrestore(&irq_events_lock, flags);
 	return result;
 }
 EXPORT_SYMBOL(create_irq);
 
+/*
+ * Create an irq on a specified core, if cpu == -1, this function selects
+ * a core.
+ */
+int create_irq_on(int cpu)
+{
+	unsigned long flags;
+	int event, irq = -ENOMEM;
+
+	BUG_ON(cpu >= NR_CPUS || cpu < -1);
+
+	spin_lock_irqsave(&irq_events_lock, flags);
+
+	/* 
+	 * Check if we ran out of available intr CPUs; need to repopulate
+	 * the intr cpu set.
+	 */
+	if (cpumask_weight(&intr_cpus_map) == 0) {
+		cpumask_copy(&intr_cpus_map, cpu_online_mask);
+
+#ifdef CONFIG_DATAPLANE
+		/* Remove dataplane cpus. */
+		cpumask_andnot(&intr_cpus_map, &intr_cpus_map, &dataplane_map);
+#endif
+	}
+
+	if (cpu == -1) {
+		/* cpu id was not specified. */
+		for (event = NR_IPI_EVENTS - 1; event >= 0; event--) {
+			for_each_cpu(cpu, &intr_cpus_map) {
+				if (per_cpu(irq_event, cpu)[event] ==
+				    IRQ_INVALID) {
+					goto event_got;
+				}
+			}
+
+		}
+	} else {
+		/* cpu id was specified. */
+		for (event = NR_IPI_EVENTS - 1; event >= 0; event--) {
+			if (per_cpu(irq_event, cpu)[event] == IRQ_INVALID)
+				break;
+		}
+	}
+
+event_got:
+	if (event <= 0) {
+		pr_err("Run out of IPI events, you may need to decrease "
+			"the number of dataplane tiles, or create irq "
+			"on another CPU.\n");
+		goto out;
+	}
+
+	/* Get an unused irq number. */
+	for (irq = 0; irq < NR_IRQS; irq++) {
+		if (irq_map[irq].event == IPI_EVENT_INVALID)
+			break;
+	}
+
+	if (irq == NR_IRQS) {
+		pr_err("Run out of IRQS, you need to increase NR_IRQS\n");
+		goto out;
+	}
+
+	/*
+ 	 * Remove the cpu from the intr cpu set,  so that next irq allocation
+	 * will start from next cpu.
+ 	 */
+	cpu_clear(cpu, intr_cpus_map);
+
+	/* Set the maps. */
+	per_cpu(irq_event, cpu)[event] = irq;
+	irq_map[irq].cpu = cpu;
+	irq_map[irq].event = event;
+	dynamic_irq_init(irq);
+
+out:
+	spin_unlock_irqrestore(&irq_events_lock, flags);
+	return irq;
+}
+EXPORT_SYMBOL(create_irq_on);
+
 void destroy_irq(unsigned int irq)
 {
 	unsigned long flags;
+	int event, cpu;
+
+	spin_lock_irqsave(&irq_events_lock, flags);
+
+	cpu = tile_irq_get_cpu(irq);
+	event = tile_irq_get_event(irq);
+
+	if (cpu == -1) {
+		for_each_possible_cpu(cpu) {
+			per_cpu(irq_event, cpu)[event] = IRQ_INVALID;
+		}
+	} else {
+		per_cpu(irq_event, cpu)[event] = IRQ_INVALID;
+	}
+
+	irq_map[irq].cpu = IPI_CORE_INVALID;
+	irq_map[irq].event = IPI_EVENT_INVALID;
 
-	spin_lock_irqsave(&available_irqs_lock, flags);
-	available_irqs |= (1UL << irq);
 	dynamic_irq_cleanup(irq);
-	spin_unlock_irqrestore(&available_irqs_lock, flags);
+	spin_unlock_irqrestore(&irq_events_lock, flags);
 }
 EXPORT_SYMBOL(destroy_irq);
-#endif
+
+#else /* !CHIP_HAS_IPI() */
+
+static inline int tile_irq_get_irqnum(int event)
+{
+	return event;
+}
+
+int tile_irq_get_event(int irq)
+{
+	return irq;
+}
+#endif /* CHIP_HAS_IPI() */
diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
index 077b7bc437e5..be371c02cd11 100644
--- a/arch/tile/kernel/pci_gx.c
+++ b/arch/tile/kernel/pci_gx.c
@@ -105,9 +105,6 @@ int num_rc_controllers;
 
 static struct pci_ops tile_cfg_ops;
 
-/* Mask of CPUs that should receive PCIe interrupts. */
-static struct cpumask intr_cpus_map;
-
 /* We don't need to worry about the alignment of resources. */
 resource_size_t pcibios_align_resource(void *data, const struct resource *res,
 				       resource_size_t size,
@@ -117,33 +114,6 @@ resource_size_t pcibios_align_resource(void *data, const struct resource *res,
 }
 EXPORT_SYMBOL(pcibios_align_resource);
 
-/*
- * Pick a CPU to receive and handle the PCIe interrupts, based on the IRQ #.
- * For now, we simply send interrupts to non-dataplane CPUs.
- * We may implement methods to allow user to specify the target CPUs,
- * e.g. via boot arguments.
- */
-static int tile_irq_cpu(int irq)
-{
-	unsigned int count;
-	int i = 0;
-	int cpu;
-
-	count = cpumask_weight(&intr_cpus_map);
-	if (unlikely(count == 0)) {
-		pr_warning("intr_cpus_map empty, interrupts will be"
-			   " delievered to dataplane tiles\n");
-		return irq % (smp_height * smp_width);
-	}
-
-	count = irq % count;
-	for_each_cpu(cpu, &intr_cpus_map) {
-		if (i++ == count)
-			break;
-	}
-	return cpu;
-}
-
 /* Open a file descriptor to the TRIO shim. */
 static int tile_pcie_open(int trio_index)
 {
@@ -274,23 +244,39 @@ static int __init tile_trio_init(void)
 }
 postcore_initcall(tile_trio_init);
 
+/*
+ * Do nothing. We leave all IPI events unmasked on all cores by default.
+ */
+static void tilegx_legacy_irq_enable(struct irq_data *d)
+{
+}
+
+static void tilegx_legacy_irq_disable(struct irq_data *d)
+{
+}
+
 static void tilegx_legacy_irq_ack(struct irq_data *d)
 {
-	__insn_mtspr(SPR_IPI_EVENT_RESET_K, 1UL << d->irq);
+	__insn_mtspr(SPR_IPI_EVENT_RESET_K,
+		     1UL << tile_irq_get_event(d->irq));
 }
 
 static void tilegx_legacy_irq_mask(struct irq_data *d)
 {
-	__insn_mtspr(SPR_IPI_MASK_SET_K, 1UL << d->irq);
+	__insn_mtspr(SPR_IPI_MASK_SET_K,
+		     1UL << tile_irq_get_event(d->irq));
 }
 
 static void tilegx_legacy_irq_unmask(struct irq_data *d)
 {
-	__insn_mtspr(SPR_IPI_MASK_RESET_K, 1UL << d->irq);
+	__insn_mtspr(SPR_IPI_MASK_RESET_K,
+		     1UL << tile_irq_get_event(d->irq));
 }
 
 static struct irq_chip tilegx_legacy_irq_chip = {
 	.name			= "tilegx_legacy_irq",
+	.irq_enable		= tilegx_legacy_irq_enable,
+	.irq_disable		= tilegx_legacy_irq_disable,
 	.irq_ack		= tilegx_legacy_irq_ack,
 	.irq_mask		= tilegx_legacy_irq_mask,
 	.irq_unmask		= tilegx_legacy_irq_unmask,
@@ -342,15 +328,12 @@ static int tile_init_irqs(struct pci_controller *controller)
 	int irq;
 	int result;
 
-	cpumask_copy(&intr_cpus_map, cpu_online_mask);
-
-
 	for (i = 0; i < 4; i++) {
 		gxio_trio_context_t *context = controller->trio;
 		int cpu;
 
 		/* Ask the kernel to allocate an IRQ. */
-		irq = create_irq();
+		irq = create_irq_on_any();
 		if (irq < 0) {
 			pr_err("PCI: no free irq vectors, failed for %d\n", i);
 
@@ -359,12 +342,13 @@ static int tile_init_irqs(struct pci_controller *controller)
 		controller->irq_intx_table[i] = irq;
 
 		/* Distribute the 4 IRQs to different tiles. */
-		cpu = tile_irq_cpu(irq);
+		cpu = tile_irq_get_cpu(irq);
 
 		/* Configure the TRIO intr binding for this IRQ. */
 		result = gxio_trio_config_legacy_intr(context, cpu_x(cpu),
 						      cpu_y(cpu), KERNEL_PL,
-						      irq, controller->mac, i);
+						      tile_irq_get_event(irq),
+						      controller->mac, i);
 		if (result < 0) {
 			pr_err("PCI: MAC intx config failed for %d\n", i);
 
@@ -1459,26 +1443,42 @@ static unsigned int tilegx_msi_startup(struct irq_data *d)
 	return 0;
 }
 
+/*
+ * Do nothing. We leave all IPI events unmasked on all cores by default.
+ */
+static void tilegx_msi_enable(struct irq_data *d)
+{
+}
+
+static void tilegx_msi_disable(struct irq_data *d)
+{
+}
+
 static void tilegx_msi_ack(struct irq_data *d)
 {
-	__insn_mtspr(SPR_IPI_EVENT_RESET_K, 1UL << d->irq);
+	__insn_mtspr(SPR_IPI_EVENT_RESET_K,
+		     1UL << tile_irq_get_event(d->irq));
 }
 
 static void tilegx_msi_mask(struct irq_data *d)
 {
 	mask_msi_irq(d);
-	__insn_mtspr(SPR_IPI_MASK_SET_K, 1UL << d->irq);
+	__insn_mtspr(SPR_IPI_MASK_SET_K,
+		     1UL << tile_irq_get_event(d->irq));
 }
 
 static void tilegx_msi_unmask(struct irq_data *d)
 {
-	__insn_mtspr(SPR_IPI_MASK_RESET_K, 1UL << d->irq);
+	__insn_mtspr(SPR_IPI_MASK_RESET_K,
+		     1UL << tile_irq_get_event(d->irq));
 	unmask_msi_irq(d);
 }
 
 static struct irq_chip tilegx_msi_chip = {
 	.name			= "tilegx_msi",
 	.irq_startup		= tilegx_msi_startup,
+	.irq_enable		= tilegx_msi_enable,
+	.irq_disable		= tilegx_msi_disable,
 	.irq_ack		= tilegx_msi_ack,
 	.irq_mask		= tilegx_msi_mask,
 	.irq_unmask		= tilegx_msi_unmask,
@@ -1500,7 +1500,7 @@ int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
 	int irq;
 	int ret;
 
-	irq = create_irq();
+	irq = create_irq_on_any();
 	if (irq < 0)
 		return irq;
 
@@ -1570,14 +1570,15 @@ int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
 	}
 
 	/* We try to distribute different IRQs to different tiles. */
-	cpu = tile_irq_cpu(irq);
+	cpu = tile_irq_get_cpu(irq);
 
 	/*
 	 * Now call up to the HV to configure the MSI interrupt and
 	 * set up the IPI binding.
 	 */
 	ret = gxio_trio_config_msi_intr(trio_context, cpu_x(cpu), cpu_y(cpu),
-					KERNEL_PL, irq, controller->mac,
+					KERNEL_PL, tile_irq_get_event(irq),
+				        controller->mac,
 					mem_map, mem_map_base, mem_map_limit,
 					trio_context->asid);
 	if (ret < 0) {
diff --git a/arch/tile/kernel/smp.c b/arch/tile/kernel/smp.c
index 01e8ab29f43a..fbba5c0000b6 100644
--- a/arch/tile/kernel/smp.c
+++ b/arch/tile/kernel/smp.c
@@ -185,7 +185,7 @@ void flush_icache_range(unsigned long start, unsigned long end)
 }
 
 
-/* Called when smp_send_reschedule() triggers IRQ_RESCHEDULE. */
+/* Called when smp_send_reschedule() triggers irq_reschedule. */
 static irqreturn_t handle_reschedule_ipi(int irq, void *token)
 {
 	__get_cpu_var(irq_stat).irq_resched_count++;
@@ -218,11 +218,17 @@ void __init ipi_init(void)
 		offset = PFN_PHYS(pte_pfn(pte));
 		ipi_mappings[cpu] = ioremap_prot(offset, PAGE_SIZE, pte);
 	}
+
+	irq_reschedule = create_irq();
+	irq_reschedule_event = tile_irq_get_event(irq_reschedule);
+#else
+	irq_reschedule = 0;
+	irq_reschedule_event = irq_reschedule;
 #endif
 
-	/* Bind handle_reschedule_ipi() to IRQ_RESCHEDULE. */
-	tile_irq_activate(IRQ_RESCHEDULE, TILE_IRQ_PERCPU);
-	BUG_ON(setup_irq(IRQ_RESCHEDULE, &resched_action));
+	/* Bind handle_reschedule_ipi() to irq_reschedule. */
+	tile_irq_activate(irq_reschedule, TILE_IRQ_PERCPU);
+	BUG_ON(setup_irq(irq_reschedule, &resched_action));
 }
 
 #if CHIP_HAS_IPI()
@@ -237,7 +243,7 @@ void smp_send_reschedule(int cpu)
 	 * directed at the PCI shim.  For now, just do a raw store,
 	 * casting away the __iomem attribute.
 	 */
-	((unsigned long __force *)ipi_mappings[cpu])[IRQ_RESCHEDULE] = 0;
+	((unsigned long __force *)ipi_mappings[cpu])[irq_reschedule_event] = 0;
 }
 
 #else
@@ -250,7 +256,7 @@ void smp_send_reschedule(int cpu)
 
 	coord.y = cpu_y(cpu);
 	coord.x = cpu_x(cpu);
-	hv_trigger_ipi(coord, IRQ_RESCHEDULE);
+	hv_trigger_ipi(coord, irq_reschedule);
 }
 
 #endif /* CHIP_HAS_IPI() */
diff --git a/drivers/net/ethernet/tile/tilegx.c b/drivers/net/ethernet/tile/tilegx.c
index 7e1c91d41a87..d98f3becc7e1 100644
--- a/drivers/net/ethernet/tile/tilegx.c
+++ b/drivers/net/ethernet/tile/tilegx.c
@@ -1233,7 +1233,8 @@ static int tile_net_setup_interrupts(struct net_device *dev)
 		struct tile_net_info *info = &per_cpu(per_cpu_info, cpu);
 		if (info->mpipe[instance].has_iqueue) {
 			gxio_mpipe_request_notif_ring_interrupt(&md->context,
-				cpu_x(cpu), cpu_y(cpu), KERNEL_PL, irq,
+				cpu_x(cpu), cpu_y(cpu), KERNEL_PL,
+				tile_irq_get_event(irq),
 				info->mpipe[instance].iqueue.ring);
 		}
 	}
diff --git a/drivers/tty/hvc/hvc_tile.c b/drivers/tty/hvc/hvc_tile.c
index af8cdaa1dcb9..602d18543eb0 100644
--- a/drivers/tty/hvc/hvc_tile.c
+++ b/drivers/tty/hvc/hvc_tile.c
@@ -81,7 +81,7 @@ static int hvc_tile_get_chars(uint32_t vt, char *buf, int count)
 static int hvc_tile_notifier_add_irq(struct hvc_struct *hp, int irq)
 {
 	int rc;
-	int cpu = raw_smp_processor_id();  /* Choose an arbitrary cpu */
+	int cpu = tile_irq_get_cpu(irq);
 	HV_Coord coord = { .x = cpu_x(cpu), .y = cpu_y(cpu) };
 
 	rc = notifier_add_irq(hp, irq);
@@ -93,7 +93,7 @@ static int hvc_tile_notifier_add_irq(struct hvc_struct *hp, int irq)
 	 * If the hypervisor returns an error, we still return 0, so that
 	 * we can fall back to polling.
 	 */
-	if (hv_console_set_ipi(KERNEL_PL, irq, coord) < 0)
+	if (hv_console_set_ipi(KERNEL_PL, tile_irq_get_event(irq), coord) < 0)
 		notifier_del_irq(hp, irq);
 
 	return 0;
@@ -133,7 +133,7 @@ static int hvc_tile_probe(struct platform_device *pdev)
 	int tile_hvc_irq;
 
 	/* Create our IRQ and register it. */
-	tile_hvc_irq = create_irq();
+	tile_hvc_irq = create_irq_on_any();
 	if (tile_hvc_irq < 0)
 		return -ENXIO;
 
diff --git a/drivers/tty/serial/tilegx.c b/drivers/tty/serial/tilegx.c
index f92d7e6bd876..434ba89522fe 100644
--- a/drivers/tty/serial/tilegx.c
+++ b/drivers/tty/serial/tilegx.c
@@ -339,8 +339,7 @@ static int tilegx_startup(struct uart_port *port)
 {
 	struct tile_uart_port *tile_uart;
 	gxio_uart_context_t *context;
-	int ret = 0;
-	int cpu = raw_smp_processor_id();  /* pick an arbitrary cpu */
+	int cpu, ret = 0;
 
 	tile_uart = container_of(port, struct tile_uart_port, uart);
 	if (mutex_lock_interruptible(&tile_uart->mutex))
@@ -359,7 +358,7 @@ static int tilegx_startup(struct uart_port *port)
 		}
 
 		/* Create our IRQs. */
-		port->irq = create_irq();
+		port->irq = create_irq_on_any();
 		if (port->irq < 0)
 			goto err_uart_dest;
 		tile_irq_activate(port->irq, TILE_IRQ_PERCPU);
@@ -371,9 +370,11 @@ static int tilegx_startup(struct uart_port *port)
 			goto err_dest_irq;
 
 		/* Request that the hardware start sending us interrupts. */
+		cpu = tile_irq_get_cpu(port->irq);
 		tile_uart->irq_cpu = cpu;
 		ret = gxio_uart_cfg_interrupt(context, cpu_x(cpu), cpu_y(cpu),
-					      KERNEL_PL, port->irq);
+					      KERNEL_PL,
+					      tile_irq_get_event(port->irq));
 		if (ret)
 			goto err_free_irq;
 
diff --git a/drivers/usb/host/ehci-tilegx.c b/drivers/usb/host/ehci-tilegx.c
index f3713d32c9a1..4798576b5ddb 100644
--- a/drivers/usb/host/ehci-tilegx.c
+++ b/drivers/usb/host/ehci-tilegx.c
@@ -103,8 +103,7 @@ static int ehci_hcd_tilegx_drv_probe(struct platform_device *pdev)
 	struct ehci_hcd *ehci;
 	struct tilegx_usb_platform_data *pdata = dev_get_platdata(&pdev->dev);
 	pte_t pte = { 0 };
-	int my_cpu = smp_processor_id();
-	int ret;
+	int my_cpu, ret;
 
 	if (usb_disabled())
 		return -ENODEV;
@@ -142,18 +141,20 @@ static int ehci_hcd_tilegx_drv_probe(struct platform_device *pdev)
 	ehci->hcs_params = readl(&ehci->caps->hcs_params);
 
 	/* Create our IRQs and register them. */
-	pdata->irq = create_irq();
+	pdata->irq = create_irq_on_any();
 	if (pdata->irq < 0) {
 		ret = -ENXIO;
 		goto err_no_irq;
 	}
 
+	my_cpu = tile_irq_get_cpu(pdata->irq);
 	tile_irq_activate(pdata->irq, TILE_IRQ_PERCPU);
 
 	/* Configure interrupts. */
 	ret = gxio_usb_host_cfg_interrupt(&pdata->usb_ctx,
 					  cpu_x(my_cpu), cpu_y(my_cpu),
-					  KERNEL_PL, pdata->irq);
+					  KERNEL_PL,
+					  tile_irq_get_event(pdata->irq));
 	if (ret) {
 		ret = -ENXIO;
 		goto err_have_irq;
diff --git a/drivers/usb/host/ohci-tilegx.c b/drivers/usb/host/ohci-tilegx.c
index 0b183e0b0a8a..b8a100be2d44 100644
--- a/drivers/usb/host/ohci-tilegx.c
+++ b/drivers/usb/host/ohci-tilegx.c
@@ -97,8 +97,7 @@ static int ohci_hcd_tilegx_drv_probe(struct platform_device *pdev)
 	struct usb_hcd *hcd;
 	struct tilegx_usb_platform_data *pdata = dev_get_platdata(&pdev->dev);
 	pte_t pte = { 0 };
-	int my_cpu = smp_processor_id();
-	int ret;
+	int my_cpu, ret;
 
 	if (usb_disabled())
 		return -ENODEV;
@@ -129,18 +128,20 @@ static int ohci_hcd_tilegx_drv_probe(struct platform_device *pdev)
 	tilegx_start_ohc();
 
 	/* Create our IRQs and register them. */
-	pdata->irq = create_irq();
+	pdata->irq = create_irq_on_any();
 	if (pdata->irq < 0) {
 		ret = -ENXIO;
 		goto err_no_irq;
 	}
 
+	my_cpu = tile_irq_get_cpu(pdata->irq);
 	tile_irq_activate(pdata->irq, TILE_IRQ_PERCPU);
 
 	/* Configure interrupts. */
 	ret = gxio_usb_host_cfg_interrupt(&pdata->usb_ctx,
 					  cpu_x(my_cpu), cpu_y(my_cpu),
-					  KERNEL_PL, pdata->irq);
+					  KERNEL_PL,
+					  tile_irq_get_event(pdata->irq));
 	if (ret) {
 		ret = -ENXIO;
 		goto err_have_irq;

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com


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

* Re: [patch 03/32] genirq: Provide generic hwirq allocation facility
  2014-05-07 20:37   ` Chris Metcalf
@ 2014-05-07 23:15     ` Thomas Gleixner
  2014-05-08 10:22       ` Thomas Gleixner
  2014-05-14 17:57       ` Chris Metcalf
  0 siblings, 2 replies; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-07 23:15 UTC (permalink / raw)
  To: Chris Metcalf
  Cc: LKML, Tony Lu, Ingo Molnar, Peter Anvin, Tony Luck,
	Peter Zijlstra, Fenghua Yu, Grant Likely, Benjamin Herrenschmidt

On Wed, 7 May 2014, Chris Metcalf wrote:

> On 5/7/2014 11:44 AM, Thomas Gleixner wrote:
> > Not really the solution to the problem, but at least it confines the
> > mess in the core code and allows to get rid of the create/destroy_irq
> > variants from hell, i.e. 3 implementations with different semantics
> > plus the x86 specific variants __create_irqs and create_irq_nr
> > which have been invented in another circle of hell.
> >
> > [...]
> >
> > tile: Might use irq domains as well, but it has a very limited
> >       interrupt space, so handling it via this functionality might be
> >       the right thing to do even in the long run.
> 
> We have an internal change that we haven't upstreamed yet that makes
> irqs actually (cpu,ipi) pairs, so that more irqs can be allocated.
> As a result we allocate some irqs as bound to a specific IPI on a single
> cpu, and some irqs get bound to a particular IPI registered on every cpu.
>
> I'll have to set aside a bit of time to look more closely at how your
> change interacts with the work we've done internally.  I've appended the
> per-cpu IRQ change from our internal tree here (and cc'ed the author).
> The API change is in the <asm/irq.h> diff at the very start.

Sure it'll break it. And I said clearly it's only designed for simple
allocations.

And no, we really can do without

> +int create_irq_on(int cpu);
> +static inline int create_irq_on_any(void)
> +int create_irq(void);

or any other new abomination of this coming along with another private
allocation mechanism.

The issue you are describing is very similar to what x86 needs for
handling the hardware vector space and that's existing x86 private
horror which needs a replacement. Itanic could use something like that
as well, but I doubt that anyone is masochistic enough to tackle the
never sinking ship :)

So the right thing to do is to provide a generic infrastructure for
handling a matrix mapping.

So basically we need something like this:

   bitmap __percpu *vector_map;

   vector_map = alloc_percpu(sizeof bitmap);

And an allocation function, which takes a cpumask and not a single
cpu. With your approach you are going to add create_irq_mask() faster
than you can mainline the first cruft. That wants to be an algorithm
which searches for a free slot in some intelligent way, i.e. using
free slots which are already occupied on at least one cpu instead of
using up the globaly free slots right away. It's not that hard to do
if you have bitmaps.

Plus the corresponding free and supporting helpers.

Now on top of that we need irq domain support for this kind of matrix
mappings down to the vector level and everything else falls in
place. I have not thought through the irq domain angle, but maybe
Grant/Ben can give some input on that.

Sorry for spoiling your plans. I went a long way in the past 10 years
to consolidate all that as far as it goes, and I'm not willing to
accept any new arch specific interrupt infrastructure which goes
beyond the low level hardware requirements.

Thanks,

	tglx

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

* Re: [patch 03/32] genirq: Provide generic hwirq allocation facility
  2014-05-07 23:15     ` Thomas Gleixner
@ 2014-05-08 10:22       ` Thomas Gleixner
  2014-05-13 16:59         ` Thomas Gleixner
  2014-05-14 17:57       ` Chris Metcalf
  1 sibling, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-08 10:22 UTC (permalink / raw)
  To: Chris Metcalf
  Cc: LKML, Tony Lu, Ingo Molnar, Peter Anvin, Tony Luck,
	Peter Zijlstra, Fenghua Yu, Grant Likely, Benjamin Herrenschmidt

On Thu, 8 May 2014, Thomas Gleixner wrote:
> Now on top of that we need irq domain support for this kind of matrix
> mappings down to the vector level and everything else falls in
> place. I have not thought through the irq domain angle, but maybe
> Grant/Ben can give some input on that.

Just talked to Grant to get my irqdomain foo up to speed.

irq domains support parent irq domains already, which allow you to
request an irq from the parent.

What's missing is:

- a bitmap based matrix vector allocator, but that shouldn't be rocket
  science to write one.

- a mechanism to hand a cpumask down in the allocation chain

- a shortcut support to avoid multi level map lookups for the fast
  path.

Once we have that everything just falls in place and when tile and x86
are switched over we can rip out the LEGACY allocator again. That'll
leave itanic with its homebrewn create_irq machinery, but I'm happy to
ignore that as this is almost completely confined in ia64 code where
is can bitrot happily until it sinks.

Thanks,

	tglx

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

* Re: [patch 03/32] genirq: Provide generic hwirq allocation facility
  2014-05-07 15:44 ` [patch 03/32] genirq: Provide generic hwirq allocation facility Thomas Gleixner
  2014-05-07 20:37   ` Chris Metcalf
@ 2014-05-08 12:07   ` Grant Likely
  2014-05-08 13:12     ` Thomas Gleixner
  2014-05-14 17:44   ` Chris Metcalf
  2014-05-16 13:31   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  3 siblings, 1 reply; 86+ messages in thread
From: Grant Likely @ 2014-05-08 12:07 UTC (permalink / raw)
  To: Thomas Gleixner, LKML
  Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra,
	Chris Metcalf, Fenghua Yu

On Wed, 07 May 2014 15:44:05 -0000, Thomas Gleixner <tglx@linutronix.de> wrote:
> Not really the solution to the problem, but at least it confines the
> mess in the core code and allows to get rid of the create/destroy_irq
> variants from hell, i.e. 3 implementations with different semantics
> plus the x86 specific variants __create_irqs and create_irq_nr
> which have been invented in another circle of hell.
> 
> x86 : x86 should be converted to irq domains and I'm deliberately
>       making it impossible to do the multi-vector MSI support by
>       adding more crap to the current mess. It's not that hard to do
>       and I'm really tired of the trainwrecks which have been invented
>       by baindaid engineering so far. Any attempt to do multi-vector
>       MSI or ioapic hotplug without converting to irq domains is NAKed
>       hereby.
> 
> tile: Might use irq domains as well, but it has a very limited
>       interrupt space, so handling it via this functionality might be
>       the right thing to do even in the long run.
> 
> ia64: That's an hopeless case, as I doubt that anyone has the stomach
>       to rewrite the homebrewn dynamic allocation facilities. I stared
>       at it for a couple of hours and gave up. The create/destroy_irq
>       mess could be made private to itanic right away if there
>       wouldn't be the iommu/dmar driver being shared with x86. So to
>       do that I'm going to add a separate ia64 specific implementation
>       later in order not to deep-six itanic right away.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: x86@kernel.org
> Cc: Chris Metcalf <cmetcalf@tilera.com>
> Cc: Tony Luck <tony.luck@intel.com>
> Cc: Fenghua Yu <fenghua.yu@intel.com>
> 
> ---
>  include/linux/irq.h  |   15 +++++++++++++++
>  kernel/irq/Kconfig   |    5 +++++
>  kernel/irq/irqdesc.c |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 71 insertions(+)
> 
> Index: tip/include/linux/irq.h
> ===================================================================
> --- tip.orig/include/linux/irq.h
> +++ tip/include/linux/irq.h
> @@ -637,6 +637,21 @@ static inline int irq_reserve_irq(unsign
>  	return irq_reserve_irqs(irq, 1);
>  }
>  
> +#ifdef CONFIG_GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
> +unsigned int irq_alloc_hwirqs(int cnt, int node);
> +static inline unsigned int irq_alloc_hwirq(int node)
> +{
> +	return irq_alloc_hwirqs(1, node);
> +}
> +void irq_free_hwirqs(unsigned int from, int cnt);
> +static inline void irq_free_hwirq(unsigned int irq)
> +{
> +	return irq_free_hwirqs(irq, 1);
> +}
> +int arch_setup_hwirq(unsigned int irq, int node);
> +void arch_teardown_hwirq(unsigned int irq);
> +#endif
> +
>  #ifndef irq_reg_writel
>  # define irq_reg_writel(val, addr)	writel(val, addr)
>  #endif
> Index: tip/kernel/irq/Kconfig
> ===================================================================
> --- tip.orig/kernel/irq/Kconfig
> +++ tip/kernel/irq/Kconfig
> @@ -17,6 +17,11 @@ config GENERIC_IRQ_SHOW
>  config GENERIC_IRQ_SHOW_LEVEL
>         bool
>  
> +# Facility to allocate an hardware interrupt. This is legacy support
> +# and should not be used in new code. Use irq domains instead.
> +config GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
> +       bool
> +
>  # Support for delayed migration from interrupt context
>  config GENERIC_PENDING_IRQ
>  	bool
> Index: tip/kernel/irq/irqdesc.c
> ===================================================================
> --- tip.orig/kernel/irq/irqdesc.c
> +++ tip/kernel/irq/irqdesc.c
> @@ -396,6 +396,57 @@ err:
>  }
>  EXPORT_SYMBOL_GPL(__irq_alloc_descs);
>  
> +#ifdef CONFIG_GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
> +/**
> + * irq_alloc_hwirqs - Allocate an irq descriptor and initialize the hardware
> + * @cnt:	number of interrupts to allocate
> + * @node:	node on which to allocate
> + *
> + * Returns an interrupt number > 0 or 0, if the allocation fails.
> + */
> +unsigned int irq_alloc_hwirqs(int cnt, int node)
> +{
> +	int i, irq = __irq_alloc_descs(-1, 0, cnt, node, NULL);
> +
> +	if (irq < 0)
> +		return 0;
> +
> +	for (i = irq; cnt > 0; i++, cnt--) {
> +		if (arch_setup_hwirq(i, node))
> +			goto err;
> +		irq_clear_status_flags(i, _IRQ_NOREQUEST);
> +	}
> +	return irq;
> +
> +err:
> +	for (i--; i >= irq; i--) {
> +		irq_set_status_flags(i, _IRQ_NOREQUEST | _IRQ_NOPROBE);
> +		arch_teardown_hwirq(i);
> +	}
> +	irq_free_descs(irq, cnt);
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(irq_alloc_hwirqs);

Okay, so regarding this and irq_domains, I think the functionality
overlaps and irq_domain conversion wouldn't directly use this API. I
could see two ways that it would be wired up in an irq_domain
conversion...

1) use an irq_domain to represent the root of the interrupt tree and be
responsible for all of the hardware irqs. Child interrupt controllers
would allocate a hwirq from the root irq_domain and program itself
accordingly. This approach would either not use this API, or make it
entirely internal to the root irq_domain.

2) Use this API as the root of the interrupt tree and make first level
of child interrupt controllers use this API to allocate HWIRQs to use
for their irq outputs.

Most of the platforms using irq_domain now fall in the first category,
which I think makes the most sense. Any platform like x86 that has
multiple hwirq vectors and the option of per-cpu vectors would be best
to keep all of that detail in one place. We could add a cpumask variant
to the irqdomain APIs, and add a stock implementation of an allocator
that can intelligently allocate when cpumasks are used.

g.

> +
> +/**
> + * irq_free_hwirqs - Free irq descriptor and cleanup the hardware
> + * @from:	Free from irq number
> + * @cnt:	number of interrupts to free
> + *
> + */
> +void irq_free_hwirqs(unsigned int from, int cnt)
> +{
> +	int i;
> +
> +	for (i = from; cnt > 0; i++, cnt--) {
> +		irq_set_status_flags(i, _IRQ_NOREQUEST | _IRQ_NOPROBE);
> +		arch_teardown_hwirq(i);
> +	}
> +	irq_free_descs(from, cnt);
> +}
> +EXPORT_SYMBOL_GPL(irq_free_hwirqs);
> +#endif
> +
>  /**
>   * irq_reserve_irqs - mark irqs allocated
>   * @from:	mark from irq number
> 
> 
> --
> 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/


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

* Re: [patch 29/32] genirq: Remove irq_reserve_irq[s]
  2014-05-07 15:44 ` [patch 29/32] genirq: Remove irq_reserve_irq[s] Thomas Gleixner
@ 2014-05-08 12:14   ` Grant Likely
  2014-05-08 12:54     ` Thomas Gleixner
  2014-05-16 13:37   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  1 sibling, 1 reply; 86+ messages in thread
From: Grant Likely @ 2014-05-08 12:14 UTC (permalink / raw)
  To: Thomas Gleixner, LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra

On Wed, 07 May 2014 15:44:21 -0000, Thomas Gleixner <tglx@linutronix.de> wrote:
> No more users. And it's not going to come back. If you need
> hotplugable irq chips, use irq domains.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Acked-by: Grant Likely <grant.likely@secretlab.ca>

The ironic thing is that irq_domain may end up bringing this function
back in some form as an optimization for irq_domains that need a
contiguous range, but don't want to allocate all the irq_descs
immediately. But if that happens it will be a very private API and it
doesn't nullify removing the function now.

g.

> ---
>  include/linux/irq.h  |    7 -------
>  kernel/irq/irqdesc.c |   25 -------------------------
>  2 files changed, 32 deletions(-)
> 
> Index: tip/include/linux/irq.h
> ===================================================================
> --- tip.orig/include/linux/irq.h
> +++ tip/include/linux/irq.h
> @@ -617,18 +617,11 @@ int __irq_alloc_descs(int irq, unsigned
>  	irq_alloc_descs(-1, from, cnt, node)
>  
>  void irq_free_descs(unsigned int irq, unsigned int cnt);
> -int irq_reserve_irqs(unsigned int from, unsigned int cnt);
> -
>  static inline void irq_free_desc(unsigned int irq)
>  {
>  	irq_free_descs(irq, 1);
>  }
>  
> -static inline int irq_reserve_irq(unsigned int irq)
> -{
> -	return irq_reserve_irqs(irq, 1);
> -}
> -
>  #ifdef CONFIG_GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
>  unsigned int irq_alloc_hwirqs(int cnt, int node);
>  static inline unsigned int irq_alloc_hwirq(int node)
> Index: tip/kernel/irq/irqdesc.c
> ===================================================================
> --- tip.orig/kernel/irq/irqdesc.c
> +++ tip/kernel/irq/irqdesc.c
> @@ -455,31 +455,6 @@ EXPORT_SYMBOL_GPL(irq_free_hwirqs);
>  #endif
>  
>  /**
> - * irq_reserve_irqs - mark irqs allocated
> - * @from:	mark from irq number
> - * @cnt:	number of irqs to mark
> - *
> - * Returns 0 on success or an appropriate error code
> - */
> -int irq_reserve_irqs(unsigned int from, unsigned int cnt)
> -{
> -	unsigned int start;
> -	int ret = 0;
> -
> -	if (!cnt || (from + cnt) > nr_irqs)
> -		return -EINVAL;
> -
> -	mutex_lock(&sparse_irq_lock);
> -	start = bitmap_find_next_zero_area(allocated_irqs, nr_irqs, from, cnt, 0);
> -	if (start == from)
> -		bitmap_set(allocated_irqs, start, cnt);
> -	else
> -		ret = -EEXIST;
> -	mutex_unlock(&sparse_irq_lock);
> -	return ret;
> -}
> -
> -/**
>   * irq_get_next_irq - get next allocated irq number
>   * @offset:	where to start the search
>   *
> 
> 
> --
> 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/


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

* Re: [patch 00/32] genirq: Another round of tree wide cleanups
  2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (31 preceding siblings ...)
  2014-05-07 15:44 ` [patch 32/32] genirq: Remove dynamic_irq mess Thomas Gleixner
@ 2014-05-08 12:17 ` Grant Likely
  32 siblings, 0 replies; 86+ messages in thread
From: Grant Likely @ 2014-05-08 12:17 UTC (permalink / raw)
  To: Thomas Gleixner, LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra

On Wed, 07 May 2014 15:44:03 -0000, Thomas Gleixner <tglx@linutronix.de> wrote:
> This cleanup series addresses a few histerical leftovers:
> 
> 1) irq_reserve_irq()
> 
>    The remaining callsites are pointless except s390, but we have a
>    better way to protect the lower interrupt space there.
> 
>    It's gone for good and it will never come back. Use irq domains, if
>    you want hot pluggable irq chips.
> 
> 2) create/destroy_irq and their variants
> 
>    Designed in different circles of hell we have an incompatible zoo
>    of those.
> 
>    Three different implementations with different semantics vs. the
>    return values. Two use cases which are just reusing the global
>    namespace. And they come along with four different flavours of
>    dynamic irq allocation.
> 
>    I created a core implementation for that and put it under
>    GENERIC_IRQ_LEGACY_ALLOC_HWIRQ to make clear that this is not for
>    new code. That implementation is used by x86 and tile. I gave up on
>    converting ia64 over, so I moved the create/destroy_irq prototypes
>    into ia64 headers and provided a wrapper for the shared dmar driver.
> 
>    The core implementation is a very basic allocator and that's
>    deliberately so. I don't want more users and every more complex
>    than that wants to use irq domains.
> 
> 3) dynamic_irq_init/cleanup
> 
>    Another leftover from the past. By moving tile and iop13xx to
>    sparse irq there is only ia64 left. I simplified the code and made
>    this available only under a legacy config option to avoid that more
>    people think they need this.
> 
> Full diffstat below.

For the whole series:

Reviewed-by: Grant Likely <grant.likely@linaro.org>

It all looks sane and a good cleanup. I've not done any testing though.

g.

> 
> Thanks,
> 
> 	tglx
> ---
>  arch/arm/Kconfig                          |    1 
>  arch/arm/mach-iop13xx/include/mach/irqs.h |    2 
>  arch/arm/mach-iop13xx/include/mach/time.h |    3 
>  arch/arm/mach-iop13xx/iq81340mc.c         |    1 
>  arch/arm/mach-iop13xx/iq81340sc.c         |    1 
>  arch/arm/mach-iop13xx/msi.c               |   51 ++---------
>  arch/arm/mach-iop13xx/setup.c             |    1 
>  arch/arm/mach-iop13xx/tpmi.c              |    1 
>  arch/ia64/Kconfig                         |    1 
>  arch/ia64/include/asm/hw_irq.h            |    1 
>  arch/ia64/include/asm/irq.h               |    3 
>  arch/ia64/include/asm/irq_remapping.h     |    2 
>  arch/ia64/kernel/iosapic.c                |    2 
>  arch/ia64/kernel/irq_ia64.c               |   15 ---
>  arch/mips/pci/msi-xlp.c                   |   10 --
>  arch/mips/pci/pci-xlr.c                   |   10 --
>  arch/s390/kernel/irq.c                    |    5 -
>  arch/s390/pci/pci.c                       |    6 -
>  arch/tile/Kconfig                         |    2 
>  arch/tile/include/asm/irq.h               |    6 -
>  arch/tile/kernel/irq.c                    |   40 ---------
>  arch/tile/kernel/pci_gx.c                 |   17 +--
>  arch/x86/Kconfig                          |    1 
>  arch/x86/include/asm/io_apic.h            |    2 
>  arch/x86/include/asm/irq_remapping.h      |    3 
>  arch/x86/kernel/apic/io_apic.c            |  130 +++++-------------------------
>  arch/x86/kernel/hpet.c                    |    5 -
>  arch/x86/platform/uv/uv_irq.c             |   10 --
>  drivers/iommu/dmar.c                      |    8 -
>  drivers/iommu/irq_remapping.c             |   12 +-
>  drivers/net/ethernet/tile/tilegx.c        |    6 -
>  drivers/pci/htirq.c                       |   13 ---
>  drivers/sh/intc/core.c                    |    6 -
>  drivers/tty/hvc/hvc_tile.c                |    8 -
>  drivers/tty/serial/tilegx.c               |    8 -
>  drivers/usb/host/ehci-tilegx.c            |    8 -
>  drivers/usb/host/ohci-tilegx.c            |    8 -
>  drivers/xen/events/events_base.c          |   17 ---
>  include/linux/irq.h                       |   38 +++-----
>  kernel/irq/Kconfig                        |    9 ++
>  kernel/irq/chip.c                         |    5 -
>  kernel/irq/internals.h                    |    6 +
>  kernel/irq/irqdesc.c                      |   95 ++++++++++++++-------
>  43 files changed, 216 insertions(+), 363 deletions(-)
> 
> 
> 
> --
> 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/


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

* Re: [patch 29/32] genirq: Remove irq_reserve_irq[s]
  2014-05-08 12:14   ` Grant Likely
@ 2014-05-08 12:54     ` Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-08 12:54 UTC (permalink / raw)
  To: Grant Likely; +Cc: LKML, Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra

On Thu, 8 May 2014, Grant Likely wrote:

> On Wed, 07 May 2014 15:44:21 -0000, Thomas Gleixner <tglx@linutronix.de> wrote:
> > No more users. And it's not going to come back. If you need
> > hotplugable irq chips, use irq domains.
> > 
> > Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> 
> Acked-by: Grant Likely <grant.likely@secretlab.ca>
> 
> The ironic thing is that irq_domain may end up bringing this function
> back in some form as an optimization for irq_domains that need a
> contiguous range, but don't want to allocate all the irq_descs
> immediately. But if that happens it will be a very private API and it
> doesn't nullify removing the function now.

Right. We can deal with it when the need arises, but that's a
completely core internal issue then which is not going to be usable
outside of kernel/irq.

Thanks,

	tglx

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

* Re: [patch 03/32] genirq: Provide generic hwirq allocation facility
  2014-05-08 12:07   ` Grant Likely
@ 2014-05-08 13:12     ` Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-08 13:12 UTC (permalink / raw)
  To: Grant Likely
  Cc: LKML, Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra,
	Chris Metcalf, Fenghua Yu

On Thu, 8 May 2014, Grant Likely wrote:
> On Wed, 07 May 2014 15:44:05 -0000, Thomas Gleixner <tglx@linutronix.de> wrote:
> > +EXPORT_SYMBOL_GPL(irq_alloc_hwirqs);
> 
> Okay, so regarding this and irq_domains, I think the functionality
> overlaps and irq_domain conversion wouldn't directly use this API. I
> could see two ways that it would be wired up in an irq_domain
> conversion...
> 
> 1) use an irq_domain to represent the root of the interrupt tree and be
> responsible for all of the hardware irqs. Child interrupt controllers
> would allocate a hwirq from the root irq_domain and program itself
> accordingly. This approach would either not use this API, or make it
> entirely internal to the root irq_domain.
> 
> 2) Use this API as the root of the interrupt tree and make first level
> of child interrupt controllers use this API to allocate HWIRQs to use
> for their irq outputs.
> 
> Most of the platforms using irq_domain now fall in the first category,
> which I think makes the most sense. Any platform like x86 that has
> multiple hwirq vectors and the option of per-cpu vectors would be best
> to keep all of that detail in one place. We could add a cpumask variant
> to the irqdomain APIs, and add a stock implementation of an allocator
> that can intelligently allocate when cpumasks are used.

When we have a root domain which handles the vector matrix, then we
can put sub domains on top which handle the various irq chips (PIC,
IOAPIC, MSI ....).

So that will need some cpumask support in irq domains, but that's not
a bad thing in general. Even ARM might get some benefit from for the
SPIs.

Thanks,

	tglx

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

* Re: [patch 24/32] sh: intc: Remove pointless irq_reserve_irqs() invocation
  2014-05-07 15:44 ` [patch 24/32] sh: intc: Remove pointless irq_reserve_irqs() invocation Thomas Gleixner
@ 2014-05-11  0:53   ` Simon Horman
  2014-05-16 13:36   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 86+ messages in thread
From: Simon Horman @ 2014-05-11  0:53 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: LKML, Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra

On Wed, May 07, 2014 at 03:44:18PM -0000, Thomas Gleixner wrote:
> The preceding call to irq_create_identity_mapping() marks the
> interrupt as allocated already. Remove the leftover.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: linux-sh@vger.kernel.org
> Cc: Simon Horman <horms@verge.net.au>

This duplicates a similar patch, "[PATCH v3 2/8] sh, irq: Remove
irq_reserve_irq calling", by Yinghai Lu. But perhaps you already know that.

Regardless, I am fine with the contents.

Acked-by: Simon Horman <horms+renesas@verge.net.au>

> ---
>  drivers/sh/intc/core.c |    6 ------
>  1 file changed, 6 deletions(-)
> 
> Index: tip/drivers/sh/intc/core.c
> ===================================================================
> --- tip.orig/drivers/sh/intc/core.c
> +++ tip/drivers/sh/intc/core.c
> @@ -80,12 +80,6 @@ static void __init intc_register_irq(str
>  	unsigned int data[2], primary;
>  	unsigned long flags;
>  
> -	/*
> -	 * Register the IRQ position with the global IRQ map, then insert
> -	 * it in to the radix tree.
> -	 */
> -	irq_reserve_irq(irq);
> -
>  	raw_spin_lock_irqsave(&intc_big_lock, flags);
>  	radix_tree_insert(&d->tree, enum_id, intc_irq_xlate_get(irq));
>  	raw_spin_unlock_irqrestore(&intc_big_lock, flags);
> 
> 

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

* Re: [patch 03/32] genirq: Provide generic hwirq allocation facility
  2014-05-08 10:22       ` Thomas Gleixner
@ 2014-05-13 16:59         ` Thomas Gleixner
  2014-05-13 17:48           ` Luck, Tony
  0 siblings, 1 reply; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-13 16:59 UTC (permalink / raw)
  To: Chris Metcalf
  Cc: LKML, Tony Lu, Ingo Molnar, Peter Anvin, Tony Luck,
	Peter Zijlstra, Fenghua Yu, Grant Likely, Benjamin Herrenschmidt

Chris,

On Thu, 8 May 2014, Thomas Gleixner wrote:
> On Thu, 8 May 2014, Thomas Gleixner wrote:
> > Now on top of that we need irq domain support for this kind of matrix
> > mappings down to the vector level and everything else falls in
> > place. I have not thought through the irq domain angle, but maybe
> > Grant/Ben can give some input on that.
> 
> Just talked to Grant to get my irqdomain foo up to speed.
> 
> irq domains support parent irq domains already, which allow you to
> request an irq from the parent.
> 
> What's missing is:
> 
> - a bitmap based matrix vector allocator, but that shouldn't be rocket
>   science to write one.
> 
> - a mechanism to hand a cpumask down in the allocation chain
> 
> - a shortcut support to avoid multi level map lookups for the fast
>   path.
> 
> Once we have that everything just falls in place and when tile and x86
> are switched over we can rip out the LEGACY allocator again. That'll
> leave itanic with its homebrewn create_irq machinery, but I'm happy to
> ignore that as this is almost completely confined in ia64 code where
> is can bitrot happily until it sinks.

any comment on this ?

Thanks,

	tglx

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

* RE: [patch 03/32] genirq: Provide generic hwirq allocation facility
  2014-05-13 16:59         ` Thomas Gleixner
@ 2014-05-13 17:48           ` Luck, Tony
  0 siblings, 0 replies; 86+ messages in thread
From: Luck, Tony @ 2014-05-13 17:48 UTC (permalink / raw)
  To: Thomas Gleixner, Chris Metcalf
  Cc: LKML, Tony Lu, Ingo Molnar, Peter Anvin, Peter Zijlstra, Yu,
	Fenghua, Grant Likely, Benjamin Herrenschmidt

> - a bitmap based matrix vector allocator, but that shouldn't be rocket
>   science to write one.

Not rocket science - but some tricky corner cases to make sure all the
allocations will fit.  MSI needs blocks of irqs that start on a power-of-two
boundary so the h/w can just fiddle with low order bits.  We'll see the
requests for allocation in some random order (rather than the more
convenient "largest block first"). We also have to handle hotplug events
adding and removing (and generally messing up the neat layout).
In the worst case we might need a callback to a driver to tell it
that we need to move irqs previously allocated to some new range
in order to free a contiguous block.

-Tony

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

* Re: [patch 05/32] x86: irq_remapping: Use irq_alloc/free_hwirq()
  2014-05-07 15:44 ` [patch 05/32] x86: irq_remapping: " Thomas Gleixner
@ 2014-05-14  9:32   ` Joerg Roedel
  2014-05-16 13:32   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 86+ messages in thread
From: Joerg Roedel @ 2014-05-14  9:32 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: LKML, Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra

Hi Thomas,

On Wed, May 07, 2014 at 03:44:07PM -0000, Thomas Gleixner wrote:
> The create_irq variants are going away. Use the new interface. The
> core and arch code already excludes the gsi interrupts from the
> allocation, so no functional change.
> 
> This does not replace the requirement to move x86 to irq domains, but
> it limits the mess to some degree.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: x86@kernel.org
> Cc: Joerg Roedel <joro@8bytes.org>
> Cc: iommu@lists.linux-foundation.org

Can patches 5, 11 and 12 go through the IOMMU tree or do they depend on
the other patches in the series?

If they have other dependencys and can't go through the IOMMU tree feel
free to add my

Acked-by: Joerg Roedel <jroedel@suse.de>


	Joerg



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

* Re: [patch 03/32] genirq: Provide generic hwirq allocation facility
  2014-05-07 15:44 ` [patch 03/32] genirq: Provide generic hwirq allocation facility Thomas Gleixner
  2014-05-07 20:37   ` Chris Metcalf
  2014-05-08 12:07   ` Grant Likely
@ 2014-05-14 17:44   ` Chris Metcalf
  2014-05-14 23:47     ` Thomas Gleixner
  2014-05-16 13:31   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  3 siblings, 1 reply; 86+ messages in thread
From: Chris Metcalf @ 2014-05-14 17:44 UTC (permalink / raw)
  To: Thomas Gleixner, LKML
  Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra, Fenghua Yu

On 5/7/2014 11:44 AM, Thomas Gleixner wrote:
> --- tip.orig/kernel/irq/Kconfig
> +++ tip/kernel/irq/Kconfig
> @@ -17,6 +17,11 @@ config GENERIC_IRQ_SHOW
>   config GENERIC_IRQ_SHOW_LEVEL
>          bool
>   
> +# Facility to allocate an hardware interrupt. This is legacy support
> +# and should not be used in new code. Use irq domains instead.
> +config GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
> +       bool

"a hardware interrupt".

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com


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

* Re: [patch 15/32] tile: Implement irq_alloc/free_hwirq() for migration
  2014-05-07 15:44 ` [patch 15/32] tile: Implement irq_alloc/free_hwirq() for migration Thomas Gleixner
@ 2014-05-14 17:48   ` Chris Metcalf
       [not found]   ` <5373AC00.7090507@tilera.com>
  2014-05-16 13:34   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2 siblings, 0 replies; 86+ messages in thread
From: Chris Metcalf @ 2014-05-14 17:48 UTC (permalink / raw)
  To: Thomas Gleixner, LKML; +Cc: Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra

(Resending since my mailer "helpfully" upgraded the previous version to multipart/mixed.)

On 5/7/2014 11:44 AM, Thomas Gleixner wrote:
> We want to convert the drivers over to the new interface and finally
> tile to sparse irqs. Implement irq_alloc/free_hwirq() for step by step
> migration.
>
>
> +void irq_free_hwirq(unsigned int irq)
> +{
> +	destroy_irq();
> +}

Should be destroy_irq(irq).

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com


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

* Re: [patch 03/32] genirq: Provide generic hwirq allocation facility
  2014-05-07 23:15     ` Thomas Gleixner
  2014-05-08 10:22       ` Thomas Gleixner
@ 2014-05-14 17:57       ` Chris Metcalf
  2014-05-14 23:57         ` Thomas Gleixner
  1 sibling, 1 reply; 86+ messages in thread
From: Chris Metcalf @ 2014-05-14 17:57 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, Tony Lu, Ingo Molnar, Peter Anvin, Tony Luck,
	Peter Zijlstra, Fenghua Yu, Grant Likely, Benjamin Herrenschmidt

On 5/7/2014 7:15 PM, Thomas Gleixner wrote:
> On Wed, 7 May 2014, Chris Metcalf wrote:
>> We have an internal change that we haven't upstreamed yet that makes
>> irqs actually (cpu,ipi) pairs, so that more irqs can be allocated.
>> As a result we allocate some irqs as bound to a specific IPI on a single
>> cpu, and some irqs get bound to a particular IPI registered on every cpu.
>>
>> I'll have to set aside a bit of time to look more closely at how your
>> change interacts with the work we've done internally.  I've appended the
>> per-cpu IRQ change from our internal tree here (and cc'ed the author).
>> The API change is in the <asm/irq.h> diff at the very start.
> Sure it'll break it. [...]

I think the right thing for now is to take my Acked-by for the tile changes
(given a couple of minor nits replied to in separate emails).

Acked-by: Chris Metcalf <cmetcalf@tilera.com>

When we have the chance to set aside some time for more upstreaming of some
of the work we've done it does seem like it makes sense to tackle doing some
kind of matrix mapping in a more generic way.

You're probably right that a cpumask approach would have made more sense
than a cpu integer in the tile API, so we'd certainly go with that in any
fgeneric matrix mapping code.

I do have one question about the irq_alloc_hwirqs() API, which is the use of
zero as an error indicator.  Given that zero can plausibly be an IRQ number,
it seems cleaner to specify this as returning a negative errno failure instead.
Doing so would also align with __irq_alloc_descs().  So, what was your thinking
around using zero?

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com


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

* Re: [patch 03/32] genirq: Provide generic hwirq allocation facility
  2014-05-14 17:44   ` Chris Metcalf
@ 2014-05-14 23:47     ` Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-14 23:47 UTC (permalink / raw)
  To: Chris Metcalf
  Cc: LKML, Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra, Fenghua Yu

On Wed, 14 May 2014, Chris Metcalf wrote:

> On 5/7/2014 11:44 AM, Thomas Gleixner wrote:
> > --- tip.orig/kernel/irq/Kconfig
> > +++ tip/kernel/irq/Kconfig
> > @@ -17,6 +17,11 @@ config GENERIC_IRQ_SHOW
> >   config GENERIC_IRQ_SHOW_LEVEL
> >          bool
> >   +# Facility to allocate an hardware interrupt. This is legacy support
> > +# and should not be used in new code. Use irq domains instead.
> > +config GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
> > +       bool
> 
> "a hardware interrupt".

I'll never get that right!

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

* Re: [patch 15/32] tile: Implement irq_alloc/free_hwirq() for migration
       [not found]   ` <5373AC00.7090507@tilera.com>
@ 2014-05-14 23:50     ` Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-14 23:50 UTC (permalink / raw)
  To: Chris Metcalf; +Cc: LKML, Ingo Molnar, Peter Anvin, Tony Luck, Peter Zijlstra

On Wed, 14 May 2014, Chris Metcalf wrote:
> On 5/7/2014 11:44 AM, Thomas Gleixner wrote:
> > We want to convert the drivers over to the new interface and finally
> > tile to sparse irqs. Implement irq_alloc/free_hwirq() for step by step
> > migration.
> > 
> > 
> > +void irq_free_hwirq(unsigned int irq)
> > +{
> > +	destroy_irq();
> > +}
> 
> Should be destroy_irq(irq).

Yep. I caught that already when I exposed the series step by step to
a compiler.

Thanks,

	tglx

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

* Re: [patch 03/32] genirq: Provide generic hwirq allocation facility
  2014-05-14 17:57       ` Chris Metcalf
@ 2014-05-14 23:57         ` Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: Thomas Gleixner @ 2014-05-14 23:57 UTC (permalink / raw)
  To: Chris Metcalf
  Cc: LKML, Tony Lu, Ingo Molnar, Peter Anvin, Tony Luck,
	Peter Zijlstra, Fenghua Yu, Grant Likely, Benjamin Herrenschmidt

On Wed, 14 May 2014, Chris Metcalf wrote:

> On 5/7/2014 7:15 PM, Thomas Gleixner wrote:
> > On Wed, 7 May 2014, Chris Metcalf wrote:
> > > We have an internal change that we haven't upstreamed yet that makes
> > > irqs actually (cpu,ipi) pairs, so that more irqs can be allocated.
> > > As a result we allocate some irqs as bound to a specific IPI on a single
> > > cpu, and some irqs get bound to a particular IPI registered on every cpu.
> > > 
> > > I'll have to set aside a bit of time to look more closely at how your
> > > change interacts with the work we've done internally.  I've appended the
> > > per-cpu IRQ change from our internal tree here (and cc'ed the author).
> > > The API change is in the <asm/irq.h> diff at the very start.
> > Sure it'll break it. [...]
> 
> I think the right thing for now is to take my Acked-by for the tile changes
> (given a couple of minor nits replied to in separate emails).
> 
> Acked-by: Chris Metcalf <cmetcalf@tilera.com>

Thanks.
 
> When we have the chance to set aside some time for more upstreaming of some
> of the work we've done it does seem like it makes sense to tackle doing some
> kind of matrix mapping in a more generic way.

Please coordinate with x86 folks on that to avoid redundant efforts.
 
> You're probably right that a cpumask approach would have made more sense
> than a cpu integer in the tile API, so we'd certainly go with that in any
> generic matrix mapping code.

Anything else is just an intermediate and non generic solution.
 
> I do have one question about the irq_alloc_hwirqs() API, which is
> the use of zero as an error indicator.  Given that zero can
> plausibly be an IRQ number, it seems cleaner to specify this as
> returning a negative errno failure instead.  Doing so would also
> align with __irq_alloc_descs().  So, what was your thinking around
> using zero?

0 has been for a long time a not allocatable irq. Google will unearth
about a gazillion heated debates about that.

I personally agree, that using a negative error code is the right
thing to do. I'll update the series before I push it into tip.

Thanks for your input and cooperation!

       tglx

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

* [tip:irq/core] arm: iop13xx: Use sparse irqs for MSI
  2014-05-07 15:44 ` [patch 01/32] arm: iop13xx: Use sparse irqs for MSI Thomas Gleixner
@ 2014-05-16 13:31   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:31 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, dan.j.williams, peterz,
	tony.luck, linux, tglx

Commit-ID:  37ebbcff78375bfa69eb69748ef00f577b7c1c6c
Gitweb:     http://git.kernel.org/tip/37ebbcff78375bfa69eb69748ef00f577b7c1c6c
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:04 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:18 +0200

arm: iop13xx: Use sparse irqs for MSI

No need for a private allocator. The core code handles it
already. 

Allocate the non MSI irqs right at boot time via machine_desc->nr_irqs
and let the sparse core handle the MSI space.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/20140507154333.809210026@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/arm/Kconfig                          |  1 +
 arch/arm/mach-iop13xx/include/mach/irqs.h |  2 --
 arch/arm/mach-iop13xx/include/mach/time.h |  3 ++
 arch/arm/mach-iop13xx/iq81340mc.c         |  1 +
 arch/arm/mach-iop13xx/iq81340sc.c         |  1 +
 arch/arm/mach-iop13xx/msi.c               | 51 +++++++------------------------
 arch/arm/mach-iop13xx/setup.c             |  1 +
 arch/arm/mach-iop13xx/tpmi.c              |  1 +
 8 files changed, 19 insertions(+), 42 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index db3c541..a2c1a18 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -480,6 +480,7 @@ config ARCH_IOP13XX
 	select PCI
 	select PLAT_IOP
 	select VMSPLIT_1G
+	select SPARSE_IRQ
 	help
 	  Support for Intel's IOP13XX (XScale) family of processors.
 
diff --git a/arch/arm/mach-iop13xx/include/mach/irqs.h b/arch/arm/mach-iop13xx/include/mach/irqs.h
index 054e7ac..e8d24d3 100644
--- a/arch/arm/mach-iop13xx/include/mach/irqs.h
+++ b/arch/arm/mach-iop13xx/include/mach/irqs.h
@@ -191,6 +191,4 @@ static inline u32 read_intpnd_3(void)
 #define NR_IOP13XX_IRQS	(IRQ_IOP13XX_HPI + 1)
 #endif
 
-#define NR_IRQS		NR_IOP13XX_IRQS
-
 #endif /* _IOP13XX_IRQ_H_ */
diff --git a/arch/arm/mach-iop13xx/include/mach/time.h b/arch/arm/mach-iop13xx/include/mach/time.h
index f1c00d6..15bc9bb 100644
--- a/arch/arm/mach-iop13xx/include/mach/time.h
+++ b/arch/arm/mach-iop13xx/include/mach/time.h
@@ -1,5 +1,8 @@
 #ifndef _IOP13XX_TIME_H_
 #define _IOP13XX_TIME_H_
+
+#include <mach/irqs.h>
+
 #define IRQ_IOP_TIMER0 IRQ_IOP13XX_TIMER0
 
 #define IOP_TMR_EN	    0x02
diff --git a/arch/arm/mach-iop13xx/iq81340mc.c b/arch/arm/mach-iop13xx/iq81340mc.c
index 02a8228..9cd07d3 100644
--- a/arch/arm/mach-iop13xx/iq81340mc.c
+++ b/arch/arm/mach-iop13xx/iq81340mc.c
@@ -93,4 +93,5 @@ MACHINE_START(IQ81340MC, "Intel IQ81340MC")
 	.init_time	= iq81340mc_timer_init,
 	.init_machine   = iq81340mc_init,
 	.restart	= iop13xx_restart,
+	.nr_irqs	= NR_IOP13XX_IRQS,
 MACHINE_END
diff --git a/arch/arm/mach-iop13xx/iq81340sc.c b/arch/arm/mach-iop13xx/iq81340sc.c
index 1b80f10..b3ec11c 100644
--- a/arch/arm/mach-iop13xx/iq81340sc.c
+++ b/arch/arm/mach-iop13xx/iq81340sc.c
@@ -95,4 +95,5 @@ MACHINE_START(IQ81340SC, "Intel IQ81340SC")
 	.init_time	= iq81340sc_timer_init,
 	.init_machine   = iq81340sc_init,
 	.restart	= iop13xx_restart,
+	.nr_irqs	= NR_IOP13XX_IRQS,
 MACHINE_END
diff --git a/arch/arm/mach-iop13xx/msi.c b/arch/arm/mach-iop13xx/msi.c
index 560d5b2..655072d 100644
--- a/arch/arm/mach-iop13xx/msi.c
+++ b/arch/arm/mach-iop13xx/msi.c
@@ -24,10 +24,6 @@
 #include <asm/mach/irq.h>
 #include <asm/irq.h>
 
-
-#define IOP13XX_NUM_MSI_IRQS 128
-static DECLARE_BITMAP(msi_irq_in_use, IOP13XX_NUM_MSI_IRQS);
-
 /* IMIPR0 CP6 R8 Page 1
  */
 static u32 read_imipr_0(void)
@@ -121,41 +117,6 @@ void __init iop13xx_msi_init(void)
 	irq_set_chained_handler(IRQ_IOP13XX_INBD_MSI, iop13xx_msi_handler);
 }
 
-/*
- * Dynamic irq allocate and deallocation
- */
-int create_irq(void)
-{
-	int irq, pos;
-
-again:
-	pos = find_first_zero_bit(msi_irq_in_use, IOP13XX_NUM_MSI_IRQS);
-	irq = IRQ_IOP13XX_MSI_0 + pos;
-	if (irq > NR_IRQS)
-		return -ENOSPC;
-	/* test_and_set_bit operates on 32-bits at a time */
-	if (test_and_set_bit(pos, msi_irq_in_use))
-		goto again;
-
-	dynamic_irq_init(irq);
-
-	return irq;
-}
-
-void destroy_irq(unsigned int irq)
-{
-	int pos = irq - IRQ_IOP13XX_MSI_0;
-
-	dynamic_irq_cleanup(irq);
-
-	clear_bit(pos, msi_irq_in_use);
-}
-
-void arch_teardown_msi_irq(unsigned int irq)
-{
-	destroy_irq(irq);
-}
-
 static void iop13xx_msi_nop(struct irq_data *d)
 {
 	return;
@@ -172,12 +133,17 @@ static struct irq_chip iop13xx_msi_chip = {
 
 int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
 {
-	int id, irq = create_irq();
+	int id, irq = irq_alloc_desc_from(IRQ_IOP13XX_MSI_0, -1);
 	struct msi_msg msg;
 
 	if (irq < 0)
 		return irq;
 
+	if (irq >= NR_IOP13XX_IRQS) {
+		irq_free_desc(irq);
+		return -ENOSPC;
+	}
+
 	irq_set_msi_desc(irq, desc);
 
 	msg.address_hi = 0x0;
@@ -191,3 +157,8 @@ int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
 
 	return 0;
 }
+
+void arch_teardown_msi_irq(unsigned int irq)
+{
+	irq_free_desc(irq);
+}
diff --git a/arch/arm/mach-iop13xx/setup.c b/arch/arm/mach-iop13xx/setup.c
index 96e6c7a..bca96f4 100644
--- a/arch/arm/mach-iop13xx/setup.c
+++ b/arch/arm/mach-iop13xx/setup.c
@@ -27,6 +27,7 @@
 #include <mach/hardware.h>
 #include <asm/irq.h>
 #include <asm/hardware/iop_adma.h>
+#include <mach/irqs.h>
 
 #define IOP13XX_UART_XTAL 33334000
 #define IOP13XX_SETUP_DEBUG 0
diff --git a/arch/arm/mach-iop13xx/tpmi.c b/arch/arm/mach-iop13xx/tpmi.c
index 6fdad7a..db511ec 100644
--- a/arch/arm/mach-iop13xx/tpmi.c
+++ b/arch/arm/mach-iop13xx/tpmi.c
@@ -24,6 +24,7 @@
 #include <linux/io.h>
 #include <asm/irq.h>
 #include <asm/sizes.h>
+#include <mach/irqs.h>
 
 /* assumes CONTROLLER_ONLY# is never asserted in the ESSR register */
 #define IOP13XX_TPMI_MMR(dev) 	IOP13XX_REG_ADDR32_PHYS(0x48000 + (dev << 12))

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

* [tip:irq/core] mips: Kill pointless destroy_irq()
  2014-05-07 15:44 ` [patch 02/32] mips: Kill pointless destroy_irq() Thomas Gleixner
@ 2014-05-16 13:31   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:31 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, peterz, tony.luck,
	jchandra, ralf, tglx

Commit-ID:  465665f78a7f47d46d7fe18195f3548b4911547f
Gitweb:     http://git.kernel.org/tip/465665f78a7f47d46d7fe18195f3548b4911547f
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:05 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:18 +0200

mips: Kill pointless destroy_irq()

Copy and paste leftovers with no functionality at all.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Jayachandran C <jchandra@broadcom.com>
Cc: linux-mips@linux-mips.org
Link: http://lkml.kernel.org/r/20140507154334.008113902@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/mips/pci/msi-xlp.c | 10 +---------
 arch/mips/pci/pci-xlr.c | 10 +---------
 2 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/arch/mips/pci/msi-xlp.c b/arch/mips/pci/msi-xlp.c
index afd8405..3249685 100644
--- a/arch/mips/pci/msi-xlp.c
+++ b/arch/mips/pci/msi-xlp.c
@@ -206,14 +206,8 @@ static struct irq_chip xlp_msix_chip = {
 	.irq_unmask	= unmask_msi_irq,
 };
 
-void destroy_irq(unsigned int irq)
-{
-	    /* nothing to do yet */
-}
-
 void arch_teardown_msi_irq(unsigned int irq)
 {
-	destroy_irq(irq);
 }
 
 /*
@@ -298,10 +292,8 @@ static int xlp_setup_msi(uint64_t lnkbase, int node, int link,
 
 	xirq = xirq + msivec;		/* msi mapped to global irq space */
 	ret = irq_set_msi_desc(xirq, desc);
-	if (ret < 0) {
-		destroy_irq(xirq);
+	if (ret < 0)
 		return ret;
-	}
 
 	write_msi_msg(xirq, &msg);
 	return 0;
diff --git a/arch/mips/pci/pci-xlr.c b/arch/mips/pci/pci-xlr.c
index 4427abb..0dde803 100644
--- a/arch/mips/pci/pci-xlr.c
+++ b/arch/mips/pci/pci-xlr.c
@@ -214,14 +214,8 @@ static int get_irq_vector(const struct pci_dev *dev)
 }
 
 #ifdef CONFIG_PCI_MSI
-void destroy_irq(unsigned int irq)
-{
-	    /* nothing to do yet */
-}
-
 void arch_teardown_msi_irq(unsigned int irq)
 {
-	destroy_irq(irq);
 }
 
 int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc)
@@ -263,10 +257,8 @@ int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc)
 		MSI_DATA_DELIVERY_FIXED;
 
 	ret = irq_set_msi_desc(irq, desc);
-	if (ret < 0) {
-		destroy_irq(irq);
+	if (ret < 0)
 		return ret;
-	}
 
 	write_msi_msg(irq, &msg);
 	return 0;

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

* [tip:irq/core] genirq: Provide generic hwirq allocation facility
  2014-05-07 15:44 ` [patch 03/32] genirq: Provide generic hwirq allocation facility Thomas Gleixner
                     ` (2 preceding siblings ...)
  2014-05-14 17:44   ` Chris Metcalf
@ 2014-05-16 13:31   ` tip-bot for Thomas Gleixner
  3 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:31 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, peterz, cmetcalf,
	tony.luck, fenghua.yu, tglx

Commit-ID:  7b6ef1262549f6afc5c881aaef80beb8fd15f908
Gitweb:     http://git.kernel.org/tip/7b6ef1262549f6afc5c881aaef80beb8fd15f908
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:05 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:18 +0200

genirq: Provide generic hwirq allocation facility

Not really the solution to the problem, but at least it confines the
mess in the core code and allows to get rid of the create/destroy_irq
variants from hell, i.e. 3 implementations with different semantics
plus the x86 specific variants __create_irqs and create_irq_nr
which have been invented in another circle of hell.

x86 : x86 should be converted to irq domains and I'm deliberately
      making it impossible to do the multi-vector MSI support by
      adding more crap to the current mess. It's not that hard to do
      and I'm really tired of the trainwrecks which have been invented
      by baindaid engineering so far. Any attempt to do multi-vector
      MSI or ioapic hotplug without converting to irq domains is NAKed
      hereby.

tile: Might use irq domains as well, but it has a very limited
      interrupt space, so handling it via this functionality might be
      the right thing to do even in the long run.

ia64: That's an hopeless case, as I doubt that anyone has the stomach
      to rewrite the homebrewn dynamic allocation facilities. I stared
      at it for a couple of hours and gave up. The create/destroy_irq
      mess could be made private to itanic right away if there
      wouldn't be the iommu/dmar driver being shared with x86. So to
      do that I'm going to add a separate ia64 specific implementation
      later in order not to deep-six itanic right away.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: x86@kernel.org
Link: http://lkml.kernel.org/r/20140507154334.208629358@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 include/linux/irq.h  | 15 +++++++++++++++
 kernel/irq/Kconfig   |  5 +++++
 kernel/irq/irqdesc.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 71 insertions(+)

diff --git a/include/linux/irq.h b/include/linux/irq.h
index 5c57efb..c75dd16 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -637,6 +637,21 @@ static inline int irq_reserve_irq(unsigned int irq)
 	return irq_reserve_irqs(irq, 1);
 }
 
+#ifdef CONFIG_GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
+unsigned int irq_alloc_hwirqs(int cnt, int node);
+static inline unsigned int irq_alloc_hwirq(int node)
+{
+	return irq_alloc_hwirqs(1, node);
+}
+void irq_free_hwirqs(unsigned int from, int cnt);
+static inline void irq_free_hwirq(unsigned int irq)
+{
+	return irq_free_hwirqs(irq, 1);
+}
+int arch_setup_hwirq(unsigned int irq, int node);
+void arch_teardown_hwirq(unsigned int irq);
+#endif
+
 #ifndef irq_reg_writel
 # define irq_reg_writel(val, addr)	writel(val, addr)
 #endif
diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig
index 07cbdfe..a83f10e 100644
--- a/kernel/irq/Kconfig
+++ b/kernel/irq/Kconfig
@@ -17,6 +17,11 @@ config GENERIC_IRQ_SHOW
 config GENERIC_IRQ_SHOW_LEVEL
        bool
 
+# Facility to allocate a hardware interrupt. This is legacy support
+# and should not be used in new code. Use irq domains instead.
+config GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
+       bool
+
 # Support for delayed migration from interrupt context
 config GENERIC_PENDING_IRQ
 	bool
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index bb07f29..f388ade 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -396,6 +396,57 @@ err:
 }
 EXPORT_SYMBOL_GPL(__irq_alloc_descs);
 
+#ifdef CONFIG_GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
+/**
+ * irq_alloc_hwirqs - Allocate an irq descriptor and initialize the hardware
+ * @cnt:	number of interrupts to allocate
+ * @node:	node on which to allocate
+ *
+ * Returns an interrupt number > 0 or 0, if the allocation fails.
+ */
+unsigned int irq_alloc_hwirqs(int cnt, int node)
+{
+	int i, irq = __irq_alloc_descs(-1, 0, cnt, node, NULL);
+
+	if (irq < 0)
+		return 0;
+
+	for (i = irq; cnt > 0; i++, cnt--) {
+		if (arch_setup_hwirq(i, node))
+			goto err;
+		irq_clear_status_flags(i, _IRQ_NOREQUEST);
+	}
+	return irq;
+
+err:
+	for (i--; i >= irq; i--) {
+		irq_set_status_flags(i, _IRQ_NOREQUEST | _IRQ_NOPROBE);
+		arch_teardown_hwirq(i);
+	}
+	irq_free_descs(irq, cnt);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(irq_alloc_hwirqs);
+
+/**
+ * irq_free_hwirqs - Free irq descriptor and cleanup the hardware
+ * @from:	Free from irq number
+ * @cnt:	number of interrupts to free
+ *
+ */
+void irq_free_hwirqs(unsigned int from, int cnt)
+{
+	int i;
+
+	for (i = from; cnt > 0; i++, cnt--) {
+		irq_set_status_flags(i, _IRQ_NOREQUEST | _IRQ_NOPROBE);
+		arch_teardown_hwirq(i);
+	}
+	irq_free_descs(from, cnt);
+}
+EXPORT_SYMBOL_GPL(irq_free_hwirqs);
+#endif
+
 /**
  * irq_reserve_irqs - mark irqs allocated
  * @from:	mark from irq number

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

* [tip:irq/core] x86: Implement arch_setup/teardown_hwirq()
  2014-05-07 15:44 ` [patch 04/32] x86: Implement arch_setup/teardown_hwirq() Thomas Gleixner
@ 2014-05-16 13:31   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:31 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, peterz, tony.luck, tglx

Commit-ID:  b1ee544174fd0eb28a7770403b9577fd70f1cd3d
Gitweb:     http://git.kernel.org/tip/b1ee544174fd0eb28a7770403b9577fd70f1cd3d
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:06 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:18 +0200

x86: Implement arch_setup/teardown_hwirq()

This is just a cleanup to get rid of the create/destroy_irq variants
which were designed in hell.

The long term solution for x86 is to switch over to irq domains and
cleanup the whole vector allocation mess.

The generic irq_alloc_hwirqs() interface deliberately prevents
multi-MSI vector allocation to further enforce the irq domain
conversion (aside of the desire to support ioapic hotplug).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: x86@kernel.org
Link: http://lkml.kernel.org/r/20140507154334.482904047@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/Kconfig               |  1 +
 arch/x86/kernel/apic/io_apic.c | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 25d2c6f..4724770 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -831,6 +831,7 @@ config X86_LOCAL_APIC
 config X86_IO_APIC
 	def_bool y
 	depends on X86_64 || SMP || X86_32_NON_STANDARD || X86_UP_IOAPIC || PCI_MSI
+	select GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
 
 config X86_REROUTE_FOR_BROKEN_BOOT_IRQS
 	bool "Reroute for broken boot IRQs"
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 992060e..b7175c0 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -3010,6 +3010,39 @@ void destroy_irqs(unsigned int irq, unsigned int count)
 		destroy_irq(irq + i);
 }
 
+int arch_setup_hwirq(unsigned int irq, int node)
+{
+	struct irq_cfg *cfg;
+	unsigned long flags;
+	int ret;
+
+	cfg = alloc_irq_cfg(irq, node);
+	if (!cfg)
+		return -ENOMEM;
+
+	raw_spin_lock_irqsave(&vector_lock, flags);
+	ret = __assign_irq_vector(irq, cfg, apic->target_cpus());
+	raw_spin_unlock_irqrestore(&vector_lock, flags);
+
+	if (!ret)
+		irq_set_chip_data(irq, cfg);
+	else
+		free_irq_cfg(irq, cfg);
+	return ret;
+}
+
+void arch_teardown_hwirq(unsigned int irq)
+{
+	struct irq_cfg *cfg = irq_get_chip_data(irq);
+	unsigned long flags;
+
+	free_remapped_irq(irq);
+	raw_spin_lock_irqsave(&vector_lock, flags);
+	__clear_irq_vector(irq, cfg);
+	raw_spin_unlock_irqrestore(&vector_lock, flags);
+	free_irq_cfg(irq, cfg);
+}
+
 /*
  * MSI message composition
  */

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

* [tip:irq/core] x86: irq_remapping: Use irq_alloc/free_hwirq()
  2014-05-07 15:44 ` [patch 05/32] x86: irq_remapping: " Thomas Gleixner
  2014-05-14  9:32   ` Joerg Roedel
@ 2014-05-16 13:32   ` tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:32 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, joro, peterz, tony.luck, tglx

Commit-ID:  d24a135412ab4dba50eb7aeffd4064eee23b4da6
Gitweb:     http://git.kernel.org/tip/d24a135412ab4dba50eb7aeffd4064eee23b4da6
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:07 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:18 +0200

x86: irq_remapping: Use irq_alloc/free_hwirq()

The create_irq variants are going away. Use the new interface. The
core and arch code already excludes the gsi interrupts from the
allocation, so no functional change.

This does not replace the requirement to move x86 to irq domains, but
it limits the mess to some degree.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Acked-by: Joerg Roedel <joro@8bytes.org>
Cc: x86@kernel.org
Cc: iommu@lists.linux-foundation.org
Link: http://lkml.kernel.org/r/20140507154334.741805075@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/iommu/irq_remapping.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
index 228632c9..33c4395 100644
--- a/drivers/iommu/irq_remapping.c
+++ b/drivers/iommu/irq_remapping.c
@@ -51,7 +51,7 @@ static void irq_remapping_disable_io_apic(void)
 
 static int do_setup_msi_irqs(struct pci_dev *dev, int nvec)
 {
-	int node, ret, sub_handle, nvec_pow2, index = 0;
+	int ret, sub_handle, nvec_pow2, index = 0;
 	unsigned int irq;
 	struct msi_desc *msidesc;
 
@@ -61,8 +61,7 @@ static int do_setup_msi_irqs(struct pci_dev *dev, int nvec)
 	WARN_ON(msidesc->msi_attrib.multiple);
 	WARN_ON(msidesc->nvec_used);
 
-	node = dev_to_node(&dev->dev);
-	irq = __create_irqs(get_nr_irqs_gsi(), nvec, node);
+	irq = irq_alloc_hwirqs(nvec, dev_to_node(&dev->dev));
 	if (irq == 0)
 		return -ENOSPC;
 
@@ -89,7 +88,7 @@ static int do_setup_msi_irqs(struct pci_dev *dev, int nvec)
 	return 0;
 
 error:
-	destroy_irqs(irq, nvec);
+	irq_free_hwirqs(irq, nvec);
 
 	/*
 	 * Restore altered MSI descriptor fields and prevent just destroyed
@@ -109,12 +108,11 @@ static int do_setup_msix_irqs(struct pci_dev *dev, int nvec)
 	unsigned int irq;
 
 	node		= dev_to_node(&dev->dev);
-	irq		= get_nr_irqs_gsi();
 	sub_handle	= 0;
 
 	list_for_each_entry(msidesc, &dev->msi_list, list) {
 
-		irq = create_irq_nr(irq, node);
+		irq = irq_alloc_hwirq(node);
 		if (irq == 0)
 			return -1;
 
@@ -137,7 +135,7 @@ static int do_setup_msix_irqs(struct pci_dev *dev, int nvec)
 	return 0;
 
 error:
-	destroy_irq(irq);
+	irq_free_hwirq(irq);
 	return ret;
 }
 

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

* [tip:irq/core] x86: hpet: Use irq_alloc/free_hwirq()
  2014-05-07 15:44 ` [patch 06/32] x86: hpet: Use irq_alloc/free_hwirq() Thomas Gleixner
@ 2014-05-16 13:32   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:32 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, peterz, tony.luck, tglx

Commit-ID:  499c2b75e9c695b57faaf6a63fde391ff9e523a3
Gitweb:     http://git.kernel.org/tip/499c2b75e9c695b57faaf6a63fde391ff9e523a3
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:07 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:18 +0200

x86: hpet: Use irq_alloc/free_hwirq()

Use the new interfaces. No functional change.

This does not replace the requirement to move x86 to irq domains, but
it limits the mess to some degree.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: x86@kernel.org
Link: http://lkml.kernel.org/r/20140507154334.991589924@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/kernel/hpet.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index 4177bfb..5f5a147 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -479,7 +479,7 @@ static int hpet_msi_next_event(unsigned long delta,
 static int hpet_setup_msi_irq(unsigned int irq)
 {
 	if (x86_msi.setup_hpet_msi(irq, hpet_blockid)) {
-		destroy_irq(irq);
+		irq_free_hwirq(irq);
 		return -EINVAL;
 	}
 	return 0;
@@ -487,9 +487,8 @@ static int hpet_setup_msi_irq(unsigned int irq)
 
 static int hpet_assign_irq(struct hpet_dev *dev)
 {
-	unsigned int irq;
+	unsigned int irq = irq_alloc_hwirq(-1);
 
-	irq = create_irq_nr(0, -1);
 	if (!irq)
 		return -EINVAL;
 

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

* [tip:irq/core] x86: uv: Use irq_alloc/free_hwirq()
  2014-05-07 15:44 ` [patch 07/32] x86: uv: Use irq_alloc/free_hwirq() Thomas Gleixner
@ 2014-05-16 13:32   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:32 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, peterz, tony.luck, tglx

Commit-ID:  0a2db49dc4fe2873f857617d320c37b6bfe40255
Gitweb:     http://git.kernel.org/tip/0a2db49dc4fe2873f857617d320c37b6bfe40255
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:08 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:19 +0200

x86: uv: Use irq_alloc/free_hwirq()

No functional change. The request to allocate the irq above
NR_IRQS_LEGACY is completely pointless as the implementation enforces
that the dynamic allocations are above the GSI interrupts, which
includes the legacy PIT irqs.

This does not replace the requirement to move x86 to irq domains, but
it limits the mess to some degree.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: x86@kernel.org
Link: http://lkml.kernel.org/r/20140507154335.252789823@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/platform/uv/uv_irq.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/x86/platform/uv/uv_irq.c b/arch/x86/platform/uv/uv_irq.c
index acf7752..b233681 100644
--- a/arch/x86/platform/uv/uv_irq.c
+++ b/arch/x86/platform/uv/uv_irq.c
@@ -238,11 +238,9 @@ uv_set_irq_affinity(struct irq_data *data, const struct cpumask *mask,
 int uv_setup_irq(char *irq_name, int cpu, int mmr_blade,
 		 unsigned long mmr_offset, int limit)
 {
-	int irq, ret;
+	int ret, irq = irq_alloc_hwirq(uv_blade_to_memory_nid(mmr_blade));
 
-	irq = create_irq_nr(NR_IRQS_LEGACY, uv_blade_to_memory_nid(mmr_blade));
-
-	if (irq <= 0)
+	if (!irq)
 		return -EBUSY;
 
 	ret = arch_enable_uv_irq(irq_name, irq, cpu, mmr_blade, mmr_offset,
@@ -250,7 +248,7 @@ int uv_setup_irq(char *irq_name, int cpu, int mmr_blade,
 	if (ret == irq)
 		uv_set_irq_2_mmr_info(irq, mmr_offset, mmr_blade);
 	else
-		destroy_irq(irq);
+		irq_free_hwirq(irq);
 
 	return ret;
 }
@@ -285,6 +283,6 @@ void uv_teardown_irq(unsigned int irq)
 			n = n->rb_right;
 	}
 	spin_unlock_irqrestore(&uv_irq_lock, irqflags);
-	destroy_irq(irq);
+	irq_free_hwirq(irq);
 }
 EXPORT_SYMBOL_GPL(uv_teardown_irq);

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

* [tip:irq/core] x86: htirq: Use irq_alloc/free_irq()
  2014-05-07 15:44 ` [patch 08/32] x86: htirq: Use irq_alloc/free_irq() Thomas Gleixner
  2014-05-07 16:03   ` Bjorn Helgaas
@ 2014-05-16 13:32   ` tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:32 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, peterz, tony.luck,
	bhelgaas, tglx

Commit-ID:  59b47ddc0b4d7ea8a625512e802832730c1feeb4
Gitweb:     http://git.kernel.org/tip/59b47ddc0b4d7ea8a625512e802832730c1feeb4
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:08 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:19 +0200

x86: htirq: Use irq_alloc/free_irq()

No functional change, just cleaned up a bit.

This does not replace the requirement to move x86 to irq domains, but
it limits the mess to some degree.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: x86@kernel.org
Cc: linux-pci@vger.kernel.org
Link: http://lkml.kernel.org/r/20140507154335.452206351@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/pci/htirq.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/pci/htirq.c b/drivers/pci/htirq.c
index 6e373ea..d68b030 100644
--- a/drivers/pci/htirq.c
+++ b/drivers/pci/htirq.c
@@ -87,12 +87,9 @@ void unmask_ht_irq(struct irq_data *data)
 int __ht_create_irq(struct pci_dev *dev, int idx, ht_irq_update_t *update)
 {
 	struct ht_irq_cfg *cfg;
+	int max_irq, pos, irq;
 	unsigned long flags;
 	u32 data;
-	int max_irq;
-	int pos;
-	int irq;
-	int node;
 
 	pos = pci_find_ht_capability(dev, HT_CAPTYPE_IRQ);
 	if (!pos)
@@ -120,10 +117,8 @@ int __ht_create_irq(struct pci_dev *dev, int idx, ht_irq_update_t *update)
 	cfg->msg.address_lo = 0xffffffff;
 	cfg->msg.address_hi = 0xffffffff;
 
-	node = dev_to_node(&dev->dev);
-	irq = create_irq_nr(0, node);
-
-	if (irq <= 0) {
+	irq = irq_alloc_hwirq(dev_to_node(&dev->dev));
+	if (!irq) {
 		kfree(cfg);
 		return -EBUSY;
 	}
@@ -166,7 +161,7 @@ void ht_destroy_irq(unsigned int irq)
 	cfg = irq_get_handler_data(irq);
 	irq_set_chip(irq, NULL);
 	irq_set_handler_data(irq, NULL);
-	destroy_irq(irq);
+	irq_free_hwirq(irq);
 
 	kfree(cfg);
 }

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

* [tip:irq/core] x86: ioapic: Use irq_alloc/free_hwirq()
  2014-05-07 15:44 ` [patch 09/32] x86: ioapic: " Thomas Gleixner
@ 2014-05-16 13:33   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:33 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, peterz, tony.luck, tglx

Commit-ID:  be47be6c28a83dd8b3c5540d0be3675af1ac7b2e
Gitweb:     http://git.kernel.org/tip/be47be6c28a83dd8b3c5540d0be3675af1ac7b2e
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:09 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:19 +0200

x86: ioapic: Use irq_alloc/free_hwirq()

No functional change just less crap.

This does not replace the requirement to move x86 to irq domains, but
it limits the mess to some degree.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: x86@kernel.org
Link: http://lkml.kernel.org/r/20140507154335.749579081@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/kernel/apic/io_apic.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index b7175c0..3c17b25 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -3169,8 +3169,8 @@ int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc,
 
 int native_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
 {
-	unsigned int irq, irq_want;
 	struct msi_desc *msidesc;
+	unsigned int irq;
 	int node, ret;
 
 	/* Multiple MSI vectors only supported with interrupt remapping */
@@ -3178,28 +3178,25 @@ int native_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
 		return 1;
 
 	node = dev_to_node(&dev->dev);
-	irq_want = nr_irqs_gsi;
+
 	list_for_each_entry(msidesc, &dev->msi_list, list) {
-		irq = create_irq_nr(irq_want, node);
-		if (irq == 0)
+		irq = irq_alloc_hwirq(node);
+		if (!irq)
 			return -ENOSPC;
 
-		irq_want = irq + 1;
-
 		ret = setup_msi_irq(dev, msidesc, irq, 0);
-		if (ret < 0)
-			goto error;
+		if (ret < 0) {
+			irq_free_hwirq(irq);
+			return ret;
+		}
+
 	}
 	return 0;
-
-error:
-	destroy_irq(irq);
-	return ret;
 }
 
 void native_teardown_msi_irq(unsigned int irq)
 {
-	destroy_irq(irq);
+	irq_free_hwirq(irq);
 }
 
 #ifdef CONFIG_DMAR_TABLE

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

* [tip:irq/core] x86: Get rid of get_nr_irqs_gsi()
  2014-05-07 15:44 ` [patch 10/32] x86: Get rid of get_nr_irqs_gsi() Thomas Gleixner
@ 2014-05-16 13:33   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:33 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, konrad.wilk, peterz,
	tony.luck, tglx

Commit-ID:  d07c9f18756e8231909a9bbcbfa7502c60cbc810
Gitweb:     http://git.kernel.org/tip/d07c9f18756e8231909a9bbcbfa7502c60cbc810
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:10 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:19 +0200

x86: Get rid of get_nr_irqs_gsi()

No need to expose this outside of the ioapic code. The dynamic
allocations are guaranteed not to happen in the gsi space. See commit
62a08ae2a.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: x86@kernel.org
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: xen-devel@lists.xenproject.org
Link: http://lkml.kernel.org/r/20140507154335.959870037@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/x86/include/asm/io_apic.h   |  2 --
 arch/x86/kernel/apic/io_apic.c   |  5 -----
 drivers/xen/events/events_base.c | 17 +----------------
 3 files changed, 1 insertion(+), 23 deletions(-)

diff --git a/arch/x86/include/asm/io_apic.h b/arch/x86/include/asm/io_apic.h
index 459e50a..90f97b4 100644
--- a/arch/x86/include/asm/io_apic.h
+++ b/arch/x86/include/asm/io_apic.h
@@ -168,8 +168,6 @@ extern int save_ioapic_entries(void);
 extern void mask_ioapic_entries(void);
 extern int restore_ioapic_entries(void);
 
-extern int get_nr_irqs_gsi(void);
-
 extern void setup_ioapic_ids_from_mpc(void);
 extern void setup_ioapic_ids_from_mpc_nocheck(void);
 
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 3c17b25..be3b574 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -3450,11 +3450,6 @@ static void __init probe_nr_irqs_gsi(void)
 	printk(KERN_DEBUG "nr_irqs_gsi: %d\n", nr_irqs_gsi);
 }
 
-int get_nr_irqs_gsi(void)
-{
-	return nr_irqs_gsi;
-}
-
 unsigned int arch_dynirq_lower_bound(unsigned int from)
 {
 	return from < nr_irqs_gsi ? nr_irqs_gsi : from;
diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index dfa12a4..c919d3d 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -390,22 +390,7 @@ static void xen_irq_init(unsigned irq)
 
 static int __must_check xen_allocate_irqs_dynamic(int nvec)
 {
-	int first = 0;
-	int i, irq;
-
-#ifdef CONFIG_X86_IO_APIC
-	/*
-	 * For an HVM guest or domain 0 which see "real" (emulated or
-	 * actual respectively) GSIs we allocate dynamic IRQs
-	 * e.g. those corresponding to event channels or MSIs
-	 * etc. from the range above those "real" GSIs to avoid
-	 * collisions.
-	 */
-	if (xen_initial_domain() || xen_hvm_domain())
-		first = get_nr_irqs_gsi();
-#endif
-
-	irq = irq_alloc_descs_from(first, nvec, -1);
+	int i, irq = irq_alloc_descs(-1, 0, nvec, -1);
 
 	if (irq >= 0) {
 		for (i = 0; i < nvec; i++)

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

* [tip:irq/core] iommu: smar: Fix return value check of create_irq( )
  2014-05-07 15:44 ` [patch 11/32] iommu: dmar: Fix return value check of create_irq() Thomas Gleixner
@ 2014-05-16 13:33   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:33 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, joro, peterz, tony.luck,
	fenghua.yu, tglx

Commit-ID:  aa5125a45568f8f666f6d2f224fe8ab261b1069e
Gitweb:     http://git.kernel.org/tip/aa5125a45568f8f666f6d2f224fe8ab261b1069e
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:10 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:19 +0200

iommu: smar: Fix return value check of create_irq()

ia64 returns a negative error code when allocation fails andx86
returns 0. Make it handle both.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: x86@kernel.org
Acked-by: Joerg Roedel <joro@8bytes.org>
Cc: linux-ia64@vger.kernel.org
Cc: iommu@lists.linux-foundation.org
Link: http://lkml.kernel.org/r/20140507154336.178850165@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/iommu/dmar.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index 39f8b71..3ce1f62 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -1551,7 +1551,7 @@ int dmar_set_interrupt(struct intel_iommu *iommu)
 		return 0;
 
 	irq = create_irq();
-	if (!irq) {
+	if (irq <= 0) {
 		pr_err("IOMMU: no free vectors\n");
 		return -EINVAL;
 	}

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

* [tip:irq/core] iommu: dmar: Provide arch specific irq allocation
  2014-05-07 15:44 ` [patch 12/32] iommu: dmar: Provide arch specific irq allocation Thomas Gleixner
@ 2014-05-16 13:33   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:33 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, joro, peterz, tony.luck,
	fenghua.yu, tglx

Commit-ID:  a553b142b8effbfcbba24ebbf8c07a1a86d32ce6
Gitweb:     http://git.kernel.org/tip/a553b142b8effbfcbba24ebbf8c07a1a86d32ce6
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:11 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:19 +0200

iommu: dmar: Provide arch specific irq allocation

ia64 and x86 share this driver. x86 is moving to a different irq
allocation and ia64 keeps its private irq_create/destroy stuff.

Use macros to redirect to one or the other. Yes, macros to avoid
include hell.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Acked-by: Joerg Roedel <joro@8bytes.org>
Cc: x86@kernel.org
Cc: linux-ia64@vger.kernel.org
Cc: iommu@lists.linux-foundation.org
Link: http://lkml.kernel.org/r/20140507154336.372289825@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/ia64/include/asm/irq_remapping.h | 2 ++
 arch/x86/include/asm/irq_remapping.h  | 3 +++
 drivers/iommu/dmar.c                  | 6 +++---
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/ia64/include/asm/irq_remapping.h b/arch/ia64/include/asm/irq_remapping.h
index a8687b1..e3b3556 100644
--- a/arch/ia64/include/asm/irq_remapping.h
+++ b/arch/ia64/include/asm/irq_remapping.h
@@ -1,4 +1,6 @@
 #ifndef __IA64_INTR_REMAPPING_H
 #define __IA64_INTR_REMAPPING_H
 #define irq_remapping_enabled 0
+#define dmar_alloc_hwirq	create_irq
+#define dmar_free_hwirq		destroy_irq
 #endif
diff --git a/arch/x86/include/asm/irq_remapping.h b/arch/x86/include/asm/irq_remapping.h
index d806b22..b7747c4 100644
--- a/arch/x86/include/asm/irq_remapping.h
+++ b/arch/x86/include/asm/irq_remapping.h
@@ -103,4 +103,7 @@ static inline bool setup_remapped_irq(int irq,
 }
 #endif /* CONFIG_IRQ_REMAP */
 
+#define dmar_alloc_hwirq()	irq_alloc_hwirq(-1)
+#define dmar_free_hwirq		irq_free_hwirq
+
 #endif /* __X86_IRQ_REMAPPING_H */
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index 3ce1f62..9a4f05e 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -994,7 +994,7 @@ static void free_iommu(struct intel_iommu *iommu)
 	if (iommu->irq) {
 		free_irq(iommu->irq, iommu);
 		irq_set_handler_data(iommu->irq, NULL);
-		destroy_irq(iommu->irq);
+		dmar_free_hwirq(iommu->irq);
 	}
 
 	if (iommu->qi) {
@@ -1550,7 +1550,7 @@ int dmar_set_interrupt(struct intel_iommu *iommu)
 	if (iommu->irq)
 		return 0;
 
-	irq = create_irq();
+	irq = dmar_alloc_hwirq();
 	if (irq <= 0) {
 		pr_err("IOMMU: no free vectors\n");
 		return -EINVAL;
@@ -1563,7 +1563,7 @@ int dmar_set_interrupt(struct intel_iommu *iommu)
 	if (ret) {
 		irq_set_handler_data(irq, NULL);
 		iommu->irq = 0;
-		destroy_irq(irq);
+		dmar_free_hwirq(irq);
 		return ret;
 	}
 

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

* [tip:irq/core] ia64: Remove unused check_irq_used()
  2014-05-07 15:44 ` [patch 13/32] ia64: Remove unused check_irq_used() Thomas Gleixner
@ 2014-05-16 13:33   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:33 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, peterz, tony.luck,
	fenghua.yu, tglx

Commit-ID:  fd5d8abf8bdf9519f40058b5cd24b6ab37b214b4
Gitweb:     http://git.kernel.org/tip/fd5d8abf8bdf9519f40058b5cd24b6ab37b214b4
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:11 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:20 +0200

ia64: Remove unused check_irq_used()

Just stumbled over it when staring into ia64 irq handling.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Tested-by: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Link: http://lkml.kernel.org/r/20140507154336.566531793@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/ia64/include/asm/hw_irq.h | 1 -
 arch/ia64/kernel/irq_ia64.c    | 8 --------
 2 files changed, 9 deletions(-)

diff --git a/arch/ia64/include/asm/hw_irq.h b/arch/ia64/include/asm/hw_irq.h
index a681d02..029bab3 100644
--- a/arch/ia64/include/asm/hw_irq.h
+++ b/arch/ia64/include/asm/hw_irq.h
@@ -132,7 +132,6 @@ extern int reserve_irq_vector (int vector);
 extern void __setup_vector_irq(int cpu);
 extern void ia64_send_ipi (int cpu, int vector, int delivery_mode, int redirect);
 extern void ia64_native_register_percpu_irq (ia64_vector vec, struct irqaction *action);
-extern int check_irq_used (int irq);
 extern void destroy_and_reserve_irq (unsigned int irq);
 
 #if defined(CONFIG_SMP) && (defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_DIG))
diff --git a/arch/ia64/kernel/irq_ia64.c b/arch/ia64/kernel/irq_ia64.c
index 0884f5e..5774c3b 100644
--- a/arch/ia64/kernel/irq_ia64.c
+++ b/arch/ia64/kernel/irq_ia64.c
@@ -93,14 +93,6 @@ static int irq_status[NR_IRQS] = {
 	[0 ... NR_IRQS -1] = IRQ_UNUSED
 };
 
-int check_irq_used(int irq)
-{
-	if (irq_status[irq] == IRQ_USED)
-		return 1;
-
-	return -1;
-}
-
 static inline int find_unassigned_irq(void)
 {
 	int irq;

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

* [tip:irq/core] x86: Remove create/destroy_irq()
  2014-05-07 15:44 ` [patch 14/32] x86: Remove create/dstroy_irq() Thomas Gleixner
@ 2014-05-16 13:34   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:34 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, peterz, tony.luck, tglx

Commit-ID:  54859f59fc18e5c104a4095420b3fcef8bc3ae63
Gitweb:     http://git.kernel.org/tip/54859f59fc18e5c104a4095420b3fcef8bc3ae63
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:12 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:20 +0200

x86: Remove create/destroy_irq()

No more users. Remove the cruft

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: x86@kernel.org
Link: http://lkml.kernel.org/r/20140507154336.760446122@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/kernel/apic/io_apic.c | 106 +----------------------------------------
 include/linux/irq.h            |   4 --
 2 files changed, 1 insertion(+), 109 deletions(-)

diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index be3b574..efda2f6 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -281,18 +281,6 @@ static struct irq_cfg *alloc_irq_and_cfg_at(unsigned int at, int node)
 	return cfg;
 }
 
-static int alloc_irqs_from(unsigned int from, unsigned int count, int node)
-{
-	return irq_alloc_descs_from(from, count, node);
-}
-
-static void free_irq_at(unsigned int at, struct irq_cfg *cfg)
-{
-	free_irq_cfg(at, cfg);
-	irq_free_desc(at);
-}
-
-
 struct io_apic {
 	unsigned int index;
 	unsigned int unused[3];
@@ -2916,100 +2904,8 @@ static int __init ioapic_init_ops(void)
 device_initcall(ioapic_init_ops);
 
 /*
- * Dynamic irq allocate and deallocation
+ * Dynamic irq allocate and deallocation. Should be replaced by irq domains!
  */
-unsigned int __create_irqs(unsigned int from, unsigned int count, int node)
-{
-	struct irq_cfg **cfg;
-	unsigned long flags;
-	int irq, i;
-
-	if (from < nr_irqs_gsi)
-		from = nr_irqs_gsi;
-
-	cfg = kzalloc_node(count * sizeof(cfg[0]), GFP_KERNEL, node);
-	if (!cfg)
-		return 0;
-
-	irq = alloc_irqs_from(from, count, node);
-	if (irq < 0)
-		goto out_cfgs;
-
-	for (i = 0; i < count; i++) {
-		cfg[i] = alloc_irq_cfg(irq + i, node);
-		if (!cfg[i])
-			goto out_irqs;
-	}
-
-	raw_spin_lock_irqsave(&vector_lock, flags);
-	for (i = 0; i < count; i++)
-		if (__assign_irq_vector(irq + i, cfg[i], apic->target_cpus()))
-			goto out_vecs;
-	raw_spin_unlock_irqrestore(&vector_lock, flags);
-
-	for (i = 0; i < count; i++) {
-		irq_set_chip_data(irq + i, cfg[i]);
-		irq_clear_status_flags(irq + i, IRQ_NOREQUEST);
-	}
-
-	kfree(cfg);
-	return irq;
-
-out_vecs:
-	for (i--; i >= 0; i--)
-		__clear_irq_vector(irq + i, cfg[i]);
-	raw_spin_unlock_irqrestore(&vector_lock, flags);
-out_irqs:
-	for (i = 0; i < count; i++)
-		free_irq_at(irq + i, cfg[i]);
-out_cfgs:
-	kfree(cfg);
-	return 0;
-}
-
-unsigned int create_irq_nr(unsigned int from, int node)
-{
-	return __create_irqs(from, 1, node);
-}
-
-int create_irq(void)
-{
-	int node = cpu_to_node(0);
-	unsigned int irq_want;
-	int irq;
-
-	irq_want = nr_irqs_gsi;
-	irq = create_irq_nr(irq_want, node);
-
-	if (irq == 0)
-		irq = -1;
-
-	return irq;
-}
-
-void destroy_irq(unsigned int irq)
-{
-	struct irq_cfg *cfg = irq_get_chip_data(irq);
-	unsigned long flags;
-
-	irq_set_status_flags(irq, IRQ_NOREQUEST|IRQ_NOPROBE);
-
-	free_remapped_irq(irq);
-
-	raw_spin_lock_irqsave(&vector_lock, flags);
-	__clear_irq_vector(irq, cfg);
-	raw_spin_unlock_irqrestore(&vector_lock, flags);
-	free_irq_at(irq, cfg);
-}
-
-void destroy_irqs(unsigned int irq, unsigned int count)
-{
-	unsigned int i;
-
-	for (i = 0; i < count; i++)
-		destroy_irq(irq + i);
-}
-
 int arch_setup_hwirq(unsigned int irq, int node)
 {
 	struct irq_cfg *cfg;
diff --git a/include/linux/irq.h b/include/linux/irq.h
index c75dd16..7549ed5 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -526,12 +526,8 @@ static inline void irq_set_percpu_devid_flags(unsigned int irq)
 }
 
 /* Handle dynamic irq creation and destruction */
-extern unsigned int create_irq_nr(unsigned int irq_want, int node);
-extern unsigned int __create_irqs(unsigned int from, unsigned int count,
-				  int node);
 extern int create_irq(void);
 extern void destroy_irq(unsigned int irq);
-extern void destroy_irqs(unsigned int irq, unsigned int count);
 
 /*
  * Dynamic irq helper functions. Obsolete. Use irq_alloc_desc* and

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

* [tip:irq/core] tile: Implement irq_alloc/free_hwirq() for migration
  2014-05-07 15:44 ` [patch 15/32] tile: Implement irq_alloc/free_hwirq() for migration Thomas Gleixner
  2014-05-14 17:48   ` Chris Metcalf
       [not found]   ` <5373AC00.7090507@tilera.com>
@ 2014-05-16 13:34   ` tip-bot for Thomas Gleixner
  2 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:34 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, peterz, cmetcalf,
	tony.luck, tglx

Commit-ID:  6ef40512c55b18f8fdf1074b2f2d7eadcd50fec7
Gitweb:     http://git.kernel.org/tip/6ef40512c55b18f8fdf1074b2f2d7eadcd50fec7
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:13 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:20 +0200

tile: Implement irq_alloc/free_hwirq() for migration

We want to convert the drivers over to the new interface and finally
tile to sparse irqs. Implement irq_alloc/free_hwirq() for step by step
migration.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Acked-by: Chris Metcalf <cmetcalf@tilera.com>
Link: http://lkml.kernel.org/r/20140507154336.947853241@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/tile/include/asm/irq.h |  3 +++
 arch/tile/kernel/irq.c      | 12 ++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/arch/tile/include/asm/irq.h b/arch/tile/include/asm/irq.h
index 33cff9a..9670a39 100644
--- a/arch/tile/include/asm/irq.h
+++ b/arch/tile/include/asm/irq.h
@@ -76,4 +76,7 @@ void tile_irq_activate(unsigned int irq, int tile_irq_type);
 
 void setup_irq_regs(void);
 
+unsigned int irq_alloc_hwirq(int node);
+void irq_free_hwirq(unsigned int irq);
+
 #endif /* _ASM_TILE_IRQ_H */
diff --git a/arch/tile/kernel/irq.c b/arch/tile/kernel/irq.c
index 906a76b..5fd197e 100644
--- a/arch/tile/kernel/irq.c
+++ b/arch/tile/kernel/irq.c
@@ -312,4 +312,16 @@ void destroy_irq(unsigned int irq)
 	spin_unlock_irqrestore(&available_irqs_lock, flags);
 }
 EXPORT_SYMBOL(destroy_irq);
+
+unsigned int irq_alloc_hwirq(int node)
+{
+	int ret = create_irq();
+	return ret < 0 ? 0 : ret;
+}
+
+void irq_free_hwirq(unsigned int irq)
+{
+	destroy_irq(irq);
+}
+
 #endif

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

* [tip:irq/core] tile: usb: Use irq_alloc/free_hwirq
  2014-05-07 15:44 ` [patch 16/32] tile: usb: Use irq_alloc/free_hwirq Thomas Gleixner
@ 2014-05-16 13:34   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:34 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, peterz, cmetcalf,
	tony.luck, tglx

Commit-ID:  7e5f01b1a1504b2777342628e365c1a0c6600b0e
Gitweb:     http://git.kernel.org/tip/7e5f01b1a1504b2777342628e365c1a0c6600b0e
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:13 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:20 +0200

tile: usb: Use irq_alloc/free_hwirq

No functional change. Just convert to the new interface.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Acked-by: Chris Metcalf <cmetcalf@tilera.com>
Link: http://lkml.kernel.org/r/20140507154337.177939962@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/usb/host/ehci-tilegx.c | 8 ++++----
 drivers/usb/host/ohci-tilegx.c | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/host/ehci-tilegx.c b/drivers/usb/host/ehci-tilegx.c
index f3713d3..0d24767 100644
--- a/drivers/usb/host/ehci-tilegx.c
+++ b/drivers/usb/host/ehci-tilegx.c
@@ -142,8 +142,8 @@ static int ehci_hcd_tilegx_drv_probe(struct platform_device *pdev)
 	ehci->hcs_params = readl(&ehci->caps->hcs_params);
 
 	/* Create our IRQs and register them. */
-	pdata->irq = create_irq();
-	if (pdata->irq < 0) {
+	pdata->irq = irq_alloc_hwirq(-1);
+	if (!pdata->irq) {
 		ret = -ENXIO;
 		goto err_no_irq;
 	}
@@ -175,7 +175,7 @@ static int ehci_hcd_tilegx_drv_probe(struct platform_device *pdev)
 	}
 
 err_have_irq:
-	destroy_irq(pdata->irq);
+	irq_free_hwirq(pdata->irq);
 err_no_irq:
 	tilegx_stop_ehc();
 	usb_put_hcd(hcd);
@@ -193,7 +193,7 @@ static int ehci_hcd_tilegx_drv_remove(struct platform_device *pdev)
 	usb_put_hcd(hcd);
 	tilegx_stop_ehc();
 	gxio_usb_host_destroy(&pdata->usb_ctx);
-	destroy_irq(pdata->irq);
+	irq_free_hwirq(pdata->irq);
 
 	return 0;
 }
diff --git a/drivers/usb/host/ohci-tilegx.c b/drivers/usb/host/ohci-tilegx.c
index 0b183e0..bef6dfb 100644
--- a/drivers/usb/host/ohci-tilegx.c
+++ b/drivers/usb/host/ohci-tilegx.c
@@ -129,8 +129,8 @@ static int ohci_hcd_tilegx_drv_probe(struct platform_device *pdev)
 	tilegx_start_ohc();
 
 	/* Create our IRQs and register them. */
-	pdata->irq = create_irq();
-	if (pdata->irq < 0) {
+	pdata->irq = irq_alloc_hwirq(-1);
+	if (!pdata->irq) {
 		ret = -ENXIO;
 		goto err_no_irq;
 	}
@@ -164,7 +164,7 @@ static int ohci_hcd_tilegx_drv_probe(struct platform_device *pdev)
 	}
 
 err_have_irq:
-	destroy_irq(pdata->irq);
+	irq_free_hwirq(pdata->irq);
 err_no_irq:
 	tilegx_stop_ohc();
 	usb_put_hcd(hcd);
@@ -182,7 +182,7 @@ static int ohci_hcd_tilegx_drv_remove(struct platform_device *pdev)
 	usb_put_hcd(hcd);
 	tilegx_stop_ohc();
 	gxio_usb_host_destroy(&pdata->usb_ctx);
-	destroy_irq(pdata->irq);
+	irq_free_hwirq(pdata->irq);
 
 	return 0;
 }

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

* [tip:irq/core] tile: net: Use irq_alloc/free_hwirq
  2014-05-07 15:44 ` [patch 17/32] tile: net: Use irq_alloc/free_hwirq Thomas Gleixner
@ 2014-05-16 13:34   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:34 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, peterz, cmetcalf,
	tony.luck, tglx

Commit-ID:  094e873c2a0bd54ced4e98f1f6f612b1fc60f426
Gitweb:     http://git.kernel.org/tip/094e873c2a0bd54ced4e98f1f6f612b1fc60f426
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:14 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:20 +0200

tile: net: Use irq_alloc/free_hwirq

No functional change. Just convert to the new interface.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Acked-by: Chris Metcalf <cmetcalf@tilera.com>
Link: http://lkml.kernel.org/r/20140507154337.410843062@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/net/ethernet/tile/tilegx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/tile/tilegx.c b/drivers/net/ethernet/tile/tilegx.c
index 7e1c91d..449011b 100644
--- a/drivers/net/ethernet/tile/tilegx.c
+++ b/drivers/net/ethernet/tile/tilegx.c
@@ -1208,8 +1208,8 @@ static int tile_net_setup_interrupts(struct net_device *dev)
 
 	irq = md->ingress_irq;
 	if (irq < 0) {
-		irq = create_irq();
-		if (irq < 0) {
+		irq = irq_alloc_hwirq(-1);
+		if (!irq) {
 			netdev_err(dev,
 				   "create_irq failed: mpipe[%d] %d\n",
 				   instance, irq);
@@ -1223,7 +1223,7 @@ static int tile_net_setup_interrupts(struct net_device *dev)
 		if (rc != 0) {
 			netdev_err(dev, "request_irq failed: mpipe[%d] %d\n",
 				   instance, rc);
-			destroy_irq(irq);
+			irq_free_hwirq(irq);
 			return rc;
 		}
 		md->ingress_irq = irq;

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

* [tip:irq/core] tile: serial: Use irq_alloc/free_hwirq
  2014-05-07 15:44 ` [patch 18/32] tile: serial: " Thomas Gleixner
@ 2014-05-16 13:34   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:34 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, peterz, cmetcalf,
	tony.luck, tglx

Commit-ID:  651fb13943304be2008b43adf813fa62435423d7
Gitweb:     http://git.kernel.org/tip/651fb13943304be2008b43adf813fa62435423d7
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:15 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:20 +0200

tile: serial: Use irq_alloc/free_hwirq

No functional change. Just convert to the new interface.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Acked-by: Chris Metcalf <cmetcalf@tilera.com>
Link: http://lkml.kernel.org/r/20140507154337.643399187@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/tty/serial/tilegx.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/tilegx.c b/drivers/tty/serial/tilegx.c
index f92d7e6..613ccf0 100644
--- a/drivers/tty/serial/tilegx.c
+++ b/drivers/tty/serial/tilegx.c
@@ -359,8 +359,8 @@ static int tilegx_startup(struct uart_port *port)
 		}
 
 		/* Create our IRQs. */
-		port->irq = create_irq();
-		if (port->irq < 0)
+		port->irq = irq_alloc_hwirq(-1);
+		if (!port->irq)
 			goto err_uart_dest;
 		tile_irq_activate(port->irq, TILE_IRQ_PERCPU);
 
@@ -395,7 +395,7 @@ static int tilegx_startup(struct uart_port *port)
 err_free_irq:
 	free_irq(port->irq, port);
 err_dest_irq:
-	destroy_irq(port->irq);
+	irq_free_hwirq(port->irq);
 err_uart_dest:
 	gxio_uart_destroy(context);
 	ret = -ENXIO;
@@ -435,7 +435,7 @@ static void tilegx_shutdown(struct uart_port *port)
 
 	if (port->irq > 0) {
 		free_irq(port->irq, port);
-		destroy_irq(port->irq);
+		irq_free_hwirq(port->irq);
 		port->irq = 0;
 	}
 

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

* [tip:irq/core] tile: hvc: Use irq_alloc/free_hwirq
  2014-05-07 15:44 ` [patch 19/32] tile: hvc: " Thomas Gleixner
@ 2014-05-16 13:35   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:35 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, peterz, cmetcalf,
	tony.luck, tglx

Commit-ID:  3dfd442e5ffc6c488e34b6f1028bbb0ce310e6c4
Gitweb:     http://git.kernel.org/tip/3dfd442e5ffc6c488e34b6f1028bbb0ce310e6c4
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:15 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:20 +0200

tile: hvc: Use irq_alloc/free_hwirq

No functional change. Just convert to the new interface.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Acked-by: Chris Metcalf <cmetcalf@tilera.com>
Link: http://lkml.kernel.org/r/20140507154337.873477334@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/tty/hvc/hvc_tile.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/hvc/hvc_tile.c b/drivers/tty/hvc/hvc_tile.c
index af8cdaa..147d49e 100644
--- a/drivers/tty/hvc/hvc_tile.c
+++ b/drivers/tty/hvc/hvc_tile.c
@@ -133,14 +133,14 @@ static int hvc_tile_probe(struct platform_device *pdev)
 	int tile_hvc_irq;
 
 	/* Create our IRQ and register it. */
-	tile_hvc_irq = create_irq();
-	if (tile_hvc_irq < 0)
+	tile_hvc_irq = irq_alloc_hwirq(-1);
+	if (!tile_hvc_irq)
 		return -ENXIO;
 
 	tile_irq_activate(tile_hvc_irq, TILE_IRQ_PERCPU);
 	hp = hvc_alloc(0, tile_hvc_irq, &hvc_tile_get_put_ops, 128);
 	if (IS_ERR(hp)) {
-		destroy_irq(tile_hvc_irq);
+		irq_free_hwirq(tile_hvc_irq);
 		return PTR_ERR(hp);
 	}
 	dev_set_drvdata(&pdev->dev, hp);
@@ -155,7 +155,7 @@ static int hvc_tile_remove(struct platform_device *pdev)
 
 	rc = hvc_remove(hp);
 	if (rc == 0)
-		destroy_irq(hp->data);
+		irq_free_hwirq(hp->data);
 
 	return rc;
 }

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

* [tip:irq/core] tile: pci: Use irq_alloc/free_hwirq()
  2014-05-07 15:44 ` [patch 20/32] tile: pci: Use irq_alloc/free_hwirq() Thomas Gleixner
@ 2014-05-16 13:35   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:35 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, peterz, cmetcalf,
	tony.luck, tglx

Commit-ID:  2aa799d891299457e4107d33f07a1ed5ac8849ae
Gitweb:     http://git.kernel.org/tip/2aa799d891299457e4107d33f07a1ed5ac8849ae
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:16 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:21 +0200

tile: pci: Use irq_alloc/free_hwirq()

No functional change. Just convert to the new interface.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Acked-by: Chris Metcalf <cmetcalf@tilera.com>
Link: http://lkml.kernel.org/r/20140507154338.132662495@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/tile/kernel/pci_gx.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
index 077b7bc..e39f9c5 100644
--- a/arch/tile/kernel/pci_gx.c
+++ b/arch/tile/kernel/pci_gx.c
@@ -350,10 +350,9 @@ static int tile_init_irqs(struct pci_controller *controller)
 		int cpu;
 
 		/* Ask the kernel to allocate an IRQ. */
-		irq = create_irq();
-		if (irq < 0) {
+		irq = irq_alloc_hwirq(-1);
+		if (!irq) {
 			pr_err("PCI: no free irq vectors, failed for %d\n", i);
-
 			goto free_irqs;
 		}
 		controller->irq_intx_table[i] = irq;
@@ -382,7 +381,7 @@ static int tile_init_irqs(struct pci_controller *controller)
 
 free_irqs:
 	for (j = 0; j < i; j++)
-		destroy_irq(controller->irq_intx_table[j]);
+		irq_free_hwirq(controller->irq_intx_table[j]);
 
 	return -1;
 }
@@ -1500,9 +1499,9 @@ int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
 	int irq;
 	int ret;
 
-	irq = create_irq();
-	if (irq < 0)
-		return irq;
+	irq = irq_alloc_hwirq(-1);
+	if (!irq)
+		return -ENOSPC;
 
 	/*
 	 * Since we use a 64-bit Mem-Map to accept the MSI write, we fail
@@ -1601,11 +1600,11 @@ hv_msi_config_failure:
 	/* Free mem-map */
 msi_mem_map_alloc_failure:
 is_64_failure:
-	destroy_irq(irq);
+	irq_free_hwirq(irq);
 	return ret;
 }
 
 void arch_teardown_msi_irq(unsigned int irq)
 {
-	destroy_irq(irq);
+	irq_free_hwirq(irq);
 }

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

* [tip:irq/core] tile: Use SPARSE_IRQ
  2014-05-07 15:44 ` [patch 21/32] tile: Use SPARSE_IRQ Thomas Gleixner
@ 2014-05-16 13:35   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:35 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, peterz, cmetcalf,
	tony.luck, tglx

Commit-ID:  b26d851ff1928b56242c4c5e16cb62bac2d9526c
Gitweb:     http://git.kernel.org/tip/b26d851ff1928b56242c4c5e16cb62bac2d9526c
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:16 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:21 +0200

tile: Use SPARSE_IRQ

Get rid of the private allocator and switch over to sparse IRQs.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Acked-by: Chris Metcalf <cmetcalf@tilera.com>
Link: http://lkml.kernel.org/r/20140507154338.423715783@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/tile/Kconfig           |  2 ++
 arch/tile/include/asm/irq.h |  9 ++++----
 arch/tile/kernel/irq.c      | 52 +++------------------------------------------
 3 files changed, 9 insertions(+), 54 deletions(-)

diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
index 85258ca..4f3006b 100644
--- a/arch/tile/Kconfig
+++ b/arch/tile/Kconfig
@@ -125,6 +125,8 @@ config HVC_TILE
 
 config TILEGX
 	bool "Building for TILE-Gx (64-bit) processor"
+	select SPARSE_IRQ
+	select GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
 	select HAVE_FUNCTION_TRACER
 	select HAVE_FUNCTION_TRACE_MCOUNT_TEST
 	select HAVE_FUNCTION_GRAPH_TRACER
diff --git a/arch/tile/include/asm/irq.h b/arch/tile/include/asm/irq.h
index 9670a39..1fe8691 100644
--- a/arch/tile/include/asm/irq.h
+++ b/arch/tile/include/asm/irq.h
@@ -18,10 +18,12 @@
 #include <linux/hardirq.h>
 
 /* The hypervisor interface provides 32 IRQs. */
-#define NR_IRQS 32
+#define NR_IRQS			32
 
 /* IRQ numbers used for linux IPIs. */
-#define IRQ_RESCHEDULE 0
+#define IRQ_RESCHEDULE	0
+/* Interrupts for dynamic allocation start at 1. Let the core allocate irq0 */
+#define NR_IRQS_LEGACY	1
 
 #define irq_canonicalize(irq)   (irq)
 
@@ -76,7 +78,4 @@ void tile_irq_activate(unsigned int irq, int tile_irq_type);
 
 void setup_irq_regs(void);
 
-unsigned int irq_alloc_hwirq(int node);
-void irq_free_hwirq(unsigned int irq);
-
 #endif /* _ASM_TILE_IRQ_H */
diff --git a/arch/tile/kernel/irq.c b/arch/tile/kernel/irq.c
index 5fd197e..637f2ff 100644
--- a/arch/tile/kernel/irq.c
+++ b/arch/tile/kernel/irq.c
@@ -54,13 +54,6 @@ static DEFINE_PER_CPU(unsigned long, irq_disable_mask)
  */
 static DEFINE_PER_CPU(int, irq_depth);
 
-/* State for allocating IRQs on Gx. */
-#if CHIP_HAS_IPI()
-static unsigned long available_irqs = ((1UL << NR_IRQS) - 1) &
-				      (~(1UL << IRQ_RESCHEDULE));
-static DEFINE_SPINLOCK(available_irqs_lock);
-#endif
-
 #if CHIP_HAS_IPI()
 /* Use SPRs to manipulate device interrupts. */
 #define mask_irqs(irq_mask) __insn_mtspr(SPR_IPI_MASK_SET_K, irq_mask)
@@ -278,50 +271,11 @@ int arch_show_interrupts(struct seq_file *p, int prec)
 	return 0;
 }
 
-/*
- * Generic, controller-independent functions:
- */
-
 #if CHIP_HAS_IPI()
-int create_irq(void)
-{
-	unsigned long flags;
-	int result;
-
-	spin_lock_irqsave(&available_irqs_lock, flags);
-	if (available_irqs == 0)
-		result = -ENOMEM;
-	else {
-		result = __ffs(available_irqs);
-		available_irqs &= ~(1UL << result);
-		dynamic_irq_init(result);
-	}
-	spin_unlock_irqrestore(&available_irqs_lock, flags);
-
-	return result;
-}
-EXPORT_SYMBOL(create_irq);
-
-void destroy_irq(unsigned int irq)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&available_irqs_lock, flags);
-	available_irqs |= (1UL << irq);
-	dynamic_irq_cleanup(irq);
-	spin_unlock_irqrestore(&available_irqs_lock, flags);
-}
-EXPORT_SYMBOL(destroy_irq);
-
-unsigned int irq_alloc_hwirq(int node)
-{
-	int ret = create_irq();
-	return ret < 0 ? 0 : ret;
-}
-
-void irq_free_hwirq(unsigned int irq)
+int arch_setup_hwirq(unsigned int irq, int node)
 {
-	destroy_irq(irq);
+	return irq >= NR_IRQS ? -EINVAL : 0;
 }
 
+void arch_teardown_hwirq(unsigned int irq) { }
 #endif

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

* [tip:irq/core] genirq: Make create/destroy_irq() ia64 private
  2014-05-07 15:44 ` [patch 22/32] genirq: Make create/destroy_irq() ia64 private Thomas Gleixner
@ 2014-05-16 13:35   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:35 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, peterz, tony.luck,
	fenghua.yu, tglx

Commit-ID:  e8784e4f9a578344023ae4e08a509b7c5eab5eb0
Gitweb:     http://git.kernel.org/tip/e8784e4f9a578344023ae4e08a509b7c5eab5eb0
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:17 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:21 +0200

genirq: Make create/destroy_irq() ia64 private

No more users outside of itanic. Confine it.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Tested-by: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Link: http://lkml.kernel.org/r/20140507154338.700598389@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/ia64/include/asm/irq.h | 3 +++
 include/linux/irq.h         | 4 ----
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/ia64/include/asm/irq.h b/arch/ia64/include/asm/irq.h
index 91b920fd..820667c 100644
--- a/arch/ia64/include/asm/irq.h
+++ b/arch/ia64/include/asm/irq.h
@@ -31,4 +31,7 @@ bool is_affinity_mask_valid(const struct cpumask *cpumask);
 
 #define is_affinity_mask_valid is_affinity_mask_valid
 
+int create_irq(void);
+void destroy_irq(unsigned int irq);
+
 #endif /* _ASM_IA64_IRQ_H */
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 7549ed5..ac96342 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -525,10 +525,6 @@ static inline void irq_set_percpu_devid_flags(unsigned int irq)
 			     IRQ_NOPROBE | IRQ_PER_CPU_DEVID);
 }
 
-/* Handle dynamic irq creation and destruction */
-extern int create_irq(void);
-extern void destroy_irq(unsigned int irq);
-
 /*
  * Dynamic irq helper functions. Obsolete. Use irq_alloc_desc* and
  * irq_free_desc instead.

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

* [tip:irq/core] x86, irq: Remove pointless irq_reserve_irqs() call
  2014-05-07 15:44 ` [patch 23/32] x86, irq: Remove pointless irq_reserve_irqs() call Thomas Gleixner
@ 2014-05-16 13:36   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:36 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, peterz, tony.luck, tglx

Commit-ID:  18a67d32c31b88679467e93e1825010d245b9bf4
Gitweb:     http://git.kernel.org/tip/18a67d32c31b88679467e93e1825010d245b9bf4
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:18 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:21 +0200

x86, irq: Remove pointless irq_reserve_irqs() call

That's a leftover from the time where x86 supported SPARSE_IRQ=n.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: x86@kernel.org
Link: http://lkml.kernel.org/r/20140507154338.967285614@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/kernel/apic/io_apic.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index efda2f6..9d0a979 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -206,9 +206,6 @@ int __init arch_early_irq_init(void)
 	count = ARRAY_SIZE(irq_cfgx);
 	node = cpu_to_node(0);
 
-	/* Make sure the legacy interrupts are marked in the bitmap */
-	irq_reserve_irqs(0, legacy_pic->nr_legacy_irqs);
-
 	for (i = 0; i < count; i++) {
 		irq_set_chip_data(i, &cfg[i]);
 		zalloc_cpumask_var_node(&cfg[i].domain, GFP_KERNEL, node);

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

* [tip:irq/core] sh: intc: Remove pointless irq_reserve_irqs() invocation
  2014-05-07 15:44 ` [patch 24/32] sh: intc: Remove pointless irq_reserve_irqs() invocation Thomas Gleixner
  2014-05-11  0:53   ` Simon Horman
@ 2014-05-16 13:36   ` tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:36 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, horms, grant.likely, hpa, mingo, peterz, tony.luck, tglx

Commit-ID:  3670802223e164f1089287d1c223d34d3c5dc3da
Gitweb:     http://git.kernel.org/tip/3670802223e164f1089287d1c223d34d3c5dc3da
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:18 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:21 +0200

sh: intc: Remove pointless irq_reserve_irqs() invocation

The preceding call to irq_create_identity_mapping() marks the
interrupt as allocated already. Remove the leftover.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Acked-by: Simon Horman <horms@verge.net.au>
Cc: linux-sh@vger.kernel.org
Link: http://lkml.kernel.org/r/20140507154339.189047829@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/sh/intc/core.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/sh/intc/core.c b/drivers/sh/intc/core.c
index 8f32a13..81f2298 100644
--- a/drivers/sh/intc/core.c
+++ b/drivers/sh/intc/core.c
@@ -80,12 +80,6 @@ static void __init intc_register_irq(struct intc_desc *desc,
 	unsigned int data[2], primary;
 	unsigned long flags;
 
-	/*
-	 * Register the IRQ position with the global IRQ map, then insert
-	 * it in to the radix tree.
-	 */
-	irq_reserve_irq(irq);
-
 	raw_spin_lock_irqsave(&intc_big_lock, flags);
 	radix_tree_insert(&d->tree, enum_id, intc_irq_xlate_get(irq));
 	raw_spin_unlock_irqrestore(&intc_big_lock, flags);

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

* [tip:irq/core] s390: pci: Check return value of alloc_irq_desc() proper
  2014-05-07 15:44 ` [patch 25/32] s390: pci: Check return value of alloc_irq_desc() proper Thomas Gleixner
@ 2014-05-16 13:36   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:36 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, schwidefsky, peterz,
	tony.luck, heiko.carstens, tglx

Commit-ID:  0a0a94219074d79370b1cd1b533ead63d51c3730
Gitweb:     http://git.kernel.org/tip/0a0a94219074d79370b1cd1b533ead63d51c3730
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:19 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:21 +0200

s390: pci: Check return value of alloc_irq_desc() proper

alloc_irq_desc() returns an integer and as documented either a valid
irq number or a negative error code. Checking for NO_IRQ is definitely
not the proper error handling.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux390@de.ibm.com
Link: http://lkml.kernel.org/r/20140507154339.409085048@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/s390/pci/pci.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 1df1d29..2c0076d4 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -401,11 +401,11 @@ static void zpci_irq_handler(struct airq_struct *airq)
 int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
 {
 	struct zpci_dev *zdev = get_zdev(pdev);
-	unsigned int hwirq, irq, msi_vecs;
+	unsigned int hwirq, msi_vecs;
 	unsigned long aisb;
 	struct msi_desc *msi;
 	struct msi_msg msg;
-	int rc;
+	int rc, irq;
 
 	if (type == PCI_CAP_ID_MSI && nvec > 1)
 		return 1;
@@ -433,7 +433,7 @@ int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
 	list_for_each_entry(msi, &pdev->msi_list, list) {
 		rc = -EIO;
 		irq = irq_alloc_desc(0);	/* Alloc irq on node 0 */
-		if (irq == NO_IRQ)
+		if (irq < 0)
 			goto out_msi;
 		rc = irq_set_msi_desc(irq, msi);
 		if (rc)

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

* [tip:irq/core] s390: Remove pointless arch_show_interrupts()
  2014-05-07 15:44 ` [patch 26/32] s390: Remove pointless arch_show_interrupts() Thomas Gleixner
@ 2014-05-16 13:36   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:36 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, schwidefsky, peterz,
	tony.luck, heiko.carstens, tglx

Commit-ID:  5fdaf1bf8a60f73a11cb4431fd06daa2b295a327
Gitweb:     http://git.kernel.org/tip/5fdaf1bf8a60f73a11cb4431fd06daa2b295a327
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:19 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:22 +0200

s390: Remove pointless arch_show_interrupts()

S390 is not using the generic show interrupts implementation so the
extra arch_show_interrupts() is just useless.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux390@de.ibm.com
Link: http://lkml.kernel.org/r/20140507154339.609149081@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/s390/kernel/irq.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/arch/s390/kernel/irq.c b/arch/s390/kernel/irq.c
index c7463aa..2fb0998 100644
--- a/arch/s390/kernel/irq.c
+++ b/arch/s390/kernel/irq.c
@@ -151,11 +151,6 @@ out:
 	return 0;
 }
 
-int arch_show_interrupts(struct seq_file *p, int prec)
-{
-	return 0;
-}
-
 /*
  * Switch to the asynchronous interrupt stack for softirq execution.
  */

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

* [tip:irq/core] s390: Avoid call to irq_reserve_irqs()
  2014-05-07 15:44 ` [patch 27/32] s390: Avoid call to irq_reserve_irqs() Thomas Gleixner
@ 2014-05-16 13:36   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:36 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, schwidefsky, peterz,
	tony.luck, heiko.carstens, tglx

Commit-ID:  be4034016c11f8913d38fccf692007fab1c50be1
Gitweb:     http://git.kernel.org/tip/be4034016c11f8913d38fccf692007fab1c50be1
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:20 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:22 +0200

s390: Avoid call to irq_reserve_irqs()

There is no need to mark the lower interrupts as reserved in order to
exclude them from dynamic allocation.

Provide arch_dynirq_lower_bound() to exclude the lower space.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux390@de.ibm.com
Link: http://lkml.kernel.org/r/20140507154339.811205235@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/s390/kernel/irq.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/s390/kernel/irq.c b/arch/s390/kernel/irq.c
index 2fb0998..99b0b09 100644
--- a/arch/s390/kernel/irq.c
+++ b/arch/s390/kernel/irq.c
@@ -92,7 +92,6 @@ static const struct irq_class irqclass_sub_desc[NR_ARCH_IRQS] = {
 
 void __init init_IRQ(void)
 {
-	irq_reserve_irqs(0, THIN_INTERRUPT);
 	init_cio_interrupts();
 	init_airq_interrupts();
 	init_ext_interrupts();
@@ -151,6 +150,11 @@ out:
 	return 0;
 }
 
+unsigned int arch_dynirq_lower_bound(unsigned int from)
+{
+	return from < THIN_INTERRUPT ? THIN_INTERRUPT : from;
+}
+
 /*
  * Switch to the asynchronous interrupt stack for softirq execution.
  */

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

* [tip:irq/core] genirq: Replace reserve_irqs in core code
  2014-05-07 15:44 ` [patch 28/32] genirq: Replace reserve_irqs in core code Thomas Gleixner
@ 2014-05-16 13:37   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:37 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, peterz, tony.luck, tglx

Commit-ID:  f63b6a05f2b11537612266a8b27a61f412344a1d
Gitweb:     http://git.kernel.org/tip/f63b6a05f2b11537612266a8b27a61f412344a1d
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:21 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:22 +0200

genirq: Replace reserve_irqs in core code

We want to get rid of the public interface.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Tested-by: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20140507154340.061990194@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/irq/chip.c      | 5 ++---
 kernel/irq/internals.h | 6 ++++++
 kernel/irq/irqdesc.c   | 7 +++++++
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index 6397df2..a2b28a2 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -40,10 +40,9 @@ int irq_set_chip(unsigned int irq, struct irq_chip *chip)
 	irq_put_desc_unlock(desc, flags);
 	/*
 	 * For !CONFIG_SPARSE_IRQ make the irq show up in
-	 * allocated_irqs. For the CONFIG_SPARSE_IRQ case, it is
-	 * already marked, and this call is harmless.
+	 * allocated_irqs.
 	 */
-	irq_reserve_irq(irq);
+	irq_mark_irq(irq);
 	return 0;
 }
 EXPORT_SYMBOL(irq_set_chip);
diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h
index ddf1ffe..c4065e3 100644
--- a/kernel/irq/internals.h
+++ b/kernel/irq/internals.h
@@ -76,6 +76,12 @@ extern void mask_irq(struct irq_desc *desc);
 extern void unmask_irq(struct irq_desc *desc);
 extern void unmask_threaded_irq(struct irq_desc *desc);
 
+#ifdef CONFIG_SPARSE_IRQ
+static inline void irq_mark_irq(unsigned int irq) { }
+#else
+extern void irq_mark_irq(unsigned int irq);
+#endif
+
 extern void init_kstat_irqs(struct irq_desc *desc, int node, int nr);
 
 irqreturn_t handle_irq_event_percpu(struct irq_desc *desc, struct irqaction *action);
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index f388ade..2402934 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -299,6 +299,13 @@ static int irq_expand_nr_irqs(unsigned int nr)
 	return -ENOMEM;
 }
 
+void irq_mark_irq(unsigned int irq)
+{
+	mutex_lock(&sparse_irq_lock);
+	bitmap_set(allocated_irqs, irq, 1);
+	mutex_unlock(&sparse_irq_lock);
+}
+
 #endif /* !CONFIG_SPARSE_IRQ */
 
 /**

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

* [tip:irq/core] genirq: Remove irq_reserve_irq[s]
  2014-05-07 15:44 ` [patch 29/32] genirq: Remove irq_reserve_irq[s] Thomas Gleixner
  2014-05-08 12:14   ` Grant Likely
@ 2014-05-16 13:37   ` tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:37 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, peterz, tony.luck, tglx

Commit-ID:  1d008353ba088fdec0b2a944e140ff9154a5fb20
Gitweb:     http://git.kernel.org/tip/1d008353ba088fdec0b2a944e140ff9154a5fb20
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:21 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:22 +0200

genirq: Remove irq_reserve_irq[s]

No more users. And it's not going to come back. If you need
hotplugable irq chips, use irq domains.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-and-acked-by: Grant Likely <grant.likely@linaro.org>
Tested-by: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20140507154340.302183048@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/irq.h  |  7 -------
 kernel/irq/irqdesc.c | 25 -------------------------
 2 files changed, 32 deletions(-)

diff --git a/include/linux/irq.h b/include/linux/irq.h
index ac96342..2110f46 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -617,18 +617,11 @@ int __irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node,
 	irq_alloc_descs(-1, from, cnt, node)
 
 void irq_free_descs(unsigned int irq, unsigned int cnt);
-int irq_reserve_irqs(unsigned int from, unsigned int cnt);
-
 static inline void irq_free_desc(unsigned int irq)
 {
 	irq_free_descs(irq, 1);
 }
 
-static inline int irq_reserve_irq(unsigned int irq)
-{
-	return irq_reserve_irqs(irq, 1);
-}
-
 #ifdef CONFIG_GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
 unsigned int irq_alloc_hwirqs(int cnt, int node);
 static inline unsigned int irq_alloc_hwirq(int node)
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 2402934..d514ed6 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -455,31 +455,6 @@ EXPORT_SYMBOL_GPL(irq_free_hwirqs);
 #endif
 
 /**
- * irq_reserve_irqs - mark irqs allocated
- * @from:	mark from irq number
- * @cnt:	number of irqs to mark
- *
- * Returns 0 on success or an appropriate error code
- */
-int irq_reserve_irqs(unsigned int from, unsigned int cnt)
-{
-	unsigned int start;
-	int ret = 0;
-
-	if (!cnt || (from + cnt) > nr_irqs)
-		return -EINVAL;
-
-	mutex_lock(&sparse_irq_lock);
-	start = bitmap_find_next_zero_area(allocated_irqs, nr_irqs, from, cnt, 0);
-	if (start == from)
-		bitmap_set(allocated_irqs, start, cnt);
-	else
-		ret = -EEXIST;
-	mutex_unlock(&sparse_irq_lock);
-	return ret;
-}
-
-/**
  * irq_get_next_irq - get next allocated irq number
  * @offset:	where to start the search
  *

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

* [tip:irq/core] genirq: Replace dynamic_irq_init/cleanup
  2014-05-07 15:44 ` [patch 30/32] genirq: Replace dynamic_irq_init/cleanup Thomas Gleixner
@ 2014-05-16 13:37   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:37 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, peterz, tony.luck, tglx

Commit-ID:  c940e01c94e73a2a5318f1b82038e0746aaec753
Gitweb:     http://git.kernel.org/tip/c940e01c94e73a2a5318f1b82038e0746aaec753
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:22 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:22 +0200

genirq: Replace dynamic_irq_init/cleanup

Create a new interface and confine it with a config switch which makes
clear that this is just legacy support and not to be used for new code.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Tested-by: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20140507154340.574437049@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/irq.h  | 4 ++++
 kernel/irq/Kconfig   | 4 ++++
 kernel/irq/irqdesc.c | 7 +++++++
 3 files changed, 15 insertions(+)

diff --git a/include/linux/irq.h b/include/linux/irq.h
index 2110f46..8ff71d1 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -637,6 +637,10 @@ int arch_setup_hwirq(unsigned int irq, int node);
 void arch_teardown_hwirq(unsigned int irq);
 #endif
 
+#ifdef CONFIG_GENERIC_IRQ_LEGACY
+void irq_init_desc(unsigned int irq);
+#endif
+
 #ifndef irq_reg_writel
 # define irq_reg_writel(val, addr)	writel(val, addr)
 #endif
diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig
index a83f10e..d269cec 100644
--- a/kernel/irq/Kconfig
+++ b/kernel/irq/Kconfig
@@ -5,6 +5,10 @@ menu "IRQ subsystem"
 config MAY_HAVE_SPARSE_IRQ
        bool
 
+# Legacy support, required for itanic
+config GENERIC_IRQ_LEGACY
+       bool
+
 # Enable the generic irq autoprobe mechanism
 config GENERIC_IRQ_PROBE
 	bool
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index d514ed6..7f26779 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -306,6 +306,13 @@ void irq_mark_irq(unsigned int irq)
 	mutex_unlock(&sparse_irq_lock);
 }
 
+#ifdef CONFIG_GENERIC_IRQ_LEGACY
+void irq_init_desc(unsigned int irq)
+{
+	dynamic_irq_cleanup(irq);
+}
+#endif
+
 #endif /* !CONFIG_SPARSE_IRQ */
 
 /**

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

* [tip:irq/core] ia64: Use irq_init_desc
  2014-05-07 15:44 ` [patch 31/32] ia64: Use irq_init_desc Thomas Gleixner
  2014-05-07 20:06   ` Luck, Tony
@ 2014-05-16 13:37   ` tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:37 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, peterz, tony.luck,
	fenghua.yu, tglx

Commit-ID:  4debd723f4934910ad1df279d80da16827f9b583
Gitweb:     http://git.kernel.org/tip/4debd723f4934910ad1df279d80da16827f9b583
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:22 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:22 +0200

ia64: Use irq_init_desc

Switch over to the new interface. No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Tested-by: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Link: http://lkml.kernel.org/r/20140507154340.782586778@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/ia64/Kconfig           | 1 +
 arch/ia64/kernel/iosapic.c  | 2 +-
 arch/ia64/kernel/irq_ia64.c | 7 +++----
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 12c3afe..2f3abcf 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -32,6 +32,7 @@ config IA64
 	select GENERIC_IRQ_PROBE
 	select GENERIC_PENDING_IRQ if SMP
 	select GENERIC_IRQ_SHOW
+	select GENERIC_IRQ_LEGACY
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	select GENERIC_IOMAP
diff --git a/arch/ia64/kernel/iosapic.c b/arch/ia64/kernel/iosapic.c
index 19f107b..cd44a57 100644
--- a/arch/ia64/kernel/iosapic.c
+++ b/arch/ia64/kernel/iosapic.c
@@ -735,7 +735,7 @@ iosapic_register_intr (unsigned int gsi,
 		rte = find_rte(irq, gsi);
 		if(iosapic_intr_info[irq].count == 0) {
 			assign_irq_vector(irq);
-			dynamic_irq_init(irq);
+			irq_init_desc(irq);
 		} else if (rte->refcnt != NO_REF_RTE) {
 			rte->refcnt++;
 			goto unlock_iosapic_lock;
diff --git a/arch/ia64/kernel/irq_ia64.c b/arch/ia64/kernel/irq_ia64.c
index 5774c3b..03ea78e 100644
--- a/arch/ia64/kernel/irq_ia64.c
+++ b/arch/ia64/kernel/irq_ia64.c
@@ -382,8 +382,7 @@ void destroy_and_reserve_irq(unsigned int irq)
 {
 	unsigned long flags;
 
-	dynamic_irq_cleanup(irq);
-
+	irq_init_desc(irq);
 	spin_lock_irqsave(&vector_lock, flags);
 	__clear_irq_vector(irq);
 	irq_status[irq] = IRQ_RSVD;
@@ -416,13 +415,13 @@ int create_irq(void)
  out:
 	spin_unlock_irqrestore(&vector_lock, flags);
 	if (irq >= 0)
-		dynamic_irq_init(irq);
+		irq_init_desc(irq);
 	return irq;
 }
 
 void destroy_irq(unsigned int irq)
 {
-	dynamic_irq_cleanup(irq);
+	irq_init_desc(irq);
 	clear_irq_vector(irq);
 }
 

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

* [tip:irq/core] genirq: Remove dynamic_irq mess
  2014-05-07 15:44 ` [patch 32/32] genirq: Remove dynamic_irq mess Thomas Gleixner
@ 2014-05-16 13:37   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 86+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-05-16 13:37 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, grant.likely, hpa, mingo, peterz, tony.luck, tglx

Commit-ID:  d8179bc0db8d0c9654d5de43de2874bf6d0a58fa
Gitweb:     http://git.kernel.org/tip/d8179bc0db8d0c9654d5de43de2874bf6d0a58fa
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 7 May 2014 15:44:23 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 16 May 2014 14:05:22 +0200

genirq: Remove dynamic_irq mess

No more users. Get rid of the cruft.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Grant Likely <grant.likely@linaro.org>
Tested-by: Tony Luck <tony.luck@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20140507154341.012847637@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/irq.h  | 10 ----------
 kernel/irq/irqdesc.c | 23 +++++++----------------
 2 files changed, 7 insertions(+), 26 deletions(-)

diff --git a/include/linux/irq.h b/include/linux/irq.h
index 8ff71d1..0d998d8 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -525,16 +525,6 @@ static inline void irq_set_percpu_devid_flags(unsigned int irq)
 			     IRQ_NOPROBE | IRQ_PER_CPU_DEVID);
 }
 
-/*
- * Dynamic irq helper functions. Obsolete. Use irq_alloc_desc* and
- * irq_free_desc instead.
- */
-extern void dynamic_irq_cleanup(unsigned int irq);
-static inline void dynamic_irq_init(unsigned int irq)
-{
-	dynamic_irq_cleanup(irq);
-}
-
 /* Set/get chip/data for an IRQ: */
 extern int irq_set_chip(unsigned int irq, struct irq_chip *chip);
 extern int irq_set_handler_data(unsigned int irq, void *data);
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 7f26779..7339e42 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -278,7 +278,12 @@ EXPORT_SYMBOL(irq_to_desc);
 
 static void free_desc(unsigned int irq)
 {
-	dynamic_irq_cleanup(irq);
+	struct irq_desc *desc = irq_to_desc(irq);
+	unsigned long flags;
+
+	raw_spin_lock_irqsave(&desc->lock, flags);
+	desc_set_defaults(irq, desc, desc_node(desc), NULL);
+	raw_spin_unlock_irqrestore(&desc->lock, flags);
 }
 
 static inline int alloc_descs(unsigned int start, unsigned int cnt, int node,
@@ -309,7 +314,7 @@ void irq_mark_irq(unsigned int irq)
 #ifdef CONFIG_GENERIC_IRQ_LEGACY
 void irq_init_desc(unsigned int irq)
 {
-	dynamic_irq_cleanup(irq);
+	free_desc(irq);
 }
 #endif
 
@@ -522,20 +527,6 @@ int irq_set_percpu_devid(unsigned int irq)
 	return 0;
 }
 
-/**
- * dynamic_irq_cleanup - cleanup a dynamically allocated irq
- * @irq:	irq number to initialize
- */
-void dynamic_irq_cleanup(unsigned int irq)
-{
-	struct irq_desc *desc = irq_to_desc(irq);
-	unsigned long flags;
-
-	raw_spin_lock_irqsave(&desc->lock, flags);
-	desc_set_defaults(irq, desc, desc_node(desc), NULL);
-	raw_spin_unlock_irqrestore(&desc->lock, flags);
-}
-
 void kstat_incr_irq_this_cpu(unsigned int irq)
 {
 	kstat_incr_irqs_this_cpu(irq, irq_to_desc(irq));

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

end of thread, other threads:[~2014-05-16 14:03 UTC | newest]

Thread overview: 86+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
2014-05-07 15:44 ` [patch 01/32] arm: iop13xx: Use sparse irqs for MSI Thomas Gleixner
2014-05-16 13:31   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 02/32] mips: Kill pointless destroy_irq() Thomas Gleixner
2014-05-16 13:31   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 03/32] genirq: Provide generic hwirq allocation facility Thomas Gleixner
2014-05-07 20:37   ` Chris Metcalf
2014-05-07 23:15     ` Thomas Gleixner
2014-05-08 10:22       ` Thomas Gleixner
2014-05-13 16:59         ` Thomas Gleixner
2014-05-13 17:48           ` Luck, Tony
2014-05-14 17:57       ` Chris Metcalf
2014-05-14 23:57         ` Thomas Gleixner
2014-05-08 12:07   ` Grant Likely
2014-05-08 13:12     ` Thomas Gleixner
2014-05-14 17:44   ` Chris Metcalf
2014-05-14 23:47     ` Thomas Gleixner
2014-05-16 13:31   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 04/32] x86: Implement arch_setup/teardown_hwirq() Thomas Gleixner
2014-05-16 13:31   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 06/32] x86: hpet: Use irq_alloc/free_hwirq() Thomas Gleixner
2014-05-16 13:32   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 05/32] x86: irq_remapping: " Thomas Gleixner
2014-05-14  9:32   ` Joerg Roedel
2014-05-16 13:32   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 08/32] x86: htirq: Use irq_alloc/free_irq() Thomas Gleixner
2014-05-07 16:03   ` Bjorn Helgaas
2014-05-07 16:30     ` Thomas Gleixner
2014-05-16 13:32   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 07/32] x86: uv: Use irq_alloc/free_hwirq() Thomas Gleixner
2014-05-16 13:32   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 09/32] x86: ioapic: " Thomas Gleixner
2014-05-16 13:33   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 11/32] iommu: dmar: Fix return value check of create_irq() Thomas Gleixner
2014-05-16 13:33   ` [tip:irq/core] iommu: smar: Fix return value check of create_irq( ) tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 10/32] x86: Get rid of get_nr_irqs_gsi() Thomas Gleixner
2014-05-16 13:33   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 13/32] ia64: Remove unused check_irq_used() Thomas Gleixner
2014-05-16 13:33   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 12/32] iommu: dmar: Provide arch specific irq allocation Thomas Gleixner
2014-05-16 13:33   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 14/32] x86: Remove create/dstroy_irq() Thomas Gleixner
2014-05-16 13:34   ` [tip:irq/core] x86: Remove create/destroy_irq() tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 16/32] tile: usb: Use irq_alloc/free_hwirq Thomas Gleixner
2014-05-16 13:34   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 15/32] tile: Implement irq_alloc/free_hwirq() for migration Thomas Gleixner
2014-05-14 17:48   ` Chris Metcalf
     [not found]   ` <5373AC00.7090507@tilera.com>
2014-05-14 23:50     ` Thomas Gleixner
2014-05-16 13:34   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 17/32] tile: net: Use irq_alloc/free_hwirq Thomas Gleixner
2014-05-16 13:34   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 18/32] tile: serial: " Thomas Gleixner
2014-05-16 13:34   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 19/32] tile: hvc: " Thomas Gleixner
2014-05-16 13:35   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 20/32] tile: pci: Use irq_alloc/free_hwirq() Thomas Gleixner
2014-05-16 13:35   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 21/32] tile: Use SPARSE_IRQ Thomas Gleixner
2014-05-16 13:35   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 22/32] genirq: Make create/destroy_irq() ia64 private Thomas Gleixner
2014-05-16 13:35   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 23/32] x86, irq: Remove pointless irq_reserve_irqs() call Thomas Gleixner
2014-05-16 13:36   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 24/32] sh: intc: Remove pointless irq_reserve_irqs() invocation Thomas Gleixner
2014-05-11  0:53   ` Simon Horman
2014-05-16 13:36   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 25/32] s390: pci: Check return value of alloc_irq_desc() proper Thomas Gleixner
2014-05-16 13:36   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 26/32] s390: Remove pointless arch_show_interrupts() Thomas Gleixner
2014-05-16 13:36   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 27/32] s390: Avoid call to irq_reserve_irqs() Thomas Gleixner
2014-05-16 13:36   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 28/32] genirq: Replace reserve_irqs in core code Thomas Gleixner
2014-05-16 13:37   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 29/32] genirq: Remove irq_reserve_irq[s] Thomas Gleixner
2014-05-08 12:14   ` Grant Likely
2014-05-08 12:54     ` Thomas Gleixner
2014-05-16 13:37   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 30/32] genirq: Replace dynamic_irq_init/cleanup Thomas Gleixner
2014-05-16 13:37   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 31/32] ia64: Use irq_init_desc Thomas Gleixner
2014-05-07 20:06   ` Luck, Tony
2014-05-16 13:37   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 32/32] genirq: Remove dynamic_irq mess Thomas Gleixner
2014-05-16 13:37   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-08 12:17 ` [patch 00/32] genirq: Another round of tree wide cleanups Grant Likely

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).