Linux wireless drivers development
 help / color / mirror / Atom feed
From: Razvan Grigore <razvan.grigore@vampirebyte.ro>
To: linux-wireless@vger.kernel.org, Felix Fietkau <nbd@nbd.name>,
	Lorenzo Bianconi <lorenzo@kernel.org>,
	Ryder Lee <ryder.lee@mediatek.com>
Cc: Shayne Chen <shayne.chen@mediatek.com>,
	Sean Wang <sean.wang@mediatek.com>,
	Razvan Grigore <razvan.grigore@vampirebyte.ro>
Subject: [PATCH 2/4] wifi: mt76: mt7921: fix returned txpower
Date: Sun,  9 Feb 2025 01:18:54 +0000	[thread overview]
Message-ID: <20250209011856.6726-3-razvan.grigore@vampirebyte.ro> (raw)
In-Reply-To: <20250209011856.6726-1-razvan.grigore@vampirebyte.ro>

This bug was noticed by me and confirmed by many more people using this chipset with openwrt: https://github.com/openwrt/mt76/issues/783

It seems that for this particular chipset the mt76_phy->txpower_cur is never set, like in the case of other chipsets like mt7603, mt7615, etc. The driver is correctly calculating the TX power adjustment based on the number of antennas. However, the base TX power (phy->txpower_cur) is not being properly initialized or set to a meaningful value. It's starting at 0, so the final result is just the antenna gain compensation divided by 2.

Signed-off-by: Razvan Grigore <razvan.grigore@vampirebyte.ro>
---
 drivers/net/wireless/mediatek/mt76/mt7921/main.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
index 13e58c328aff..9e8961533fd1 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
@@ -1251,6 +1251,8 @@ int mt7921_set_tx_sar_pwr(struct ieee80211_hw *hw,
 			  const struct cfg80211_sar_specs *sar)
 {
 	struct mt76_phy *mphy = hw->priv;
+	int tx_power;
+	struct mt76_power_limits limits_array;
 
 	if (sar) {
 		int err = mt76_init_sar_power(hw, sar);
@@ -1260,6 +1262,11 @@ int mt7921_set_tx_sar_pwr(struct ieee80211_hw *hw,
 	}
 	mt792x_init_acpi_sar_power(mt792x_hw_phy(hw), !sar);
 
+	tx_power = mt76_get_power_bound(mphy, hw->conf.power_level);
+	tx_power = mt76_get_rate_power_limits(mphy, mphy->chandef.chan,
+					      &limits_array, tx_power);
+	mphy->txpower_cur = tx_power;
+
 	return mt76_connac_mcu_set_rate_txpower(mphy);
 }
 
-- 
2.34.1


  parent reply	other threads:[~2025-02-09  1:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-09  1:18 [PATCH 0/4] wifi: mt76: fix returned txpower for mt7921 and mt7925 Razvan Grigore
2025-02-09  1:18 ` [PATCH 1/4] wifi: mt76: add mt76_get_power_bound helper function Razvan Grigore
2025-02-09  1:18 ` Razvan Grigore [this message]
2025-02-09  1:18 ` [PATCH 3/4] wifi: mt76: mt7925: fix returned txpower Razvan Grigore
2025-02-09  1:18 ` [PATCH 4/4] wifi: mt76: mt7915: cleanup mt7915_get_power_bound Razvan Grigore
2025-02-09  8:02   ` Shengyu Qu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250209011856.6726-3-razvan.grigore@vampirebyte.ro \
    --to=razvan.grigore@vampirebyte.ro \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=nbd@nbd.name \
    --cc=ryder.lee@mediatek.com \
    --cc=sean.wang@mediatek.com \
    --cc=shayne.chen@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox