History

genirq: Move INPROGRESS, MASKED and DISABLED state flags to irq_data

We really need these flags for some of the interrupt chips. Move it from internal state to irq_data and provide proper accessors.

Thomas Gleixner committed 15 years ago

Commit 32f41251 parent c2d0c559 files · +64 −59Browse files

Showing the changes to kernel (8 of 9 files). Show all

Unified · Split

8 files
  1. kernel/irq/chip.c +19 −21
  2. kernel/irq/debug.h +7 −3
  3. kernel/irq/handle.c +2 −2
  4. kernel/irq/internals.h +0 −6
  5. kernel/irq/irqdesc.c +0 −2
  6. kernel/irq/manage.c +14 −16
  7. kernel/irq/migration.c +2 −2
  8. kernel/irq/spurious.c +5 −5
kernel/irq/chip.c+19−21
@@ -140,27 +140,25 @@ EXPORT_SYMBOL_GPL(irq_get_irq_data); · 139 unmodified lines
140140
141141 static void irq_state_clr_disabled(struct irq_desc *desc)
142142 {
143− desc->istate &= ~IRQS_DISABLED;
144143 irqd_clear(&desc->irq_data, IRQD_IRQ_DISABLED);
145144 irq_compat_clr_disabled(desc);
146145 }
147146
148147 static void irq_state_set_disabled(struct irq_desc *desc)
149148 {
150− desc->istate |= IRQS_DISABLED;
151149 irqd_set(&desc->irq_data, IRQD_IRQ_DISABLED);
152150 irq_compat_set_disabled(desc);
153151 }
154152
155153 static void irq_state_clr_masked(struct irq_desc *desc)
156154 {
157− desc->istate &= ~IRQS_MASKED;
155+ irqd_clear(&desc->irq_data, IRQD_IRQ_MASKED);
158156 irq_compat_clr_masked(desc);
159157 }
160158
161159 static void irq_state_set_masked(struct irq_desc *desc)
162160 {
163− desc->istate |= IRQS_MASKED;
161+ irqd_set(&desc->irq_data, IRQD_IRQ_MASKED);
164162 irq_compat_set_masked(desc);
165163 }
166164
@@ -380,11 +378,11 @@ void handle_nested_irq(unsigned int irq) · 213 unmodified lines
380378 kstat_incr_irqs_this_cpu(irq, desc);
381379
382380 action = desc->action;
383− if (unlikely(!action || (desc->istate & IRQS_DISABLED)))
381+ if (unlikely(!action || irqd_irq_disabled(&desc->irq_data)))
384382 goto out_unlock;
385383
386384 irq_compat_set_progress(desc);
387− desc->istate |= IRQS_INPROGRESS;
385+ irqd_set(&desc->irq_data, IRQD_IRQ_INPROGRESS);
388386 raw_spin_unlock_irq(&desc->lock);
389387
390388 action_ret = action->thread_fn(action->irq, action->dev_id);
@@ -392,7 +390,7 @@ void handle_nested_irq(unsigned int irq) · 1 unmodified line
392390 note_interrupt(irq, desc, action_ret);
393391
394392 raw_spin_lock_irq(&desc->lock);
395− desc->istate &= ~IRQS_INPROGRESS;
393+ irqd_clear(&desc->irq_data, IRQD_IRQ_INPROGRESS);
396394 irq_compat_clr_progress(desc);
397395
398396 out_unlock:
@@ -424,14 +422,14 @@ handle_simple_irq(unsigned int irq, struct irq_desc *desc) · 25 unmodified lines
424422 {
425423 raw_spin_lock(&desc->lock);
426424
427− if (unlikely(desc->istate & IRQS_INPROGRESS))
425+ if (unlikely(irqd_irq_inprogress(&desc->irq_data)))
428426 if (!irq_check_poll(desc))
429427 goto out_unlock;
430428
431429 desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
432430 kstat_incr_irqs_this_cpu(irq, desc);
433431
434− if (unlikely(!desc->action || (desc->istate & IRQS_DISABLED)))
432+ if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data)))
435433 goto out_unlock;
436434
437435 handle_irq_event(desc);
@@ -456,7 +454,7 @@ handle_level_irq(unsigned int irq, struct irq_desc *desc) · 18 unmodified lines
456454 raw_spin_lock(&desc->lock);
457455 mask_ack_irq(desc);
458456
459− if (unlikely(desc->istate & IRQS_INPROGRESS))
457+ if (unlikely(irqd_irq_inprogress(&desc->irq_data)))
460458 if (!irq_check_poll(desc))
461459 goto out_unlock;
462460
@@ -467,12 +465,12 @@ handle_level_irq(unsigned int irq, struct irq_desc *desc) · 4 unmodified lines
467465 * If its disabled or no action available
468466 * keep it masked and get out of here
469467 */
470− if (unlikely(!desc->action || (desc->istate & IRQS_DISABLED)))
468+ if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data)))
471469 goto out_unlock;
472470
473471 handle_irq_event(desc);
474472
475− if (!(desc->istate & (IRQS_DISABLED | IRQS_ONESHOT)))
473+ if (!irqd_irq_disabled(&desc->irq_data) && !(desc->istate & IRQS_ONESHOT))
476474 unmask_irq(desc);
477475 out_unlock:
478476 raw_spin_unlock(&desc->lock);
@@ -504,7 +502,7 @@ handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc) · 25 unmodified lines
504502 {
505503 raw_spin_lock(&desc->lock);
506504
507− if (unlikely(desc->istate & IRQS_INPROGRESS))
505+ if (unlikely(irqd_irq_inprogress(&desc->irq_data)))
508506 if (!irq_check_poll(desc))
509507 goto out;
510508
@@ -515,7 +513,7 @@ handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc) · 4 unmodified lines
515513 * If its disabled or no action available
516514 * then mask it and get out of here:
517515 */
518− if (unlikely(!desc->action || (desc->istate & IRQS_DISABLED))) {
516+ if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data))) {
519517 irq_compat_set_pending(desc);
520518 desc->istate |= IRQS_PENDING;
521519 mask_irq(desc);
@@ -566,8 +564,8 @@ handle_edge_irq(unsigned int irq, struct irq_desc *desc) · 44 unmodified lines
566564 * we shouldn't process the IRQ. Mark it pending, handle
567565 * the necessary masking and go out
568566 */
569− if (unlikely((desc->istate & (IRQS_DISABLED | IRQS_INPROGRESS) ||
570− !desc->action))) {
567+ if (unlikely(irqd_irq_disabled(&desc->irq_data) ||
568+ irqd_irq_inprogress(&desc->irq_data) || !desc->action)) {
571569 if (!irq_check_poll(desc)) {
572570 irq_compat_set_pending(desc);
573571 desc->istate |= IRQS_PENDING;
@@ -592,15 +590,15 @@ handle_edge_irq(unsigned int irq, struct irq_desc *desc) · 18 unmodified lines
592590 * Renable it, if it was not disabled in meantime.
593591 */
594592 if (unlikely(desc->istate & IRQS_PENDING)) {
595− if (!(desc->istate & IRQS_DISABLED) &&
596− (desc->istate & IRQS_MASKED))
593+ if (!irqd_irq_disabled(&desc->irq_data) &&
594+ irqd_irq_masked(&desc->irq_data))
597595 unmask_irq(desc);
598596 }
599597
600598 handle_irq_event(desc);
601599
602600 } while ((desc->istate & IRQS_PENDING) &&
603− !(desc->istate & IRQS_DISABLED));
601+ !irqd_irq_disabled(&desc->irq_data));
604602
605603 out_unlock:
606604 raw_spin_unlock(&desc->lock);
@@ -720,7 +718,7 @@ void irq_cpu_online(void) · 113 unmodified lines
720718 chip = irq_data_get_irq_chip(&desc->irq_data);
721719 if (chip && chip->irq_cpu_online &&
722720 (!(chip->flags & IRQCHIP_ONOFFLINE_ENABLED) ||
723− !(desc->istate & IRQS_DISABLED)))
721+ !irqd_irq_disabled(&desc->irq_data)))
724722 chip->irq_cpu_online(&desc->irq_data);
725723
726724 raw_spin_unlock_irqrestore(&desc->lock, flags);
@@ -750,7 +748,7 @@ void irq_cpu_offline(void) · 23 unmodified lines
750748 chip = irq_data_get_irq_chip(&desc->irq_data);
751749 if (chip && chip->irq_cpu_offline &&
752750 (!(chip->flags & IRQCHIP_ONOFFLINE_ENABLED) ||
753− !(desc->istate & IRQS_DISABLED)))
751+ !irqd_irq_disabled(&desc->irq_data)))
754752 chip->irq_cpu_offline(&desc->irq_data);
755753
756754 raw_spin_unlock_irqrestore(&desc->lock, flags);
kernel/irq/debug.h+7−3
@@ -6,6 +6,8 @@ · 5 unmodified lines
66
77 #define P(f) if (desc->status & f) printk("%14s set\n", #f)
88 #define PS(f) if (desc->istate & f) printk("%14s set\n", #f)
9+/* FIXME */
10+#define PD(f) do { } while (0)
911
1012 static inline void print_irq_desc(unsigned int irq, struct irq_desc *desc)
1113 {
@@ -28,13 +30,15 @@ static inline void print_irq_desc(unsigned int irq, struct irq_desc *desc) · 16 unmodified lines
2830 P(IRQ_NOAUTOEN);
2931
3032 PS(IRQS_AUTODETECT);
31− PS(IRQS_INPROGRESS);
3233 PS(IRQS_REPLAY);
3334 PS(IRQS_WAITING);
34− PS(IRQS_DISABLED);
3535 PS(IRQS_PENDING);
36− PS(IRQS_MASKED);
36+
37+ PD(IRQS_INPROGRESS);
38+ PD(IRQS_DISABLED);
39+ PD(IRQS_MASKED);
3740 }
3841
3942 #undef P
4043 #undef PS
44+#undef PD
kernel/irq/handle.c+2−2
@@ -178,13 +178,13 @@ irqreturn_t handle_irq_event(struct irq_desc *desc) · 177 unmodified lines
178178 irq_compat_clr_pending(desc);
179179 desc->istate &= ~IRQS_PENDING;
180180 irq_compat_set_progress(desc);
181− desc->istate |= IRQS_INPROGRESS;
181+ irqd_set(&desc->irq_data, IRQD_IRQ_INPROGRESS);
182182 raw_spin_unlock(&desc->lock);
183183
184184 ret = handle_irq_event_percpu(desc, action);
185185
186186 raw_spin_lock(&desc->lock);
187− desc->istate &= ~IRQS_INPROGRESS;
187+ irqd_clear(&desc->irq_data, IRQD_IRQ_INPROGRESS);
188188 irq_compat_clr_progress(desc);
189189 return ret;
190190 }
kernel/irq/internals.h+0−6
@@ -44,26 +44,20 @@ enum { · 43 unmodified lines
4444 * IRQS_SPURIOUS_DISABLED - was disabled due to spurious interrupt
4545 * detection
4646 * IRQS_POLL_INPROGRESS - polling in progress
47− * IRQS_INPROGRESS - Interrupt in progress
4847 * IRQS_ONESHOT - irq is not unmasked in primary handler
4948 * IRQS_REPLAY - irq is replayed
5049 * IRQS_WAITING - irq is waiting
51− * IRQS_DISABLED - irq is disabled
5250 * IRQS_PENDING - irq is pending and replayed later
53− * IRQS_MASKED - irq is masked
5451 * IRQS_SUSPENDED - irq is suspended
5552 */
5653 enum {
5754 IRQS_AUTODETECT = 0x00000001,
5855 IRQS_SPURIOUS_DISABLED = 0x00000002,
5956 IRQS_POLL_INPROGRESS = 0x00000008,
60− IRQS_INPROGRESS = 0x00000010,
6157 IRQS_ONESHOT = 0x00000020,
6258 IRQS_REPLAY = 0x00000040,
6359 IRQS_WAITING = 0x00000080,
64− IRQS_DISABLED = 0x00000100,
6560 IRQS_PENDING = 0x00000200,
66− IRQS_MASKED = 0x00000400,
6761 IRQS_SUSPENDED = 0x00000800,
6862 };
6963
kernel/irq/irqdesc.c+0−2
@@ -81,7 +81,6 @@ static void desc_set_defaults(unsigned int irq, struct irq_desc *desc, int node) · 80 unmodified lines
8181 desc->irq_data.msi_desc = NULL;
8282 irq_settings_clr_and_set(desc, ~0, _IRQ_DEFAULT_INIT_FLAGS);
8383 irqd_set(&desc->irq_data, IRQD_IRQ_DISABLED);
84− desc->istate = IRQS_DISABLED;
8584 desc->handle_irq = handle_bad_irq;
8685 desc->depth = 1;
8786 desc->irq_count = 0;
@@ -239,7 +238,6 @@ int __init early_irq_init(void) · 151 unmodified lines
239238
240239 struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp = {
241240 [0 ... NR_IRQS-1] = {
242− .istate = IRQS_DISABLED,
243241 .handle_irq = handle_bad_irq,
244242 .depth = 1,
245243 .lock = __RAW_SPIN_LOCK_UNLOCKED(irq_desc->lock),
kernel/irq/manage.c+14−16
@@ -41,7 +41,7 @@ early_param("threadirqs", setup_forced_irqthreads); · 40 unmodified lines
4141 void synchronize_irq(unsigned int irq)
4242 {
4343 struct irq_desc *desc = irq_to_desc(irq);
44− unsigned int state;
44+ bool inprogress;
4545
4646 if (!desc)
4747 return;
@@ -53,16 +53,16 @@ void synchronize_irq(unsigned int irq) · 5 unmodified lines
5353 * Wait until we're out of the critical section. This might
5454 * give the wrong answer due to the lack of memory barriers.
5555 */
56− while (desc->istate & IRQS_INPROGRESS)
56+ while (irqd_irq_inprogress(&desc->irq_data))
5757 cpu_relax();
5858
5959 /* Ok, that indicated we're done: double-check carefully. */
6060 raw_spin_lock_irqsave(&desc->lock, flags);
61− state = desc->istate;
61+ inprogress = irqd_irq_inprogress(&desc->irq_data);
6262 raw_spin_unlock_irqrestore(&desc->lock, flags);
6363
6464 /* Oops, that failed? */
65− } while (state & IRQS_INPROGRESS);
65+ } while (inprogress);
6666
6767 /*
6868 * We made sure that no hardirq handler is running. Now verify
@@ -563,9 +563,9 @@ int __irq_set_trigger(struct irq_desc *desc, unsigned int irq, · 494 unmodified lines
563563 flags &= IRQ_TYPE_SENSE_MASK;
564564
565565 if (chip->flags & IRQCHIP_SET_TYPE_MASKED) {
566− if (!(desc->istate & IRQS_MASKED))
566+ if (!irqd_irq_masked(&desc->irq_data))
567567 mask_irq(desc);
568− if (!(desc->istate & IRQS_DISABLED))
568+ if (!irqd_irq_disabled(&desc->irq_data))
569569 unmask = 1;
570570 }
571571
@@ -663,7 +663,7 @@ again: · 91 unmodified lines
663663 * irq_wake_thread(). See the comment there which explains the
664664 * serialization.
665665 */
666− if (unlikely(desc->istate & IRQS_INPROGRESS)) {
666+ if (unlikely(irqd_irq_inprogress(&desc->irq_data))) {
667667 raw_spin_unlock_irq(&desc->lock);
668668 chip_bus_sync_unlock(desc);
669669 cpu_relax();
@@ -680,12 +680,10 @@ again: · 10 unmodified lines
680680
681681 desc->threads_oneshot &= ~action->thread_mask;
682682
683− if (!desc->threads_oneshot && !(desc->istate & IRQS_DISABLED) &&
684− (desc->istate & IRQS_MASKED)) {
685− irq_compat_clr_masked(desc);
686− desc->istate &= ~IRQS_MASKED;
687− desc->irq_data.chip->irq_unmask(&desc->irq_data);
688− }
683+ if (!desc->threads_oneshot && !irqd_irq_disabled(&desc->irq_data) &&
684+ irqd_irq_masked(&desc->irq_data))
685+ unmask_irq(desc);
686+
689687 out_unlock:
690688 raw_spin_unlock_irq(&desc->lock);
691689 chip_bus_sync_unlock(desc);
@@ -779,7 +777,7 @@ static int irq_thread(void *data) · 87 unmodified lines
779777 atomic_inc(&desc->threads_active);
780778
781779 raw_spin_lock_irq(&desc->lock);
782− if (unlikely(desc->istate & IRQS_DISABLED)) {
780+ if (unlikely(irqd_irq_disabled(&desc->irq_data))) {
783781 /*
784782 * CHECKME: We might need a dedicated
785783 * IRQ_THREAD_PENDING flag here, which
@@ -997,8 +995,8 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) · 211 unmodified lines
997995 }
998996
999997 desc->istate &= ~(IRQS_AUTODETECT | IRQS_SPURIOUS_DISABLED | \
1000− IRQS_INPROGRESS | IRQS_ONESHOT | \
1001− IRQS_WAITING);
998+ IRQS_ONESHOT | IRQS_WAITING);
999+ irqd_clear(&desc->irq_data, IRQD_IRQ_INPROGRESS);
10021000
10031001 if (new->flags & IRQF_PERCPU) {
10041002 irqd_set(&desc->irq_data, IRQD_PER_CPU);
kernel/irq/migration.c+2−2
@@ -66,7 +66,7 @@ void irq_move_irq(struct irq_data *idata) · 65 unmodified lines
6666 if (likely(!irqd_is_setaffinity_pending(idata)))
6767 return;
6868
69− if (unlikely(desc->istate & IRQS_DISABLED))
69+ if (unlikely(irqd_irq_disabled(idata)))
7070 return;
7171
7272 /*
@@ -74,7 +74,7 @@ void irq_move_irq(struct irq_data *idata) · 1 unmodified line
7474 * threaded interrupt with ONESHOT set, we can end up with an
7575 * interrupt storm.
7676 */
77− masked = desc->istate & IRQS_MASKED;
77+ masked = irqd_irq_masked(idata);
7878 if (!masked)
7979 idata->chip->irq_mask(idata);
8080 irq_move_masked_irq(idata);
kernel/irq/spurious.c+5−5
@@ -45,12 +45,12 @@ bool irq_wait_for_poll(struct irq_desc *desc) · 44 unmodified lines
4545 #ifdef CONFIG_SMP
4646 do {
4747 raw_spin_unlock(&desc->lock);
48− while (desc->istate & IRQS_INPROGRESS)
48+ while (irqd_irq_inprogress(&desc->irq_data))
4949 cpu_relax();
5050 raw_spin_lock(&desc->lock);
51− } while (desc->istate & IRQS_INPROGRESS);
51+ } while irqd_irq_inprogress(&desc->irq_data);
5252 /* Might have been disabled in meantime */
53− return !(desc->istate & IRQS_DISABLED) && desc->action;
53+ return !irqd_irq_disabled(&desc->irq_data) && desc->action;
5454 #else
5555 return false;
5656 #endif
@@ -75,7 +75,7 @@ static int try_one_irq(int irq, struct irq_desc *desc, bool force) · 18 unmodified lines
7575 * Do not poll disabled interrupts unless the spurious
7676 * disabled poller asks explicitely.
7777 */
78− if ((desc->istate & IRQS_DISABLED) && !force)
78+ if (irqd_irq_disabled(&desc->irq_data) && !force)
7979 goto out;
8080
8181 /*
@@ -88,7 +88,7 @@ static int try_one_irq(int irq, struct irq_desc *desc, bool force) · 6 unmodified lines
8888 goto out;
8989
9090 /* Already running on another processor */
91− if (desc->istate & IRQS_INPROGRESS) {
91+ if (irqd_irq_inprogress(&desc->irq_data)) {
9292 /*
9393 * Already running: If it is shared get the other
9494 * CPU to go looking for our mystery interrupt too

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t