mt7915_mcu_rx_ps_sync() reads the PS state at payload byte 1, as the mt7915 firmware sends it. The mt7986 and mt7981 firmware send a longer event. It holds the index as two 16-bit words and the state at payload byte 6. Byte 1 is always 0 in that layout. Every event of these chips thus clears MT_WCID_FLAG_PS. The host then never throttles the TX of a station in power save. Take the layout from the event length of the firmware, and drop an event that the buffer does not hold. Fixes: dc930cf883c8 ("wifi: mt76: mt7915: handle MCU PS sync events") Signed-off-by: Felix Fietkau --- .../net/wireless/mediatek/mt76/mt7915/mcu.c | 20 +++++++++++++++++-- .../net/wireless/mediatek/mt76/mt7915/mcu.h | 10 ++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c index 6e1c3e5e2fe9..02426feb6182 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c @@ -411,16 +411,32 @@ mt7915_mcu_rx_bcc_notify(struct mt7915_dev *dev, struct sk_buff *skb) static void mt7915_mcu_rx_ps_sync(struct mt7915_dev *dev, struct sk_buff *skb) { + struct mt7915_mcu_ps_notify_v2 *p2 = (void *)skb->data; struct mt7915_mcu_ps_notify *p = (void *)skb->data; struct mt76_wcid *wcid; u16 wcid_idx; + bool v2, ps; + + /* the mt7986 and mt7981 firmware send the longer v2 layout */ + v2 = le16_to_cpu(p->rxd.len) >= + sizeof(*p2) - offsetof(struct mt76_connac2_mcu_rxd_hdr, len); + if (skb->len < (v2 ? sizeof(*p2) : sizeof(*p))) + return; + + if (v2) { + wcid_idx = le16_to_cpu(p2->wtbl_lower) | + (le16_to_cpu(p2->wtbl_higher) << 8); + ps = p2->ps_bit; + } else { + wcid_idx = p->wtbl_lower | (p->wtbl_higher << 8); + ps = p->ps_bit; + } - wcid_idx = p->wtbl_lower | (p->wtbl_higher << 8); wcid = mt76_wcid_ptr(dev, wcid_idx); if (!wcid || !wcid_to_sta(wcid)) return; - mt76_sta_ps_transition(&dev->mt76, wcid, !!p->ps_bit); + mt76_sta_ps_transition(&dev->mt76, wcid, ps); } static void diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h index 76e39e899797..7dbe43200fb4 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h @@ -63,6 +63,16 @@ struct mt7915_mcu_ps_notify { u8 rsv; } __packed; +struct mt7915_mcu_ps_notify_v2 { + struct mt76_connac2_mcu_rxd_hdr rxd; + + __le16 wtbl_lower; + __le16 wtbl_higher; + __le16 rsv; + u8 ps_bit; + u8 rsv2; +} __packed; + struct mt7915_mcu_rdd_report { struct mt76_connac2_mcu_rxd_hdr rxd; -- 2.47.3