From d1bef4ed5faf7d9872337b33c4269e45ae1bf960 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Thu, 29 Jun 2006 02:24:36 -0700 Subject: [PATCH] genirq: rename desc->handler to desc->chip This patch-queue improves the generic IRQ layer to be truly generic, by adding various abstractions and features to it, without impacting existing functionality. While the queue can be best described as "fix and improve everything in the generic IRQ layer that we could think of", and thus it consists of many smaller features and lots of cleanups, the one feature that stands out most is the new 'irq chip' abstraction. The irq-chip abstraction is about describing and coding and IRQ controller driver by mapping its raw hardware capabilities [and quirks, if needed] in a straightforward way, without having to think about "IRQ flow" (level/edge/etc.) type of details. This stands in contrast with the current 'irq-type' model of genirq architectures, which 'mixes' raw hardware capabilities with 'flow' details. The patchset supports both types of irq controller designs at once, and converts i386 and x86_64 to the new irq-chip design. As a bonus side-effect of the irq-chip approach, chained interrupt controllers (master/slave PIC constructs, etc.) are now supported by design as well. The end result of this patchset intends to be simpler architecture-level code and more consolidation between architectures. We reused many bits of code and many concepts from Russell King's ARM IRQ layer, the merging of which was one of the motivations for this patchset. This patch: rename desc->handler to desc->chip. Originally i did not want to do this, because it's a big patch. But having both "desc->handler", "desc->handle_irq" and "action->handler" caused a large degree of confusion and made the code appear alot less clean than it truly is. I have also attempted a dual approach as well by introducing a desc->chip alias - but that just wasnt robust enough and broke frequently. So lets get over with this quickly. The conversion was done automatically via scripts and converts all the code in the kernel. This renaming patch is the first one amongst the patches, so that the remaining patches can stay flexible and can be merged and split up without having some big monolithic patch act as a merge barrier. [akpm@osdl.org: build fix] [akpm@osdl.org: another build fix] Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/irq.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/linux/irq.h') diff --git a/include/linux/irq.h b/include/linux/irq.h index 676e00dfb21..9597a690423 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -69,8 +69,8 @@ typedef struct hw_interrupt_type hw_irq_controller; * Pad this out to 32 bytes for cache and indexing reasons. */ typedef struct irq_desc { - hw_irq_controller *handler; - void *handler_data; + hw_irq_controller *chip; + void *chip_data; struct irqaction *action; /* IRQ action list */ unsigned int status; /* IRQ status */ unsigned int depth; /* nested irq disables */ -- cgit v1.2.3-70-g09d2 From a53da52fd743fd637637572838c0a7af23a2d038 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Thu, 29 Jun 2006 02:24:38 -0700 Subject: [PATCH] genirq: cleanup: merge irq_affinity[] into irq_desc[] Consolidation: remove the irq_affinity[NR_IRQS] array and move it into the irq_desc[NR_IRQS].affinity field. [akpm@osdl.org: sparc64 build fix] Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/alpha/kernel/irq.c | 2 +- arch/i386/kernel/irq.c | 2 +- arch/ia64/kernel/irq.c | 4 ++-- arch/parisc/kernel/irq.c | 8 ++++---- arch/powerpc/kernel/irq.c | 2 +- arch/powerpc/platforms/pseries/xics.c | 4 ++-- arch/powerpc/sysdev/mpic.c | 2 +- arch/ppc/syslib/open_pic.c | 4 ++-- arch/sparc64/kernel/irq.c | 2 +- arch/x86_64/kernel/irq.c | 2 +- include/linux/irq.h | 7 ++++--- kernel/irq/handle.c | 5 ++++- kernel/irq/manage.c | 2 -- kernel/irq/proc.c | 4 ++-- 14 files changed, 26 insertions(+), 24 deletions(-) (limited to 'include/linux/irq.h') diff --git a/arch/alpha/kernel/irq.c b/arch/alpha/kernel/irq.c index ec9d243d42c..63af36cf7f6 100644 --- a/arch/alpha/kernel/irq.c +++ b/arch/alpha/kernel/irq.c @@ -56,7 +56,7 @@ select_smp_affinity(unsigned int irq) cpu = (cpu < (NR_CPUS-1) ? cpu + 1 : 0); last_cpu = cpu; - irq_affinity[irq] = cpumask_of_cpu(cpu); + irq_desc[irq].affinity = cpumask_of_cpu(cpu); irq_desc[irq].chip->set_affinity(irq, cpumask_of_cpu(cpu)); return 0; } diff --git a/arch/i386/kernel/irq.c b/arch/i386/kernel/irq.c index b942a5918da..3336cef9605 100644 --- a/arch/i386/kernel/irq.c +++ b/arch/i386/kernel/irq.c @@ -291,7 +291,7 @@ void fixup_irqs(cpumask_t map) if (irq == 2) continue; - cpus_and(mask, irq_affinity[irq], map); + cpus_and(mask, irq_desc[irq].affinity, map); if (any_online_cpu(mask) == NR_CPUS) { printk("Breaking affinity for irq %i\n", irq); mask = map; diff --git a/arch/ia64/kernel/irq.c b/arch/ia64/kernel/irq.c index 2645153dba8..c4e1b3b60b4 100644 --- a/arch/ia64/kernel/irq.c +++ b/arch/ia64/kernel/irq.c @@ -100,7 +100,7 @@ void set_irq_affinity_info (unsigned int irq, int hwid, int redir) cpu_set(cpu_logical_id(hwid), mask); if (irq < NR_IRQS) { - irq_affinity[irq] = mask; + irq_desc[irq].affinity = mask; irq_redir[irq] = (char) (redir & 0xff); } } @@ -131,7 +131,7 @@ static void migrate_irqs(void) if (desc->status == IRQ_PER_CPU) continue; - cpus_and(mask, irq_affinity[irq], cpu_online_map); + cpus_and(mask, irq_desc[irq].affinity, cpu_online_map); if (any_online_cpu(mask) == NR_CPUS) { /* * Save it for phase 2 processing diff --git a/arch/parisc/kernel/irq.c b/arch/parisc/kernel/irq.c index 26e69f73fdb..ea6a55e1a0c 100644 --- a/arch/parisc/kernel/irq.c +++ b/arch/parisc/kernel/irq.c @@ -94,7 +94,7 @@ int cpu_check_affinity(unsigned int irq, cpumask_t *dest) if (irq == TIMER_IRQ || irq == IPI_IRQ) { /* Bad linux design decision. The mask has already * been set; we must reset it */ - irq_affinity[irq] = CPU_MASK_ALL; + irq_desc[irq].affinity = CPU_MASK_ALL; return -EINVAL; } @@ -110,7 +110,7 @@ static void cpu_set_affinity_irq(unsigned int irq, cpumask_t dest) if (cpu_check_affinity(irq, &dest)) return; - irq_affinity[irq] = dest; + irq_desc[irq].affinity = dest; } #endif @@ -265,7 +265,7 @@ int txn_alloc_irq(unsigned int bits_wide) unsigned long txn_affinity_addr(unsigned int irq, int cpu) { #ifdef CONFIG_SMP - irq_affinity[irq] = cpumask_of_cpu(cpu); + irq_desc[irq].affinity = cpumask_of_cpu(cpu); #endif return cpu_data[cpu].txn_addr; @@ -326,7 +326,7 @@ void do_cpu_irq_mask(struct pt_regs *regs) /* Work our way from MSb to LSb...same order we alloc EIRs */ for (irq = TIMER_IRQ; eirr_val && bit; bit>>=1, irq++) { #ifdef CONFIG_SMP - cpumask_t dest = irq_affinity[irq]; + cpumask_t dest = irq_desc[irq].affinity; #endif if (!(bit & eirr_val)) continue; diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c index 8cfc779d882..24f6050aa4a 100644 --- a/arch/powerpc/kernel/irq.c +++ b/arch/powerpc/kernel/irq.c @@ -164,7 +164,7 @@ void fixup_irqs(cpumask_t map) if (irq_desc[irq].status & IRQ_PER_CPU) continue; - cpus_and(mask, irq_affinity[irq], map); + cpus_and(mask, irq_desc[irq].affinity, map); if (any_online_cpu(mask) == NR_CPUS) { printk("Breaking affinity for irq %i\n", irq); mask = map; diff --git a/arch/powerpc/platforms/pseries/xics.c b/arch/powerpc/platforms/pseries/xics.c index bdc9e26a93c..19c03dd4300 100644 --- a/arch/powerpc/platforms/pseries/xics.c +++ b/arch/powerpc/platforms/pseries/xics.c @@ -238,7 +238,7 @@ static int get_irq_server(unsigned int irq) { unsigned int server; /* For the moment only implement delivery to all cpus or one cpu */ - cpumask_t cpumask = irq_affinity[irq]; + cpumask_t cpumask = irq_desc[irq].affinity; cpumask_t tmp = CPU_MASK_NONE; if (!distribute_irqs) @@ -729,7 +729,7 @@ void xics_migrate_irqs_away(void) /* Reset affinity to all cpus */ desc->chip->set_affinity(virq, CPU_MASK_ALL); - irq_affinity[virq] = CPU_MASK_ALL; + irq_desc[irq].affinity = CPU_MASK_ALL; unlock: spin_unlock_irqrestore(&desc->lock, flags); } diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c index f4613ee6b7a..28df9c827ca 100644 --- a/arch/powerpc/sysdev/mpic.c +++ b/arch/powerpc/sysdev/mpic.c @@ -906,7 +906,7 @@ void mpic_setup_this_cpu(void) /* let the mpic know we want intrs. default affinity is 0xffffffff * until changed via /proc. That's how it's done on x86. If we want * it differently, then we should make sure we also change the default - * values of irq_affinity in irq.c. + * values of irq_desc[].affinity in irq.c. */ if (distribute_irqs) { for (i = 0; i < mpic->num_sources ; i++) diff --git a/arch/ppc/syslib/open_pic.c b/arch/ppc/syslib/open_pic.c index 822058c2983..767a0bc9581 100644 --- a/arch/ppc/syslib/open_pic.c +++ b/arch/ppc/syslib/open_pic.c @@ -615,8 +615,8 @@ void __devinit do_openpic_setup_cpu(void) /* let the openpic know we want intrs. default affinity * is 0xffffffff until changed via /proc * That's how it's done on x86. If we want it differently, then - * we should make sure we also change the default values of irq_affinity - * in irq.c. + * we should make sure we also change the default values of + * irq_desc[].affinity in irq.c. */ for (i = 0; i < NumSources; i++) openpic_mapirq(i, msk, CPU_MASK_ALL); diff --git a/arch/sparc64/kernel/irq.c b/arch/sparc64/kernel/irq.c index 5d7c821ab7f..ab9e640df22 100644 --- a/arch/sparc64/kernel/irq.c +++ b/arch/sparc64/kernel/irq.c @@ -224,7 +224,7 @@ static inline struct ino_bucket *virt_irq_to_bucket(unsigned int virt_irq) #ifdef CONFIG_SMP static int irq_choose_cpu(unsigned int virt_irq) { - cpumask_t mask = irq_affinity[virt_irq]; + cpumask_t mask = irq_desc[virt_irq].affinity; int cpuid; if (cpus_equal(mask, CPU_MASK_ALL)) { diff --git a/arch/x86_64/kernel/irq.c b/arch/x86_64/kernel/irq.c index 0c2fb2c77bd..a1f1df5f7bf 100644 --- a/arch/x86_64/kernel/irq.c +++ b/arch/x86_64/kernel/irq.c @@ -146,7 +146,7 @@ void fixup_irqs(cpumask_t map) if (irq == 2) continue; - cpus_and(mask, irq_affinity[irq], map); + cpus_and(mask, irq_desc[irq].affinity, map); if (any_online_cpu(mask) == NR_CPUS) { printk("Breaking affinity for irq %i\n", irq); mask = map; diff --git a/include/linux/irq.h b/include/linux/irq.h index 9597a690423..6e3ad6245bd 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -77,6 +77,9 @@ typedef struct irq_desc { unsigned int irq_count; /* For detecting broken interrupts */ unsigned int irqs_unhandled; spinlock_t lock; +#ifdef CONFIG_SMP + cpumask_t affinity; +#endif #if defined (CONFIG_GENERIC_PENDING_IRQ) || defined (CONFIG_IRQBALANCE) unsigned int move_irq; /* Flag need to re-target intr dest*/ #endif @@ -96,12 +99,10 @@ irq_descp (int irq) extern int setup_irq(unsigned int irq, struct irqaction * new); #ifdef CONFIG_GENERIC_HARDIRQS -extern cpumask_t irq_affinity[NR_IRQS]; - #ifdef CONFIG_SMP static inline void set_native_irq_info(int irq, cpumask_t mask) { - irq_affinity[irq] = mask; + irq_desc[irq].affinity = mask; } #else static inline void set_native_irq_info(int irq, cpumask_t mask) diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c index f9d95705a4a..cc786aaf30d 100644 --- a/kernel/irq/handle.c +++ b/kernel/irq/handle.c @@ -32,7 +32,10 @@ irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = { [0 ... NR_IRQS-1] = { .status = IRQ_DISABLED, .chip = &no_irq_type, - .lock = SPIN_LOCK_UNLOCKED + .lock = SPIN_LOCK_UNLOCKED, +#ifdef CONFIG_SMP + .affinity = CPU_MASK_ALL +#endif } }; diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 31ee1f3bfcf..c53662edc73 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -16,8 +16,6 @@ #ifdef CONFIG_SMP -cpumask_t irq_affinity[NR_IRQS] = { [0 ... NR_IRQS-1] = CPU_MASK_ALL }; - #if defined (CONFIG_GENERIC_PENDING_IRQ) || defined (CONFIG_IRQBALANCE) cpumask_t __cacheline_aligned pending_irq_cpumask[NR_IRQS]; #endif diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c index 90fe05f23e6..847b98a611e 100644 --- a/kernel/irq/proc.c +++ b/kernel/irq/proc.c @@ -36,7 +36,7 @@ void proc_set_irq_affinity(unsigned int irq, cpumask_t mask_val) void proc_set_irq_affinity(unsigned int irq, cpumask_t mask_val) { set_balance_irq_affinity(irq, mask_val); - irq_affinity[irq] = mask_val; + irq_desc[irq].affinity = mask_val; irq_desc[irq].chip->set_affinity(irq, mask_val); } #endif @@ -44,7 +44,7 @@ void proc_set_irq_affinity(unsigned int irq, cpumask_t mask_val) static int irq_affinity_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data) { - int len = cpumask_scnprintf(page, count, irq_affinity[(long)data]); + int len = cpumask_scnprintf(page, count, irq_desc[(long)data].affinity); if (count - len < 2) return -EINVAL; -- cgit v1.2.3-70-g09d2 From a8553acd6c14e827078779c0a0ee1c18f27b2403 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Thu, 29 Jun 2006 02:24:38 -0700 Subject: [PATCH] genirq: cleanup: remove irq_descp() Cleanup: remove irq_descp() - explicit use of irq_desc[] is shorter and more readable. Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/ia64/hp/sim/hpsim_irq.c | 6 +++--- arch/ia64/kernel/iosapic.c | 14 +++++++------- arch/ia64/kernel/irq.c | 2 +- arch/ia64/kernel/irq_ia64.c | 2 +- arch/ia64/kernel/mca.c | 2 +- arch/ia64/kernel/smpboot.c | 2 +- arch/powerpc/kernel/crash.c | 2 +- include/linux/irq.h | 7 ------- kernel/irq/migration.c | 2 +- 9 files changed, 16 insertions(+), 23 deletions(-) (limited to 'include/linux/irq.h') diff --git a/arch/ia64/hp/sim/hpsim_irq.c b/arch/ia64/hp/sim/hpsim_irq.c index c0d25a2a3e9..8145547bb52 100644 --- a/arch/ia64/hp/sim/hpsim_irq.c +++ b/arch/ia64/hp/sim/hpsim_irq.c @@ -44,8 +44,8 @@ hpsim_irq_init (void) int i; for (i = 0; i < NR_IRQS; ++i) { - idesc = irq_descp(i); - if (idesc->handler == &no_irq_type) - idesc->handler = &irq_type_hp_sim; + idesc = irq_desc + i; + if (idesc->chip == &no_irq_type) + idesc->chip = &irq_type_hp_sim; } } diff --git a/arch/ia64/kernel/iosapic.c b/arch/ia64/kernel/iosapic.c index abb4cb1c831..efc7df4b0fd 100644 --- a/arch/ia64/kernel/iosapic.c +++ b/arch/ia64/kernel/iosapic.c @@ -456,7 +456,7 @@ iosapic_startup_edge_irq (unsigned int irq) static void iosapic_ack_edge_irq (unsigned int irq) { - irq_desc_t *idesc = irq_descp(irq); + irq_desc_t *idesc = irq_desc + irq; move_native_irq(irq); /* @@ -659,7 +659,7 @@ register_intr (unsigned int gsi, int vector, unsigned char delivery, else irq_type = &irq_type_iosapic_level; - idesc = irq_descp(vector); + idesc = irq_desc + vector; if (idesc->chip != irq_type) { if (idesc->chip != &no_irq_type) printk(KERN_WARNING @@ -793,14 +793,14 @@ again: return -ENOSPC; } - spin_lock_irqsave(&irq_descp(vector)->lock, flags); + spin_lock_irqsave(&irq_desc[vector].lock, flags); spin_lock(&iosapic_lock); { if (gsi_to_vector(gsi) > 0) { if (list_empty(&iosapic_intr_info[vector].rtes)) free_irq_vector(vector); spin_unlock(&iosapic_lock); - spin_unlock_irqrestore(&irq_descp(vector)->lock, + spin_unlock_irqrestore(&irq_desc[vector].lock, flags); goto again; } @@ -810,7 +810,7 @@ again: polarity, trigger); if (err < 0) { spin_unlock(&iosapic_lock); - spin_unlock_irqrestore(&irq_descp(vector)->lock, + spin_unlock_irqrestore(&irq_desc[vector].lock, flags); return err; } @@ -825,7 +825,7 @@ again: set_rte(gsi, vector, dest, mask); } spin_unlock(&iosapic_lock); - spin_unlock_irqrestore(&irq_descp(vector)->lock, flags); + spin_unlock_irqrestore(&irq_desc[vector].lock, flags); printk(KERN_INFO "GSI %u (%s, %s) -> CPU %d (0x%04x) vector %d\n", gsi, (trigger == IOSAPIC_EDGE ? "edge" : "level"), @@ -860,7 +860,7 @@ iosapic_unregister_intr (unsigned int gsi) } vector = irq_to_vector(irq); - idesc = irq_descp(irq); + idesc = irq_desc + irq; spin_lock_irqsave(&idesc->lock, flags); spin_lock(&iosapic_lock); { diff --git a/arch/ia64/kernel/irq.c b/arch/ia64/kernel/irq.c index c4e1b3b60b4..7852382de2f 100644 --- a/arch/ia64/kernel/irq.c +++ b/arch/ia64/kernel/irq.c @@ -120,7 +120,7 @@ static void migrate_irqs(void) int irq, new_cpu; for (irq=0; irq < NR_IRQS; irq++) { - desc = irq_descp(irq); + desc = irq_desc + irq; /* * No handling for now. diff --git a/arch/ia64/kernel/irq_ia64.c b/arch/ia64/kernel/irq_ia64.c index 6d8fc9498ed..f5035304594 100644 --- a/arch/ia64/kernel/irq_ia64.c +++ b/arch/ia64/kernel/irq_ia64.c @@ -249,7 +249,7 @@ register_percpu_irq (ia64_vector vec, struct irqaction *action) for (irq = 0; irq < NR_IRQS; ++irq) if (irq_to_vector(irq) == vec) { - desc = irq_descp(irq); + desc = irq_desc + irq; desc->status |= IRQ_PER_CPU; desc->chip = &irq_type_ia64_lsapic; if (action) diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c index 6a0880639bc..d7dc5e63de6 100644 --- a/arch/ia64/kernel/mca.c +++ b/arch/ia64/kernel/mca.c @@ -1788,7 +1788,7 @@ ia64_mca_late_init(void) cpe_poll_enabled = 0; for (irq = 0; irq < NR_IRQS; ++irq) if (irq_to_vector(irq) == cpe_vector) { - desc = irq_descp(irq); + desc = irq_desc + irq; desc->status |= IRQ_PER_CPU; setup_irq(irq, &mca_cpe_irqaction); ia64_cpe_irq = irq; diff --git a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c index d6928805559..5203df78f15 100644 --- a/arch/ia64/kernel/smpboot.c +++ b/arch/ia64/kernel/smpboot.c @@ -677,7 +677,7 @@ int migrate_platform_irqs(unsigned int cpu) new_cpei_cpu = any_online_cpu(cpu_online_map); mask = cpumask_of_cpu(new_cpei_cpu); set_cpei_target_cpu(new_cpei_cpu); - desc = irq_descp(ia64_cpe_irq); + desc = irq_desc + ia64_cpe_irq; /* * Switch for now, immediatly, we need to do fake intr * as other interrupts, but need to study CPEI behaviour with diff --git a/arch/powerpc/kernel/crash.c b/arch/powerpc/kernel/crash.c index 1bfad7c2f8c..22ceba844bf 100644 --- a/arch/powerpc/kernel/crash.c +++ b/arch/powerpc/kernel/crash.c @@ -190,7 +190,7 @@ void default_machine_crash_shutdown(struct pt_regs *regs) local_irq_disable(); for_each_irq(irq) { - struct irq_desc *desc = irq_descp(irq); + struct irq_desc *desc = irq_desc + irq; if (desc->status & IRQ_INPROGRESS) desc->chip->end(irq); diff --git a/include/linux/irq.h b/include/linux/irq.h index 6e3ad6245bd..80713d6e8c8 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -87,13 +87,6 @@ typedef struct irq_desc { extern irq_desc_t irq_desc [NR_IRQS]; -/* Return a pointer to the irq descriptor for IRQ. */ -static inline irq_desc_t * -irq_descp (int irq) -{ - return irq_desc + irq; -} - #include /* the arch dependent stuff */ extern int setup_irq(unsigned int irq, struct irqaction * new); diff --git a/kernel/irq/migration.c b/kernel/irq/migration.c index d978c87bca9..b4a4354d03d 100644 --- a/kernel/irq/migration.c +++ b/kernel/irq/migration.c @@ -15,7 +15,7 @@ void set_pending_irq(unsigned int irq, cpumask_t mask) void move_native_irq(int irq) { cpumask_t tmp; - irq_desc_t *desc = irq_descp(irq); + irq_desc_t *desc = irq_desc + irq; if (likely(!desc->move_irq)) return; -- cgit v1.2.3-70-g09d2 From 2e60bbb6d50de654d8e68f115161e27878b5e72d Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Thu, 29 Jun 2006 02:24:39 -0700 Subject: [PATCH] genirq: cleanup: remove fastcall Now that i386 defaults to regparm, explicit uses of fastcall are not needed anymore. Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/irq.h | 10 +++++++--- kernel/irq/handle.c | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'include/linux/irq.h') diff --git a/include/linux/irq.h b/include/linux/irq.h index 80713d6e8c8..eac1273dc4e 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -170,11 +170,15 @@ static inline void set_balance_irq_affinity(unsigned int irq, cpumask_t mask) extern int no_irq_affinity; extern int noirqdebug_setup(char *str); -extern fastcall irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs, - struct irqaction *action); +extern irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs, + struct irqaction *action); +/* + * Explicit fastcall, because i386 4KSTACKS calls it from assembly: + */ extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs); + extern void note_interrupt(unsigned int irq, irq_desc_t *desc, - int action_ret, struct pt_regs *regs); + int action_ret, struct pt_regs *regs); extern int can_request_irq(unsigned int irq, unsigned long irqflags); extern void init_irq_proc(void); diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c index cc786aaf30d..6b313ccf0ed 100644 --- a/kernel/irq/handle.c +++ b/kernel/irq/handle.c @@ -79,8 +79,8 @@ irqreturn_t no_action(int cpl, void *dev_id, struct pt_regs *regs) /* * Have got an event to handle: */ -fastcall irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs, - struct irqaction *action) +irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs, + struct irqaction *action) { irqreturn_t ret, retval = IRQ_NONE; unsigned int status = 0; -- cgit v1.2.3-70-g09d2 From 06fcb0c6fb3aae9570a32ac3b72a8222563baa69 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Thu, 29 Jun 2006 02:24:40 -0700 Subject: [PATCH] genirq: cleanup: misc code cleanups Assorted code cleanups to the generic IRQ code. Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/irq.h | 54 ++++++++++++++++++++++++++++++-------------------- kernel/irq/autoprobe.c | 16 +++++++-------- kernel/irq/handle.c | 4 ++-- kernel/irq/manage.c | 29 +++++++++++---------------- kernel/irq/spurious.c | 23 +++++++++++---------- 5 files changed, 66 insertions(+), 60 deletions(-) (limited to 'include/linux/irq.h') diff --git a/include/linux/irq.h b/include/linux/irq.h index eac1273dc4e..92c68541462 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -1,5 +1,5 @@ -#ifndef __irq_h -#define __irq_h +#ifndef _LINUX_IRQ_H +#define _LINUX_IRQ_H /* * Please do not include this file in generic code. There is currently @@ -11,7 +11,7 @@ #include -#if !defined(CONFIG_S390) +#ifndef CONFIG_S390 #include #include @@ -33,7 +33,7 @@ #define IRQ_WAITING 32 /* IRQ not yet seen - for autodetection */ #define IRQ_LEVEL 64 /* IRQ level triggered */ #define IRQ_MASKED 128 /* IRQ masked - shouldn't be seen again */ -#if defined(ARCH_HAS_IRQ_PER_CPU) +#ifdef ARCH_HAS_IRQ_PER_CPU # define IRQ_PER_CPU 256 /* IRQ is per CPU */ # define CHECK_IRQ_PER_CPU(var) ((var) & IRQ_PER_CPU) #else @@ -45,7 +45,7 @@ * to describe about the low-level hardware. */ struct hw_interrupt_type { - const char * typename; + const char *typename; unsigned int (*startup)(unsigned int irq); void (*shutdown)(unsigned int irq); void (*enable)(unsigned int irq); @@ -80,7 +80,7 @@ typedef struct irq_desc { #ifdef CONFIG_SMP cpumask_t affinity; #endif -#if defined (CONFIG_GENERIC_PENDING_IRQ) || defined (CONFIG_IRQBALANCE) +#if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE) unsigned int move_irq; /* Flag need to re-target intr dest*/ #endif } ____cacheline_aligned irq_desc_t; @@ -89,9 +89,10 @@ extern irq_desc_t irq_desc [NR_IRQS]; #include /* the arch dependent stuff */ -extern int setup_irq(unsigned int irq, struct irqaction * new); +extern int setup_irq(unsigned int irq, struct irqaction *new); #ifdef CONFIG_GENERIC_HARDIRQS + #ifdef CONFIG_SMP static inline void set_native_irq_info(int irq, cpumask_t mask) { @@ -105,7 +106,7 @@ static inline void set_native_irq_info(int irq, cpumask_t mask) #ifdef CONFIG_SMP -#if defined (CONFIG_GENERIC_PENDING_IRQ) || defined (CONFIG_IRQBALANCE) +#if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE) extern cpumask_t pending_irq_cpumask[NR_IRQS]; void set_pending_irq(unsigned int irq, cpumask_t mask); @@ -127,7 +128,7 @@ static inline void set_irq_info(int irq, cpumask_t mask) { } -#else // CONFIG_PCI_MSI +#else /* CONFIG_PCI_MSI */ static inline void move_irq(int irq) { @@ -138,26 +139,36 @@ static inline void set_irq_info(int irq, cpumask_t mask) { set_native_irq_info(irq, mask); } -#endif // CONFIG_PCI_MSI -#else // CONFIG_GENERIC_PENDING_IRQ || CONFIG_IRQBALANCE +#endif /* CONFIG_PCI_MSI */ + +#else /* CONFIG_GENERIC_PENDING_IRQ || CONFIG_IRQBALANCE */ + +static inline void move_irq(int irq) +{ +} + +static inline void move_native_irq(int irq) +{ +} + +static inline void set_pending_irq(unsigned int irq, cpumask_t mask) +{ +} -#define move_irq(x) -#define move_native_irq(x) -#define set_pending_irq(x,y) static inline void set_irq_info(int irq, cpumask_t mask) { set_native_irq_info(irq, mask); } -#endif // CONFIG_GENERIC_PENDING_IRQ +#endif /* CONFIG_GENERIC_PENDING_IRQ */ -#else // CONFIG_SMP +#else /* CONFIG_SMP */ #define move_irq(x) #define move_native_irq(x) -#endif // CONFIG_SMP +#endif /* CONFIG_SMP */ #ifdef CONFIG_IRQBALANCE extern void set_balance_irq_affinity(unsigned int irq, cpumask_t mask); @@ -186,17 +197,16 @@ extern void init_irq_proc(void); #ifdef CONFIG_AUTO_IRQ_AFFINITY extern int select_smp_affinity(unsigned int irq); #else -static inline int -select_smp_affinity(unsigned int irq) +static inline int select_smp_affinity(unsigned int irq) { return 1; } #endif -#endif +#endif /* CONFIG_GENERIC_HARDIRQS */ extern hw_irq_controller no_irq_type; /* needed in every arch ? */ -#endif +#endif /* !CONFIG_S390 */ -#endif /* __irq_h */ +#endif /* _LINUX_IRQ_H */ diff --git a/kernel/irq/autoprobe.c b/kernel/irq/autoprobe.c index d1f1e6f10a2..d6eab98a317 100644 --- a/kernel/irq/autoprobe.c +++ b/kernel/irq/autoprobe.c @@ -27,7 +27,7 @@ static DEFINE_MUTEX(probing_active); */ unsigned long probe_irq_on(void) { - unsigned long val; + unsigned long mask; irq_desc_t *desc; unsigned int i; @@ -40,8 +40,8 @@ unsigned long probe_irq_on(void) desc = irq_desc + i; spin_lock_irq(&desc->lock); - if (!irq_desc[i].action) - irq_desc[i].chip->startup(i); + if (!desc->action) + desc->chip->startup(i); spin_unlock_irq(&desc->lock); } @@ -73,11 +73,11 @@ unsigned long probe_irq_on(void) /* * Now filter out any obviously spurious interrupts */ - val = 0; + mask = 0; for (i = 0; i < NR_IRQS; i++) { - irq_desc_t *desc = irq_desc + i; unsigned int status; + desc = irq_desc + i; spin_lock_irq(&desc->lock); status = desc->status; @@ -88,14 +88,13 @@ unsigned long probe_irq_on(void) desc->chip->shutdown(i); } else if (i < 32) - val |= 1 << i; + mask |= 1 << i; } spin_unlock_irq(&desc->lock); } - return val; + return mask; } - EXPORT_SYMBOL(probe_irq_on); /** @@ -184,6 +183,5 @@ int probe_irq_off(unsigned long val) return irq_found; } - EXPORT_SYMBOL(probe_irq_off); diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c index 6b313ccf0ed..f9c33a86cbd 100644 --- a/kernel/irq/handle.c +++ b/kernel/irq/handle.c @@ -18,7 +18,7 @@ * Linux has a controller-independent interrupt architecture. * Every controller has a 'controller-template', that is used * by the main code to do the right thing. Each driver-visible - * interrupt source is transparently wired to the apropriate + * interrupt source is transparently wired to the appropriate * controller. Thus drivers need not be aware of the * interrupt-controller. * @@ -111,7 +111,7 @@ irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs, fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs) { irq_desc_t *desc = irq_desc + irq; - struct irqaction * action; + struct irqaction *action; unsigned int status; kstat_this_cpu.irqs[irq]++; diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index c53662edc73..261906ebdf0 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -40,7 +40,6 @@ void synchronize_irq(unsigned int irq) while (desc->status & IRQ_INPROGRESS) cpu_relax(); } - EXPORT_SYMBOL(synchronize_irq); #endif @@ -71,7 +70,6 @@ void disable_irq_nosync(unsigned int irq) } spin_unlock_irqrestore(&desc->lock, flags); } - EXPORT_SYMBOL(disable_irq_nosync); /** @@ -97,7 +95,6 @@ void disable_irq(unsigned int irq) if (desc->action) synchronize_irq(irq); } - EXPORT_SYMBOL(disable_irq); /** @@ -139,7 +136,6 @@ void enable_irq(unsigned int irq) } spin_unlock_irqrestore(&desc->lock, flags); } - EXPORT_SYMBOL(enable_irq); /* @@ -166,7 +162,7 @@ int can_request_irq(unsigned int irq, unsigned long irqflags) * Internal function to register an irqaction - typically used to * allocate special interrupts that are part of the architecture. */ -int setup_irq(unsigned int irq, struct irqaction * new) +int setup_irq(unsigned int irq, struct irqaction *new) { struct irq_desc *desc = irq_desc + irq; struct irqaction *old, **p; @@ -198,9 +194,10 @@ int setup_irq(unsigned int irq, struct irqaction * new) /* * The following block of code has to be executed atomically */ - spin_lock_irqsave(&desc->lock,flags); + spin_lock_irqsave(&desc->lock, flags); p = &desc->action; - if ((old = *p) != NULL) { + old = *p; + if (old) { /* Can't share interrupts unless both agree to */ if (!(old->flags & new->flags & SA_SHIRQ)) goto mismatch; @@ -233,7 +230,7 @@ int setup_irq(unsigned int irq, struct irqaction * new) else desc->chip->enable(irq); } - spin_unlock_irqrestore(&desc->lock,flags); + spin_unlock_irqrestore(&desc->lock, flags); new->irq = irq; register_irq_proc(irq); @@ -276,10 +273,10 @@ void free_irq(unsigned int irq, void *dev_id) return; desc = irq_desc + irq; - spin_lock_irqsave(&desc->lock,flags); + spin_lock_irqsave(&desc->lock, flags); p = &desc->action; for (;;) { - struct irqaction * action = *p; + struct irqaction *action = *p; if (action) { struct irqaction **pp = p; @@ -304,7 +301,7 @@ void free_irq(unsigned int irq, void *dev_id) else desc->chip->disable(irq); } - spin_unlock_irqrestore(&desc->lock,flags); + spin_unlock_irqrestore(&desc->lock, flags); unregister_handler_proc(irq, action); /* Make sure it's not being used on another CPU */ @@ -312,12 +309,11 @@ void free_irq(unsigned int irq, void *dev_id) kfree(action); return; } - printk(KERN_ERR "Trying to free free IRQ%d\n",irq); - spin_unlock_irqrestore(&desc->lock,flags); + printk(KERN_ERR "Trying to free free IRQ%d\n", irq); + spin_unlock_irqrestore(&desc->lock, flags); return; } } - EXPORT_SYMBOL(free_irq); /** @@ -351,9 +347,9 @@ EXPORT_SYMBOL(free_irq); */ int request_irq(unsigned int irq, irqreturn_t (*handler)(int, void *, struct pt_regs *), - unsigned long irqflags, const char * devname, void *dev_id) + unsigned long irqflags, const char *devname, void *dev_id) { - struct irqaction * action; + struct irqaction *action; int retval; /* @@ -388,6 +384,5 @@ int request_irq(unsigned int irq, return retval; } - EXPORT_SYMBOL(request_irq); diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c index ea3ceed362d..5eae7bf3c34 100644 --- a/kernel/irq/spurious.c +++ b/kernel/irq/spurious.c @@ -16,22 +16,20 @@ static int irqfixup __read_mostly; /* * Recovery handler for misrouted interrupts. */ - static int misrouted_irq(int irq, struct pt_regs *regs) { int i; - irq_desc_t *desc; int ok = 0; int work = 0; /* Did we do work for a real IRQ */ - for(i = 1; i < NR_IRQS; i++) { + for (i = 1; i < NR_IRQS; i++) { + struct irq_desc *desc = irq_desc + i; struct irqaction *action; if (i == irq) /* Already tried */ continue; - desc = &irq_desc[i]; + spin_lock(&desc->lock); - action = desc->action; /* Already running on another processor */ if (desc->status & IRQ_INPROGRESS) { /* @@ -45,7 +43,9 @@ static int misrouted_irq(int irq, struct pt_regs *regs) } /* Honour the normal IRQ locking */ desc->status |= IRQ_INPROGRESS; + action = desc->action; spin_unlock(&desc->lock); + while (action) { /* Only shared IRQ handlers are safe to call */ if (action->flags & SA_SHIRQ) { @@ -62,9 +62,8 @@ static int misrouted_irq(int irq, struct pt_regs *regs) /* * While we were looking for a fixup someone queued a real - * IRQ clashing with our walk + * IRQ clashing with our walk: */ - while ((desc->status & IRQ_PENDING) && action) { /* * Perform real IRQ processing for the IRQ we deferred @@ -80,7 +79,7 @@ static int misrouted_irq(int irq, struct pt_regs *regs) * If we did actual work for the real IRQ line we must let the * IRQ controller clean up too */ - if(work) + if (work) desc->chip->end(i); spin_unlock(&desc->lock); } @@ -113,6 +112,7 @@ __report_bad_irq(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret) } dump_stack(); printk(KERN_ERR "handlers:\n"); + action = desc->action; while (action) { printk(KERN_ERR "[<%p>]", action->handler); @@ -123,7 +123,8 @@ __report_bad_irq(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret) } } -static void report_bad_irq(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret) +static void +report_bad_irq(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret) { static int count = 100; @@ -134,7 +135,7 @@ static void report_bad_irq(unsigned int irq, irq_desc_t *desc, irqreturn_t actio } void note_interrupt(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret, - struct pt_regs *regs) + struct pt_regs *regs) { if (unlikely(action_ret != IRQ_HANDLED)) { desc->irqs_unhandled++; @@ -177,6 +178,7 @@ int __init noirqdebug_setup(char *str) { noirqdebug = 1; printk(KERN_INFO "IRQ lockup detection disabled\n"); + return 1; } @@ -187,6 +189,7 @@ static int __init irqfixup_setup(char *str) irqfixup = 1; printk(KERN_WARNING "Misrouted IRQ fixup support enabled.\n"); printk(KERN_WARNING "This may impact system performance.\n"); + return 1; } -- cgit v1.2.3-70-g09d2 From 34ffdb7233d5847808d2b63ca6761dac3af9c942 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Thu, 29 Jun 2006 02:24:40 -0700 Subject: [PATCH] genirq: cleanup: reduce irq_desc_t use, mark it obsolete Cleanup: remove irq_desc_t use from the generic IRQ code, and mark it obsolete. Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/irq.h | 18 +++++++++++++----- kernel/irq/autoprobe.c | 6 +++--- kernel/irq/handle.c | 4 ++-- kernel/irq/manage.c | 6 +++--- kernel/irq/migration.c | 4 ++-- kernel/irq/spurious.c | 9 +++++---- 6 files changed, 28 insertions(+), 19 deletions(-) (limited to 'include/linux/irq.h') diff --git a/include/linux/irq.h b/include/linux/irq.h index 92c68541462..9ce276a2374 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -68,7 +68,7 @@ typedef struct hw_interrupt_type hw_irq_controller; * * Pad this out to 32 bytes for cache and indexing reasons. */ -typedef struct irq_desc { +struct irq_desc { hw_irq_controller *chip; void *chip_data; struct irqaction *action; /* IRQ action list */ @@ -83,11 +83,19 @@ typedef struct irq_desc { #if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE) unsigned int move_irq; /* Flag need to re-target intr dest*/ #endif -} ____cacheline_aligned irq_desc_t; +} ____cacheline_aligned; -extern irq_desc_t irq_desc [NR_IRQS]; +extern struct irq_desc irq_desc[NR_IRQS]; -#include /* the arch dependent stuff */ +/* + * Migration helpers for obsolete names, they will go away: + */ +typedef struct irq_desc irq_desc_t; + +/* + * Pick up the arch-dependent methods: + */ +#include extern int setup_irq(unsigned int irq, struct irqaction *new); @@ -188,7 +196,7 @@ extern irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs, */ extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs); -extern void note_interrupt(unsigned int irq, irq_desc_t *desc, +extern void note_interrupt(unsigned int irq, struct irq_desc *desc, int action_ret, struct pt_regs *regs); extern int can_request_irq(unsigned int irq, unsigned long irqflags); diff --git a/kernel/irq/autoprobe.c b/kernel/irq/autoprobe.c index d6eab98a317..5c988bba401 100644 --- a/kernel/irq/autoprobe.c +++ b/kernel/irq/autoprobe.c @@ -27,8 +27,8 @@ static DEFINE_MUTEX(probing_active); */ unsigned long probe_irq_on(void) { + struct irq_desc *desc; unsigned long mask; - irq_desc_t *desc; unsigned int i; mutex_lock(&probing_active); @@ -116,7 +116,7 @@ unsigned int probe_irq_mask(unsigned long val) mask = 0; for (i = 0; i < NR_IRQS; i++) { - irq_desc_t *desc = irq_desc + i; + struct irq_desc *desc = irq_desc + i; unsigned int status; spin_lock_irq(&desc->lock); @@ -159,7 +159,7 @@ int probe_irq_off(unsigned long val) int i, irq_found = 0, nr_irqs = 0; for (i = 0; i < NR_IRQS; i++) { - irq_desc_t *desc = irq_desc + i; + struct irq_desc *desc = irq_desc + i; unsigned int status; spin_lock_irq(&desc->lock); diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c index f9c33a86cbd..8eda1005d10 100644 --- a/kernel/irq/handle.c +++ b/kernel/irq/handle.c @@ -28,7 +28,7 @@ * * Controller mappings for all interrupt sources: */ -irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = { +struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned = { [0 ... NR_IRQS-1] = { .status = IRQ_DISABLED, .chip = &no_irq_type, @@ -110,7 +110,7 @@ irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs, */ fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs) { - irq_desc_t *desc = irq_desc + irq; + struct irq_desc *desc = irq_desc + irq; struct irqaction *action; unsigned int status; diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 261906ebdf0..6a6f1d3dd39 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -57,7 +57,7 @@ EXPORT_SYMBOL(synchronize_irq); */ void disable_irq_nosync(unsigned int irq) { - irq_desc_t *desc = irq_desc + irq; + struct irq_desc *desc = irq_desc + irq; unsigned long flags; if (irq >= NR_IRQS) @@ -86,7 +86,7 @@ EXPORT_SYMBOL(disable_irq_nosync); */ void disable_irq(unsigned int irq) { - irq_desc_t *desc = irq_desc + irq; + struct irq_desc *desc = irq_desc + irq; if (irq >= NR_IRQS) return; @@ -109,7 +109,7 @@ EXPORT_SYMBOL(disable_irq); */ void enable_irq(unsigned int irq) { - irq_desc_t *desc = irq_desc + irq; + struct irq_desc *desc = irq_desc + irq; unsigned long flags; if (irq >= NR_IRQS) diff --git a/kernel/irq/migration.c b/kernel/irq/migration.c index b4a4354d03d..a571c3abb79 100644 --- a/kernel/irq/migration.c +++ b/kernel/irq/migration.c @@ -3,7 +3,7 @@ void set_pending_irq(unsigned int irq, cpumask_t mask) { - irq_desc_t *desc = irq_desc + irq; + struct irq_desc *desc = irq_desc + irq; unsigned long flags; spin_lock_irqsave(&desc->lock, flags); @@ -14,8 +14,8 @@ void set_pending_irq(unsigned int irq, cpumask_t mask) void move_native_irq(int irq) { + struct irq_desc *desc = irq_desc + irq; cpumask_t tmp; - irq_desc_t *desc = irq_desc + irq; if (likely(!desc->move_irq)) return; diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c index 5eae7bf3c34..3a0a6212330 100644 --- a/kernel/irq/spurious.c +++ b/kernel/irq/spurious.c @@ -99,7 +99,8 @@ static int misrouted_irq(int irq, struct pt_regs *regs) */ static void -__report_bad_irq(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret) +__report_bad_irq(unsigned int irq, struct irq_desc *desc, + irqreturn_t action_ret) { struct irqaction *action; @@ -124,7 +125,7 @@ __report_bad_irq(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret) } static void -report_bad_irq(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret) +report_bad_irq(unsigned int irq, struct irq_desc *desc, irqreturn_t action_ret) { static int count = 100; @@ -134,8 +135,8 @@ report_bad_irq(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret) } } -void note_interrupt(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret, - struct pt_regs *regs) +void note_interrupt(unsigned int irq, struct irq_desc *desc, + irqreturn_t action_ret, struct pt_regs *regs) { if (unlikely(action_ret != IRQ_HANDLED)) { desc->irqs_unhandled++; -- cgit v1.2.3-70-g09d2 From 71d218b75fa91219c6bd310fbdd257dfbcac6c88 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Thu, 29 Jun 2006 02:24:41 -0700 Subject: [PATCH] genirq: cleanup: include/linux/irq.h Small cleanups in include/linux/irq.h. Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/irq.h | 56 ++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'include/linux/irq.h') diff --git a/include/linux/irq.h b/include/linux/irq.h index 9ce276a2374..c13f23dee28 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -45,17 +45,17 @@ * to describe about the low-level hardware. */ struct hw_interrupt_type { - const char *typename; - unsigned int (*startup)(unsigned int irq); - void (*shutdown)(unsigned int irq); - void (*enable)(unsigned int irq); - void (*disable)(unsigned int irq); - void (*ack)(unsigned int irq); - void (*end)(unsigned int irq); - void (*set_affinity)(unsigned int irq, cpumask_t dest); + const char *typename; + unsigned int (*startup)(unsigned int irq); + void (*shutdown)(unsigned int irq); + void (*enable)(unsigned int irq); + void (*disable)(unsigned int irq); + void (*ack)(unsigned int irq); + void (*end)(unsigned int irq); + void (*set_affinity)(unsigned int irq, cpumask_t dest); /* Currently used only by UML, might disappear one day.*/ #ifdef CONFIG_IRQ_RELEASE_METHOD - void (*release)(unsigned int irq, void *dev_id); + void (*release)(unsigned int irq, void *dev_id); #endif }; @@ -69,19 +69,19 @@ typedef struct hw_interrupt_type hw_irq_controller; * Pad this out to 32 bytes for cache and indexing reasons. */ struct irq_desc { - hw_irq_controller *chip; - void *chip_data; - struct irqaction *action; /* IRQ action list */ - unsigned int status; /* IRQ status */ - unsigned int depth; /* nested irq disables */ - unsigned int irq_count; /* For detecting broken interrupts */ - unsigned int irqs_unhandled; - spinlock_t lock; + hw_irq_controller *chip; + void *chip_data; + struct irqaction *action; /* IRQ action list */ + unsigned int status; /* IRQ status */ + unsigned int depth; /* nested irq disables */ + unsigned int irq_count; /* For detecting broken IRQs */ + unsigned int irqs_unhandled; + spinlock_t lock; #ifdef CONFIG_SMP - cpumask_t affinity; + cpumask_t affinity; #endif #if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE) - unsigned int move_irq; /* Flag need to re-target intr dest*/ + unsigned int move_irq; /* need to re-target IRQ dest */ #endif } ____cacheline_aligned; @@ -186,6 +186,15 @@ static inline void set_balance_irq_affinity(unsigned int irq, cpumask_t mask) } #endif +#ifdef CONFIG_AUTO_IRQ_AFFINITY +extern int select_smp_affinity(unsigned int irq); +#else +static inline int select_smp_affinity(unsigned int irq) +{ + return 1; +} +#endif + extern int no_irq_affinity; extern int noirqdebug_setup(char *str); @@ -202,15 +211,6 @@ extern int can_request_irq(unsigned int irq, unsigned long irqflags); extern void init_irq_proc(void); -#ifdef CONFIG_AUTO_IRQ_AFFINITY -extern int select_smp_affinity(unsigned int irq); -#else -static inline int select_smp_affinity(unsigned int irq) -{ - return 1; -} -#endif - #endif /* CONFIG_GENERIC_HARDIRQS */ extern hw_irq_controller no_irq_type; /* needed in every arch ? */ -- cgit v1.2.3-70-g09d2 From 4a733ee12618cf3ec25cbc337a5e0ba3ad5d7fb6 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Thu, 29 Jun 2006 02:24:42 -0700 Subject: [PATCH] genirq: cleanup: merge irq_dir[], smp_affinity_entry[] into irq_desc[] Consolidation: remove the irq_dir[NR_IRQS] and the smp_affinity_entry[NR_IRQS] arrays and move them into the irq_desc[] array. Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/irq.h | 5 +++++ kernel/irq/proc.c | 20 +++++++------------- 2 files changed, 12 insertions(+), 13 deletions(-) (limited to 'include/linux/irq.h') diff --git a/include/linux/irq.h b/include/linux/irq.h index c13f23dee28..1022c5d4254 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -61,6 +61,8 @@ struct hw_interrupt_type { typedef struct hw_interrupt_type hw_irq_controller; +struct proc_dir_entry; + /* * This is the "IRQ descriptor", which contains various information * about the irq, including what kind of hardware handling it has, @@ -83,6 +85,9 @@ struct irq_desc { #if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE) unsigned int move_irq; /* need to re-target IRQ dest */ #endif +#ifdef CONFIG_PROC_FS + struct proc_dir_entry *dir; +#endif } ____cacheline_aligned; extern struct irq_desc irq_desc[NR_IRQS]; diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c index 847b98a611e..f60b85b61e8 100644 --- a/kernel/irq/proc.c +++ b/kernel/irq/proc.c @@ -12,15 +12,10 @@ #include "internals.h" -static struct proc_dir_entry *root_irq_dir, *irq_dir[NR_IRQS]; +static struct proc_dir_entry *root_irq_dir; #ifdef CONFIG_SMP -/* - * The /proc/irq//smp_affinity values: - */ -static struct proc_dir_entry *smp_affinity_entry[NR_IRQS]; - #ifdef CONFIG_GENERIC_PENDING_IRQ void proc_set_irq_affinity(unsigned int irq, cpumask_t mask_val) { @@ -102,7 +97,7 @@ void register_handler_proc(unsigned int irq, struct irqaction *action) { char name [MAX_NAMELEN]; - if (!irq_dir[irq] || action->dir || !action->name || + if (!irq_desc[irq].dir || action->dir || !action->name || !name_unique(irq, action)) return; @@ -110,7 +105,7 @@ void register_handler_proc(unsigned int irq, struct irqaction *action) snprintf(name, MAX_NAMELEN, "%s", action->name); /* create /proc/irq/1234/handler/ */ - action->dir = proc_mkdir(name, irq_dir[irq]); + action->dir = proc_mkdir(name, irq_desc[irq].dir); } #undef MAX_NAMELEN @@ -123,21 +118,21 @@ void register_irq_proc(unsigned int irq) if (!root_irq_dir || (irq_desc[irq].chip == &no_irq_type) || - irq_dir[irq]) + irq_desc[irq].dir) return; memset(name, 0, MAX_NAMELEN); sprintf(name, "%d", irq); /* create /proc/irq/1234 */ - irq_dir[irq] = proc_mkdir(name, root_irq_dir); + irq_desc[irq].dir = proc_mkdir(name, root_irq_dir); #ifdef CONFIG_SMP { struct proc_dir_entry *entry; /* create /proc/irq//smp_affinity */ - entry = create_proc_entry("smp_affinity", 0600, irq_dir[irq]); + entry = create_proc_entry("smp_affinity", 0600, irq_desc[irq].dir); if (entry) { entry->nlink = 1; @@ -145,7 +140,6 @@ void register_irq_proc(unsigned int irq) entry->read_proc = irq_affinity_read_proc; entry->write_proc = irq_affinity_write_proc; } - smp_affinity_entry[irq] = entry; } #endif } @@ -155,7 +149,7 @@ void register_irq_proc(unsigned int irq) void unregister_handler_proc(unsigned int irq, struct irqaction *action) { if (action->dir) - remove_proc_entry(action->dir->name, irq_dir[irq]); + remove_proc_entry(action->dir->name, irq_desc[irq].dir); } void init_irq_proc(void) -- cgit v1.2.3-70-g09d2 From cd916d31cc31273eca8a620fae02b7bf7f577559 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Thu, 29 Jun 2006 02:24:42 -0700 Subject: [PATCH] genirq: cleanup: merge pending_irq_cpumask[] into irq_desc[] Consolidation: remove the pending_irq_cpumask[NR_IRQS] array and move it into the irq_desc[NR_IRQS].pending_mask field. Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/io_apic.c | 2 +- include/linux/irq.h | 2 +- kernel/irq/manage.c | 4 ---- kernel/irq/migration.c | 8 ++++---- 4 files changed, 6 insertions(+), 10 deletions(-) (limited to 'include/linux/irq.h') diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c index 4a74b696c6a..afe54f257cb 100644 --- a/arch/i386/kernel/io_apic.c +++ b/arch/i386/kernel/io_apic.c @@ -581,7 +581,7 @@ static int balanced_irq(void *unused) /* push everything to CPU 0 to give us a starting point. */ for (i = 0 ; i < NR_IRQS ; i++) { - pending_irq_cpumask[i] = cpumask_of_cpu(0); + irq_desc[i].pending_mask = cpumask_of_cpu(0); set_pending_irq(i, cpumask_of_cpu(0)); } diff --git a/include/linux/irq.h b/include/linux/irq.h index 1022c5d4254..81f3d976bb3 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -83,6 +83,7 @@ struct irq_desc { cpumask_t affinity; #endif #if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE) + cpumask_t pending_mask; unsigned int move_irq; /* need to re-target IRQ dest */ #endif #ifdef CONFIG_PROC_FS @@ -120,7 +121,6 @@ static inline void set_native_irq_info(int irq, cpumask_t mask) #ifdef CONFIG_SMP #if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE) -extern cpumask_t pending_irq_cpumask[NR_IRQS]; void set_pending_irq(unsigned int irq, cpumask_t mask); void move_native_irq(int irq); diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 6a6f1d3dd39..ca9b5d36abe 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -16,10 +16,6 @@ #ifdef CONFIG_SMP -#if defined (CONFIG_GENERIC_PENDING_IRQ) || defined (CONFIG_IRQBALANCE) -cpumask_t __cacheline_aligned pending_irq_cpumask[NR_IRQS]; -#endif - /** * synchronize_irq - wait for pending IRQ handlers (on other CPUs) * @irq: interrupt number to wait for diff --git a/kernel/irq/migration.c b/kernel/irq/migration.c index a571c3abb79..a57ebe9fa6f 100644 --- a/kernel/irq/migration.c +++ b/kernel/irq/migration.c @@ -8,7 +8,7 @@ void set_pending_irq(unsigned int irq, cpumask_t mask) spin_lock_irqsave(&desc->lock, flags); desc->move_irq = 1; - pending_irq_cpumask[irq] = mask; + irq_desc[irq].pending_mask = mask; spin_unlock_irqrestore(&desc->lock, flags); } @@ -30,7 +30,7 @@ void move_native_irq(int irq) desc->move_irq = 0; - if (unlikely(cpus_empty(pending_irq_cpumask[irq]))) + if (unlikely(cpus_empty(irq_desc[irq].pending_mask))) return; if (!desc->chip->set_affinity) @@ -38,7 +38,7 @@ void move_native_irq(int irq) assert_spin_locked(&desc->lock); - cpus_and(tmp, pending_irq_cpumask[irq], cpu_online_map); + cpus_and(tmp, irq_desc[irq].pending_mask, cpu_online_map); /* * If there was a valid mask to work with, please @@ -58,5 +58,5 @@ void move_native_irq(int irq) if (likely(!(desc->status & IRQ_DISABLED))) desc->chip->enable(irq); } - cpus_clear(pending_irq_cpumask[irq]); + cpus_clear(irq_desc[irq].pending_mask); } -- cgit v1.2.3-70-g09d2 From 0d7012a968d006e277eb0fe20edd7a9b5563c2b7 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Thu, 29 Jun 2006 02:24:43 -0700 Subject: [PATCH] genirq: cleanup: turn ARCH_HAS_IRQ_PER_CPU into CONFIG_IRQ_PER_CPU Cleanup: change ARCH_HAS_IRQ_PER_CPU into a Kconfig method. Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/cris/Kconfig | 4 ++++ arch/ia64/Kconfig | 4 ++++ arch/mips/Kconfig | 5 +++++ arch/parisc/Kconfig | 4 ++++ arch/powerpc/Kconfig | 4 ++++ include/asm-cris/irq.h | 5 ----- include/asm-ia64/irq.h | 5 ----- include/asm-mips/mach-mips/irq.h | 6 ------ include/asm-parisc/irq.h | 5 ----- include/asm-powerpc/irq.h | 5 ----- include/linux/irq.h | 2 +- kernel/irq/manage.c | 4 ++-- 12 files changed, 24 insertions(+), 29 deletions(-) (limited to 'include/linux/irq.h') diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig index 856b665020e..6a1238a29d6 100644 --- a/arch/cris/Kconfig +++ b/arch/cris/Kconfig @@ -28,6 +28,10 @@ config GENERIC_CALIBRATE_DELAY bool default y +config IRQ_PER_CPU + bool + default y + config CRIS bool default y diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 5faacbb8d16..b487e227a1f 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -492,6 +492,10 @@ config GENERIC_PENDING_IRQ depends on GENERIC_HARDIRQS && SMP default y +config IRQ_PER_CPU + bool + default y + source "arch/ia64/hp/sim/Kconfig" menu "Instrumentation Support" diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 35e038a974c..08c2ece4ae4 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -1618,6 +1618,11 @@ config GENERIC_IRQ_PROBE bool default y +config IRQ_PER_CPU + depends on SMP + bool + default y + # # - Highmem only makes sense for the 32-bit kernel. # - The current highmem code will only work properly on physically indexed diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig index 910fb3afc0b..6dd0ea8f88e 100644 --- a/arch/parisc/Kconfig +++ b/arch/parisc/Kconfig @@ -51,6 +51,10 @@ config GENERIC_HARDIRQS config GENERIC_IRQ_PROBE def_bool y +config IRQ_PER_CPU + bool + default y + # unless you want to implement ACPI on PA-RISC ... ;-) config PM bool diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index e2e9df344ab..d43e4521abf 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -30,6 +30,10 @@ config GENERIC_HARDIRQS bool default y +config IRQ_PER_CPU + bool + default y + config RWSEM_GENERIC_SPINLOCK bool diff --git a/include/asm-cris/irq.h b/include/asm-cris/irq.h index 4b338792218..998cce9f320 100644 --- a/include/asm-cris/irq.h +++ b/include/asm-cris/irq.h @@ -1,11 +1,6 @@ #ifndef _ASM_IRQ_H #define _ASM_IRQ_H -/* - * IRQ line status macro IRQ_PER_CPU is used - */ -#define ARCH_HAS_IRQ_PER_CPU - #include static inline int irq_canonicalize(int irq) diff --git a/include/asm-ia64/irq.h b/include/asm-ia64/irq.h index dbe86c0bbce..79479e2c696 100644 --- a/include/asm-ia64/irq.h +++ b/include/asm-ia64/irq.h @@ -14,11 +14,6 @@ #define NR_IRQS 256 #define NR_IRQ_VECTORS NR_IRQS -/* - * IRQ line status macro IRQ_PER_CPU is used - */ -#define ARCH_HAS_IRQ_PER_CPU - static __inline__ int irq_canonicalize (int irq) { diff --git a/include/asm-mips/mach-mips/irq.h b/include/asm-mips/mach-mips/irq.h index 083d9c512a0..e994b0c0122 100644 --- a/include/asm-mips/mach-mips/irq.h +++ b/include/asm-mips/mach-mips/irq.h @@ -4,10 +4,4 @@ #define NR_IRQS 256 -#ifdef CONFIG_SMP - -#define ARCH_HAS_IRQ_PER_CPU - -#endif - #endif /* __ASM_MACH_MIPS_IRQ_H */ diff --git a/include/asm-parisc/irq.h b/include/asm-parisc/irq.h index 377ba90c7d0..5cae260615a 100644 --- a/include/asm-parisc/irq.h +++ b/include/asm-parisc/irq.h @@ -26,11 +26,6 @@ #define NR_IRQS (CPU_IRQ_MAX + 1) -/* - * IRQ line status macro IRQ_PER_CPU is used - */ -#define ARCH_HAS_IRQ_PER_CPU - static __inline__ int irq_canonicalize(int irq) { return (irq == 2) ? 9 : irq; diff --git a/include/asm-powerpc/irq.h b/include/asm-powerpc/irq.h index a10feec29d4..eb5f33e1977 100644 --- a/include/asm-powerpc/irq.h +++ b/include/asm-powerpc/irq.h @@ -30,11 +30,6 @@ #define IRQ_POLARITY_POSITIVE 0x2 /* high level or low->high edge */ #define IRQ_POLARITY_NEGATIVE 0x0 /* low level or high->low edge */ -/* - * IRQ line status macro IRQ_PER_CPU is used - */ -#define ARCH_HAS_IRQ_PER_CPU - #define get_irq_desc(irq) (&irq_desc[(irq)]) /* Define a way to iterate across irqs. */ diff --git a/include/linux/irq.h b/include/linux/irq.h index 81f3d976bb3..519a1cb7c33 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -33,7 +33,7 @@ #define IRQ_WAITING 32 /* IRQ not yet seen - for autodetection */ #define IRQ_LEVEL 64 /* IRQ level triggered */ #define IRQ_MASKED 128 /* IRQ masked - shouldn't be seen again */ -#ifdef ARCH_HAS_IRQ_PER_CPU +#ifdef CONFIG_IRQ_PER_CPU # define IRQ_PER_CPU 256 /* IRQ is per CPU */ # define CHECK_IRQ_PER_CPU(var) ((var) & IRQ_PER_CPU) #else diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index ca9b5d36abe..8389d1817fe 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -198,7 +198,7 @@ int setup_irq(unsigned int irq, struct irqaction *new) if (!(old->flags & new->flags & SA_SHIRQ)) goto mismatch; -#if defined(ARCH_HAS_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ) +#if defined(CONFIG_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ) /* All handlers must agree on per-cpuness */ if ((old->flags & IRQ_PER_CPU) != (new->flags & IRQ_PER_CPU)) goto mismatch; @@ -213,7 +213,7 @@ int setup_irq(unsigned int irq, struct irqaction *new) } *p = new; -#if defined(ARCH_HAS_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ) +#if defined(CONFIG_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ) if (new->flags & SA_PERCPU_IRQ) desc->status |= IRQ_PER_CPU; #endif -- cgit v1.2.3-70-g09d2 From c0ad90a32fb60f4129d0e24dfd5fd7128e2e09f2 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Thu, 29 Jun 2006 02:24:44 -0700 Subject: [PATCH] genirq: add ->retrigger() irq op to consolidate hw_irq_resend() Add ->retrigger() irq op to consolidate hw_irq_resend() implementations. (Most architectures had it defined to NOP anyway.) NOTE: ia64 needs testing. i386 and x86_64 tested. Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/io_apic.c | 9 +++++++++ arch/ia64/kernel/irq_lsapic.c | 10 +++++++++- arch/ia64/kernel/perfmon.c | 4 ++-- arch/parisc/kernel/irq.c | 11 ++++------- arch/x86_64/kernel/io_apic.c | 9 +++++++++ include/asm-alpha/hw_irq.h | 2 -- include/asm-cris/hw_irq.h | 2 -- include/asm-i386/hw_irq.h | 10 ---------- include/asm-ia64/hw_irq.h | 3 +-- include/asm-m32r/hw_irq.h | 5 ----- include/asm-mips/hw_irq.h | 8 ++++---- include/asm-parisc/hw_irq.h | 9 --------- include/asm-powerpc/hw_irq.h | 6 +++--- include/asm-sh/hw_irq.h | 5 ----- include/asm-sh64/hw_irq.h | 1 - include/asm-um/hw_irq.h | 3 --- include/asm-v850/hw_irq.h | 4 ---- include/asm-x86_64/hw_irq.h | 9 --------- include/asm-xtensa/hw_irq.h | 4 ---- include/linux/irq.h | 2 ++ kernel/irq/manage.c | 3 ++- 21 files changed, 45 insertions(+), 74 deletions(-) (limited to 'include/linux/irq.h') diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c index afe54f257cb..ec9ea0269d3 100644 --- a/arch/i386/kernel/io_apic.c +++ b/arch/i386/kernel/io_apic.c @@ -2071,6 +2071,13 @@ static void set_ioapic_affinity_vector (unsigned int vector, #endif #endif +static int ioapic_retrigger(unsigned int irq) +{ + send_IPI_self(IO_APIC_VECTOR(irq)); + + return 1; +} + /* * Level and edge triggered IO-APIC interrupts need different handling, * so we use two separate IRQ descriptors. Edge triggered IRQs can be @@ -2090,6 +2097,7 @@ static struct hw_interrupt_type ioapic_edge_type __read_mostly = { #ifdef CONFIG_SMP .set_affinity = set_ioapic_affinity, #endif + .retrigger = ioapic_retrigger, }; static struct hw_interrupt_type ioapic_level_type __read_mostly = { @@ -2103,6 +2111,7 @@ static struct hw_interrupt_type ioapic_level_type __read_mostly = { #ifdef CONFIG_SMP .set_affinity = set_ioapic_affinity, #endif + .retrigger = ioapic_retrigger, }; static inline void init_IO_APIC_traps(void) diff --git a/arch/ia64/kernel/irq_lsapic.c b/arch/ia64/kernel/irq_lsapic.c index ea14e6a0440..1ab58b09f3d 100644 --- a/arch/ia64/kernel/irq_lsapic.c +++ b/arch/ia64/kernel/irq_lsapic.c @@ -26,6 +26,13 @@ lsapic_noop (unsigned int irq) /* nuthing to do... */ } +static int lsapic_retrigger(unsigned int irq) +{ + ia64_resend_irq(irq); + + return 1; +} + struct hw_interrupt_type irq_type_ia64_lsapic = { .typename = "LSAPIC", .startup = lsapic_noop_startup, @@ -33,5 +40,6 @@ struct hw_interrupt_type irq_type_ia64_lsapic = { .enable = lsapic_noop, .disable = lsapic_noop, .ack = lsapic_noop, - .end = lsapic_noop + .end = lsapic_noop, + .retrigger = lsapic_retrigger, }; diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c index 6d7bc8ff7b3..a0055d3d695 100644 --- a/arch/ia64/kernel/perfmon.c +++ b/arch/ia64/kernel/perfmon.c @@ -6165,7 +6165,7 @@ pfm_load_regs (struct task_struct *task) /* * will replay the PMU interrupt */ - if (need_irq_resend) hw_resend_irq(NULL, IA64_PERFMON_VECTOR); + if (need_irq_resend) ia64_resend_irq(IA64_PERFMON_VECTOR); pfm_stats[smp_processor_id()].pfm_replay_ovfl_intr_count++; } @@ -6305,7 +6305,7 @@ pfm_load_regs (struct task_struct *task) /* * will replay the PMU interrupt */ - if (need_irq_resend) hw_resend_irq(NULL, IA64_PERFMON_VECTOR); + if (need_irq_resend) ia64_resend_irq(IA64_PERFMON_VECTOR); pfm_stats[smp_processor_id()].pfm_replay_ovfl_intr_count++; } diff --git a/arch/parisc/kernel/irq.c b/arch/parisc/kernel/irq.c index ea6a55e1a0c..82fe6ba2972 100644 --- a/arch/parisc/kernel/irq.c +++ b/arch/parisc/kernel/irq.c @@ -125,6 +125,10 @@ static struct hw_interrupt_type cpu_interrupt_type = { #ifdef CONFIG_SMP .set_affinity = cpu_set_affinity_irq, #endif + /* XXX: Needs to be written. We managed without it so far, but + * we really ought to write it. + */ + .retrigger = NULL, }; int show_interrupts(struct seq_file *p, void *v) @@ -404,13 +408,6 @@ void __init init_IRQ(void) } -void hw_resend_irq(struct hw_interrupt_type *type, unsigned int irq) -{ - /* XXX: Needs to be written. We managed without it so far, but - * we really ought to write it. - */ -} - void ack_bad_irq(unsigned int irq) { printk("unexpected IRQ %d\n", irq); diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c index 88a8736eb8c..401b687fef2 100644 --- a/arch/x86_64/kernel/io_apic.c +++ b/arch/x86_64/kernel/io_apic.c @@ -1618,6 +1618,13 @@ static void set_ioapic_affinity_vector (unsigned int vector, #endif // CONFIG_SMP #endif // CONFIG_PCI_MSI +static int ioapic_retrigger(unsigned int irq) +{ + send_IPI_self(IO_APIC_VECTOR(irq)); + + return 1; +} + /* * Level and edge triggered IO-APIC interrupts need different handling, * so we use two separate IRQ descriptors. Edge triggered IRQs can be @@ -1638,6 +1645,7 @@ static struct hw_interrupt_type ioapic_edge_type __read_mostly = { #ifdef CONFIG_SMP .set_affinity = set_ioapic_affinity, #endif + .retrigger = ioapic_retrigger, }; static struct hw_interrupt_type ioapic_level_type __read_mostly = { @@ -1651,6 +1659,7 @@ static struct hw_interrupt_type ioapic_level_type __read_mostly = { #ifdef CONFIG_SMP .set_affinity = set_ioapic_affinity, #endif + .retrigger = ioapic_retrigger, }; static inline void init_IO_APIC_traps(void) diff --git a/include/asm-alpha/hw_irq.h b/include/asm-alpha/hw_irq.h index ca9d43b6350..a37db0f9509 100644 --- a/include/asm-alpha/hw_irq.h +++ b/include/asm-alpha/hw_irq.h @@ -2,8 +2,6 @@ #define _ALPHA_HW_IRQ_H -static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) {} - extern volatile unsigned long irq_err_count; #ifdef CONFIG_ALPHA_GENERIC diff --git a/include/asm-cris/hw_irq.h b/include/asm-cris/hw_irq.h index 341536a234e..298066020af 100644 --- a/include/asm-cris/hw_irq.h +++ b/include/asm-cris/hw_irq.h @@ -1,7 +1,5 @@ #ifndef _ASM_HW_IRQ_H #define _ASM_HW_IRQ_H -static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) {} - #endif diff --git a/include/asm-i386/hw_irq.h b/include/asm-i386/hw_irq.h index a4c0a5a9ffd..87e5a351d88 100644 --- a/include/asm-i386/hw_irq.h +++ b/include/asm-i386/hw_irq.h @@ -69,14 +69,4 @@ extern atomic_t irq_mis_count; #define IO_APIC_IRQ(x) (((x) >= 16) || ((1<<(x)) & io_apic_irqs)) -#if defined(CONFIG_X86_IO_APIC) -static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) -{ - if (IO_APIC_IRQ(i)) - send_IPI_self(IO_APIC_VECTOR(i)); -} -#else -static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) {} -#endif - #endif /* _ASM_HW_IRQ_H */ diff --git a/include/asm-ia64/hw_irq.h b/include/asm-ia64/hw_irq.h index ea8b8c407ab..27f9df6b914 100644 --- a/include/asm-ia64/hw_irq.h +++ b/include/asm-ia64/hw_irq.h @@ -97,8 +97,7 @@ extern int reserve_irq_vector (int vector); extern void ia64_send_ipi (int cpu, int vector, int delivery_mode, int redirect); extern void register_percpu_irq (ia64_vector vec, struct irqaction *action); -static inline void -hw_resend_irq (struct hw_interrupt_type *h, unsigned int vector) +static inline void ia64_resend_irq(unsigned int vector) { platform_send_ipi(smp_processor_id(), vector, IA64_IPI_DM_INT, 0); } diff --git a/include/asm-m32r/hw_irq.h b/include/asm-m32r/hw_irq.h index 8d7e9d0e09e..7138537cda0 100644 --- a/include/asm-m32r/hw_irq.h +++ b/include/asm-m32r/hw_irq.h @@ -1,9 +1,4 @@ #ifndef _ASM_M32R_HW_IRQ_H #define _ASM_M32R_HW_IRQ_H -static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) -{ - /* Nothing to do */ -} - #endif /* _ASM_M32R_HW_IRQ_H */ diff --git a/include/asm-mips/hw_irq.h b/include/asm-mips/hw_irq.h index c854d017c0e..458d9fdc76b 100644 --- a/include/asm-mips/hw_irq.h +++ b/include/asm-mips/hw_irq.h @@ -19,9 +19,9 @@ extern void init_8259A(int aeoi); extern atomic_t irq_err_count; -/* This may not be apropriate for all machines, we'll see ... */ -static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) -{ -} +/* + * interrupt-retrigger: NOP for now. This may not be apropriate for all + * machines, we'll see ... + */ #endif /* __ASM_HW_IRQ_H */ diff --git a/include/asm-parisc/hw_irq.h b/include/asm-parisc/hw_irq.h index 151426e2752..6707f7df392 100644 --- a/include/asm-parisc/hw_irq.h +++ b/include/asm-parisc/hw_irq.h @@ -3,15 +3,6 @@ /* * linux/include/asm/hw_irq.h - * - * (C) 1992, 1993 Linus Torvalds, (C) 1997 Ingo Molnar - * - * moved some of the old arch/i386/kernel/irq.h to here. VY - * - * IRQ/IPI changes taken from work by Thomas Radke - * */ -extern void hw_resend_irq(struct hw_interrupt_type *, unsigned int); - #endif diff --git a/include/asm-powerpc/hw_irq.h b/include/asm-powerpc/hw_irq.h index a27ed3feb31..d40359204ab 100644 --- a/include/asm-powerpc/hw_irq.h +++ b/include/asm-powerpc/hw_irq.h @@ -102,11 +102,11 @@ static inline void local_irq_save_ptr(unsigned long *flags) desc->chip->ack(irq); \ }) -/* Should we handle this via lost interrupts and IPIs or should we don't care like - * we do now ? --BenH. +/* + * interrupt-retrigger: should we handle this via lost interrupts and IPIs + * or should we not care like we do now ? --BenH. */ struct hw_interrupt_type; -static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) {} #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_HW_IRQ_H */ diff --git a/include/asm-sh/hw_irq.h b/include/asm-sh/hw_irq.h index 1d934fb2c58..fed26616967 100644 --- a/include/asm-sh/hw_irq.h +++ b/include/asm-sh/hw_irq.h @@ -1,9 +1,4 @@ #ifndef __ASM_SH_HW_IRQ_H #define __ASM_SH_HW_IRQ_H -static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) -{ - /* Nothing to do */ -} - #endif /* __ASM_SH_HW_IRQ_H */ diff --git a/include/asm-sh64/hw_irq.h b/include/asm-sh64/hw_irq.h index ae718d1f2d6..ebb39089b0a 100644 --- a/include/asm-sh64/hw_irq.h +++ b/include/asm-sh64/hw_irq.h @@ -11,6 +11,5 @@ * Copyright (C) 2000, 2001 Paolo Alberelli * */ -static __inline__ void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) { /* Nothing to do */ } #endif /* __ASM_SH64_HW_IRQ_H */ diff --git a/include/asm-um/hw_irq.h b/include/asm-um/hw_irq.h index 4ee38c0b6a6..1cf84cf5f21 100644 --- a/include/asm-um/hw_irq.h +++ b/include/asm-um/hw_irq.h @@ -4,7 +4,4 @@ #include "asm/irq.h" #include "asm/archparam.h" -static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) -{} - #endif diff --git a/include/asm-v850/hw_irq.h b/include/asm-v850/hw_irq.h index a8aab434271..043e94bb6bd 100644 --- a/include/asm-v850/hw_irq.h +++ b/include/asm-v850/hw_irq.h @@ -1,8 +1,4 @@ #ifndef __V850_HW_IRQ_H__ #define __V850_HW_IRQ_H__ -static inline void hw_resend_irq (struct hw_interrupt_type *h, unsigned int i) -{ -} - #endif /* __V850_HW_IRQ_H__ */ diff --git a/include/asm-x86_64/hw_irq.h b/include/asm-x86_64/hw_irq.h index 93187746278..48a4a5364e8 100644 --- a/include/asm-x86_64/hw_irq.h +++ b/include/asm-x86_64/hw_irq.h @@ -127,15 +127,6 @@ __asm__( \ "push $~(" #nr ") ; " \ "jmp common_interrupt"); -#if defined(CONFIG_X86_IO_APIC) -static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) { - if (IO_APIC_IRQ(i)) - send_IPI_self(IO_APIC_VECTOR(i)); -} -#else -static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) {} -#endif - #define platform_legacy_irq(irq) ((irq) < 16) #endif diff --git a/include/asm-xtensa/hw_irq.h b/include/asm-xtensa/hw_irq.h index ccf436249ea..3ddbea759b2 100644 --- a/include/asm-xtensa/hw_irq.h +++ b/include/asm-xtensa/hw_irq.h @@ -11,8 +11,4 @@ #ifndef _XTENSA_HW_IRQ_H #define _XTENSA_HW_IRQ_H -static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) -{ -} - #endif diff --git a/include/linux/irq.h b/include/linux/irq.h index 519a1cb7c33..e58cfb9c66a 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -53,6 +53,8 @@ struct hw_interrupt_type { void (*ack)(unsigned int irq); void (*end)(unsigned int irq); void (*set_affinity)(unsigned int irq, cpumask_t dest); + int (*retrigger)(unsigned int irq); + /* Currently used only by UML, might disappear one day.*/ #ifdef CONFIG_IRQ_RELEASE_METHOD void (*release)(unsigned int irq, void *dev_id); diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 76c8eda6729..19b438e09f1 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -123,7 +123,8 @@ void enable_irq(unsigned int irq) desc->status = status; if ((status & (IRQ_PENDING | IRQ_REPLAY)) == IRQ_PENDING) { desc->status = status | IRQ_REPLAY; - hw_resend_irq(desc->chip,irq); + if (desc->chip && desc->chip->retrigger) + desc->chip->retrigger(irq); } desc->chip->enable(irq); /* fall-through */ -- cgit v1.2.3-70-g09d2 From 8fee5c36177ee098fa41f5fe72999609fef4df6b Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Thu, 29 Jun 2006 02:24:45 -0700 Subject: [PATCH] genirq: doc: comment include/linux/irq.h structures Better document the hw_interrupt_type and irq_desc structures. Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/irq.h | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) (limited to 'include/linux/irq.h') diff --git a/include/linux/irq.h b/include/linux/irq.h index e58cfb9c66a..b2688157b51 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -40,9 +40,27 @@ # define CHECK_IRQ_PER_CPU(var) 0 #endif -/* - * Interrupt controller descriptor. This is all we need - * to describe about the low-level hardware. +/** + * struct hw_interrupt_type - hardware interrupt type descriptor + * + * @name: name for /proc/interrupts + * @startup: start up the interrupt (defaults to ->enable if NULL) + * @shutdown: shut down the interrupt (defaults to ->disable if NULL) + * @enable: enable the interrupt (defaults to chip->unmask if NULL) + * @disable: disable the interrupt (defaults to chip->mask if NULL) + * @handle_irq: irq flow handler called from the arch IRQ glue code + * @ack: start of a new interrupt + * @mask: mask an interrupt source + * @mask_ack: ack and mask an interrupt source + * @unmask: unmask an interrupt source + * @hold: same interrupt while the handler is running + * @end: end of interrupt + * @set_affinity: set the CPU affinity on SMP machines + * @retrigger: resend an IRQ to the CPU + * @set_type: set the flow type (IRQ_TYPE_LEVEL/etc.) of an IRQ + * @set_wake: enable/disable power-management wake-on of an IRQ + * + * @release: release function solely used by UML */ struct hw_interrupt_type { const char *typename; @@ -65,10 +83,22 @@ typedef struct hw_interrupt_type hw_irq_controller; struct proc_dir_entry; -/* - * This is the "IRQ descriptor", which contains various information - * about the irq, including what kind of hardware handling it has, - * whether it is disabled etc etc. +/** + * struct irq_desc - interrupt descriptor + * + * @handler: interrupt type dependent handler functions + * @handler_data: data for the type handlers + * @action: the irq action chain + * @status: status information + * @depth: disable-depth, for nested irq_disable() calls + * @irq_count: stats field to detect stalled irqs + * @irqs_unhandled: stats field for spurious unhandled interrupts + * @lock: locking for SMP + * @affinity: IRQ affinity on SMP + * @pending_mask: pending rebalanced interrupts + * @move_irq: need to re-target IRQ destination + * @dir: /proc/irq/ procfs entry + * @affinity_entry: /proc/irq/smp_affinity procfs entry on SMP * * Pad this out to 32 bytes for cache and indexing reasons. */ -- cgit v1.2.3-70-g09d2 From a4633adcdbc15ac51afcd0e1395de58cee27cf92 Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Thu, 29 Jun 2006 02:24:48 -0700 Subject: [PATCH] genirq: add genirq sw IRQ-retrigger Enable platforms that do not have a hardware-assisted hardirq-resend mechanism to resend them via a softirq-driven IRQ emulation mechanism. Signed-off-by: Thomas Gleixner Signed-off-by: Ingo Molnar Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/irq.h | 3 +++ kernel/irq/Makefile | 2 +- kernel/irq/manage.c | 10 +------ kernel/irq/resend.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 10 deletions(-) create mode 100644 kernel/irq/resend.c (limited to 'include/linux/irq.h') diff --git a/include/linux/irq.h b/include/linux/irq.h index b2688157b51..9a39756bfd3 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -246,6 +246,9 @@ extern void note_interrupt(unsigned int irq, struct irq_desc *desc, int action_ret, struct pt_regs *regs); extern int can_request_irq(unsigned int irq, unsigned long irqflags); +/* Resending of interrupts :*/ +void check_irq_resend(struct irq_desc *desc, unsigned int irq); + extern void init_irq_proc(void); #endif /* CONFIG_GENERIC_HARDIRQS */ diff --git a/kernel/irq/Makefile b/kernel/irq/Makefile index 9f77f50d814..627ace98d4a 100644 --- a/kernel/irq/Makefile +++ b/kernel/irq/Makefile @@ -1,5 +1,5 @@ -obj-y := handle.o manage.o spurious.o +obj-y := handle.o manage.o spurious.o resend.o obj-$(CONFIG_GENERIC_IRQ_PROBE) += autoprobe.o obj-$(CONFIG_PROC_FS) += proc.o obj-$(CONFIG_GENERIC_PENDING_IRQ) += migration.o diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 19b438e09f1..cffde484389 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -118,15 +118,7 @@ void enable_irq(unsigned int irq) WARN_ON(1); break; case 1: { - unsigned int status = desc->status & ~IRQ_DISABLED; - - desc->status = status; - if ((status & (IRQ_PENDING | IRQ_REPLAY)) == IRQ_PENDING) { - desc->status = status | IRQ_REPLAY; - if (desc->chip && desc->chip->retrigger) - desc->chip->retrigger(irq); - } - desc->chip->enable(irq); + check_irq_resend(desc, irq); /* fall-through */ } default: diff --git a/kernel/irq/resend.c b/kernel/irq/resend.c new file mode 100644 index 00000000000..096b102fb39 --- /dev/null +++ b/kernel/irq/resend.c @@ -0,0 +1,78 @@ +/* + * linux/kernel/irq/resend.c + * + * Copyright (C) 1992, 1998-2006 Linus Torvalds, Ingo Molnar + * Copyright (C) 2005-2006, Thomas Gleixner + * + * This file contains the IRQ-resend code + * + * If the interrupt is waiting to be processed, we try to re-run it. + * We can't directly run it from here since the caller might be in an + * interrupt-protected region. Not all irq controller chips can + * retrigger interrupts at the hardware level, so in those cases + * we allow the resending of IRQs via a tasklet. + */ + +#include +#include +#include +#include + +#include "internals.h" + +#ifdef CONFIG_HARDIRQS_SW_RESEND + +/* Bitmap to handle software resend of interrupts: */ +static DECLARE_BITMAP(irqs_resend, NR_IRQS); + +/* + * Run software resends of IRQ's + */ +static void resend_irqs(unsigned long arg) +{ + struct irq_desc *desc; + int irq; + + while (!bitmap_empty(irqs_resend, NR_IRQS)) { + irq = find_first_bit(irqs_resend, NR_IRQS); + clear_bit(irq, irqs_resend); + desc = irq_desc + irq; + spin_lock_irqsave(&desc->lock, flags); + desc->handle_irq(irq, desc, NULL); + spin_unlock_irqrestore(&desc->lock, flags); + } +} + +/* Tasklet to handle resend: */ +static DECLARE_TASKLET(resend_tasklet, resend_irqs, 0); + +#endif + +/* + * IRQ resend + * + * Is called with interrupts disabled and desc->lock held. + */ +void check_irq_resend(struct irq_desc *desc, unsigned int irq) +{ + unsigned int status = desc->status; + + /* + * Make sure the interrupt is enabled, before resending it: + */ + desc->chip->enable(irq); + + if ((status & (IRQ_PENDING | IRQ_REPLAY)) == IRQ_PENDING) { + desc->status &= ~IRQ_PENDING; + desc->status = status | IRQ_REPLAY; + + if (!desc->chip || !desc->chip->retrigger || + !desc->chip->retrigger(irq)) { +#ifdef CONFIG_HARDIRQS_SW_RESEND + /* Set it pending and activate the softirq: */ + set_bit(irq, irqs_resend); + tasklet_schedule(&resend_tasklet); +#endif + } + } +} -- cgit v1.2.3-70-g09d2 From 3418d72404e35eb19e7995cbf3e7a76ba8fefbce Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Thu, 29 Jun 2006 02:24:49 -0700 Subject: [PATCH] genirq: add IRQ_NOPROBE support Introduce IRQ_NOPROBE: enables platforms to control chip-probing. Signed-off-by: Thomas Gleixner Signed-off-by: Ingo Molnar Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/irq.h | 1 + kernel/irq/autoprobe.c | 4 ++-- kernel/irq/manage.c | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'include/linux/irq.h') diff --git a/include/linux/irq.h b/include/linux/irq.h index 9a39756bfd3..b2fcf330cf2 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -40,6 +40,7 @@ # define CHECK_IRQ_PER_CPU(var) 0 #endif +#define IRQ_NOPROBE 512 /* IRQ is not valid for probing */ /** * struct hw_interrupt_type - hardware interrupt type descriptor * diff --git a/kernel/irq/autoprobe.c b/kernel/irq/autoprobe.c index 5c988bba401..ed98c7d46cf 100644 --- a/kernel/irq/autoprobe.c +++ b/kernel/irq/autoprobe.c @@ -40,7 +40,7 @@ unsigned long probe_irq_on(void) desc = irq_desc + i; spin_lock_irq(&desc->lock); - if (!desc->action) + if (!desc->action && !(desc->status & IRQ_NOPROBE)) desc->chip->startup(i); spin_unlock_irq(&desc->lock); } @@ -57,7 +57,7 @@ unsigned long probe_irq_on(void) desc = irq_desc + i; spin_lock_irq(&desc->lock); - if (!desc->action) { + if (!desc->action && !(desc->status & IRQ_NOPROBE)) { desc->status |= IRQ_AUTODETECT | IRQ_WAITING; if (desc->chip->startup(i)) desc->status |= IRQ_PENDING; diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index cffde484389..90a944a7fad 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -118,6 +118,10 @@ void enable_irq(unsigned int irq) WARN_ON(1); break; case 1: { + unsigned int status = desc->status & ~IRQ_DISABLED; + + /* Prevent probing on this irq: */ + desc->status = status | IRQ_NOPROBE; check_irq_resend(desc, irq); /* fall-through */ } -- cgit v1.2.3-70-g09d2 From 6550c775cb5ee94c132d93d84de3bb23f0abf37b Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Thu, 29 Jun 2006 02:24:49 -0700 Subject: [PATCH] genirq: add IRQ_NOREQUEST support Enable platforms to disable request_irq() for certain interrupts. Signed-off-by: Thomas Gleixner Signed-off-by: Ingo Molnar Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/irq.h | 1 + kernel/irq/manage.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'include/linux/irq.h') diff --git a/include/linux/irq.h b/include/linux/irq.h index b2fcf330cf2..1df49ec7f82 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -41,6 +41,7 @@ #endif #define IRQ_NOPROBE 512 /* IRQ is not valid for probing */ +#define IRQ_NOREQUEST 1024 /* IRQ cannot be requested */ /** * struct hw_interrupt_type - hardware interrupt type descriptor * diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 90a944a7fad..cae900a849c 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -141,7 +141,7 @@ int can_request_irq(unsigned int irq, unsigned long irqflags) { struct irqaction *action; - if (irq >= NR_IRQS) + if (irq >= NR_IRQS || irq_desc[irq].status & IRQ_NOREQUEST) return 0; action = irq_desc[irq].action; @@ -356,6 +356,8 @@ int request_irq(unsigned int irq, return -EINVAL; if (irq >= NR_IRQS) return -EINVAL; + if (irq_desc[irq].status & IRQ_NOREQUEST) + return -EINVAL; if (!handler) return -EINVAL; -- cgit v1.2.3-70-g09d2 From 94d39e1f6e8132ea982a1d61acbe0423d3d14365 Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Thu, 29 Jun 2006 02:24:50 -0700 Subject: [PATCH] genirq: add IRQ_NOAUTOEN support Enable platforms to disable the automatic enabling of freshly set up irqs. Signed-off-by: Thomas Gleixner Signed-off-by: Ingo Molnar Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/irq.h | 1 + kernel/irq/handle.c | 1 + kernel/irq/manage.c | 18 +++++++++++------- 3 files changed, 13 insertions(+), 7 deletions(-) (limited to 'include/linux/irq.h') diff --git a/include/linux/irq.h b/include/linux/irq.h index 1df49ec7f82..14d7e94048d 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -42,6 +42,7 @@ #define IRQ_NOPROBE 512 /* IRQ is not valid for probing */ #define IRQ_NOREQUEST 1024 /* IRQ cannot be requested */ +#define IRQ_NOAUTOEN 2048 /* IRQ will not be enabled on request irq */ /** * struct hw_interrupt_type - hardware interrupt type descriptor * diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c index 402fa3aec1e..9b398d52f1b 100644 --- a/kernel/irq/handle.c +++ b/kernel/irq/handle.c @@ -32,6 +32,7 @@ struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned = { [0 ... NR_IRQS-1] = { .status = IRQ_DISABLED, .chip = &no_irq_type, + .depth = 1, .lock = SPIN_LOCK_UNLOCKED, #ifdef CONFIG_SMP .affinity = CPU_MASK_ALL diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index cae900a849c..9ea18879fb6 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -216,13 +216,17 @@ int setup_irq(unsigned int irq, struct irqaction *new) desc->status |= IRQ_PER_CPU; #endif if (!shared) { - desc->depth = 0; - desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT | - IRQ_WAITING | IRQ_INPROGRESS); - if (desc->chip->startup) - desc->chip->startup(irq); - else - desc->chip->enable(irq); + desc->status &= ~(IRQ_AUTODETECT | IRQ_WAITING | + IRQ_INPROGRESS); + + if (!(desc->status & IRQ_NOAUTOEN)) { + desc->depth = 0; + desc->status &= ~IRQ_DISABLED; + if (desc->chip->startup) + desc->chip->startup(irq); + else + desc->chip->enable(irq); + } } spin_unlock_irqrestore(&desc->lock, flags); -- cgit v1.2.3-70-g09d2 From 6a6de9ef5850d063c3d3fb50784bfe3a6d0712c6 Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Thu, 29 Jun 2006 02:24:51 -0700 Subject: [PATCH] genirq: core Core genirq support: add the irq-chip and irq-flow abstractions. Signed-off-by: Thomas Gleixner Signed-off-by: Ingo Molnar Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/irq.h | 160 +++++++++++++++++++++++++++++++++++++++++++------ kernel/irq/autoprobe.c | 9 ++- kernel/irq/handle.c | 10 ++++ kernel/irq/internals.h | 6 ++ kernel/irq/manage.c | 14 +++++ kernel/irq/resend.c | 4 +- kernel/irq/spurious.c | 1 + 7 files changed, 182 insertions(+), 22 deletions(-) (limited to 'include/linux/irq.h') diff --git a/include/linux/irq.h b/include/linux/irq.h index 14d7e94048d..437f2c635db 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -43,20 +43,36 @@ #define IRQ_NOPROBE 512 /* IRQ is not valid for probing */ #define IRQ_NOREQUEST 1024 /* IRQ cannot be requested */ #define IRQ_NOAUTOEN 2048 /* IRQ will not be enabled on request irq */ +#define IRQ_DELAYED_DISABLE \ + 4096 /* IRQ disable (masking) happens delayed. */ + +/* + * IRQ types, see also include/linux/interrupt.h + */ +#define IRQ_TYPE_NONE 0x0000 /* Default, unspecified type */ +#define IRQ_TYPE_EDGE_RISING 0x0001 /* Edge rising type */ +#define IRQ_TYPE_EDGE_FALLING 0x0002 /* Edge falling type */ +#define IRQ_TYPE_EDGE_BOTH (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING) +#define IRQ_TYPE_LEVEL_HIGH 0x0004 /* Level high type */ +#define IRQ_TYPE_LEVEL_LOW 0x0008 /* Level low type */ +#define IRQ_TYPE_SIMPLE 0x0010 /* Simple type */ +#define IRQ_TYPE_PERCPU 0x0020 /* Per CPU type */ +#define IRQ_TYPE_PROBE 0x0040 /* Probing in progress */ + +struct proc_dir_entry; + /** - * struct hw_interrupt_type - hardware interrupt type descriptor + * struct irq_chip - hardware interrupt chip descriptor * * @name: name for /proc/interrupts * @startup: start up the interrupt (defaults to ->enable if NULL) * @shutdown: shut down the interrupt (defaults to ->disable if NULL) * @enable: enable the interrupt (defaults to chip->unmask if NULL) * @disable: disable the interrupt (defaults to chip->mask if NULL) - * @handle_irq: irq flow handler called from the arch IRQ glue code * @ack: start of a new interrupt * @mask: mask an interrupt source * @mask_ack: ack and mask an interrupt source * @unmask: unmask an interrupt source - * @hold: same interrupt while the handler is running * @end: end of interrupt * @set_affinity: set the CPU affinity on SMP machines * @retrigger: resend an IRQ to the CPU @@ -64,33 +80,45 @@ * @set_wake: enable/disable power-management wake-on of an IRQ * * @release: release function solely used by UML + * @typename: obsoleted by name, kept as migration helper */ -struct hw_interrupt_type { - const char *typename; +struct irq_chip { + const char *name; unsigned int (*startup)(unsigned int irq); void (*shutdown)(unsigned int irq); void (*enable)(unsigned int irq); void (*disable)(unsigned int irq); + void (*ack)(unsigned int irq); + void (*mask)(unsigned int irq); + void (*mask_ack)(unsigned int irq); + void (*unmask)(unsigned int irq); + void (*end)(unsigned int irq); void (*set_affinity)(unsigned int irq, cpumask_t dest); int (*retrigger)(unsigned int irq); + int (*set_type)(unsigned int irq, unsigned int flow_type); + int (*set_wake)(unsigned int irq, unsigned int on); /* Currently used only by UML, might disappear one day.*/ #ifdef CONFIG_IRQ_RELEASE_METHOD void (*release)(unsigned int irq, void *dev_id); #endif + /* + * For compatibility, ->typename is copied into ->name. + * Will disappear. + */ + const char *typename; }; -typedef struct hw_interrupt_type hw_irq_controller; - -struct proc_dir_entry; - /** * struct irq_desc - interrupt descriptor * - * @handler: interrupt type dependent handler functions - * @handler_data: data for the type handlers + * @handle_irq: highlevel irq-events handler [if NULL, __do_IRQ()] + * @chip: low level interrupt hardware access + * @handler_data: per-IRQ data for the irq_chip methods + * @chip_data: platform-specific per-chip private data for the chip + * methods, to allow shared chip implementations * @action: the irq action chain * @status: status information * @depth: disable-depth, for nested irq_disable() calls @@ -98,6 +126,7 @@ struct proc_dir_entry; * @irqs_unhandled: stats field for spurious unhandled interrupts * @lock: locking for SMP * @affinity: IRQ affinity on SMP + * @cpu: cpu index useful for balancing * @pending_mask: pending rebalanced interrupts * @move_irq: need to re-target IRQ destination * @dir: /proc/irq/ procfs entry @@ -106,16 +135,22 @@ struct proc_dir_entry; * Pad this out to 32 bytes for cache and indexing reasons. */ struct irq_desc { - hw_irq_controller *chip; + void fastcall (*handle_irq)(unsigned int irq, + struct irq_desc *desc, + struct pt_regs *regs); + struct irq_chip *chip; + void *handler_data; void *chip_data; struct irqaction *action; /* IRQ action list */ unsigned int status; /* IRQ status */ + unsigned int depth; /* nested irq disables */ unsigned int irq_count; /* For detecting broken IRQs */ unsigned int irqs_unhandled; spinlock_t lock; #ifdef CONFIG_SMP cpumask_t affinity; + unsigned int cpu; #endif #if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE) cpumask_t pending_mask; @@ -131,6 +166,9 @@ extern struct irq_desc irq_desc[NR_IRQS]; /* * Migration helpers for obsolete names, they will go away: */ +#define hw_interrupt_type irq_chip +typedef struct irq_chip hw_irq_controller; +#define no_irq_type no_irq_chip typedef struct irq_desc irq_desc_t; /* @@ -138,6 +176,17 @@ typedef struct irq_desc irq_desc_t; */ #include +/* + * Architectures call this to let the generic IRQ layer + * handle an interrupt: + */ +static inline void generic_handle_irq(unsigned int irq, struct pt_regs *regs) +{ + struct irq_desc *desc = irq_desc + irq; + + desc->handle_irq(irq, desc, regs); +} + extern int setup_irq(unsigned int irq, struct irqaction *new); #ifdef CONFIG_GENERIC_HARDIRQS @@ -236,27 +285,100 @@ static inline int select_smp_affinity(unsigned int irq) #endif extern int no_irq_affinity; -extern int noirqdebug_setup(char *str); -extern irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs, - struct irqaction *action); +/* Handle irq action chains: */ +extern int handle_IRQ_event(unsigned int irq, struct pt_regs *regs, + struct irqaction *action); + +/* + * Built-in IRQ handlers for various IRQ types, + * callable via desc->chip->handle_irq() + */ +extern void fastcall +handle_level_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs); +extern void fastcall +handle_fastack_irq(unsigned int irq, struct irq_desc *desc, + struct pt_regs *regs); +extern void fastcall +handle_edge_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs); +extern void fastcall +handle_simple_irq(unsigned int irq, struct irq_desc *desc, + struct pt_regs *regs); +extern void fastcall +handle_percpu_irq(unsigned int irq, struct irq_desc *desc, + struct pt_regs *regs); +extern void fastcall +handle_bad_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs); + +/* + * Get a descriptive string for the highlevel handler, for + * /proc/interrupts output: + */ +extern const char * +handle_irq_name(void fastcall (*handle)(unsigned int, struct irq_desc *, + struct pt_regs *)); + /* - * Explicit fastcall, because i386 4KSTACKS calls it from assembly: + * Monolithic do_IRQ implementation. + * (is an explicit fastcall, because i386 4KSTACKS calls it from assembly) */ extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs); +/* Handling of unhandled and spurious interrupts: */ extern void note_interrupt(unsigned int irq, struct irq_desc *desc, int action_ret, struct pt_regs *regs); -extern int can_request_irq(unsigned int irq, unsigned long irqflags); /* Resending of interrupts :*/ void check_irq_resend(struct irq_desc *desc, unsigned int irq); +/* Initialize /proc/irq/ */ extern void init_irq_proc(void); -#endif /* CONFIG_GENERIC_HARDIRQS */ +/* Enable/disable irq debugging output: */ +extern int noirqdebug_setup(char *str); + +/* Checks whether the interrupt can be requested by request_irq(): */ +extern int can_request_irq(unsigned int irq, unsigned long irqflags); + +/* Dummy irq-chip implementation: */ +extern struct irq_chip no_irq_chip; + +extern void +set_irq_chip_and_handler(unsigned int irq, struct irq_chip *chip, + void fastcall (*handle)(unsigned int, + struct irq_desc *, + struct pt_regs *)); +extern void +__set_irq_handler(unsigned int irq, + void fastcall (*handle)(unsigned int, struct irq_desc *, + struct pt_regs *), + int is_chained); -extern hw_irq_controller no_irq_type; /* needed in every arch ? */ +/* + * Set a highlevel flow handler for a given IRQ: + */ +static inline void +set_irq_handler(unsigned int irq, + void fastcall (*handle)(unsigned int, struct irq_desc *, + struct pt_regs *)) +{ + __set_irq_handler(irq, handle, 0); +} + +/* + * Set a highlevel chained flow handler for a given IRQ. + * (a chained handler is automatically enabled and set to + * IRQ_NOREQUEST and IRQ_NOPROBE) + */ +static inline void +set_irq_chained_handler(unsigned int irq, + void fastcall (*handle)(unsigned int, struct irq_desc *, + struct pt_regs *)) +{ + __set_irq_handler(irq, handle, 1); +} + +#endif /* CONFIG_GENERIC_HARDIRQS */ #endif /* !CONFIG_S390 */ diff --git a/kernel/irq/autoprobe.c b/kernel/irq/autoprobe.c index ed98c7d46cf..cfdb63eb5c9 100644 --- a/kernel/irq/autoprobe.c +++ b/kernel/irq/autoprobe.c @@ -40,8 +40,15 @@ unsigned long probe_irq_on(void) desc = irq_desc + i; spin_lock_irq(&desc->lock); - if (!desc->action && !(desc->status & IRQ_NOPROBE)) + if (!desc->action && !(desc->status & IRQ_NOPROBE)) { + /* + * Some chips need to know about probing in + * progress: + */ + if (desc->chip->set_type) + desc->chip->set_type(i, IRQ_TYPE_PROBE); desc->chip->startup(i); + } spin_unlock_irq(&desc->lock); } diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c index bddcb8f5fea..a04b516afa5 100644 --- a/kernel/irq/handle.c +++ b/kernel/irq/handle.c @@ -18,6 +18,16 @@ #include "internals.h" +/** + * handle_bad_irq - handle spurious and unhandled irqs + */ +void fastcall +handle_bad_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs) +{ + kstat_this_cpu.irqs[irq]++; + ack_bad_irq(irq); +} + /* * Linux has a controller-independent interrupt architecture. * Every controller has a 'controller-template', that is used diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h index 46feba63026..2ba8ae3c8e9 100644 --- a/kernel/irq/internals.h +++ b/kernel/irq/internals.h @@ -4,6 +4,12 @@ extern int noirqdebug; +/* Set default functions for irq_chip structures: */ +extern void irq_chip_set_defaults(struct irq_chip *chip); + +/* Set default handler: */ +extern void compat_irq_chip_set_default_handler(struct irq_desc *desc); + #ifdef CONFIG_PROC_FS extern void register_irq_proc(unsigned int irq); extern void register_handler_proc(unsigned int irq, struct irqaction *action); diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 1a2e7663096..b61784ee78b 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -153,6 +153,17 @@ int can_request_irq(unsigned int irq, unsigned long irqflags) return !action; } +void compat_irq_chip_set_default_handler(struct irq_desc *desc) +{ + /* + * If the architecture still has not overriden + * the flow handler then zap the default. This + * should catch incorrect flow-type setting. + */ + if (desc->handle_irq == &handle_bad_irq) + desc->handle_irq = NULL; +} + /* * Internal function to register an irqaction - typically used to * allocate special interrupts that are part of the architecture. @@ -217,6 +228,9 @@ int setup_irq(unsigned int irq, struct irqaction *new) desc->status |= IRQ_PER_CPU; #endif if (!shared) { + irq_chip_set_defaults(desc->chip); + compat_irq_chip_set_default_handler(desc); + desc->status &= ~(IRQ_AUTODETECT | IRQ_WAITING | IRQ_INPROGRESS); diff --git a/kernel/irq/resend.c b/kernel/irq/resend.c index 096b102fb39..872f91ba2ce 100644 --- a/kernel/irq/resend.c +++ b/kernel/irq/resend.c @@ -37,9 +37,9 @@ static void resend_irqs(unsigned long arg) irq = find_first_bit(irqs_resend, NR_IRQS); clear_bit(irq, irqs_resend); desc = irq_desc + irq; - spin_lock_irqsave(&desc->lock, flags); + local_irq_disable(); desc->handle_irq(irq, desc, NULL); - spin_unlock_irqrestore(&desc->lock, flags); + local_irq_enable(); } } diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c index 3a0a6212330..ca187b83f89 100644 --- a/kernel/irq/spurious.c +++ b/kernel/irq/spurious.c @@ -168,6 +168,7 @@ void note_interrupt(unsigned int irq, struct irq_desc *desc, */ printk(KERN_EMERG "Disabling IRQ #%d\n", irq); desc->status |= IRQ_DISABLED; + desc->depth = 1; desc->chip->disable(irq); } desc->irqs_unhandled = 0; -- cgit v1.2.3-70-g09d2 From dae8620421833bb2e9a01c4ccc42bdc3759b81df Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Thu, 29 Jun 2006 02:24:52 -0700 Subject: [PATCH] genirq MSI fixes This is a fixed up and cleaned up replacement for genirq-msi-fixes.patch, which should solve the i386 4KSTACKS problem. I also added Ben's idea of pushing the __do_IRQ() check into generic_handle_irq(). I booted this with MSI enabled, but i only have MSI devices, not MSI-X devices. I'd still expect MSI-X to work now. irqchip migration helper: call __do_IRQ() if a descriptor is attached to an irqtype-style controller. This also fixes MSI-X IRQ handling on i386 and x86_64. Signed-off-by: Ingo Molnar Cc: Thomas Gleixner Cc: Benjamin Herrenschmidt Cc: Roland Dreier Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/irq.c | 5 +++++ include/linux/irq.h | 27 ++++++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-) (limited to 'include/linux/irq.h') diff --git a/arch/i386/kernel/irq.c b/arch/i386/kernel/irq.c index 3336cef9605..16b49170396 100644 --- a/arch/i386/kernel/irq.c +++ b/arch/i386/kernel/irq.c @@ -82,6 +82,10 @@ fastcall unsigned int do_IRQ(struct pt_regs *regs) } #endif + if (!irq_desc[irq].handle_irq) { + __do_IRQ(irq, regs); + goto out_exit; + } #ifdef CONFIG_4KSTACKS curctx = (union irq_ctx *) current_thread_info(); @@ -121,6 +125,7 @@ fastcall unsigned int do_IRQ(struct pt_regs *regs) #endif __do_IRQ(irq, regs); +out_exit: irq_exit(); return 1; diff --git a/include/linux/irq.h b/include/linux/irq.h index 437f2c635db..b40771dd114 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -176,17 +176,6 @@ typedef struct irq_desc irq_desc_t; */ #include -/* - * Architectures call this to let the generic IRQ layer - * handle an interrupt: - */ -static inline void generic_handle_irq(unsigned int irq, struct pt_regs *regs) -{ - struct irq_desc *desc = irq_desc + irq; - - desc->handle_irq(irq, desc, regs); -} - extern int setup_irq(unsigned int irq, struct irqaction *new); #ifdef CONFIG_GENERIC_HARDIRQS @@ -324,6 +313,22 @@ handle_irq_name(void fastcall (*handle)(unsigned int, struct irq_desc *, */ extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs); +/* + * Architectures call this to let the generic IRQ layer + * handle an interrupt. If the descriptor is attached to an + * irqchip-style controller then we call the ->handle_irq() handler, + * and it calls __do_IRQ() if it's attached to an irqtype-style controller. + */ +static inline void generic_handle_irq(unsigned int irq, struct pt_regs *regs) +{ + struct irq_desc *desc = irq_desc + irq; + + if (likely(desc->handle_irq)) + desc->handle_irq(irq, desc, regs); + else + __do_IRQ(irq, regs); +} + /* Handling of unhandled and spurious interrupts: */ extern void note_interrupt(unsigned int irq, struct irq_desc *desc, int action_ret, struct pt_regs *regs); -- cgit v1.2.3-70-g09d2 From dd87eb3a24c4527741122713e223d74b85d43c85 Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Thu, 29 Jun 2006 02:24:53 -0700 Subject: [PATCH] genirq: add irq-chip support Enable platforms to use the irq-chip and irq-flow abstractions: allow setting of the chip, the type and provide highlevel handlers for common irq-flows. [rostedt@goodmis.org: misroute-irq: Don't call desc->chip->end because of edge interrupts] Signed-off-by: Thomas Gleixner Signed-off-by: Ingo Molnar Cc: Benjamin Herrenschmidt Signed-off-by: Steven Rostedt Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/irq.h | 11 ++ kernel/irq/Makefile | 2 +- kernel/irq/chip.c | 525 ++++++++++++++++++++++++++++++++++++++++++++++++++ kernel/irq/spurious.c | 2 +- 4 files changed, 538 insertions(+), 2 deletions(-) create mode 100644 kernel/irq/chip.c (limited to 'include/linux/irq.h') diff --git a/include/linux/irq.h b/include/linux/irq.h index b40771dd114..ca8d2a849cf 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -383,6 +383,17 @@ set_irq_chained_handler(unsigned int irq, __set_irq_handler(irq, handle, 1); } +/* Set/get chip/data for an IRQ: */ + +extern int set_irq_chip(unsigned int irq, struct irq_chip *chip); +extern int set_irq_data(unsigned int irq, void *data); +extern int set_irq_chip_data(unsigned int irq, void *data); +extern int set_irq_type(unsigned int irq, unsigned int type); + +#define get_irq_chip(irq) (irq_desc[irq].chip) +#define get_irq_chip_data(irq) (irq_desc[irq].chip_data) +#define get_irq_data(irq) (irq_desc[irq].handler_data) + #endif /* CONFIG_GENERIC_HARDIRQS */ #endif /* !CONFIG_S390 */ diff --git a/kernel/irq/Makefile b/kernel/irq/Makefile index 627ace98d4a..1dab0ac3f79 100644 --- a/kernel/irq/Makefile +++ b/kernel/irq/Makefile @@ -1,5 +1,5 @@ -obj-y := handle.o manage.o spurious.o resend.o +obj-y := handle.o manage.o spurious.o resend.o chip.o obj-$(CONFIG_GENERIC_IRQ_PROBE) += autoprobe.o obj-$(CONFIG_PROC_FS) += proc.o obj-$(CONFIG_GENERIC_PENDING_IRQ) += migration.o diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c new file mode 100644 index 00000000000..8736f2ca8a3 --- /dev/null +++ b/kernel/irq/chip.c @@ -0,0 +1,525 @@ +/* + * linux/kernel/irq/chip.c + * + * Copyright (C) 1992, 1998-2006 Linus Torvalds, Ingo Molnar + * Copyright (C) 2005-2006, Thomas Gleixner, Russell King + * + * This file contains the core interrupt handling code, for irq-chip + * based architectures. + * + * Detailed information is available in Documentation/DocBook/genericirq + */ + +#include +#include +#include +#include + +#include "internals.h" + +/** + * set_irq_chip - set the irq chip for an irq + * @irq: irq number + * @chip: pointer to irq chip description structure + */ +int set_irq_chip(unsigned int irq, struct irq_chip *chip) +{ + struct irq_desc *desc; + unsigned long flags; + + if (irq >= NR_IRQS) { + printk(KERN_ERR "Trying to install chip for IRQ%d\n", irq); + WARN_ON(1); + return -EINVAL; + } + + if (!chip) + chip = &no_irq_chip; + + desc = irq_desc + irq; + spin_lock_irqsave(&desc->lock, flags); + irq_chip_set_defaults(chip); + desc->chip = chip; + /* + * For compatibility only: + */ + desc->chip = chip; + spin_unlock_irqrestore(&desc->lock, flags); + + return 0; +} +EXPORT_SYMBOL(set_irq_chip); + +/** + * set_irq_type - set the irq type for an irq + * @irq: irq number + * @type: interrupt type - see include/linux/interrupt.h + */ +int set_irq_type(unsigned int irq, unsigned int type) +{ + struct irq_desc *desc; + unsigned long flags; + int ret = -ENXIO; + + if (irq >= NR_IRQS) { + printk(KERN_ERR "Trying to set irq type for IRQ%d\n", irq); + return -ENODEV; + } + + desc = irq_desc + irq; + if (desc->chip->set_type) { + spin_lock_irqsave(&desc->lock, flags); + ret = desc->chip->set_type(irq, type); + spin_unlock_irqrestore(&desc->lock, flags); + } + return ret; +} +EXPORT_SYMBOL(set_irq_type); + +/** + * set_irq_data - set irq type data for an irq + * @irq: Interrupt number + * @data: Pointer to interrupt specific data + * + * Set the hardware irq controller data for an irq + */ +int set_irq_data(unsigned int irq, void *data) +{ + struct irq_desc *desc; + unsigned long flags; + + if (irq >= NR_IRQS) { + printk(KERN_ERR + "Trying to install controller data for IRQ%d\n", irq); + return -EINVAL; + } + + desc = irq_desc + irq; + spin_lock_irqsave(&desc->lock, flags); + desc->handler_data = data; + spin_unlock_irqrestore(&desc->lock, flags); + return 0; +} +EXPORT_SYMBOL(set_irq_data); + +/** + * set_irq_chip_data - set irq chip data for an irq + * @irq: Interrupt number + * @data: Pointer to chip specific data + * + * Set the hardware irq chip data for an irq + */ +int set_irq_chip_data(unsigned int irq, void *data) +{ + struct irq_desc *desc = irq_desc + irq; + unsigned long flags; + + if (irq >= NR_IRQS || !desc->chip) { + printk(KERN_ERR "BUG: bad set_irq_chip_data(IRQ#%d)\n", irq); + return -EINVAL; + } + + spin_lock_irqsave(&desc->lock, flags); + desc->chip_data = data; + spin_unlock_irqrestore(&desc->lock, flags); + + return 0; +} +EXPORT_SYMBOL(set_irq_chip_data); + +/* + * default enable function + */ +static void default_enable(unsigned int irq) +{ + struct irq_desc *desc = irq_desc + irq; + + desc->chip->unmask(irq); + desc->status &= ~IRQ_MASKED; +} + +/* + * default disable function + */ +static void default_disable(unsigned int irq) +{ + struct irq_desc *desc = irq_desc + irq; + + if (!(desc->status & IRQ_DELAYED_DISABLE)) + irq_desc[irq].chip->mask(irq); +} + +/* + * default startup function + */ +static unsigned int default_startup(unsigned int irq) +{ + irq_desc[irq].chip->enable(irq); + + return 0; +} + +/* + * Fixup enable/disable function pointers + */ +void irq_chip_set_defaults(struct irq_chip *chip) +{ + if (!chip->enable) + chip->enable = default_enable; + if (!chip->disable) + chip->disable = default_disable; + if (!chip->startup) + chip->startup = default_startup; + if (!chip->shutdown) + chip->shutdown = chip->disable; + if (!chip->name) + chip->name = chip->typename; +} + +static inline void mask_ack_irq(struct irq_desc *desc, int irq) +{ + if (desc->chip->mask_ack) + desc->chip->mask_ack(irq); + else { + desc->chip->mask(irq); + desc->chip->ack(irq); + } +} + +/** + * handle_simple_irq - Simple and software-decoded IRQs. + * @irq: the interrupt number + * @desc: the interrupt description structure for this irq + * @regs: pointer to a register structure + * + * Simple interrupts are either sent from a demultiplexing interrupt + * handler or come from hardware, where no interrupt hardware control + * is necessary. + * + * Note: The caller is expected to handle the ack, clear, mask and + * unmask issues if necessary. + */ +void fastcall +handle_simple_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs) +{ + struct irqaction *action; + irqreturn_t action_ret; + const unsigned int cpu = smp_processor_id(); + + spin_lock(&desc->lock); + + if (unlikely(desc->status & IRQ_INPROGRESS)) + goto out_unlock; + desc->status &= ~(IRQ_REPLAY | IRQ_WAITING); + kstat_cpu(cpu).irqs[irq]++; + + action = desc->action; + if (unlikely(!action || (desc->status & IRQ_DISABLED))) + goto out_unlock; + + desc->status |= IRQ_INPROGRESS; + spin_unlock(&desc->lock); + + action_ret = handle_IRQ_event(irq, regs, action); + if (!noirqdebug) + note_interrupt(irq, desc, action_ret, regs); + + spin_lock(&desc->lock); + desc->status &= ~IRQ_INPROGRESS; +out_unlock: + spin_unlock(&desc->lock); +} + +/** + * handle_level_irq - Level type irq handler + * @irq: the interrupt number + * @desc: the interrupt description structure for this irq + * @regs: pointer to a register structure + * + * Level type interrupts are active as long as the hardware line has + * the active level. This may require to mask the interrupt and unmask + * it after the associated handler has acknowledged the device, so the + * interrupt line is back to inactive. + */ +void fastcall +handle_level_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs) +{ + unsigned int cpu = smp_processor_id(); + struct irqaction *action; + irqreturn_t action_ret; + + spin_lock(&desc->lock); + mask_ack_irq(desc, irq); + + if (unlikely(desc->status & IRQ_INPROGRESS)) + goto out; + desc->status &= ~(IRQ_REPLAY | IRQ_WAITING); + kstat_cpu(cpu).irqs[irq]++; + + /* + * If its disabled or no action available + * keep it masked and get out of here + */ + action = desc->action; + if (unlikely(!action || (desc->status & IRQ_DISABLED))) + goto out; + + desc->status |= IRQ_INPROGRESS; + spin_unlock(&desc->lock); + + action_ret = handle_IRQ_event(irq, regs, action); + if (!noirqdebug) + note_interrupt(irq, desc, action_ret, regs); + + spin_lock(&desc->lock); + desc->status &= ~IRQ_INPROGRESS; +out: + if (!(desc->status & IRQ_DISABLED) && desc->chip->unmask) + desc->chip->unmask(irq); + spin_unlock(&desc->lock); +} + +/** + * handle_fastack_irq - irq handler for transparent controllers + * @irq: the interrupt number + * @desc: the interrupt description structure for this irq + * @regs: pointer to a register structure + * + * Only a single callback will be issued to the chip: an ->ack() + * call when the interrupt has been serviced. This enables support + * for modern forms of interrupt handlers, which handle the flow + * details in hardware, transparently. + */ +void fastcall +handle_fastack_irq(unsigned int irq, struct irq_desc *desc, + struct pt_regs *regs) +{ + unsigned int cpu = smp_processor_id(); + struct irqaction *action; + irqreturn_t action_ret; + + spin_lock(&desc->lock); + + if (unlikely(desc->status & IRQ_INPROGRESS)) + goto out; + + desc->status &= ~(IRQ_REPLAY | IRQ_WAITING); + kstat_cpu(cpu).irqs[irq]++; + + /* + * If its disabled or no action available + * keep it masked and get out of here + */ + action = desc->action; + if (unlikely(!action || (desc->status & IRQ_DISABLED))) + goto out; + + desc->status |= IRQ_INPROGRESS; + spin_unlock(&desc->lock); + + action_ret = handle_IRQ_event(irq, regs, action); + if (!noirqdebug) + note_interrupt(irq, desc, action_ret, regs); + + spin_lock(&desc->lock); + desc->status &= ~IRQ_INPROGRESS; +out: + if (!(desc->status & IRQ_DISABLED)) + desc->chip->ack(irq); + else + desc->chip->mask(irq); + + spin_unlock(&desc->lock); +} + +/** + * handle_edge_irq - edge type IRQ handler + * @irq: the interrupt number + * @desc: the interrupt description structure for this irq + * @regs: pointer to a register structure + * + * Interrupt occures on the falling and/or rising edge of a hardware + * signal. The occurence is latched into the irq controller hardware + * and must be acked in order to be reenabled. After the ack another + * interrupt can happen on the same source even before the first one + * is handled by the assosiacted event handler. If this happens it + * might be necessary to disable (mask) the interrupt depending on the + * controller hardware. This requires to reenable the interrupt inside + * of the loop which handles the interrupts which have arrived while + * the handler was running. If all pending interrupts are handled, the + * loop is left. + */ +void fastcall +handle_edge_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs) +{ + const unsigned int cpu = smp_processor_id(); + + spin_lock(&desc->lock); + + desc->status &= ~(IRQ_REPLAY | IRQ_WAITING); + + /* + * If we're currently running this IRQ, or its disabled, + * we shouldn't process the IRQ. Mark it pending, handle + * the necessary masking and go out + */ + if (unlikely((desc->status & (IRQ_INPROGRESS | IRQ_DISABLED)) || + !desc->action)) { + desc->status |= (IRQ_PENDING | IRQ_MASKED); + mask_ack_irq(desc, irq); + goto out_unlock; + } + + kstat_cpu(cpu).irqs[irq]++; + + /* Start handling the irq */ + desc->chip->ack(irq); + + /* Mark the IRQ currently in progress.*/ + desc->status |= IRQ_INPROGRESS; + + do { + struct irqaction *action = desc->action; + irqreturn_t action_ret; + + if (unlikely(!action)) { + desc->chip->mask(irq); + goto out_unlock; + } + + /* + * When another irq arrived while we were handling + * one, we could have masked the irq. + * Renable it, if it was not disabled in meantime. + */ + if (unlikely((desc->status & + (IRQ_PENDING | IRQ_MASKED | IRQ_DISABLED)) == + (IRQ_PENDING | IRQ_MASKED))) { + desc->chip->unmask(irq); + desc->status &= ~IRQ_MASKED; + } + + desc->status &= ~IRQ_PENDING; + spin_unlock(&desc->lock); + action_ret = handle_IRQ_event(irq, regs, action); + if (!noirqdebug) + note_interrupt(irq, desc, action_ret, regs); + spin_lock(&desc->lock); + + } while ((desc->status & (IRQ_PENDING | IRQ_DISABLED)) == IRQ_PENDING); + + desc->status &= ~IRQ_INPROGRESS; +out_unlock: + spin_unlock(&desc->lock); +} + +#ifdef CONFIG_SMP +/** + * handle_percpu_IRQ - Per CPU local irq handler + * @irq: the interrupt number + * @desc: the interrupt description structure for this irq + * @regs: pointer to a register structure + * + * Per CPU interrupts on SMP machines without locking requirements + */ +void fastcall +handle_percpu_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs) +{ + irqreturn_t action_ret; + + kstat_this_cpu.irqs[irq]++; + + if (desc->chip->ack) + desc->chip->ack(irq); + + action_ret = handle_IRQ_event(irq, regs, desc->action); + if (!noirqdebug) + note_interrupt(irq, desc, action_ret, regs); + + if (desc->chip->eoi) + desc->chip->eoi(irq); +} + +#endif /* CONFIG_SMP */ + +void +__set_irq_handler(unsigned int irq, + void fastcall (*handle)(unsigned int, irq_desc_t *, + struct pt_regs *), + int is_chained) +{ + struct irq_desc *desc; + unsigned long flags; + + if (irq >= NR_IRQS) { + printk(KERN_ERR + "Trying to install type control for IRQ%d\n", irq); + return; + } + + desc = irq_desc + irq; + + if (!handle) + handle = handle_bad_irq; + + if (is_chained && desc->chip == &no_irq_chip) + printk(KERN_WARNING "Trying to install " + "chained interrupt type for IRQ%d\n", irq); + + spin_lock_irqsave(&desc->lock, flags); + + /* Uninstall? */ + if (handle == handle_bad_irq) { + if (desc->chip != &no_irq_chip) { + desc->chip->mask(irq); + desc->chip->ack(irq); + } + desc->status |= IRQ_DISABLED; + desc->depth = 1; + } + desc->handle_irq = handle; + + if (handle != handle_bad_irq && is_chained) { + desc->status &= ~IRQ_DISABLED; + desc->status |= IRQ_NOREQUEST | IRQ_NOPROBE; + desc->depth = 0; + desc->chip->unmask(irq); + } + spin_unlock_irqrestore(&desc->lock, flags); +} + +void +set_irq_chip_and_handler(unsigned int irq, struct irq_chip *chip, + void fastcall (*handle)(unsigned int, + struct irq_desc *, + struct pt_regs *)) +{ + set_irq_chip(irq, chip); + __set_irq_handler(irq, handle, 0); +} + +/* + * Get a descriptive string for the highlevel handler, for + * /proc/interrupts output: + */ +const char * +handle_irq_name(void fastcall (*handle)(unsigned int, struct irq_desc *, + struct pt_regs *)) +{ + if (handle == handle_level_irq) + return "level "; + if (handle == handle_fastack_irq) + return "level "; + if (handle == handle_edge_irq) + return "edge "; + if (handle == handle_simple_irq) + return "simple"; +#ifdef CONFIG_SMP + if (handle == handle_percpu_irq) + return "percpu"; +#endif + if (handle == handle_bad_irq) + return "bad "; + + return NULL; +} diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c index ca187b83f89..b483deed311 100644 --- a/kernel/irq/spurious.c +++ b/kernel/irq/spurious.c @@ -79,7 +79,7 @@ static int misrouted_irq(int irq, struct pt_regs *regs) * If we did actual work for the real IRQ line we must let the * IRQ controller clean up too */ - if (work) + if (work && desc->chip && desc->chip->end) desc->chip->end(i); spin_unlock(&desc->lock); } -- cgit v1.2.3-70-g09d2 From f210be198ddd3f54b17d4aa6e69b829f75f226e5 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Thu, 29 Jun 2006 02:25:00 -0700 Subject: [PATCH] genirq: add IRQ_TYPE_SENSE_MASK Add a #define for the mask of the part of IRQ_TYPE that represents the trigger type. I use that in my in-progress work as I've standardized the way the irq description in the firmware device-tree get translated to linux useable things by using those constants. Having this mask to isolate the "trigger type" part of the flags is useful in a few places. Signed-off-by: Benjamin Herrenschmidt Acked-by: Thomas Gleixner Cc: Ingo Molnar Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/irq.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/linux/irq.h') diff --git a/include/linux/irq.h b/include/linux/irq.h index ca8d2a849cf..0d8eaf3e403 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -55,6 +55,7 @@ #define IRQ_TYPE_EDGE_BOTH (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING) #define IRQ_TYPE_LEVEL_HIGH 0x0004 /* Level high type */ #define IRQ_TYPE_LEVEL_LOW 0x0008 /* Level low type */ +#define IRQ_TYPE_SENSE_MASK 0x000f /* Mask of the above */ #define IRQ_TYPE_SIMPLE 0x0010 /* Simple type */ #define IRQ_TYPE_PERCPU 0x0020 /* Per CPU type */ #define IRQ_TYPE_PROBE 0x0040 /* Probing in progress */ -- cgit v1.2.3-70-g09d2 From 47c2a3aa4475d27073dd3c7e183fcc13f495c8f5 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Thu, 29 Jun 2006 02:25:03 -0700 Subject: [PATCH] genirq: add chip->eoi(), fastack -> fasteoi Clean up the fastack concept by turning it into fasteoi and introducing the ->eoi() method for chips. This also allows the cleanup of an i386 EOI quirk - now the quirk is cleanly separated from the pure ACK implementation. Signed-off-by: Ingo Molnar Cc: Benjamin Herrenschmidt Cc: Roland Dreier Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/irq.h | 6 ++++-- kernel/irq/chip.c | 25 +++++++++++-------------- 2 files changed, 15 insertions(+), 16 deletions(-) (limited to 'include/linux/irq.h') diff --git a/include/linux/irq.h b/include/linux/irq.h index 0d8eaf3e403..0832149cdb1 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -74,7 +74,8 @@ struct proc_dir_entry; * @mask: mask an interrupt source * @mask_ack: ack and mask an interrupt source * @unmask: unmask an interrupt source - * @end: end of interrupt + * @eoi: end of interrupt - chip level + * @end: end of interrupt - flow level * @set_affinity: set the CPU affinity on SMP machines * @retrigger: resend an IRQ to the CPU * @set_type: set the flow type (IRQ_TYPE_LEVEL/etc.) of an IRQ @@ -94,6 +95,7 @@ struct irq_chip { void (*mask)(unsigned int irq); void (*mask_ack)(unsigned int irq); void (*unmask)(unsigned int irq); + void (*eoi)(unsigned int irq); void (*end)(unsigned int irq); void (*set_affinity)(unsigned int irq, cpumask_t dest); @@ -287,7 +289,7 @@ extern int handle_IRQ_event(unsigned int irq, struct pt_regs *regs, extern void fastcall handle_level_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs); extern void fastcall -handle_fastack_irq(unsigned int irq, struct irq_desc *desc, +handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs); extern void fastcall handle_edge_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs); diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index a99047a324e..4a0952d9458 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -280,18 +280,18 @@ out: } /** - * handle_fastack_irq - irq handler for transparent controllers + * handle_fasteoi_irq - irq handler for transparent controllers * @irq: the interrupt number * @desc: the interrupt description structure for this irq * @regs: pointer to a register structure * - * Only a single callback will be issued to the chip: an ->ack() + * Only a single callback will be issued to the chip: an ->eoi() * call when the interrupt has been serviced. This enables support * for modern forms of interrupt handlers, which handle the flow * details in hardware, transparently. */ void fastcall -handle_fastack_irq(unsigned int irq, struct irq_desc *desc, +handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs) { unsigned int cpu = smp_processor_id(); @@ -327,10 +327,7 @@ handle_fastack_irq(unsigned int irq, struct irq_desc *desc, spin_lock(&desc->lock); desc->status &= ~IRQ_INPROGRESS; out: - if (!(desc->status & IRQ_DISABLED)) - desc->chip->ack(irq); - else - desc->chip->mask(irq); + desc->chip->eoi(irq); spin_unlock(&desc->lock); } @@ -510,19 +507,19 @@ handle_irq_name(void fastcall (*handle)(unsigned int, struct irq_desc *, struct pt_regs *)) { if (handle == handle_level_irq) - return "level "; - if (handle == handle_fastack_irq) - return "level "; + return "level "; + if (handle == handle_fasteoi_irq) + return "fasteoi"; if (handle == handle_edge_irq) - return "edge "; + return "edge "; if (handle == handle_simple_irq) - return "simple"; + return "simple "; #ifdef CONFIG_SMP if (handle == handle_percpu_irq) - return "percpu"; + return "percpu "; #endif if (handle == handle_bad_irq) - return "bad "; + return "bad "; return NULL; } -- cgit v1.2.3-70-g09d2 From f8b5473fcbddbfde827ecf82aa0e81fa2a878220 Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Sat, 1 Jul 2006 22:30:08 +0100 Subject: [ARM] 3690/1: genirq: Introduce and make use of dummy irq chip Patch from Thomas Gleixner From: Thomas Gleixner ARM has a couple of really dumb interrupt controllers. Implement a generic one and fixup the ARM migration. ARM reused the no_irq_chip for this purpose, but this does not work out for platforms which are not converted to the new interrupt type handling model. Signed-off-by: Thomas Gleixner Signed-off-by: Ingo Molnar Signed-off-by: Russell King --- include/linux/irq.h | 3 ++- kernel/irq/chip.c | 15 ++++++++++++--- kernel/irq/handle.c | 16 ++++++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) (limited to 'include/linux/irq.h') diff --git a/include/linux/irq.h b/include/linux/irq.h index 0832149cdb1..00b6ef8b2f9 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -348,8 +348,9 @@ extern int noirqdebug_setup(char *str); /* Checks whether the interrupt can be requested by request_irq(): */ extern int can_request_irq(unsigned int irq, unsigned long irqflags); -/* Dummy irq-chip implementation: */ +/* Dummy irq-chip implementations: */ extern struct irq_chip no_irq_chip; +extern struct irq_chip dummy_irq_chip; extern void set_irq_chip_and_handler(unsigned int irq, struct irq_chip *chip, diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index 4a0952d9458..54105bdfe20 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -462,9 +462,18 @@ __set_irq_handler(unsigned int irq, if (!handle) handle = handle_bad_irq; - if (is_chained && desc->chip == &no_irq_chip) - printk(KERN_WARNING "Trying to install " - "chained interrupt type for IRQ%d\n", irq); + if (desc->chip == &no_irq_chip) { + printk(KERN_WARNING "Trying to install %sinterrupt handler " + "for IRQ%d\n", is_chained ? "chained " : " ", irq); + /* + * Some ARM implementations install a handler for really dumb + * interrupt hardware without setting an irq_chip. This worked + * with the ARM no_irq_chip but the check in setup_irq would + * prevent us to setup the interrupt at all. Switch it to + * dummy_irq_chip for easy transition. + */ + desc->chip = &dummy_irq_chip; + } spin_lock_irqsave(&desc->lock, flags); diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c index 961b8759173..e71266c3803 100644 --- a/kernel/irq/handle.c +++ b/kernel/irq/handle.c @@ -95,6 +95,22 @@ struct irq_chip no_irq_chip = { .end = noop, }; +/* + * Generic dummy implementation which can be used for + * real dumb interrupt sources + */ +struct irq_chip dummy_irq_chip = { + .name = "dummy", + .startup = noop_ret, + .shutdown = noop, + .enable = noop, + .disable = noop, + .ack = noop, + .mask = noop, + .unmask = noop, + .end = noop, +}; + /* * Special, empty irq handler: */ -- cgit v1.2.3-70-g09d2 From 6e21361619328751e2637b004e14cf360aafbddc Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Sat, 1 Jul 2006 19:29:03 -0700 Subject: [PATCH] irq-flags: consolidate flags for request_irq The recent interrupt rework introduced bit value conflicts with sparc. Instead of introducing new architecture flags mess, move the interrupt SA_ flags out of the signal namespace and replace them by interrupt related flags. This allows to remove the obsolete SA_INTERRUPT flag and clean up the bit field values. This patch: Move the interrupt related SA_ flags out of linux/signal.h and rename them to IRQF_ . This moves the interrupt related flags out of the signal namespace and allows to remove the architecture dependencies. SA_INTERRUPT is not needed by userspace and glibc so it can be removed safely. The existing SA_ constants are kept for easy transition and will be removed after a 6 month grace period. Signed-off-by: Thomas Gleixner Cc: Ingo Molnar Cc: "David S. Miller" Cc: Benjamin Herrenschmidt Cc: "Randy.Dunlap" Cc: Jaroslav Kysela Cc: Takashi Iwai Cc: "Antonino A. Daplas" Cc: Greg KH Cc: Russell King Cc: James Bottomley Cc: Kyle McMartin Cc: Jeff Garzik Cc: Mauro Carvalho Chehab Cc: Karsten Keil Cc: Jody McIntyre Cc: Ben Collins Cc: Stefan Richter Cc: Alan Cox Cc: Bartlomiej Zolnierkiewicz Cc: Dave Airlie Cc: Jens Axboe Cc: Chris Zankel Cc: Andi Kleen Cc: Miles Bader Cc: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Cc: Paul Mundt Cc: Kazumoto Kojima Cc: Martin Schwidefsky Cc: Heiko Carstens Cc: Ralf Baechle Cc: Roman Zippel Cc: Geert Uytterhoeven Cc: Greg Ungerer Cc: "Luck, Tony" Cc: Yoshinori Sato Cc: David Howells Cc: Mikael Starvik Cc: Russell King Cc: Ivan Kokshaysky Cc: Richard Henderson Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- Documentation/feature-removal-schedule.txt | 9 +++++ include/linux/interrupt.h | 47 +++++++++++++++++++++++++ include/linux/irq.h | 55 +++++++++++++++--------------- include/linux/signal.h | 26 -------------- 4 files changed, 83 insertions(+), 54 deletions(-) (limited to 'include/linux/irq.h') diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt index 1cbbb8e2899..99f219a01e0 100644 --- a/Documentation/feature-removal-schedule.txt +++ b/Documentation/feature-removal-schedule.txt @@ -257,3 +257,12 @@ Why: Code does no longer build since at least 2.6.0, apparently there is Who: Ralf Baechle --------------------------- + +What: Interrupt only SA_* flags +When: Januar 2007 +Why: The interrupt related SA_* flags are replaced by IRQF_* to move them + out of the signal namespace. + +Who: Thomas Gleixner + +--------------------------- diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index db2a63a1163..cf682a73a6f 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h @@ -14,6 +14,53 @@ #include #include +/* + * These correspond to the IORESOURCE_IRQ_* defines in + * linux/ioport.h to select the interrupt line behaviour. When + * requesting an interrupt without specifying a IRQF_TRIGGER, the + * setting should be assumed to be "as already configured", which + * may be as per machine or firmware initialisation. + */ +#define IRQF_TRIGGER_NONE 0x00000000 +#define IRQF_TRIGGER_RISING 0x00000001 +#define IRQF_TRIGGER_FALLING 0x00000002 +#define IRQF_TRIGGER_HIGH 0x00000004 +#define IRQF_TRIGGER_LOW 0x00000008 +#define IRQF_TRIGGER_MASK (IRQF_TRIGGER_HIGH | IRQF_TRIGGER_LOW | \ + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING) +#define IRQF_TRIGGER_PROBE 0x00000010 + +/* + * These flags used only by the kernel as part of the + * irq handling routines. + * + * IRQF_DISABLED - keep irqs disabled when calling the action handler + * IRQF_SAMPLE_RANDOM - irq is used to feed the random generator + * IRQF_SHARED - allow sharing the irq among several devices + * IRQF_PROBE_SHARED - set by callers when they expect sharing mismatches to occur + * IRQF_TIMER - Flag to mark this interrupt as timer interrupt + */ +#define IRQF_DISABLED 0x00000020 +#define IRQF_SAMPLE_RANDOM 0x00000040 +#define IRQF_SHARED 0x00000080 +#define IRQF_PROBE_SHARED 0x00000100 +#define IRQF_TIMER 0x00000200 + +/* + * Migration helpers. Scheduled for removal in 1/2007 + * Do not use for new code ! + */ +#define SA_INTERRUPT IRQF_DISABLED +#define SA_SAMPLE_RANDOM IRQF_SAMPLE_RANDOM +#define SA_SHIRQ IRQF_SHARED +#define SA_PROBEIRQ IRQF_PROBE_SHARED + +#define SA_TRIGGER_LOW IRQF_TRIGGER_LOW +#define SA_TRIGGER_HIGH IRQF_TRIGGER_HIGH +#define SA_TRIGGER_FALLING IRQF_TRIGGER_FALLING +#define SA_TRIGGER_RISING IRQF_TRIGGER_RISING +#define SA_TRIGGER_MASK IRQF_TRIGGER_MASK + struct irqaction { irqreturn_t (*handler)(int, void *, struct pt_regs *); unsigned long flags; diff --git a/include/linux/irq.h b/include/linux/irq.h index 0832149cdb1..ae1e422f18e 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -24,41 +24,40 @@ /* * IRQ line status. + * + * Bits 0-16 are reserved for the IRQF_* bits in linux/interrupt.h + * + * IRQ types */ -#define IRQ_INPROGRESS 1 /* IRQ handler active - do not enter! */ -#define IRQ_DISABLED 2 /* IRQ disabled - do not enter! */ -#define IRQ_PENDING 4 /* IRQ pending - replay on enable */ -#define IRQ_REPLAY 8 /* IRQ has been replayed but not acked yet */ -#define IRQ_AUTODETECT 16 /* IRQ is being autodetected */ -#define IRQ_WAITING 32 /* IRQ not yet seen - for autodetection */ -#define IRQ_LEVEL 64 /* IRQ level triggered */ -#define IRQ_MASKED 128 /* IRQ masked - shouldn't be seen again */ +#define IRQ_TYPE_NONE 0x00000000 /* Default, unspecified type */ +#define IRQ_TYPE_EDGE_RISING 0x00000001 /* Edge rising type */ +#define IRQ_TYPE_EDGE_FALLING 0x00000002 /* Edge falling type */ +#define IRQ_TYPE_EDGE_BOTH (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING) +#define IRQ_TYPE_LEVEL_HIGH 0x00000004 /* Level high type */ +#define IRQ_TYPE_LEVEL_LOW 0x00000008 /* Level low type */ +#define IRQ_TYPE_SENSE_MASK 0x0000000f /* Mask of the above */ +#define IRQ_TYPE_PROBE 0x00000010 /* Probing in progress */ + +/* Internal flags */ +#define IRQ_INPROGRESS 0x00010000 /* IRQ handler active - do not enter! */ +#define IRQ_DISABLED 0x00020000 /* IRQ disabled - do not enter! */ +#define IRQ_PENDING 0x00040000 /* IRQ pending - replay on enable */ +#define IRQ_REPLAY 0x00080000 /* IRQ has been replayed but not acked yet */ +#define IRQ_AUTODETECT 0x00100000 /* IRQ is being autodetected */ +#define IRQ_WAITING 0x00200000 /* IRQ not yet seen - for autodetection */ +#define IRQ_LEVEL 0x00400000 /* IRQ level triggered */ +#define IRQ_MASKED 0x00800000 /* IRQ masked - shouldn't be seen again */ #ifdef CONFIG_IRQ_PER_CPU -# define IRQ_PER_CPU 256 /* IRQ is per CPU */ +# define IRQ_PER_CPU 0x01000000 /* IRQ is per CPU */ # define CHECK_IRQ_PER_CPU(var) ((var) & IRQ_PER_CPU) #else # define CHECK_IRQ_PER_CPU(var) 0 #endif -#define IRQ_NOPROBE 512 /* IRQ is not valid for probing */ -#define IRQ_NOREQUEST 1024 /* IRQ cannot be requested */ -#define IRQ_NOAUTOEN 2048 /* IRQ will not be enabled on request irq */ -#define IRQ_DELAYED_DISABLE \ - 4096 /* IRQ disable (masking) happens delayed. */ - -/* - * IRQ types, see also include/linux/interrupt.h - */ -#define IRQ_TYPE_NONE 0x0000 /* Default, unspecified type */ -#define IRQ_TYPE_EDGE_RISING 0x0001 /* Edge rising type */ -#define IRQ_TYPE_EDGE_FALLING 0x0002 /* Edge falling type */ -#define IRQ_TYPE_EDGE_BOTH (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING) -#define IRQ_TYPE_LEVEL_HIGH 0x0004 /* Level high type */ -#define IRQ_TYPE_LEVEL_LOW 0x0008 /* Level low type */ -#define IRQ_TYPE_SENSE_MASK 0x000f /* Mask of the above */ -#define IRQ_TYPE_SIMPLE 0x0010 /* Simple type */ -#define IRQ_TYPE_PERCPU 0x0020 /* Per CPU type */ -#define IRQ_TYPE_PROBE 0x0040 /* Probing in progress */ +#define IRQ_NOPROBE 0x02000000 /* IRQ is not valid for probing */ +#define IRQ_NOREQUEST 0x04000000 /* IRQ cannot be requested */ +#define IRQ_NOAUTOEN 0x08000000 /* IRQ will not be enabled on request irq */ +#define IRQ_DELAYED_DISABLE 0x10000000 /* IRQ disable (masking) happens delayed. */ struct proc_dir_entry; diff --git a/include/linux/signal.h b/include/linux/signal.h index 1e4ce7225ee..117135e33d6 100644 --- a/include/linux/signal.h +++ b/include/linux/signal.h @@ -8,32 +8,6 @@ #include #include -/* - * These values of sa_flags are used only by the kernel as part of the - * irq handling routines. - * - * SA_INTERRUPT is also used by the irq handling routines. - * SA_SHIRQ is for shared interrupt support on PCI and EISA. - * SA_PROBEIRQ is set by callers when they expect sharing mismatches to occur - */ -#define SA_SAMPLE_RANDOM SA_RESTART -#define SA_SHIRQ 0x04000000 -#define SA_PROBEIRQ 0x08000000 - -/* - * As above, these correspond to the IORESOURCE_IRQ_* defines in - * linux/ioport.h to select the interrupt line behaviour. When - * requesting an interrupt without specifying a SA_TRIGGER, the - * setting should be assumed to be "as already configured", which - * may be as per machine or firmware initialisation. - */ -#define SA_TRIGGER_LOW 0x00000008 -#define SA_TRIGGER_HIGH 0x00000004 -#define SA_TRIGGER_FALLING 0x00000002 -#define SA_TRIGGER_RISING 0x00000001 -#define SA_TRIGGER_MASK (SA_TRIGGER_HIGH|SA_TRIGGER_LOW|\ - SA_TRIGGER_RISING|SA_TRIGGER_FALLING) - /* * Real Time signals may be queued. */ -- cgit v1.2.3-70-g09d2 From d061daa0e3abdddc28e21a37c8ac4536dedbf239 Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Mon, 3 Jul 2006 02:18:48 +0200 Subject: [PATCH] genirq: ARM dyntick cleanup Linus: "The hacks in kernel/irq/handle.c are really horrid. REALLY horrid." They are indeed. Move the dyntick quirks to ARM where they belong. Signed-off-by: Thomas Gleixner Signed-off-by: Linus Torvalds --- include/asm-arm/hw_irq.h | 11 +++++++++++ include/asm-arm/mach/time.h | 1 + include/linux/irq.h | 4 ++++ kernel/irq/handle.c | 13 +------------ 4 files changed, 17 insertions(+), 12 deletions(-) (limited to 'include/linux/irq.h') diff --git a/include/asm-arm/hw_irq.h b/include/asm-arm/hw_irq.h index f1a08a50060..275b574fd1a 100644 --- a/include/asm-arm/hw_irq.h +++ b/include/asm-arm/hw_irq.h @@ -6,4 +6,15 @@ #include +#if defined(CONFIG_NO_IDLE_HZ) +# include +# define handle_dynamic_tick(action) \ + if (!(action->flags & SA_TIMER) && system_timer->dyn_tick) { \ + write_seqlock(&xtime_lock); \ + if (system_timer->dyn_tick->state & DYN_TICK_ENABLED) \ + system_timer->dyn_tick->handler(irq, 0, regs); \ + write_sequnlock(&xtime_lock); \ + } +#endif + #endif diff --git a/include/asm-arm/mach/time.h b/include/asm-arm/mach/time.h index 9f28073559e..dee0bc336fe 100644 --- a/include/asm-arm/mach/time.h +++ b/include/asm-arm/mach/time.h @@ -69,6 +69,7 @@ extern void timer_tick(struct pt_regs *); /* * Kernel time keeping support. */ +struct timespec; extern int (*set_rtc)(void); extern void save_time_delta(struct timespec *delta, struct timespec *rtc); extern void restore_time_delta(struct timespec *delta, struct timespec *rtc); diff --git a/include/linux/irq.h b/include/linux/irq.h index 95d7aa7954d..b48eae32dc6 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -182,6 +182,10 @@ extern int setup_irq(unsigned int irq, struct irqaction *new); #ifdef CONFIG_GENERIC_HARDIRQS +#ifndef handle_dynamic_tick +# define handle_dynamic_tick(a) do { } while (0) +#endif + #ifdef CONFIG_SMP static inline void set_native_irq_info(int irq, cpumask_t mask) { diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c index 6d8b3011496..aeb6e391276 100644 --- a/kernel/irq/handle.c +++ b/kernel/irq/handle.c @@ -16,10 +16,6 @@ #include #include -#if defined(CONFIG_NO_IDLE_HZ) && defined(CONFIG_ARM) -#include -#endif - #include "internals.h" /** @@ -133,14 +129,7 @@ irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs, irqreturn_t ret, retval = IRQ_NONE; unsigned int status = 0; -#if defined(CONFIG_NO_IDLE_HZ) && defined(CONFIG_ARM) - if (!(action->flags & SA_TIMER) && system_timer->dyn_tick != NULL) { - write_seqlock(&xtime_lock); - if (system_timer->dyn_tick->state & DYN_TICK_ENABLED) - system_timer->dyn_tick->handler(irq, 0, regs); - write_sequnlock(&xtime_lock); - } -#endif + handle_dynamic_tick(action); if (!(action->flags & IRQF_DISABLED)) local_irq_enable(); -- cgit v1.2.3-70-g09d2