Linux wireless drivers development
 help / color / mirror / Atom feed
From: Felix Fietkau <nbd@nbd.name>
To: linux-wireless@vger.kernel.org
Subject: [PATCH mt76-next 02/18] wifi: mt76: mt7915: hold the rate update of a station in power save
Date: Wed, 25 Nov 2026 18:36:00 +0100	[thread overview]
Message-ID: <20261125173616.3776951-2-nbd@nbd.name> (raw)
In-Reply-To: <20261125173616.3776951-1-nbd@nbd.name>

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 <nbd@nbd.name>
---
 .../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


  reply	other threads:[~2026-11-25 17:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 17:35 [PATCH mt76-next 01/18] wifi: mt76: mt7925: keep the RX PN state of a station across a rekey Felix Fietkau
2026-11-25 17:36 ` Felix Fietkau [this message]
2026-11-25 17:36 ` [PATCH mt76-next 03/18] wifi: mt76: mt7996: take the phy of a fixed rate from the station link Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 04/18] wifi: mt76: mt7915: keep the BF column count within the row count Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 05/18] wifi: mt76: mt7996: report the tx power of the requested link Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 06/18] wifi: mt76: mt7996: refuse an RF register offset above 12 bits Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 07/18] wifi: mt76: mt7996: hold the mutex across the thermal protection store Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 08/18] wifi: mt76: mt7996: wait for the answer of each state command Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 09/18] wifi: mt76: mt7915: wait for the answer of the background chain control Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 10/18] wifi: mt76: mt7996: bound the in-band discovery frame by its buffer Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 11/18] wifi: mt76: mt7915: reset on an MCU timeout only once the hw is registered Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 12/18] wifi: mt76: mt7996: " Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 13/18] wifi: mt76: mt7915: mask the LDPC bits of STA_REC_HT and STA_REC_VHT Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 14/18] wifi: mt76: mt7996: mask the LDPC bits of STA_REC_HT, _VHT and _HE_V2 Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 15/18] wifi: mt76: mt7996: send HE_BASIC for each HE link of an MLD Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 16/18] wifi: mt76: restore the operating channel after a failed ROC start Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 17/18] wifi: mt76: mt7996: set the duplicate WTBL range again after a reset Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 18/18] wifi: mt76: mt7996: keep station wcids out of the duplicate WTBL range Felix Fietkau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261125173616.3776951-2-nbd@nbd.name \
    --to=nbd@nbd.name \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox