b43-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Luca Casati <luk00casati@gmail.com>
To: linux-wireless@vger.kernel.org
Cc: johannes@sipsolutions.net, Luca Casati <luk00casati@gmail.com>,
	arend.vanspriel@broadcom.com, b43-dev@lists.infradead.org
Subject: [PATCH wireless-next v2 3/5] b43: N-PHY: fix rev3+ RSSI calibration
Date: Fri,  6 Nov 2026 22:15:14 +0100	[thread overview]
Message-ID: <20261106211516.273791-4-luk00casati@gmail.com> (raw)
In-Reply-To: <20261106211516.273791-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).

mmiotraces: https://github.com/Luca00casati/b43patch/blob/755c2d8/traces/excerpts/patch3-rssi-vcm.txt

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 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/broadcom/b43/phy_n.c b/drivers/net/wireless/broadcom/b43/phy_n.c
index 6b0140f05..36c07d891 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;
@@ -2184,7 +2184,7 @@ static void b43_nphy_rev3_rssi_cal(struct b43_wldev *dev)
 			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 +2219,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


_______________________________________________
b43-dev mailing list
b43-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/b43-dev

  parent reply	other threads:[~2026-11-06 21:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 21:15 [PATCH wireless-next v2 0/5] b43: N-PHY: fix calibrations on rev7+ (BCM43228) Luca Casati
2026-11-06 21:15 ` [PATCH wireless-next v2 1/5] b43: N-PHY: fix the TX tone sample table Luca Casati
2026-11-06 22:12   ` Alessio Ferri
2026-11-06 21:15 ` [PATCH wireless-next v2 2/5] b43: N-PHY: fix TX IQ/LO calibration Luca Casati
2026-11-06 21:15 ` Luca Casati [this message]
2026-11-07 12:00   ` [PATCH wireless-next v2 3/5] b43: N-PHY: fix rev3+ RSSI calibration Alessio Ferri
2026-11-06 21:15 ` [PATCH wireless-next v2 4/5] b43: N-PHY: use wl's delays in the 2057 RC calibration Luca Casati
2026-11-06 21:15 ` [PATCH wireless-next v2 5/5] b43: N-PHY: add the missing override to the rev7 TX_PU command Luca Casati
2026-11-07 11:48 ` [PATCH wireless-next v2 0/5] b43: N-PHY: fix calibrations on rev7+ (BCM43228) Alessio Ferri

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=20261106211516.273791-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