b43_radio_2057_rccal() follows wl's sequence, but sleeps with usleep_range(x, 2 * x) where wl waits x us, and polls DONE every 500 us where wl polls about every 30 us. Every step takes about twice as long as in wl. That breaks the first run. Its poll comes straight after the start, while RCCAL_DONE_OSCCAP still has the done bit set from before, so it returns at once and the run is stopped. wl does the same, but writes the stop about 40 us after the start; b43 writes it about 85 us in, while the cal is running. RCCAL_SCAP_VAL then reads 0 or 0x1f instead of 8 on a BCM43228 (radio 2057 rev 9), which detunes the TX low-pass filter set up in the rev7+ workarounds. With only that delay fixed it reads 7; with all of wl's delays it reads 8, as with wl. Use wl's delays, with udelay(): the whole cal busy-waits about 2 ms, as brcmsmac's version does. mmiotraces: https://github.com/Luca00casati/b43patch/blob/755c2d8/traces/excerpts/patch4-rccal.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 --- drivers/net/wireless/broadcom/b43/phy_n.c | 26 +++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/broadcom/b43/phy_n.c b/drivers/net/wireless/broadcom/b43/phy_n.c index 36c07d891..ab8fab018 100644 --- a/drivers/net/wireless/broadcom/b43/phy_n.c +++ b/drivers/net/wireless/broadcom/b43/phy_n.c @@ -940,12 +940,12 @@ static u16 b43_radio_2057_rccal(struct b43_wldev *dev) /* Start, wait, stop */ b43_radio_write(dev, R2057_RCCAL_START_R1_Q1_P1, 0x55); - if (!b43_radio_wait_value(dev, R2057_RCCAL_DONE_OSCCAP, 2, 2, 500, + if (!b43_radio_wait_value(dev, R2057_RCCAL_DONE_OSCCAP, 2, 2, 30, 5000000)) b43dbg(dev->wl, "Radio 0x2057 rccal timeout\n"); - usleep_range(35, 70); + udelay(35); b43_radio_write(dev, R2057_RCCAL_START_R1_Q1_P1, 0x15); - usleep_range(70, 140); + udelay(70); /* Setup cal */ if (special) { @@ -958,15 +958,15 @@ static u16 b43_radio_2057_rccal(struct b43_wldev *dev) b43_radio_write(dev, R2057_RCCAL_X1, 0x6E); /* Start, wait, stop */ - usleep_range(35, 70); + udelay(35); b43_radio_write(dev, R2057_RCCAL_START_R1_Q1_P1, 0x55); - usleep_range(70, 140); - if (!b43_radio_wait_value(dev, R2057_RCCAL_DONE_OSCCAP, 2, 2, 500, + udelay(70); + if (!b43_radio_wait_value(dev, R2057_RCCAL_DONE_OSCCAP, 2, 2, 30, 5000000)) b43dbg(dev->wl, "Radio 0x2057 rccal timeout\n"); - usleep_range(35, 70); + udelay(35); b43_radio_write(dev, R2057_RCCAL_START_R1_Q1_P1, 0x15); - usleep_range(70, 140); + udelay(70); /* Setup cal */ if (special) { @@ -980,18 +980,18 @@ static u16 b43_radio_2057_rccal(struct b43_wldev *dev) } /* Start, wait, stop */ - usleep_range(35, 70); + udelay(35); b43_radio_write(dev, R2057_RCCAL_START_R1_Q1_P1, 0x55); - usleep_range(70, 140); - if (!b43_radio_wait_value(dev, R2057_RCCAL_DONE_OSCCAP, 2, 2, 500, + udelay(70); + if (!b43_radio_wait_value(dev, R2057_RCCAL_DONE_OSCCAP, 2, 2, 30, 5000000)) { b43err(dev->wl, "Radio 0x2057 rcal timeout\n"); return 0; } tmp = b43_radio_read(dev, R2057_RCCAL_DONE_OSCCAP); - usleep_range(35, 70); + udelay(35); b43_radio_write(dev, R2057_RCCAL_START_R1_Q1_P1, 0x15); - usleep_range(70, 140); + udelay(70); if (special) b43_radio_mask(dev, R2057_RCCAL_MASTER, ~0x1); -- 2.43.0