mt76: mt76x02: issue watchdog reset on MCU request timeout
authorFelix Fietkau <nbd@nbd.name>
Sun, 24 Feb 2019 22:16:45 +0000 (23:16 +0100)
committerFelix Fietkau <nbd@nbd.name>
Tue, 26 Feb 2019 09:28:19 +0000 (10:28 +0100)
MCU request timeout usually indicates that the device is no longer responsive,
and it usually does not recover without a reset

Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76x02.h
drivers/net/wireless/mediatek/mt76/mt76x02_mcu.c
drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c

index 3464b4ca2ea86a859895df384bc1650d016ee260..6915cce5def9342935784c888c477417e26b5c69 100644 (file)
@@ -98,6 +98,7 @@ struct mt76x02_dev {
 
        u32 tx_hang_reset;
        u8 tx_hang_check;
+       u8 mcu_timeout;
 
        struct mt76x02_calibration cal;
 
index 4752c104abf336ca0f6ccf1cb1704fa1de671bf6..6501b853b65ca65d3e4cf80ebe747fa9c4f62f8b 100644 (file)
@@ -61,6 +61,7 @@ int mt76x02_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,
                                "MCU message %d (seq %d) timed out\n", cmd,
                                seq);
                        ret = -ETIMEDOUT;
+                       dev->mcu_timeout = 1;
                        break;
                }
 
index f0198eea2bb82b1cfa09dd48a35c4a9d11e10c5e..1229f19f2b02c68b4144662e8097333d5133f3ac 100644 (file)
@@ -494,18 +494,28 @@ static void mt76x02_watchdog_reset(struct mt76x02_dev *dev)
 static void mt76x02_check_tx_hang(struct mt76x02_dev *dev)
 {
        if (mt76x02_tx_hang(dev)) {
-               if (++dev->tx_hang_check < MT_TX_HANG_TH)
-                       return;
-
-               mt76x02_watchdog_reset(dev);
-
-               dev->tx_hang_reset++;
-               dev->tx_hang_check = 0;
-               memset(dev->mt76.tx_dma_idx, 0xff,
-                      sizeof(dev->mt76.tx_dma_idx));
+               if (++dev->tx_hang_check >= MT_TX_HANG_TH)
+                       goto restart;
        } else {
                dev->tx_hang_check = 0;
        }
+
+       if (dev->mcu_timeout)
+               goto restart;
+
+       return;
+
+restart:
+       mt76x02_watchdog_reset(dev);
+
+       mutex_lock(&dev->mt76.mmio.mcu.mutex);
+       dev->mcu_timeout = 0;
+       mutex_unlock(&dev->mt76.mmio.mcu.mutex);
+
+       dev->tx_hang_reset++;
+       dev->tx_hang_check = 0;
+       memset(dev->mt76.tx_dma_idx, 0xff,
+              sizeof(dev->mt76.tx_dma_idx));
 }
 
 void mt76x02_wdt_work(struct work_struct *work)