At each STA_REC_RA the firmware clears every stop reason of the TX queue of the wlan index. It also clears the power save reason, and it stops the queue again only at the next enter. mt7915_mac_sta_rc_work() sends STA_REC_RA for a sleeping station too, so its frames go out while it sleeps and are lost. Reachable via a channel width change, an Operating Mode Notification and mt7915_set_bitrate_mask(). Keep the update of a station in power save in the work. Send it when the PS state clears: at the leave, a TWT add or an L1 recovery. An SMPS change of a sleeping station waits too. While the update waits, PS-Poll and U-APSD deliveries use the old rate state. Whether the hardware limits the width to the channel is not read. A fixed rate from user space reaches a sleeping station at its wake. An enter that the host did not see before the send can still restart the queue once. Fixes: e57b7901469f ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets") Signed-off-by: Felix Fietkau --- .../net/wireless/mediatek/mt76/mt7915/mac.c | 27 ++++++++++++++++++- .../net/wireless/mediatek/mt76/mt7915/mcu.c | 4 +-- .../wireless/mediatek/mt76/mt7915/mt7915.h | 2 ++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index 84f75526da58..e458661d750b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -1524,7 +1524,7 @@ mt7915_mac_reset_sta_ps(struct mt7915_dev *dev) !test_bit(MT_WCID_FLAG_PS, &wcid->flags)) continue; - mt76_sta_ps_transition(&dev->mt76, wcid, false); + mt7915_mac_sta_ps_transition(dev, wcid, false); } rcu_read_unlock(); } @@ -2074,6 +2074,10 @@ void mt7915_mac_sta_rc_work(struct work_struct *work) while (!list_empty(&list)) { msta = list_first_entry(&list, struct mt7915_sta, rc_list); list_del_init(&msta->rc_list); + + if (test_bit(MT_WCID_FLAG_PS, &msta->wcid.flags)) + continue; + changed = msta->changed; msta->changed = 0; spin_unlock_bh(&dev->mt76.sta_poll_lock); @@ -2097,6 +2101,27 @@ void mt7915_mac_sta_rc_work(struct work_struct *work) mutex_unlock(&dev->mt76.mutex); } +void mt7915_mac_sta_ps_transition(struct mt7915_dev *dev, + struct mt76_wcid *wcid, bool ps) +{ + struct mt7915_sta *msta = container_of(wcid, struct mt7915_sta, wcid); + bool held; + + mt76_sta_ps_transition(&dev->mt76, wcid, ps); + if (ps) + return; + + spin_lock_bh(&dev->mt76.sta_poll_lock); + held = msta->changed && list_empty(&msta->rc_list); + if (held) + list_add_tail(&msta->rc_list, &dev->sta_rc_list); + spin_unlock_bh(&dev->mt76.sta_poll_lock); + + if (held) + ieee80211_queue_work(mt76_phy_hw(&dev->mt76, wcid->phy_idx), + &dev->rc_work); +} + void mt7915_mac_work(struct work_struct *work) { struct mt7915_phy *phy; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c index 59042d043481..bb71e6437a62 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c @@ -456,11 +456,11 @@ mt7915_mcu_rx_ps_sync(struct mt7915_dev *dev, struct sk_buff *skb) if (path == MT7915_PS_SYNC_TWT || path == MT7915_PS_SYNC_TWT_MANY) { if (ps) - mt76_sta_ps_transition(&dev->mt76, wcid, false); + mt7915_mac_sta_ps_transition(dev, wcid, false); return; } - mt76_sta_ps_transition(&dev->mt76, wcid, ps); + mt7915_mac_sta_ps_transition(dev, wcid, ps); } static void diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h index cab0ed54ca84..42a59f9e3ba1 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -613,6 +613,8 @@ void mt7915_mac_work(struct work_struct *work); void mt7915_mac_reset_work(struct work_struct *work); void mt7915_mac_dump_work(struct work_struct *work); void mt7915_mac_sta_rc_work(struct work_struct *work); +void mt7915_mac_sta_ps_transition(struct mt7915_dev *dev, + struct mt76_wcid *wcid, bool ps); void mt7915_mac_update_stats(struct mt7915_phy *phy); void mt7915_mac_twt_teardown_flow(struct mt7915_dev *dev, struct mt7915_sta *msta, -- 2.47.3