[PATCH] genirq: cleanup: misc code cleanups

Assorted code cleanups to the generic IRQ code.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Ingo Molnar
2006-06-29 02:24:40 -07:00
committed by Linus Torvalds
parent 2e60bbb6d5
commit 06fcb0c6fb
5 changed files with 66 additions and 60 deletions

View File

@@ -1,5 +1,5 @@
#ifndef __irq_h #ifndef _LINUX_IRQ_H
#define __irq_h #define _LINUX_IRQ_H
/* /*
* Please do not include this file in generic code. There is currently * Please do not include this file in generic code. There is currently
@@ -11,7 +11,7 @@
#include <linux/smp.h> #include <linux/smp.h>
#if !defined(CONFIG_S390) #ifndef CONFIG_S390
#include <linux/linkage.h> #include <linux/linkage.h>
#include <linux/cache.h> #include <linux/cache.h>
@@ -33,7 +33,7 @@
#define IRQ_WAITING 32 /* IRQ not yet seen - for autodetection */ #define IRQ_WAITING 32 /* IRQ not yet seen - for autodetection */
#define IRQ_LEVEL 64 /* IRQ level triggered */ #define IRQ_LEVEL 64 /* IRQ level triggered */
#define IRQ_MASKED 128 /* IRQ masked - shouldn't be seen again */ #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 IRQ_PER_CPU 256 /* IRQ is per CPU */
# define CHECK_IRQ_PER_CPU(var) ((var) & IRQ_PER_CPU) # define CHECK_IRQ_PER_CPU(var) ((var) & IRQ_PER_CPU)
#else #else
@@ -92,6 +92,7 @@ extern irq_desc_t irq_desc [NR_IRQS];
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_GENERIC_HARDIRQS
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
static inline void set_native_irq_info(int irq, cpumask_t mask) static inline void set_native_irq_info(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) 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); 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) static inline void set_irq_info(int irq, cpumask_t mask)
{ {
set_native_irq_info(irq, 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_irq(x)
#define move_native_irq(x) #define move_native_irq(x)
#endif // CONFIG_SMP #endif /* CONFIG_SMP */
#ifdef CONFIG_IRQBALANCE #ifdef CONFIG_IRQBALANCE
extern void set_balance_irq_affinity(unsigned int irq, cpumask_t mask); 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 #ifdef CONFIG_AUTO_IRQ_AFFINITY
extern int select_smp_affinity(unsigned int irq); extern int select_smp_affinity(unsigned int irq);
#else #else
static inline int static inline int select_smp_affinity(unsigned int irq)
select_smp_affinity(unsigned int irq)
{ {
return 1; return 1;
} }
#endif #endif
#endif #endif /* CONFIG_GENERIC_HARDIRQS */
extern hw_irq_controller no_irq_type; /* needed in every arch ? */ extern hw_irq_controller no_irq_type; /* needed in every arch ? */
#endif #endif /* !CONFIG_S390 */
#endif /* __irq_h */ #endif /* _LINUX_IRQ_H */

View File

@@ -27,7 +27,7 @@ static DEFINE_MUTEX(probing_active);
*/ */
unsigned long probe_irq_on(void) unsigned long probe_irq_on(void)
{ {
unsigned long val; unsigned long mask;
irq_desc_t *desc; irq_desc_t *desc;
unsigned int i; unsigned int i;
@@ -40,8 +40,8 @@ unsigned long probe_irq_on(void)
desc = irq_desc + i; desc = irq_desc + i;
spin_lock_irq(&desc->lock); spin_lock_irq(&desc->lock);
if (!irq_desc[i].action) if (!desc->action)
irq_desc[i].chip->startup(i); desc->chip->startup(i);
spin_unlock_irq(&desc->lock); spin_unlock_irq(&desc->lock);
} }
@@ -73,11 +73,11 @@ unsigned long probe_irq_on(void)
/* /*
* Now filter out any obviously spurious interrupts * Now filter out any obviously spurious interrupts
*/ */
val = 0; mask = 0;
for (i = 0; i < NR_IRQS; i++) { for (i = 0; i < NR_IRQS; i++) {
irq_desc_t *desc = irq_desc + i;
unsigned int status; unsigned int status;
desc = irq_desc + i;
spin_lock_irq(&desc->lock); spin_lock_irq(&desc->lock);
status = desc->status; status = desc->status;
@@ -88,14 +88,13 @@ unsigned long probe_irq_on(void)
desc->chip->shutdown(i); desc->chip->shutdown(i);
} else } else
if (i < 32) if (i < 32)
val |= 1 << i; mask |= 1 << i;
} }
spin_unlock_irq(&desc->lock); spin_unlock_irq(&desc->lock);
} }
return val; return mask;
} }
EXPORT_SYMBOL(probe_irq_on); EXPORT_SYMBOL(probe_irq_on);
/** /**
@@ -184,6 +183,5 @@ int probe_irq_off(unsigned long val)
return irq_found; return irq_found;
} }
EXPORT_SYMBOL(probe_irq_off); EXPORT_SYMBOL(probe_irq_off);

View File

@@ -18,7 +18,7 @@
* Linux has a controller-independent interrupt architecture. * Linux has a controller-independent interrupt architecture.
* Every controller has a 'controller-template', that is used * Every controller has a 'controller-template', that is used
* by the main code to do the right thing. Each driver-visible * 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 * controller. Thus drivers need not be aware of the
* interrupt-controller. * interrupt-controller.
* *

View File

@@ -40,7 +40,6 @@ void synchronize_irq(unsigned int irq)
while (desc->status & IRQ_INPROGRESS) while (desc->status & IRQ_INPROGRESS)
cpu_relax(); cpu_relax();
} }
EXPORT_SYMBOL(synchronize_irq); EXPORT_SYMBOL(synchronize_irq);
#endif #endif
@@ -71,7 +70,6 @@ void disable_irq_nosync(unsigned int irq)
} }
spin_unlock_irqrestore(&desc->lock, flags); spin_unlock_irqrestore(&desc->lock, flags);
} }
EXPORT_SYMBOL(disable_irq_nosync); EXPORT_SYMBOL(disable_irq_nosync);
/** /**
@@ -97,7 +95,6 @@ void disable_irq(unsigned int irq)
if (desc->action) if (desc->action)
synchronize_irq(irq); synchronize_irq(irq);
} }
EXPORT_SYMBOL(disable_irq); EXPORT_SYMBOL(disable_irq);
/** /**
@@ -139,7 +136,6 @@ void enable_irq(unsigned int irq)
} }
spin_unlock_irqrestore(&desc->lock, flags); spin_unlock_irqrestore(&desc->lock, flags);
} }
EXPORT_SYMBOL(enable_irq); EXPORT_SYMBOL(enable_irq);
/* /*
@@ -200,7 +196,8 @@ int setup_irq(unsigned int irq, struct irqaction * new)
*/ */
spin_lock_irqsave(&desc->lock, flags); spin_lock_irqsave(&desc->lock, flags);
p = &desc->action; p = &desc->action;
if ((old = *p) != NULL) { old = *p;
if (old) {
/* Can't share interrupts unless both agree to */ /* Can't share interrupts unless both agree to */
if (!(old->flags & new->flags & SA_SHIRQ)) if (!(old->flags & new->flags & SA_SHIRQ))
goto mismatch; goto mismatch;
@@ -317,7 +314,6 @@ void free_irq(unsigned int irq, void *dev_id)
return; return;
} }
} }
EXPORT_SYMBOL(free_irq); EXPORT_SYMBOL(free_irq);
/** /**
@@ -388,6 +384,5 @@ int request_irq(unsigned int irq,
return retval; return retval;
} }
EXPORT_SYMBOL(request_irq); EXPORT_SYMBOL(request_irq);

View File

@@ -16,22 +16,20 @@ static int irqfixup __read_mostly;
/* /*
* Recovery handler for misrouted interrupts. * Recovery handler for misrouted interrupts.
*/ */
static int misrouted_irq(int irq, struct pt_regs *regs) static int misrouted_irq(int irq, struct pt_regs *regs)
{ {
int i; int i;
irq_desc_t *desc;
int ok = 0; int ok = 0;
int work = 0; /* Did we do work for a real IRQ */ 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; struct irqaction *action;
if (i == irq) /* Already tried */ if (i == irq) /* Already tried */
continue; continue;
desc = &irq_desc[i];
spin_lock(&desc->lock); spin_lock(&desc->lock);
action = desc->action;
/* Already running on another processor */ /* Already running on another processor */
if (desc->status & IRQ_INPROGRESS) { if (desc->status & IRQ_INPROGRESS) {
/* /*
@@ -45,7 +43,9 @@ static int misrouted_irq(int irq, struct pt_regs *regs)
} }
/* Honour the normal IRQ locking */ /* Honour the normal IRQ locking */
desc->status |= IRQ_INPROGRESS; desc->status |= IRQ_INPROGRESS;
action = desc->action;
spin_unlock(&desc->lock); spin_unlock(&desc->lock);
while (action) { while (action) {
/* Only shared IRQ handlers are safe to call */ /* Only shared IRQ handlers are safe to call */
if (action->flags & SA_SHIRQ) { 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 * 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) { while ((desc->status & IRQ_PENDING) && action) {
/* /*
* Perform real IRQ processing for the IRQ we deferred * Perform real IRQ processing for the IRQ we deferred
@@ -113,6 +112,7 @@ __report_bad_irq(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret)
} }
dump_stack(); dump_stack();
printk(KERN_ERR "handlers:\n"); printk(KERN_ERR "handlers:\n");
action = desc->action; action = desc->action;
while (action) { while (action) {
printk(KERN_ERR "[<%p>]", action->handler); 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; static int count = 100;
@@ -177,6 +178,7 @@ int __init noirqdebug_setup(char *str)
{ {
noirqdebug = 1; noirqdebug = 1;
printk(KERN_INFO "IRQ lockup detection disabled\n"); printk(KERN_INFO "IRQ lockup detection disabled\n");
return 1; return 1;
} }
@@ -187,6 +189,7 @@ static int __init irqfixup_setup(char *str)
irqfixup = 1; irqfixup = 1;
printk(KERN_WARNING "Misrouted IRQ fixup support enabled.\n"); printk(KERN_WARNING "Misrouted IRQ fixup support enabled.\n");
printk(KERN_WARNING "This may impact system performance.\n"); printk(KERN_WARNING "This may impact system performance.\n");
return 1; return 1;
} }