Skip to contentSkip to conversation

wifi: mt76: mt7921: handle BSS_CHANGED_TXPOWER and update txpower_cur

PATCH New Niels Lüttge 1 participant 1 message Nov 19

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: mt76: mt7921: handle BSS_CHANGED_TXPOWER and update txpower_cur

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:[email protected]
---------------------------------------------

drivers/net/wireless/mediatek/mt76/mt7921/main.c +6 -0
@@ -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);
 
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +1 -0
@@ -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);