Skip to content

Commit edd14cf

Browse files
Keith BuschKAGA-KOKO
authored andcommitted
genirq: Add untracked irq handler
This adds a software irq handler for controllers that multiplex interrupts from multiple devices, but don't know which device generated the interrupt. For these devices, the irq handler that demuxes must check every action for every software irq using the same h/w irq in order to find out which device generated the interrupt. This will inevitably trigger spurious interrupt detection if we are noting the irq. The new irq handler does not track the handling for spurious interrupt detection. An irq that uses this also won't get stats tracked since it didn't generate the interrupt, nor added to randomness since they are not random. Signed-off-by: Keith Busch <keith.busch@intel.com> Cc: Bjorn Helgaas <bhelgaas@google.com> Cc: linux-pci@vger.kernel.org Cc: Jon Derrick <jonathan.derrick@intel.com> Link: http://lkml.kernel.org/r/1466200821-29159-1-git-send-email-keith.busch@intel.com Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent 21c57fd commit edd14cf

4 files changed

Lines changed: 59 additions & 4 deletions

File tree

‎include/linux/irq.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ extern void handle_fasteoi_irq(struct irq_desc *desc);
484484
extern void handle_edge_irq(struct irq_desc *desc);
485485
extern void handle_edge_eoi_irq(struct irq_desc *desc);
486486
extern void handle_simple_irq(struct irq_desc *desc);
487+
extern void handle_untracked_irq(struct irq_desc *desc);
487488
extern void handle_percpu_irq(struct irq_desc *desc);
488489
extern void handle_percpu_devid_irq(struct irq_desc *desc);
489490
extern void handle_bad_irq(struct irq_desc *desc);

‎kernel/irq/chip.c‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,49 @@ void handle_simple_irq(struct irq_desc *desc)
426426
}
427427
EXPORT_SYMBOL_GPL(handle_simple_irq);
428428

429+
/**
430+
* handle_untracked_irq - Simple and software-decoded IRQs.
431+
* @desc: the interrupt description structure for this irq
432+
*
433+
* Untracked interrupts are sent from a demultiplexing interrupt
434+
* handler when the demultiplexer does not know which device it its
435+
* multiplexed irq domain generated the interrupt. IRQ's handled
436+
* through here are not subjected to stats tracking, randomness, or
437+
* spurious interrupt detection.
438+
*
439+
* Note: Like handle_simple_irq, the caller is expected to handle
440+
* the ack, clear, mask and unmask issues if necessary.
441+
*/
442+
void handle_untracked_irq(struct irq_desc *desc)
443+
{
444+
unsigned int flags = 0;
445+
446+
raw_spin_lock(&desc->lock);
447+
448+
if (!irq_may_run(desc))
449+
goto out_unlock;
450+
451+
desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
452+
453+
if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data))) {
454+
desc->istate |= IRQS_PENDING;
455+
goto out_unlock;
456+
}
457+
458+
desc->istate &= ~IRQS_PENDING;
459+
irqd_set(&desc->irq_data, IRQD_IRQ_INPROGRESS);
460+
raw_spin_unlock(&desc->lock);
461+
462+
__handle_irq_event_percpu(desc, &flags);
463+
464+
raw_spin_lock(&desc->lock);
465+
irqd_clear(&desc->irq_data, IRQD_IRQ_INPROGRESS);
466+
467+
out_unlock:
468+
raw_spin_unlock(&desc->lock);
469+
}
470+
EXPORT_SYMBOL_GPL(handle_untracked_irq);
471+
429472
/*
430473
* Called unconditionally from handle_level_irq() and only for oneshot
431474
* interrupts from handle_fasteoi_irq()

‎kernel/irq/handle.c‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ void __irq_wake_thread(struct irq_desc *desc, struct irqaction *action)
132132
wake_up_process(action->thread);
133133
}
134134

135-
irqreturn_t handle_irq_event_percpu(struct irq_desc *desc)
135+
irqreturn_t __handle_irq_event_percpu(struct irq_desc *desc, unsigned int *flags)
136136
{
137137
irqreturn_t retval = IRQ_NONE;
138-
unsigned int flags = 0, irq = desc->irq_data.irq;
138+
unsigned int irq = desc->irq_data.irq;
139139
struct irqaction *action;
140140

141141
for_each_action_of_desc(desc, action) {
@@ -164,7 +164,7 @@ irqreturn_t handle_irq_event_percpu(struct irq_desc *desc)
164164

165165
/* Fall through to add to randomness */
166166
case IRQ_HANDLED:
167-
flags |= action->flags;
167+
*flags |= action->flags;
168168
break;
169169

170170
default:
@@ -174,7 +174,17 @@ irqreturn_t handle_irq_event_percpu(struct irq_desc *desc)
174174
retval |= res;
175175
}
176176

177-
add_interrupt_randomness(irq, flags);
177+
return retval;
178+
}
179+
180+
irqreturn_t handle_irq_event_percpu(struct irq_desc *desc)
181+
{
182+
irqreturn_t retval;
183+
unsigned int flags = 0;
184+
185+
retval = __handle_irq_event_percpu(desc, &flags);
186+
187+
add_interrupt_randomness(desc->irq_data.irq, flags);
178188

179189
if (!noirqdebug)
180190
note_interrupt(desc, retval);

‎kernel/irq/internals.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ extern void irq_mark_irq(unsigned int irq);
8484

8585
extern void init_kstat_irqs(struct irq_desc *desc, int node, int nr);
8686

87+
irqreturn_t __handle_irq_event_percpu(struct irq_desc *desc, unsigned int *flags);
8788
irqreturn_t handle_irq_event_percpu(struct irq_desc *desc);
8889
irqreturn_t handle_irq_event(struct irq_desc *desc);
8990

0 commit comments

Comments
 (0)