Skip to contentSkip to conversation

mt76: mmio: introduce mt76x02_check_tx_hang watchdog

PATCH Applied Lorenzo Bianconi 4 participants 6 messages Dec 28, 2018 – Jan 7, 2019 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

PATCH v2 1/1 mt76: mmio: introduce mt76x02_check_tx_hang watchdog

In reply to a message not in the archive

Port mt76x02_check_tx_hang watchdog from vendor driver in order to perform a device reset when tx mac/dma logic hangs. Tx mac/dma stuck has been observed when the device is heavy loaded or in a noisy environment. Moreover introduce wdt delayed work in order to run tx_hang watchdog. For the moment run mt76x02_check_tx_hang watchdog just on mt76x2 devices since the issue has not been observed on mt76x0 driver yet

---
Changes since v1:
- drop patch 1/2 and introduce wdt work
- move watchdog routines in mt76x02_mmio.c

---
 drivers/net/wireless/mediatek/mt76/mt76.h     |   1 +
 drivers/net/wireless/mediatek/mt76/mt76x02.h  |   8 ++
 .../wireless/mediatek/mt76/mt76x02_debugfs.c  |   2 +
 .../net/wireless/mediatek/mt76/mt76x02_mac.c  |   1 -
 .../net/wireless/mediatek/mt76/mt76x02_mmio.c | 124 ++++++++++++++++++
 .../net/wireless/mediatek/mt76/mt76x02_util.c |   2 +
 .../wireless/mediatek/mt76/mt76x2/pci_init.c  |   1 +
 .../wireless/mediatek/mt76/mt76x2/pci_main.c  |   2 +
 8 files changed, 140 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt76.h +1 -0
