Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH] wifi: mt76: mt7921: handle BSS_CHANGED_TXPOWER and update txpower_cur
@ 2026-11-19 19:57 Niels Lüttge
  0 siblings, 0 replies; only message in thread
From: Niels Lüttge @ 2026-11-19 19:57 UTC (permalink / raw)
  To: nbd, lorenzo, sean.wang; +Cc: linux-wireless, linux-mediatek

[-- Attachment #1: Type: text/plain, Size: 1810 bytes --]

Hi!

Currently, mt7921 ignores BSS_CHANGED_TXPOWER in mt7921_bss_info_changed(),
so runtime TX power limits configured via nl80211/iw (e.g. "iw dev <if>
set txpower limit <mbm>") have no effect in AP or STA mode.

On hardware like MT7922, running at the full regulatory limit (e.g. 23 dBm)
pushes tmac values above the EEPROM calibration limits visible in
txpower_sku. This causes PA overdrive/saturation, severe throughput
degradation, and thermal overheating—which eventually wedges the firmware
and driver (MCU timeouts) so badly that only a hard reboot / power cycle
can recover the device, with no way for users or hostapd to reduce TX
power at runtime.

Furthermore, mt76_connac_mcu_rate_txpower_band() never updates
phy->txpower_cur, causing mt76_get_txpower() ("iw dev <if> info") to
always report a static 3.00 dBm regardless of the actual configured
TX power.

Fix both issues by:
1. Handling BSS_CHANGED_TXPOWER in mt7921_bss_info_changed(), refreshing
   the CLC country power table via mt7921_mcu_set_clc() before calling
   mt76_connac_mcu_set_rate_txpower() so both downward and upward runtime
   TX power adjustments take effect immediately on MT7921/MT7922 firmware.
2. Updating phy->txpower_cur in mt76_connac_mcu_rate_txpower_band().

Tested on:
- Hardware: Compulab fitlet2 with MediaTek MT7922 (RZ616, PCIe 14c3:0616)
- Mode: 5 GHz 80 MHz AP mode (hostapd, regdom DE)
- Kernel: Linux 7.0.0 (also verified on 6.8.0)
- Firmware: WM Firmware Build 20250523103234 (and 20231120)
- OS: Linux Mint 22.3

Analyzed and fixed with AI support. 

Tested on MT7922 (PCIe) in 5 GHz 80 MHz AP mode.

Best regards,

Niels

---------------------------------------------
Niels Luettge
mailto:niels@luettge.info
---------------------------------------------



[-- Attachment #2: mt7921-txpower-fix-upstream.patch --]
[-- Type: application/octet-stream, Size: 878 bytes --]

--- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
@@ -719,6 +719,12 @@
 	if (changed & (BSS_CHANGED_QOS | BSS_CHANGED_BEACON_ENABLED))
 		mt7921_mcu_set_tx(dev, vif);
 
+	if (changed & BSS_CHANGED_TXPOWER) {
+		hw->conf.power_level = info->txpower > 0 ? info->txpower : 0;
+		mt7921_mcu_set_clc(dev, dev->mt76.alpha2, dev->country_ie_env);
+		mt76_connac_mcu_set_rate_txpower(&dev->mphy);
+	}
+
 	if (changed & BSS_CHANGED_PS)
 		mt7921_mcu_uni_bss_ps(dev, vif);
 
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
@@ -2179,6 +2179,7 @@
 	tx_power = 2 * phy->hw->conf.power_level;
 	if (!tx_power)
 		tx_power = 127;
+	phy->txpower_cur = tx_power;
 
 	if (band == NL80211_BAND_2GHZ) {
 		n_chan = ARRAY_SIZE(chan_list_2ghz);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-19 19:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 19:57 [PATCH] wifi: mt76: mt7921: handle BSS_CHANGED_TXPOWER and update txpower_cur Niels Lüttge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox