]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
tg3: Eliminate timer race with reset_task
authorMatt Carlson <mcarlson@broadcom.com>
Fri, 4 Nov 2011 09:15:04 +0000 (09:15 +0000)
committerJoe Jin <joe.jin@oracle.com>
Wed, 16 May 2012 02:33:30 +0000 (10:33 +0800)
During shutdown, it is impossible to reliably disable the timer and
reset_task threads.  Each thread can schedule the other, which leads to
shutdown code that chases its tail.

To fix the problem, this patch removes the ability of tg3_reset_task to
schedule a new timer thread.  To support this change, tg3_timer no
longer terminates itself, but rather goes into a polling mode.

(cherry picked from commit 5b1906241905d9bd1abe920854b3d43c2b9c85e1)
Signed-off-by: Matt Carlson <mcarlson@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Joe Jin <joe.jin@oracle.com>
drivers/net/tg3.c
drivers/net/tg3.h

index 15adc022f39bfec0be9c1dfd3db8c746ea7a2b74..ed46b7625b5b0c72b81bda4dba60e7fee89ca29b 100644 (file)
@@ -6358,7 +6358,6 @@ static void tg3_reset_task(struct work_struct *work)
 {
        struct tg3 *tp = container_of(work, struct tg3, reset_task);
        int err;
-       unsigned int restart_timer;
 
        tg3_full_lock(tp, 0);
 
@@ -6376,9 +6375,6 @@ static void tg3_reset_task(struct work_struct *work)
 
        tg3_full_lock(tp, 1);
 
-       restart_timer = tg3_flag(tp, RESTART_TIMER);
-       tg3_flag_clear(tp, RESTART_TIMER);
-
        if (tg3_flag(tp, TX_RECOVERY_PENDING)) {
                tp->write32_tx_mbox = tg3_write32_tx_mbox;
                tp->write32_rx_mbox = tg3_write_flush_reg32;
@@ -6393,9 +6389,6 @@ static void tg3_reset_task(struct work_struct *work)
 
        tg3_netif_start(tp);
 
-       if (restart_timer)
-               mod_timer(&tp->timer, jiffies + 1);
-
 out:
        tg3_full_unlock(tp);
 
@@ -9226,7 +9219,7 @@ static void tg3_timer(unsigned long __opaque)
 {
        struct tg3 *tp = (struct tg3 *) __opaque;
 
-       if (tp->irq_sync)
+       if (tp->irq_sync || tg3_flag(tp, RESET_TASK_PENDING))
                goto restart_timer;
 
        spin_lock(&tp->lock);
@@ -9249,10 +9242,9 @@ static void tg3_timer(unsigned long __opaque)
                }
 
                if (!(tr32(WDMAC_MODE) & WDMAC_MODE_ENABLE)) {
-                       tg3_flag_set(tp, RESTART_TIMER);
                        spin_unlock(&tp->lock);
                        tg3_reset_task_schedule(tp);
-                       return;
+                       goto restart_timer;
                }
        }
 
@@ -15855,12 +15847,10 @@ static pci_ers_result_t tg3_io_error_detected(struct pci_dev *pdev,
        tg3_netif_stop(tp);
 
        del_timer_sync(&tp->timer);
-       tg3_flag_clear(tp, RESTART_TIMER);
 
        /* Want to make sure that the reset task doesn't run */
        tg3_reset_task_cancel(tp);
        tg3_flag_clear(tp, TX_RECOVERY_PENDING);
-       tg3_flag_clear(tp, RESTART_TIMER);
 
        netif_device_detach(netdev);
 
index 69ffac1d4b2c352321621c25785e5a93e41c963e..fa7a46cad3af8899a17f51f29098b59827c1ab40 100644 (file)
@@ -2879,7 +2879,6 @@ enum TG3_FLAGS {
        TG3_FLAG_JUMBO_CAPABLE,
        TG3_FLAG_CHIP_RESETTING,
        TG3_FLAG_INIT_COMPLETE,
-       TG3_FLAG_RESTART_TIMER,
        TG3_FLAG_TSO_BUG,
        TG3_FLAG_IS_5788,
        TG3_FLAG_MAX_RXPEND_64,