1 /* Modified by Broadcom Corp. Portions Copyright (c) Broadcom Corp, 2012. */
3 * linux/kernel/irq/resend.c
5 * Copyright (C) 1992, 1998-2006 Linus Torvalds, Ingo Molnar
6 * Copyright (C) 2005-2006, Thomas Gleixner
8 * This file contains the IRQ-resend code
10 * If the interrupt is waiting to be processed, we try to re-run it.
11 * We can't directly run it from here since the caller might be in an
12 * interrupt-protected region. Not all irq controller chips can
13 * retrigger interrupts at the hardware level, so in those cases
14 * we allow the resending of IRQs via a tasklet.
17 #include <linux/irq.h>
18 #include <linux/module.h>
19 #include <linux/random.h>
20 #include <linux/interrupt.h>
22 #if defined(CONFIG_BUZZZ)
23 #include <asm/buzzz.h>
24 #endif /* CONFIG_BUZZZ */
26 #include "internals.h"
28 #ifdef CONFIG_HARDIRQS_SW_RESEND
30 /* Bitmap to handle software resend of interrupts: */
31 static DECLARE_BITMAP(irqs_resend
, NR_IRQS
);
34 * Run software resends of IRQ's
36 static void resend_irqs(unsigned long arg
)
38 struct irq_desc
*desc
;
41 while (!bitmap_empty(irqs_resend
, nr_irqs
)) {
42 irq
= find_first_bit(irqs_resend
, nr_irqs
);
44 #if defined(BUZZZ_KEVT_LVL) && (BUZZZ_KEVT_LVL >= 1)
45 buzzz_kevt_log1(BUZZZ_KEVT_ID_IRQ_RESEND
, irq
);
46 #endif /* BUZZZ_KEVT_LVL */
48 clear_bit(irq
, irqs_resend
);
49 desc
= irq_to_desc(irq
);
51 desc
->handle_irq(irq
, desc
);
56 /* Tasklet to handle resend: */
57 static DECLARE_TASKLET(resend_tasklet
, resend_irqs
, 0);
64 * Is called with interrupts disabled and desc->lock held.
66 void check_irq_resend(struct irq_desc
*desc
, unsigned int irq
)
68 unsigned int status
= desc
->status
;
70 #if defined(BUZZZ_KEVT_LVL) && (BUZZZ_KEVT_LVL >= 1)
71 buzzz_kevt_log1(BUZZZ_KEVT_ID_IRQ_CHECK
, irq
);
72 #endif /* BUZZZ_KEVT_LVL */
75 * Make sure the interrupt is enabled, before resending it:
77 desc
->chip
->enable(irq
);
80 * We do not resend level type interrupts. Level type
81 * interrupts are resent by hardware when they are still
84 if ((status
& (IRQ_LEVEL
| IRQ_PENDING
| IRQ_REPLAY
)) == IRQ_PENDING
) {
85 desc
->status
= (status
& ~IRQ_PENDING
) | IRQ_REPLAY
;
87 if (!desc
->chip
->retrigger
|| !desc
->chip
->retrigger(irq
)) {
88 #ifdef CONFIG_HARDIRQS_SW_RESEND
89 /* Set it pending and activate the softirq: */
90 set_bit(irq
, irqs_resend
);
91 tasklet_schedule(&resend_tasklet
);