Re: Threaded interrupt handlers broken?

Michael Buesch
2009-08-16T12:45:54Z

On Sunday 16 August 2009 12:14:36 Michael Buesch wrote:
> > 506 spin_lock_irq(&desc->lock);
> > 507 if (unlikely(desc->status & IRQ_DISABLED)) {
> > 508 /*
> > 509 * CHECKME: We might need a dedicated
> > 510 * IRQ_THREAD_PENDING flag here, which
> > 511 * retriggers the thread in check_irq_resend()
> > 512 * but AFAICT IRQ_PENDING should be fine as it
> > 513 * retriggers the interrupt itself --- tglx
> > 514 */
> > 515 desc->status |= IRQ_PENDING;
> > 516 spin_unlock_irq(&desc->lock);
> > 517 } else {
> > 518 spin_unlock_irq(&desc->lock);
> > 519
> > 520 action->thread_fn(action->irq, action->dev_id);
> > 521 }
> > 522
> > 523 wake = atomic_dec_and_test(&desc->threads_active);
>
> Is this test logic inverted? atomic_dec_and_test() means
> (threads_active - 1) == 0
> Shouldn't it be like this?
> (threads_active - 1) != 0

I need the following patch for threaded IRQs to work.
The first hunk obviously is incorrect. But without it the thread_fn is
never called.

Index: wireless-testing/kernel/irq/manage.c
===================================================================
--- wireless-testing.orig/kernel/irq/manage.c 2009-08-15 22:22:07.000000000 +0200
+++ wireless-testing/kernel/irq/manage.c 2009-08-16 14:05:23.000000000 +0200
@@ -504,7 +504,7 @@ static int irq_thread(void *data)
atomic_inc(&desc->threads_active);

spin_lock_irq(&desc->lock);
- if (unlikely(desc->status & IRQ_DISABLED)) {
+ if (0&&unlikely(desc->status & IRQ_DISABLED)) {
/*
* CHECKME: We might need a dedicated
* IRQ_THREAD_PENDING flag here, which
@@ -520,7 +520,7 @@ static int irq_thread(void *data)
action->thread_fn(action->irq, action->dev_id);
}

- wake = atomic_dec_and_test(&desc->threads_active);
+ wake = !atomic_dec_and_test(&desc->threads_active);

if (wake && waitqueue_active(&desc->wait_for_threads))
wake_up(&desc->wait_for_threads);