From: Luca Casati <luk00casati@gmail.com>
To: linux-wireless@vger.kernel.org
Cc: johannes@sipsolutions.net, arend.vanspriel@broadcom.com,
b43-dev@lists.infradead.org, Luca Casati <luk00casati@gmail.com>
Subject: [PATCH wireless-next 3/5] b43: N-PHY: fix rev3+ RSSI calibration
Date: Mon, 26 Oct 2026 19:15:41 +0100 [thread overview]
Message-ID: <20261026181543.77763-4-luk00casati@gmail.com> (raw)
In-Reply-To: <20261026181543.77763-1-luk00casati@gmail.com>
Three bugs in b43_nphy_rev3_rssi_cal():
- On rev7+ the selected VCM was written using the loop counter (8 after
the search loop) instead of vcm_final; the 3-bit field turned that
into VCM 0 on every rev7+ PHY.
- The distance used I*I + Q*I instead of I*I + Q*Q (brcmsmac
wlc_phy_rssi_cal_nphy_rev3()).
- Negative W1/W2 offsets were rounded as -(abs(x + 4) / 8) instead of
-((abs(x) + 4) / 8).
Found and fixed with the help of an AI coding assistant (Claude Opus 5.5),
by comparing mmiotraces of b43 and wl on the same card.
Signed-off-by: Luca Casati <luk00casati@gmail.com>
---
drivers/net/wireless/broadcom/b43/phy_n.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/net/wireless/broadcom/b43/phy_n.c b/drivers/net/wireless/broadcom/b43/phy_n.c
index cabf61870..44769dbb7 100644
--- a/drivers/net/wireless/broadcom/b43/phy_n.c
+++ b/drivers/net/wireless/broadcom/b43/phy_n.c
@@ -2167,7 +2167,7 @@ static void b43_nphy_rev3_rssi_cal(struct b43_wldev *dev)
continue;
for (vcm = 0; vcm < 8; vcm++) {
currd = results[vcm][i] * results[vcm][i] +
- results[vcm][i + 1] * results[vcm][i];
+ results[vcm][i + 1] * results[vcm][i + 1];
if (currd < mind) {
mind = currd;
minvcm = vcm;
@@ -2179,12 +2179,16 @@ static void b43_nphy_rev3_rssi_cal(struct b43_wldev *dev)
results_min[i] = minpoll;
}
- /* Select the best VCM */
+ /*
+ * Select the best VCM. (This used to write the loop counter,
+ * 8, which the 3-bit field turned into VCM 0 on every rev7+
+ * PHY.)
+ */
if (dev->phy.rev >= 7)
b43_radio_maskset(dev,
core ? R2057_NB_MASTER_CORE1 :
R2057_NB_MASTER_CORE0,
- ~R2057_VCM_MASK, vcm);
+ ~R2057_VCM_MASK, vcm_final);
else
b43_radio_maskset(dev, r | B2056_RX_RSSI_MISC,
0xE3, vcm_final << 2);
@@ -2219,7 +2223,7 @@ static void b43_nphy_rev3_rssi_cal(struct b43_wldev *dev)
if (j / 2 == core) {
offset[j] = 232 - poll_results[j];
if (offset[j] < 0)
- offset[j] = -(abs(offset[j] + 4) / 8);
+ offset[j] = -((abs(offset[j]) + 4) / 8);
else
offset[j] = (offset[j] + 4) / 8;
b43_nphy_scale_offset_rssi(dev, 0,
--
2.43.0
next prev parent reply other threads:[~2026-10-26 18:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-26 18:15 [PATCH wireless-next 0/5] b43: N-PHY: fix calibrations on rev7+ (BCM43228) Luca Casati
2026-10-26 18:15 ` [PATCH wireless-next 1/5] b43: N-PHY: fix the TX tone sample table Luca Casati
2026-10-26 18:15 ` [PATCH wireless-next 2/5] b43: N-PHY: fix TX IQ/LO calibration Luca Casati
2026-10-26 18:15 ` Luca Casati [this message]
2026-10-26 18:15 ` [PATCH wireless-next 4/5] b43: N-PHY: wait for the first 2057 RC calibration run Luca Casati
2026-10-26 18:15 ` [PATCH wireless-next 5/5] b43: N-PHY: add the missing override to the rev7 TX_PU command Luca Casati
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=20261026181543.77763-4-luk00casati@gmail.com \
--to=luk00casati@gmail.com \
--cc=arend.vanspriel@broadcom.com \
--cc=b43-dev@lists.infradead.org \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
/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