]> git.baikalelectronics.ru Git - kernel.git/commit
Fix synchronize_irq races with IRQ handler
authorHerbert Xu <herbert@gondor.apana.org.au>
Tue, 23 Oct 2007 03:26:25 +0000 (11:26 +0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 23 Oct 2007 16:01:31 +0000 (09:01 -0700)
commite5c9383cd05ba55bcee43cfe4d3020a56e594407
tree7bbd027e40805966ad908e40f09ffd412a72a88b
parente7ac09c348761d24722945832a9521710027b430
Fix synchronize_irq races with IRQ handler

As it is some callers of synchronize_irq rely on memory barriers
to provide synchronisation against the IRQ handlers.  For example,
the tg3 driver does

tp->irq_sync = 1;
smp_mb();
synchronize_irq();

and then in the IRQ handler:

if (!tp->irq_sync)
netif_rx_schedule(dev, &tp->napi);

Unfortunately memory barriers only work well when they come in
pairs.  Because we don't actually have memory barriers on the
IRQ path, the memory barrier before the synchronize_irq() doesn't
actually protect us.

In particular, synchronize_irq() may return followed by the
result of netif_rx_schedule being made visible.

This patch (mostly written by Linus) fixes this by using spin
locks instead of memory barries on the synchronize_irq() path.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
kernel/irq/manage.c