]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: mt76: connac: use a helper to cache txpower_cur
authorSean Wang <sean.wang@mediatek.com>
Wed, 1 Apr 2026 18:23:20 +0000 (13:23 -0500)
committerFelix Fietkau <nbd@nbd.name>
Tue, 9 Jun 2026 10:15:22 +0000 (10:15 +0000)
The cached txpower value is derived from the bounded channel power after
applying the chainmask path delta.

Use a helper for that conversion so callers do not open-code it.

--
v2:
- Rebased onto the latest mt76 tree
- Added Reported-by, Tested-by, Co-developed-by and Signed-off-by tags

Reported-by: Devin Wittmayer <lucid_duck@justthetip.ca>
Closes: https://lore.kernel.org/linux-wireless/20260130215839.53270-1-lucid_duck@justthetip.ca/
Tested-by: Devin Wittmayer <lucid_duck@justthetip.ca>
Tested-by: Satadru Pramanik <satadru@gmail.com>
Co-developed-by: Devin Wittmayer <lucid_duck@justthetip.ca>
Signed-off-by: Devin Wittmayer <lucid_duck@justthetip.ca>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Reported-by: Lucid Duck <lucid_duck@justthetip.ca>
Tested-by: Lucid Duck <lucid_duck@justthetip.ca>
Link: https://patch.msgid.link/20260401182322.64355-1-sean.wang@kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76_connac.h
drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c

index 1994863dc59d11ae08bf235e1f974deff0c7c92a..4afcc6477a99caf4f3733aefd658de901bf1944c 100644 (file)
@@ -436,7 +436,7 @@ mt76_connac_mutex_release(struct mt76_dev *dev, struct mt76_connac_pm *pm)
 void mt76_connac_gen_ppe_thresh(u8 *he_ppet, int nss, enum nl80211_band band);
 int mt76_connac_init_tx_queues(struct mt76_phy *phy, int idx, int n_desc,
                               int ring_base, void *wed, u32 flags);
-
+void mt76_connac_set_txpower_cur(struct mt76_phy *phy, s8 max_power);
 void mt76_connac_write_hw_txp(struct mt76_dev *dev,
                              struct mt76_tx_info *tx_info,
                              void *txp_ptr, u32 id);
index c341595e91383574bec6221be887758fd742ce99..fc9f782032ef2b2dbfbe28bf0691e81e39e2b37b 100644 (file)
@@ -275,6 +275,15 @@ int mt76_connac_init_tx_queues(struct mt76_phy *phy, int idx, int n_desc,
 }
 EXPORT_SYMBOL_GPL(mt76_connac_init_tx_queues);
 
+void mt76_connac_set_txpower_cur(struct mt76_phy *phy, s8 max_power)
+{
+       int delta;
+
+       delta = mt76_tx_power_path_delta(hweight16(phy->chainmask));
+       phy->txpower_cur = max_power - delta;
+}
+EXPORT_SYMBOL_GPL(mt76_connac_set_txpower_cur);
+
 #define __bitrate_mask_check(_mcs, _mode)                              \
 ({                                                                     \
        u8 i = 0;                                                       \
index be0ec1eaa7467b9d097bc2dd2068ee419b105483..03348463f2db990cd225f3c43988fe6d3c9d6652 100644 (file)
@@ -2235,14 +2235,19 @@ mt76_connac_mcu_rate_txpower_band(struct mt76_phy *phy,
                                .hw_value = ch_list[idx],
                                .band = band,
                        };
-                       s8 reg_power, sar_power;
+                       s8 reg_power, sar_power, max_power;
 
                        reg_power = mt76_connac_get_ch_power(phy, &chan,
                                                             tx_power);
                        sar_power = mt76_get_sar_power(phy, &chan, reg_power);
 
-                       mt76_get_rate_power_limits(phy, &chan, limits,
-                                                  sar_power);
+                       max_power = mt76_get_rate_power_limits(phy, &chan, limits,
+                                                              sar_power);
+
+                       if (phy->chandef.chan &&
+                           phy->chandef.chan->hw_value == ch_list[idx] &&
+                           phy->chandef.chan->band == band)
+                               mt76_connac_set_txpower_cur(phy, max_power);
 
                        tx_power_tlv.last_msg = ch_list[idx] == last_ch;
                        sku_tlbv.channel = ch_list[idx];