wifi: mt76: mt7915: fix bogus Tx/Rx airtime duration values
authorHenry Yen <henry.yen@mediatek.com>
Thu, 22 Feb 2024 03:24:46 +0000 (11:24 +0800)
committerFelix Fietkau <nbd@nbd.name>
Thu, 2 May 2024 10:44:50 +0000 (12:44 +0200)
Do not report measurements if the airtime counter was cleared since the
last update (possibly by firmware)

Signed-off-by: Henry Yen <henry.yen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7915/mac.c

index e45361111f9bf3d5fb36dfec172fbb2802765ec1..f350b3f7a0bde628e6ad062bea7a64d504e77af1 100644 (file)
@@ -140,8 +140,15 @@ static void mt7915_mac_sta_poll(struct mt7915_dev *dev)
                        msta->airtime_ac[i] = mt76_rr(dev, addr);
                        msta->airtime_ac[i + 4] = mt76_rr(dev, addr + 4);
 
-                       tx_time[i] = msta->airtime_ac[i] - tx_last;
-                       rx_time[i] = msta->airtime_ac[i + 4] - rx_last;
+                       if (msta->airtime_ac[i] <= tx_last)
+                               tx_time[i] = 0;
+                       else
+                               tx_time[i] = msta->airtime_ac[i] - tx_last;
+
+                       if (msta->airtime_ac[i + 4] <= rx_last)
+                               rx_time[i] = 0;
+                       else
+                               rx_time[i] = msta->airtime_ac[i + 4] - rx_last;
 
                        if ((tx_last | rx_last) & BIT(30))
                                clear = true;