Linux wireless drivers development
 help / color / mirror / Atom feed
From: Alessio Ferri <alessio.ferri@mythread.it>
To: Luca Casati <luk00casati@gmail.com>
Cc: linux-wireless@vger.kernel.org, johannes@sipsolutions.net,
	arend.vanspriel@broadcom.com, b43-dev@lists.infradead.org
Subject: Re: [PATCH wireless-next 3/5] b43: N-PHY: fix rev3+ RSSI calibration
Date: Fri, 6 Nov 2026 09:08:46 +0100	[thread overview]
Message-ID: <20261106090846.00007154@mythread.it> (raw)
In-Reply-To: <20261026181543.77763-4-luk00casati@gmail.com>

Il giorno Mon, 26 Oct 2026 19:15:41 +0100
Luca Casati <luk00casati@gmail.com> ha scritto:

> 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,

Drop comments talking about what used to be.

At this point i suggest you the following indication to claude (taken
from mine):

"When you edit files inside a git repository, never add comments stating
what the code was doing or why you changed it, as git can already do
that without polluting the code. Those comments will usually rot at the
next change. Never add trivial comments, they have no use. If you see
comments like those, delete them. If I ever see you leaving N blocks of
comment back to back in my code, for any amount of N > 1, I'll come
after you."

It stops claude from polluting the code, with the added benefit of
reducing its own confusion when it rereads the code and finds its own
rotten and trivial comments.

Alessio

  reply	other threads:[~2026-11-06  8:08 UTC|newest]

Thread overview: 12+ 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-11-06  7:37   ` Alessio Ferri
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 ` [PATCH wireless-next 3/5] b43: N-PHY: fix rev3+ RSSI calibration Luca Casati
2026-11-06  8:08   ` Alessio Ferri [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-11-06 10:41   ` Alessio Ferri
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
2026-10-28 18:12 ` [PATCH wireless-next 0/5] b43: N-PHY: fix calibrations on rev7+ (BCM43228) Rosen Penev
2026-10-29  7:13   ` Johannes Berg
2026-11-06  7:23 ` 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=20261106090846.00007154@mythread.it \
    --to=alessio.ferri@mythread.it \
    --cc=arend.vanspriel@broadcom.com \
    --cc=b43-dev@lists.infradead.org \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=luk00casati@gmail.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