diff options
author | Maciej W. Rozycki <macro@linux-mips.org> | 2007-09-29 01:42:14 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:53:55 -0400 |
commit | 0ac49527318bc388a881152d60f49d7951606024 (patch) | |
tree | 64b99a7543c913ff17344259b3938d6a5702ef69 /include/linux/phy.h | |
parent | f7ab697d328b0a417d9e3cb891d45693ea89e83d (diff) |
PHYLIB: IRQ event workqueue handling fixes
Keep track of disable_irq_nosync() invocations and call enable_irq() the
right number of times if work has been cancelled that would include them.
Now that the call to flush_work_keventd() (problematic because of
rtnl_mutex being held) has been replaced by cancel_work_sync() another
issue has arisen and been left unresolved. As the MDIO bus cannot be
accessed from the interrupt context the PHY interrupt handler uses
disable_irq_nosync() to prevent from looping and schedules some work to be
done as a softirq, which, apart from handling the state change of the
originating PHY, is responsible for reenabling the interrupt. Now if the
interrupt line is shared by another device and a call to the softirq
handler has been cancelled, that call to enable_irq() never happens and the
other device cannot use its interrupt anymore as its stuck disabled.
I decided to use a counter rather than a flag because there may be more
than one call to phy_change() cancelled in the queue -- a real one and a
fake one triggered by free_irq() if DEBUG_SHIRQ is used, if nothing else.
Therefore because of its nesting property enable_irq() has to be called the
right number of times to match the number disable_irq_nosync() was called
and restore the original state. This DEBUG_SHIRQ feature is also the
reason why free_irq() has to be called before cancel_work_sync().
While at it I updated the comment about phy_stop_interrupts() being called
from `keventd' -- this is no longer relevant as the use of
cancel_work_sync() makes such an approach unnecessary. OTOH a similar
comment referring to flush_scheduled_work() in phy_stop() still applies as
using cancel_work_sync() there would be dangerous.
Checked with checkpatch.pl and at the run time (with and without
DEBUG_SHIRQ).
Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
Cc: Andy Fleming <afleming@freescale.com>
Cc: Jeff Garzik <jgarzik@pobox.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'include/linux/phy.h')
-rw-r--r-- | include/linux/phy.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/include/linux/phy.h b/include/linux/phy.h index 2a659789f9ca..f0742b6aaa64 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h | |||
@@ -25,6 +25,8 @@ | |||
25 | #include <linux/timer.h> | 25 | #include <linux/timer.h> |
26 | #include <linux/workqueue.h> | 26 | #include <linux/workqueue.h> |
27 | 27 | ||
28 | #include <asm/atomic.h> | ||
29 | |||
28 | #define PHY_BASIC_FEATURES (SUPPORTED_10baseT_Half | \ | 30 | #define PHY_BASIC_FEATURES (SUPPORTED_10baseT_Half | \ |
29 | SUPPORTED_10baseT_Full | \ | 31 | SUPPORTED_10baseT_Full | \ |
30 | SUPPORTED_100baseT_Half | \ | 32 | SUPPORTED_100baseT_Half | \ |
@@ -281,6 +283,7 @@ struct phy_device { | |||
281 | /* Interrupt and Polling infrastructure */ | 283 | /* Interrupt and Polling infrastructure */ |
282 | struct work_struct phy_queue; | 284 | struct work_struct phy_queue; |
283 | struct timer_list phy_timer; | 285 | struct timer_list phy_timer; |
286 | atomic_t irq_disable; | ||
284 | 287 | ||
285 | spinlock_t lock; | 288 | spinlock_t lock; |
286 | 289 | ||