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 0/4] wifi: mt76: fix returned txpower for mt7921 and mt7925
Date: Sun, 9 Feb 2025 01:18:52 +0000 [thread overview]
Message-ID: <20250209011856.6726-1-razvan.grigore@vampirebyte.ro> (raw)
When reading the txpower with `iw dev wlan1` the returned value is
always 3.00 dBm, no matter what reg domain is set or if one changes the
txpower manually.
This bug was discovered by me and confirmed by many people using this
chipset on openwrt: https://github.com/openwrt/mt76/issues/783
I tracked the code for this and it seems that for those 2 chipsets
particularly, the mt76_phy->txpower_cur is never set, in contrast to
other chipsets like mt7603, mt7615, mt76x0, mt7915, etc.
Added some debug logs in the mt76_get_txpower function and I got:
[ 26.816227] mt7921u 2-1:1.3: mt76_get_txpower: phy->txpower_cur = 0
[ 26.816234] mt7921u 2-1:1.3: mt76_get_txpower: n_chains = 2
[ 26.816236] mt7921u 2-1:1.3: mt76_get_txpower: delta = 6
[ 26.816237] mt7921u 2-1:1.3: mt76_get_txpower: *dbm = 3
So 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.
While investigating this I found commit ff94604 that adds a separate
function for _get_power_bound so decided to reuse it for all 3 chipsets,
might be needed in the future as well.
Tested-on: Alfa Network AWUS036AXML
... and it also reacts to manual txpower changes now.
Thank you in advance for looking into this!
R
Razvan Grigore (4):
wifi: mt76: add mt76_get_power_bound helper function
wifi: mt76: mt7921: fix returned txpower
wifi: mt76: mt7925: fix returned txpower
wifi: mt76: mt7915: cleanup mt7915_get_power_bound
drivers/net/wireless/mediatek/mt76/mac80211.c | 11 +++++++++++
drivers/net/wireless/mediatek/mt76/mt76.h | 2 ++
drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c | 8 ++++----
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 4 ++--
drivers/net/wireless/mediatek/mt76/mt7915/mcu.h | 12 ------------
drivers/net/wireless/mediatek/mt76/mt7921/main.c | 7 +++++++
drivers/net/wireless/mediatek/mt76/mt7925/main.c | 7 +++++++
7 files changed, 33 insertions(+), 18 deletions(-)
--
2.34.1
next 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 Razvan Grigore [this message]
2025-02-09 1:18 ` [PATCH 1/4] wifi: mt76: add mt76_get_power_bound helper function Razvan Grigore
2025-02-09 1:18 ` [PATCH 2/4] wifi: mt76: mt7921: fix returned txpower Razvan Grigore
2025-02-09 1:18 ` [PATCH 3/4] wifi: mt76: mt7925: " 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-1-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