diff options
author | David Brownell <david-b@pacbell.net> | 2006-07-30 06:03:08 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-07-31 16:28:36 -0400 |
commit | 15a647eba94c3da27ccc666bea72e7cca06b2d19 (patch) | |
tree | b4fbc1e78cb298a36d1106847be1433553d217c8 | |
parent | 5e44ef238b7eb607532e89249e7b2523faf77a92 (diff) |
[PATCH] genirq: {en,dis}able_irq_wake() need refcounting too
IRQs need refcounting and a state flag to track whether the the IRQ should
be enabled or disabled as a "normal IRQ" source after a series of calls to
{en,dis}able_irq(). For shared IRQs, the IRQ must be enabled so long as at
least one driver needs it active.
Likewise, IRQs need the same support to track whether the IRQ should be
enabled or disabled as a "wakeup event" source after a series of calls to
{en,dis}able_irq_wake(). For shared IRQs, the IRQ must be enabled as a
wakeup source during sleep so long as at least one driver needs it. But
right now they _don't have_ that refcounting ... which means sharing a
wakeup-capable IRQ can't work correctly in some configurations.
This patch adds the refcount and flag mechanisms to set_irq_wake() -- which
is what {en,dis}able_irq_wake() call -- and minimal documentation of what
the irq wake mechanism does.
Drivers relying on the older (broken) "toggle" semantics will trigger a
warning; that'll be a handful of drivers on ARM systems.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Acked-by: Ingo Molnar <mingo@elte.hu>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | include/linux/irq.h | 3 | ||||
-rw-r--r-- | kernel/irq/manage.c | 28 |
2 files changed, 29 insertions, 2 deletions
diff --git a/include/linux/irq.h b/include/linux/irq.h index b48eae32dc61..6e59ac05ef2a 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h | |||
@@ -58,6 +58,7 @@ | |||
58 | #define IRQ_NOREQUEST 0x04000000 /* IRQ cannot be requested */ | 58 | #define IRQ_NOREQUEST 0x04000000 /* IRQ cannot be requested */ |
59 | #define IRQ_NOAUTOEN 0x08000000 /* IRQ will not be enabled on request irq */ | 59 | #define IRQ_NOAUTOEN 0x08000000 /* IRQ will not be enabled on request irq */ |
60 | #define IRQ_DELAYED_DISABLE 0x10000000 /* IRQ disable (masking) happens delayed. */ | 60 | #define IRQ_DELAYED_DISABLE 0x10000000 /* IRQ disable (masking) happens delayed. */ |
61 | #define IRQ_WAKEUP 0x20000000 /* IRQ triggers system wakeup */ | ||
61 | 62 | ||
62 | struct proc_dir_entry; | 63 | struct proc_dir_entry; |
63 | 64 | ||
@@ -124,6 +125,7 @@ struct irq_chip { | |||
124 | * @action: the irq action chain | 125 | * @action: the irq action chain |
125 | * @status: status information | 126 | * @status: status information |
126 | * @depth: disable-depth, for nested irq_disable() calls | 127 | * @depth: disable-depth, for nested irq_disable() calls |
128 | * @wake_depth: enable depth, for multiple set_irq_wake() callers | ||
127 | * @irq_count: stats field to detect stalled irqs | 129 | * @irq_count: stats field to detect stalled irqs |
128 | * @irqs_unhandled: stats field for spurious unhandled interrupts | 130 | * @irqs_unhandled: stats field for spurious unhandled interrupts |
129 | * @lock: locking for SMP | 131 | * @lock: locking for SMP |
@@ -147,6 +149,7 @@ struct irq_desc { | |||
147 | unsigned int status; /* IRQ status */ | 149 | unsigned int status; /* IRQ status */ |
148 | 150 | ||
149 | unsigned int depth; /* nested irq disables */ | 151 | unsigned int depth; /* nested irq disables */ |
152 | unsigned int wake_depth; /* nested wake enables */ | ||
150 | unsigned int irq_count; /* For detecting broken IRQs */ | 153 | unsigned int irq_count; /* For detecting broken IRQs */ |
151 | unsigned int irqs_unhandled; | 154 | unsigned int irqs_unhandled; |
152 | spinlock_t lock; | 155 | spinlock_t lock; |
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 4e461438e48b..92be519eff26 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c | |||
@@ -137,16 +137,40 @@ EXPORT_SYMBOL(enable_irq); | |||
137 | * @irq: interrupt to control | 137 | * @irq: interrupt to control |
138 | * @on: enable/disable power management wakeup | 138 | * @on: enable/disable power management wakeup |
139 | * | 139 | * |
140 | * Enable/disable power management wakeup mode | 140 | * Enable/disable power management wakeup mode, which is |
141 | * disabled by default. Enables and disables must match, | ||
142 | * just as they match for non-wakeup mode support. | ||
143 | * | ||
144 | * Wakeup mode lets this IRQ wake the system from sleep | ||
145 | * states like "suspend to RAM". | ||
141 | */ | 146 | */ |
142 | int set_irq_wake(unsigned int irq, unsigned int on) | 147 | int set_irq_wake(unsigned int irq, unsigned int on) |
143 | { | 148 | { |
144 | struct irq_desc *desc = irq_desc + irq; | 149 | struct irq_desc *desc = irq_desc + irq; |
145 | unsigned long flags; | 150 | unsigned long flags; |
146 | int ret = -ENXIO; | 151 | int ret = -ENXIO; |
152 | int (*set_wake)(unsigned, unsigned) = desc->chip->set_wake; | ||
147 | 153 | ||
154 | /* wakeup-capable irqs can be shared between drivers that | ||
155 | * don't need to have the same sleep mode behaviors. | ||
156 | */ | ||
148 | spin_lock_irqsave(&desc->lock, flags); | 157 | spin_lock_irqsave(&desc->lock, flags); |
149 | if (desc->chip->set_wake) | 158 | if (on) { |
159 | if (desc->wake_depth++ == 0) | ||
160 | desc->status |= IRQ_WAKEUP; | ||
161 | else | ||
162 | set_wake = NULL; | ||
163 | } else { | ||
164 | if (desc->wake_depth == 0) { | ||
165 | printk(KERN_WARNING "Unbalanced IRQ %d " | ||
166 | "wake disable\n", irq); | ||
167 | WARN_ON(1); | ||
168 | } else if (--desc->wake_depth == 0) | ||
169 | desc->status &= ~IRQ_WAKEUP; | ||
170 | else | ||
171 | set_wake = NULL; | ||
172 | } | ||
173 | if (set_wake) | ||
150 | ret = desc->chip->set_wake(irq, on); | 174 | ret = desc->chip->set_wake(irq, on); |
151 | spin_unlock_irqrestore(&desc->lock, flags); | 175 | spin_unlock_irqrestore(&desc->lock, flags); |
152 | return ret; | 176 | return ret; |