From 6ef40512c55b18f8fdf1074b2f2d7eadcd50fec7 Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Wed, 7 May 2014 15:44:13 +0000 Subject: 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 Reviewed-by: Grant Likely Cc: Tony Luck Cc: Peter Zijlstra Acked-by: Chris Metcalf Link: http://lkml.kernel.org/r/20140507154336.947853241@linutronix.de Signed-off-by: Thomas Gleixner --- arch/tile/include/asm/irq.h | 3 +++ arch/tile/kernel/irq.c | 12 ++++++++++++ 2 files changed, 15 insertions(+) (limited to 'arch/tile') diff --git a/arch/tile/include/asm/irq.h b/arch/tile/include/asm/irq.h index 33cff9a3058b..9670a39d924d 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 906a76bdb31d..5fd197e0a2d4 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 -- cgit v1.2.3 From 2aa799d891299457e4107d33f07a1ed5ac8849ae Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Wed, 7 May 2014 15:44:16 +0000 Subject: tile: pci: Use irq_alloc/free_hwirq() No functional change. Just convert to the new interface. Signed-off-by: Thomas Gleixner Reviewed-by: Grant Likely Cc: Tony Luck Cc: Peter Zijlstra Acked-by: Chris Metcalf Link: http://lkml.kernel.org/r/20140507154338.132662495@linutronix.de Signed-off-by: Thomas Gleixner --- arch/tile/kernel/pci_gx.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'arch/tile') diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c index 077b7bc437e5..e39f9c542807 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); } -- cgit v1.2.3 From b26d851ff1928b56242c4c5e16cb62bac2d9526c Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Wed, 7 May 2014 15:44:16 +0000 Subject: tile: Use SPARSE_IRQ Get rid of the private allocator and switch over to sparse IRQs. Signed-off-by: Thomas Gleixner Reviewed-by: Grant Likely Cc: Tony Luck Cc: Peter Zijlstra Acked-by: Chris Metcalf Link: http://lkml.kernel.org/r/20140507154338.423715783@linutronix.de Signed-off-by: Thomas Gleixner --- arch/tile/Kconfig | 2 ++ arch/tile/include/asm/irq.h | 9 ++++---- arch/tile/kernel/irq.c | 52 +++------------------------------------------ 3 files changed, 9 insertions(+), 54 deletions(-) (limited to 'arch/tile') diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig index 85258ca43ff5..4f3006b600e3 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 9670a39d924d..1fe86911838b 100644 --- a/arch/tile/include/asm/irq.h +++ b/arch/tile/include/asm/irq.h @@ -18,10 +18,12 @@ #include /* 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 5fd197e0a2d4..637f2ffaa5f5 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 -- cgit v1.2.3