diff options
author | Felix Fietkau <nbd@nbd.name> | 2022-06-23 11:39:58 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2022-07-11 13:40:03 +0200 |
commit | 8916e4e513a85ff6315d1e7fef999916b35023d7 (patch) | |
tree | 5d3cf3ed947dd7589b1241f1a8d7d49a2778b4e2 /drivers/net/wireless/mediatek | |
parent | df6b739fd7d15371357c32d4b1190e681434a096 (diff) | |
download | linux-8916e4e513a85ff6315d1e7fef999916b35023d7.tar.bz2 |
mt76: mt76x02: improve reliability of the beacon hang check
Increment the counter only when writing beacons to the hardware in order
to avoid triggering restarts if beacons are disabled.
Additionally, avoid resetting the MAC if stopping it failed
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'drivers/net/wireless/mediatek')
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/mt76x02_beacon.c | 6 | ||||
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/mt76x02_mac.c | 11 |
2 files changed, 13 insertions, 4 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_beacon.c b/drivers/net/wireless/mediatek/mt76/mt76x02_beacon.c index b72510949877..ad4dc8e17b58 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_beacon.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_beacon.c @@ -57,8 +57,11 @@ void mt76x02_mac_set_beacon(struct mt76x02_dev *dev, int bcn_len = dev->beacon_ops->slot_size; int bcn_addr = MT_BEACON_BASE + (bcn_len * dev->beacon_data_count); - if (!mt76x02_write_beacon(dev, bcn_addr, skb)) + if (!mt76x02_write_beacon(dev, bcn_addr, skb)) { + if (!dev->beacon_data_count) + dev->beacon_hang_check++; dev->beacon_data_count++; + } dev_kfree_skb(skb); } EXPORT_SYMBOL_GPL(mt76x02_mac_set_beacon); @@ -74,6 +77,7 @@ void mt76x02_mac_set_beacon_enable(struct mt76x02_dev *dev, if (!dev->mt76.beacon_mask) dev->tbtt_count = 0; + dev->beacon_hang_check = 0; if (enable) { dev->mt76.beacon_mask |= BIT(mvif->idx); } else { diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c index cf4d4110cc99..de30cf5e2d2f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c @@ -1044,10 +1044,9 @@ static void mt76x02_check_mac_err(struct mt76x02_dev *dev) return; } - if (++dev->beacon_hang_check < 10) + if (dev->beacon_hang_check < 10) return; - dev->beacon_hang_check = 0; } else { u32 val = mt76_rr(dev, 0x10f4); if (!(val & BIT(29)) || !(val & (BIT(7) | BIT(5)))) @@ -1057,10 +1056,16 @@ static void mt76x02_check_mac_err(struct mt76x02_dev *dev) dev_err(dev->mt76.dev, "MAC error detected\n"); mt76_wr(dev, MT_MAC_SYS_CTRL, 0); - mt76x02_wait_for_txrx_idle(&dev->mt76); + if (!mt76x02_wait_for_txrx_idle(&dev->mt76)) { + dev_err(dev->mt76.dev, "MAC stop failed\n"); + goto out; + } + dev->beacon_hang_check = 0; mt76_set(dev, MT_MAC_SYS_CTRL, MT_MAC_SYS_CTRL_RESET_CSR); udelay(10); + +out: mt76_wr(dev, MT_MAC_SYS_CTRL, MT_MAC_SYS_CTRL_ENABLE_TX | MT_MAC_SYS_CTRL_ENABLE_RX); } |