Skip to content

Commit 32f4125

Browse files
committed
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. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: David Daney <ddaney@caviumnetworks.com>
1 parent c2d0c55 commit 32f4125

9 files changed

Lines changed: 64 additions & 59 deletions

File tree

‎include/linux/irq.h‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,9 @@ struct irq_data {
174174
* from suspend
175175
* IRDQ_MOVE_PCNTXT - Interrupt can be moved in process
176176
* context
177-
* IRQD_IRQ_DISABLED - Some chip function need to know the
178-
* disabled state.
177+
* IRQD_IRQ_DISABLED - Disabled state of the interrupt
178+
* IRQD_IRQ_MASKED - Masked state of the interrupt
179+
* IRQD_IRQ_INPROGRESS - In progress state of the interrupt
179180
*/
180181
enum {
181182
IRQD_TRIGGER_MASK = 0xf,
@@ -187,6 +188,8 @@ enum {
187188
IRQD_WAKEUP_STATE = (1 << 14),
188189
IRQD_MOVE_PCNTXT = (1 << 15),
189190
IRQD_IRQ_DISABLED = (1 << 16),
191+
IRQD_IRQ_MASKED = (1 << 17),
192+
IRQD_IRQ_INPROGRESS = (1 << 18),
190193
};
191194

192195
static inline bool irqd_is_setaffinity_pending(struct irq_data *d)
@@ -243,6 +246,16 @@ static inline bool irqd_irq_disabled(struct irq_data *d)
243246
return d->state_use_accessors & IRQD_IRQ_DISABLED;
244247
}
245248

249+
static inline bool irqd_irq_masked(struct irq_data *d)
250+
{
251+
return d->state_use_accessors & IRQD_IRQ_MASKED;
252+
}
253+
254+
static inline bool irqd_irq_inprogress(struct irq_data *d)
255+
{
256+
return d->state_use_accessors & IRQD_IRQ_INPROGRESS;
257+
}
258+
246259
/**
247260
* struct irq_chip - hardware interrupt chip descriptor
248261
*

‎kernel/irq/chip.c‎

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -140,27 +140,25 @@ EXPORT_SYMBOL_GPL(irq_get_irq_data);
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,19 +378,19 @@ void handle_nested_irq(unsigned int irq)
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);
391389
if (!noirqdebug)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
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)
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‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,13 @@ irqreturn_t handle_irq_event(struct irq_desc *desc)
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‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,20 @@ enum {
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‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ static void desc_set_defaults(unsigned int irq, struct irq_desc *desc, int node)
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)
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‎

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ early_param("threadirqs", setup_forced_irqthreads);
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)
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,
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 @@ static void irq_finalize_oneshot(struct irq_desc *desc,
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 @@ static void irq_finalize_oneshot(struct irq_desc *desc,
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)
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)
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‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ void irq_move_irq(struct irq_data *idata)
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
/*
7373
* Be careful vs. already masked interrupts. If this is a
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);

0 commit comments

Comments
 (0)