[PATCH 4/4] wifi: mt76: connac: synchronize token_count access in mt76_connac_skip_fw_pmctrl

Mingyen Hsieh mingyen.hsieh at mediatek.com
Wed Sep 3 20:06:49 PDT 2025


From: Ming Yen Hsieh <mingyen.hsieh at mediatek.com>

Read dev->token_count under token_lock to prevent race conditions with
concurrent token updates, ensuring accurate power management decisions.

Signed-off-by: Ming Yen Hsieh <mingyen.hsieh at mediatek.com>
---
 drivers/net/wireless/mediatek/mt76/mt76_connac.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac.h b/drivers/net/wireless/mediatek/mt76/mt76_connac.h
index 93e5d36206e8..756719ce0e48 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac.h
@@ -383,9 +383,14 @@ static inline bool
 mt76_connac_skip_fw_pmctrl(struct mt76_phy *phy, struct mt76_connac_pm *pm)
 {
 	struct mt76_dev *dev = phy->dev;
+	u16 token_count = 0;
 	bool ret;
 
-	if (dev->token_count)
+	spin_lock_bh(&dev->token_lock);
+	token_count = dev->token_count;
+	spin_unlock_bh(&dev->token_lock);
+
+	if (token_count)
 		return true;
 
 	spin_lock_bh(&pm->wake.lock);
-- 
2.34.1




More information about the Linux-mediatek mailing list