index 5cd508a68609..8ef430d8afc4 100644
@@ -421,6 +421,7 @@ struct mt76_dev {
 	struct mt76_queue q_tx[__MT_TXQ_MAX];
 	struct mt76_queue q_rx[__MT_RXQ_MAX];
 	const struct mt76_queue_ops *queue_ops;
+	int tx_dma_idx[4];
 
 	wait_queue_head_t tx_wait;
 	struct sk_buff_head status_list;
drivers/net/wireless/mediatek/mt76/mt76x02.h +8 -0
index f383fdd914c5..f594e8c82500 100644
@@ -28,6 +28,9 @@
 
 #define MT_CALIBRATE_INTERVAL	HZ
 
+#define MT_WATCHDOG_TIME	(HZ / 10)
+#define MT_TX_HANG_TH		10
+
 #define MT_MAX_CHAINS		2
 struct mt76x02_rx_freq_cal {
 	s8 high_gain[MT_MAX_CHAINS];
@@ -79,6 +82,7 @@ struct mt76x02_dev {
 	struct tasklet_struct pre_tbtt_tasklet;
 	struct delayed_work cal_work;
 	struct delayed_work mac_work;
+	struct delayed_work wdt_work;
 
 	u32 aggr_stats[32];
 
@@ -89,6 +93,9 @@ struct mt76x02_dev {
 	u8 tbtt_count;
 	u16 beacon_int;
 
+	u32 tx_hang_reset;
+	u8 tx_hang_check;
+
 	struct mt76x02_calibration cal;
 
 	s8 target_power;
@@ -142,6 +149,7 @@ s8 mt76x02_tx_get_max_txpwr_adj(struct mt76x02_dev *dev,
 				const struct ieee80211_tx_rate *rate);
 s8 mt76x02_tx_get_txpwr_adj(struct mt76x02_dev *dev, s8 txpwr,
 			    s8 max_txpwr_adj);
+void mt76x02_wdt_work(struct work_struct *work);
 void mt76x02_tx_set_txpwr_auto(struct mt76x02_dev *dev, s8 txpwr);
 void mt76x02_set_tx_ackto(struct mt76x02_dev *dev);
 void mt76x02_set_coverage_class(struct ieee80211_hw *hw,
drivers/net/wireless/mediatek/mt76/mt76x02_debugfs.c +2 -0
index a9d52ba1e270..7580c5c986ff 100644
@@ -133,5 +133,7 @@ void mt76x02_init_debugfs(struct mt76x02_dev *dev)
 				    read_txpower);
 
 	debugfs_create_devm_seqfile(dev->mt76.dev, "agc", dir, read_agc);
+
+	debugfs_create_u32("tx_hang_reset", 0400, dir, &dev->tx_hang_reset);
 }
 EXPORT_SYMBOL_GPL(mt76x02_init_debugfs);
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +0 -1
index cc584ea4a8d7..6adea0278284 100644
@@ -943,7 +943,6 @@ void mt76x02_mac_work(struct work_struct *work)
 		dev->aggr_stats[idx++] += val >> 16;
 	}
 
-	/* XXX: check beacon stuck for ap mode */
 	if (!dev->beacon_mask)
 		mt76x02_check_mac_err(dev);
 
drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c +124 -0

127 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt76x02_util.c +2 -0
index aac64d0969b8..3c878f18e05d 100644
@@ -93,6 +93,8 @@ void mt76x02_init_device(struct mt76x02_dev *dev)
 					 MT_DMA_HDR_LEN;
 		wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
 	} else {
+		INIT_DELAYED_WORK(&dev->wdt_work, mt76x02_wdt_work);
+
 		mt76x02_dfs_init_detector(dev);
 
 		wiphy->reg_notifier = mt76x02_regd_notifier;
drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c +1 -0
index 9f313824eead..34418e575542 100644
@@ -301,6 +301,7 @@ void mt76x2_stop_hardware(struct mt76x02_dev *dev)
 {
 	cancel_delayed_work_sync(&dev->cal_work);
 	cancel_delayed_work_sync(&dev->mac_work);
+	cancel_delayed_work_sync(&dev->wdt_work);
 	mt76x02_mcu_set_radio_state(dev, false);
 	mt76x2_mac_stop(dev, false);
 }
drivers/net/wireless/mediatek/mt76/mt76x2/pci_main.c +2 -0
index b54a32397486..6a87b88eb036 100644
@@ -34,6 +34,8 @@ mt76x2_start(struct ieee80211_hw *hw)
 
 	ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mac_work,
 				     MT_CALIBRATE_INTERVAL);
+	ieee80211_queue_delayed_work(mt76_hw(dev), &dev->wdt_work,
+				     MT_WATCHDOG_TIME);
 
 	set_bit(MT76_STATE_RUNNING, &dev->mt76.state);
 
Signature · 1 line
2.20.1
#2 lore raw
I love your patch! Yet something to improve:

Hi Lorenzo,

I love your patch! Yet something to improve:

[auto build test ERROR on wireless-drivers-next/master]
[also build test ERROR on next-20181224]
[cannot apply to v4.20]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Lorenzo-Bianconi/mt76-mmio-introduce-mt76x02_check_tx_hang-watchdog/20181228-224737
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master
config: i386-randconfig-sb0-12290140 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

In file included from drivers/net/wireless/mediatek/mt76/mt76x02.h:23:0,

                    from drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c:21:
   drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c: In function 'mt76x02_watchdog_reset':
>> drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c:435:36: error: 'MT_TXOP_ED_CCA_EN' undeclared (first use in this function)
     mt76_clear(dev, MT_TXOP_CTRL_CFG, MT_TXOP_ED_CCA_EN);
                                       ^
   drivers/net/wireless/mediatek/mt76/mt76.h:507:65: note: in definition of macro 'mt76_rmw'
    #define mt76_rmw(dev, ...) (dev)->mt76.bus->rmw(&((dev)->mt76), __VA_ARGS__)
                                                                    ^
   drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c:435:2: note: in expansion of macro 'mt76_clear'
     mt76_clear(dev, MT_TXOP_CTRL_CFG, MT_TXOP_ED_CCA_EN);
     ^
   drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c:435:36: note: each undeclared identifier is reported only once for each function it appears in
     mt76_clear(dev, MT_TXOP_CTRL_CFG, MT_TXOP_ED_CCA_EN);
                                       ^
   drivers/net/wireless/mediatek/mt76/mt76.h:507:65: note: in definition of macro 'mt76_rmw'
    #define mt76_rmw(dev, ...) (dev)->mt76.bus->rmw(&((dev)->mt76), __VA_ARGS__)
                                                                    ^
   drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c:435:2: note: in expansion of macro 'mt76_clear'
     mt76_clear(dev, MT_TXOP_CTRL_CFG, MT_TXOP_ED_CCA_EN);
     ^
   drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c:455:9: error: 'struct mt76x02_dev' has no member named 'ed_monitor'
     if (dev->ed_monitor)
            ^

vim +/MT_TXOP_ED_CCA_EN +435 drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c

410
411 static void mt76x02_watchdog_reset(struct mt76x02_dev *dev)
412 {
413 u32 mask = dev->mt76.mmio.irqmask;
414 int i;
415
416 ieee80211_stop_queues(dev->mt76.hw);
417 set_bit(MT76_RESET, &dev->mt76.state);
418
419 tasklet_disable(&dev->pre_tbtt_tasklet);
420 tasklet_disable(&dev->tx_tasklet);
421
422 for (i = 0; i < ARRAY_SIZE(dev->mt76.napi); i++)
423 napi_disable(&dev->mt76.napi[i]);
424
425 mutex_lock(&dev->mt76.mutex);
426
427 if (dev->beacon_mask)
428 mt76_clear(dev, MT_BEACON_TIME_CFG,
429 MT_BEACON_TIME_CFG_BEACON_TX |
430 MT_BEACON_TIME_CFG_TBTT_EN);
431
432 mt76x02_irq_disable(dev, mask);
433
434 /* perform device reset */

 > 435		mt76_clear(dev, MT_TXOP_CTRL_CFG, MT_TXOP_ED_CCA_EN);

436 mt76_wr(dev, MT_MAC_SYS_CTRL, 0);
437 mt76_clear(dev, MT_WPDMA_GLO_CFG,
438 MT_WPDMA_GLO_CFG_TX_DMA_EN | MT_WPDMA_GLO_CFG_RX_DMA_EN);
439 usleep_range(5000, 10000);
440 mt76_wr(dev, MT_INT_SOURCE_CSR, 0xffffffff);
441
442 /* let fw reset DMA */
443 mt76_set(dev, 0x734, 0x3);
444
445 for (i = 0; i < ARRAY_SIZE(dev->mt76.q_tx); i++)
446 mt76_queue_tx_cleanup(dev, i, true);
447
448 for (i = 0; i < ARRAY_SIZE(dev->mt76.q_rx); i++)
449 mt76_queue_rx_reset(dev, i);
450
451 mt76_wr(dev, MT_MAC_SYS_CTRL,
452 MT_MAC_SYS_CTRL_ENABLE_TX | MT_MAC_SYS_CTRL_ENABLE_RX);
453 mt76_set(dev, MT_WPDMA_GLO_CFG,
454 MT_WPDMA_GLO_CFG_TX_DMA_EN | MT_WPDMA_GLO_CFG_RX_DMA_EN);
455 if (dev->ed_monitor)
456 mt76_set(dev, MT_TXOP_CTRL_CFG, MT_TXOP_ED_CCA_EN);
457
458 if (dev->beacon_mask)
459 mt76_set(dev, MT_BEACON_TIME_CFG,
460 MT_BEACON_TIME_CFG_BEACON_TX |
461 MT_BEACON_TIME_CFG_TBTT_EN);
462
463 mt76x02_irq_enable(dev, mask);
464
465 mutex_unlock(&dev->mt76.mutex);
466
467 clear_bit(MT76_RESET, &dev->mt76.state);
468
469 tasklet_enable(&dev->tx_tasklet);
470 tasklet_schedule(&dev->tx_tasklet);
471
472 tasklet_enable(&dev->pre_tbtt_tasklet);
473
474 for (i = 0; i < ARRAY_SIZE(dev->mt76.napi); i++) {
475 napi_enable(&dev->mt76.napi[i]);
476 napi_schedule(&dev->mt76.napi[i]);
477 }
478
479 ieee80211_wake_queues(dev->mt76.hw);
480
481 mt76_txq_schedule_all(&dev->mt76);
482 }
483

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

maintainer Applied
#6 lore raw
In reply to Lorenzo Bianconi
Quoted 9 lines · Lorenzo Bianconi

Port mt76x02_check_tx_hang watchdog from vendor driver in order to perform a device reset when tx mac/dma logic hangs. Tx mac/dma stuck has been observed when the device is heavy loaded or in a noisy environment. Moreover introduce wdt delayed work in order to run tx_hang watchdog. For the moment run mt76x02_check_tx_hang watchdog just on mt76x2 devices since the issue has not been observed on mt76x0 driver yet

Applied, thanks.

- Felix

#3 lore raw
In reply to kbuild test robot
Quoted 17 lines · kbuild test robot

Hi Lorenzo,

I love your patch! Yet something to improve:

[auto build test ERROR on wireless-drivers-next/master]
[also build test ERROR on next-20181224]
[cannot apply to v4.20]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Lorenzo-Bianconi/mt76-mmio-introduce-mt76x02_check_tx_hang-watchdog/20181228-224737
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master
config: i386-randconfig-sb0-12290140 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 
Quoted 6 lines

All errors (new ones prefixed by >>):

   In file included from drivers/net/wireless/mediatek/mt76/mt76x02.h:23:0,
                    from drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c:21:
   drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c: In function 'mt76x02_watchdog_reset':
Quoted 1 line
Quoted 1 line

drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c:435:36: error: 'MT_TXOP_ED_CCA_EN' undeclared (first use in this function)

Didn't check the sources but looks like a valid error to me. Can you fix this, please?

Signature · 1 line
Kalle Valo
#4 lore raw
Quoted 21 lines
Quoted 19 lines · kbuild test robot

Hi Lorenzo,

I love your patch! Yet something to improve:

[auto build test ERROR on wireless-drivers-next/master]
[also build test ERROR on next-20181224]
[cannot apply to v4.20]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Lorenzo-Bianconi/mt76-mmio-introduce-mt76x02_check_tx_hang-watchdog/20181228-224737
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master
config: i386-randconfig-sb0-12290140 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

Quoted 7 lines
Quoted 4 lines
   In file included from drivers/net/wireless/mediatek/mt76/mt76x02.h:23:0,
                    from drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c:21:
   drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c: In function 'mt76x02_watchdog_reset':
Quoted 1 line
Quoted 1 line

drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c:435:36: error: 'MT_TXOP_ED_CCA_EN' undeclared (first use in this function)

Didn't check the sources but looks like a valid error to me. Can you fix this, please?

Hi Kalle,

This patch needs to be applied on top of 'add EDCCA support to mt76x{0,2}e drivers' series (https://patchwork.kernel.org/cover/10727149/). I forgot to point it out, sorry. However Felix has already applied them in the correct order, so nothing to do here.

Regards,
Lorenzo

Quoted 3 lines
Signature · 2 lines
-- 
Kalle Valo
#5 lore raw
Quoted 29 lines · Lorenzo Bianconi
Quoted 21 lines
Quoted 19 lines · kbuild test robot

Hi Lorenzo,

I love your patch! Yet something to improve:

[auto build test ERROR on wireless-drivers-next/master]
[also build test ERROR on next-20181224]
[cannot apply to v4.20]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Lorenzo-Bianconi/mt76-mmio-introduce-mt76x02_check_tx_hang-watchdog/20181228-224737
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master
config: i386-randconfig-sb0-12290140 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

Quoted 7 lines
Quoted 4 lines
   In file included from drivers/net/wireless/mediatek/mt76/mt76x02.h:23:0,
                    from drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c:21:
   drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c: In function 'mt76x02_watchdog_reset':
Quoted 1 line
Quoted 1 line

drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c:435:36: error: 'MT_TXOP_ED_CCA_EN' undeclared (first use in this function)

Didn't check the sources but looks like a valid error to me. Can you fix this, please?

Quoted 6 lines

Hi Kalle,

This patch needs to be applied on top of 'add EDCCA support to mt76x{0,2}e drivers' series (https://patchwork.kernel.org/cover/10727149/). I forgot to point it out, sorry. However Felix has already applied them in the correct order, so nothing to do here.

Good to know, thanks.

Signature · 1 line
Kalle Valo