[PATCH 1/2] mt76: connac: fix txpower_cur not updated in mt76_connac_mcu_set_rate_txpower()
Sean Wang
sean.wang at kernel.org
Wed Mar 11 22:24:42 PDT 2026
Hi,
I just realized that Lucid already implemented another approach to
obtain the TX power here:
https://lore.kernel.org/linux-wireless/20260130215839.53270-1-lucid_duck@justthetip.ca/
We should respect his work. Could you also take a look at it and reply
to his patch to avoid potential rework?
On Wed, Mar 11, 2026 at 3:57 PM bryam vargas
<bryamestebanvargas at gmail.com> wrote:
>
> From 6c75ad481f0c3667d6ae2a2c8f7c2df08b1d52b5 Mon Sep 17 00:00:00 2001
> From: bryam <bryamestebanvargas at gmail.com>
> Date: Mon, 9 Mar 2026 11:52:53 -0500
> Subject: [PATCH v2 1/2] mt76: mt7921: add mt7921-specific get_txpower callback
>
> Instead of updating txpower_cur in the write path
> (mt76_connac_mcu_set_rate_txpower), implement a mt7921-specific
> .get_txpower callback that derives the reported TX power directly
> from the SKU limits at query time.
>
> This avoids mixing write-side configuration with reporting logic.
> The callback uses mt76_get_power_bound() for SAR constraints and
> chain delta, then mt76_get_rate_power_limits() for per-rate EEPROM
> limits, yielding the actual TX power value.
>
> Fixes: 3b4a3bdba808 ("mt76: mt7921: add support for reporting tx power")
> Signed-off-by: Bryam Vargas <bryamestebanvargas at gmail.com>
> ---
> .../net/wireless/mediatek/mt76/mt7921/main.c | 27 ++++++++++++++++++-
> 1 file changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> index 67383c4..35454e5 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> @@ -1517,6 +1517,31 @@ static void mt7921_rfkill_poll(struct ieee80211_hw *hw)
> wiphy_rfkill_set_hw_state(hw->wiphy, ret ? false : true);
> }
>
> +
> +static int mt7921_get_txpower(struct ieee80211_hw *hw,
> + struct ieee80211_vif *vif,
> + unsigned int link_id, int *dbm)
> +{
> + struct mt76_phy *phy = mt76_vif_phy(hw, vif);
> + struct mt76_power_limits limits;
> + int n_chains, delta;
> + s8 tx_power;
> +
> + if (!phy)
> + return -EINVAL;
> +
> + if (!phy->chandef.chan)
> + return mt76_get_txpower(hw, vif, link_id, dbm);
> +
> + n_chains = hweight16(phy->chainmask);
> + delta = mt76_tx_power_path_delta(n_chains);
> + tx_power = mt76_get_power_bound(phy, phy->chandef.chan->max_power);
> + tx_power = mt76_get_rate_power_limits(phy, phy->chandef.chan,
> + &limits, tx_power);
> + *dbm = DIV_ROUND_UP(tx_power + delta, 2);
how can you make sure it is the result of the maximum rate power used
in the loop within mt76_connac_mcu_rate_txpower_band (updated with
each call) ?
> + return 0;
> +}
> +
> const struct ieee80211_ops mt7921_ops = {
> .tx = mt792x_tx,
> .start = mt7921_start,
> @@ -1541,7 +1566,7 @@ const struct ieee80211_ops mt7921_ops = {
> .wake_tx_queue = mt76_wake_tx_queue,
> .release_buffered_frames = mt76_release_buffered_frames,
> .channel_switch_beacon = mt7921_channel_switch_beacon,
> - .get_txpower = mt76_get_txpower,
> + .get_txpower = mt7921_get_txpower,
> .get_stats = mt792x_get_stats,
> .get_et_sset_count = mt792x_get_et_sset_count,
> .get_et_strings = mt792x_get_et_strings,
> --
> 2.43.0
More information about the Linux-mediatek
mailing list