/*1* linux/kernel/irq/resend.c2*3* Copyright (C) 1992, 1998-2006 Linus Torvalds, Ingo Molnar4* Copyright (C) 2005-2006, Thomas Gleixner5*6* This file contains the IRQ-resend code7*8* If the interrupt is waiting to be processed, we try to re-run it.9* We can't directly run it from here since the caller might be in an10* interrupt-protected region. Not all irq controller chips can11* retrigger interrupts at the hardware level, so in those cases12* we allow the resending of IRQs via a tasklet.13*/1415#include <linux/irq.h>16#include <linux/module.h>17#include <linux/random.h>18#include <linux/interrupt.h>1920#include "internals.h"2122#ifdef CONFIG_HARDIRQS_SW_RESEND2324/* Bitmap to handle software resend of interrupts: */25static DECLARE_BITMAP(irqs_resend, IRQ_BITMAP_BITS);2627/*28* Run software resends of IRQ's29*/30static void resend_irqs(unsigned long arg)31{32struct irq_desc *desc;33int irq;3435while (!bitmap_empty(irqs_resend, nr_irqs)) {36irq = find_first_bit(irqs_resend, nr_irqs);37clear_bit(irq, irqs_resend);38desc = irq_to_desc(irq);39local_irq_disable();40desc->handle_irq(irq, desc);41local_irq_enable();42}43}4445/* Tasklet to handle resend: */46static DECLARE_TASKLET(resend_tasklet, resend_irqs, 0);4748#endif4950/*51* IRQ resend52*53* Is called with interrupts disabled and desc->lock held.54*/55void check_irq_resend(struct irq_desc *desc, unsigned int irq)56{57/*58* We do not resend level type interrupts. Level type59* interrupts are resent by hardware when they are still60* active.61*/62if (irq_settings_is_level(desc))63return;64if (desc->istate & IRQS_REPLAY)65return;66if (desc->istate & IRQS_PENDING) {67desc->istate &= ~IRQS_PENDING;68desc->istate |= IRQS_REPLAY;6970if (!desc->irq_data.chip->irq_retrigger ||71!desc->irq_data.chip->irq_retrigger(&desc->irq_data)) {72#ifdef CONFIG_HARDIRQS_SW_RESEND73/* Set it pending and activate the softirq: */74set_bit(irq, irqs_resend);75tasklet_schedule(&resend_tasklet);76#endif77}78}79}808182