RE: [PATCH rtw-next v3 2/2] wifi: rtw88: 8822c: ignore nrx values without CCK PD registers
From: Ping-Ke Shih
Date: Tue Nov 17 2026 - 01:38:50 EST
Zeshan Ahmed Nobin <zeshanahmednobin@xxxxxxxxx> wrote:
> rtw8822c_phy_cck_pd_set() reads nrx, the number of CCK RX paths minus
> one, from a 2-bit register field. The driver only ever sets it to 0 or
> 1, for one or two RX paths (see rtw8822c_config_cck_rx_path()), and
> rtw8822c_cck_pd_reg[] only has registers for those two values; its
> entries for nrx 2 and 3 are all zero.
Just describe you validate NRX, otherwise it crashes because a device
surprisedly remove.
>
> A device that stops responding can return any value. On PCIe, register
> reads then return all ones, so nrx is 3. On USB, a failed read returns
> whatever an earlier read left in the buffer. bw comes from
> rtwdev->hal.current_band_width and stays valid.
No need to describe what other patch does.
> When the level then
> changes, rtw8822c_phy_cck_pd_set_reg() gets past its WARN_ON(), which
> only checks nrx against RTW_RF_PATH_MAX, and calls rtw_read32_mask()
> and rtw_write32_mask() on register 0x0 with a zero mask. Both compute
> __ffs(0), which is undefined, and the write puts back whatever was read
> from register 0x0.
>
> Return early when rtw8822c_cck_pd_reg[] has no registers for nrx.
>
> The fix and this message were drafted with an AI coding assistant
> (Claude Opus 5.5 by Anthropic), then reviewed and tested by the
> submitter.
I think no need this. Just rephrase your commit message, and keep the
key points.
> diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.c
> b/drivers/net/wireless/realtek/rtw88/rtw8822c.c
> index df7df76785e4..1eb1a9656886 100644
> --- a/drivers/net/wireless/realtek/rtw88/rtw8822c.c
> +++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.c
> @@ -4406,6 +4406,14 @@ static void rtw8822c_phy_cck_pd_set(struct rtw_dev *rtwdev, u8 new_lvl)
> nrx = (u8)rtw_read32_mask(rtwdev, 0x1a2c, 0x60000);
> bw = rtwdev->hal.current_band_width;
Since this only can happen when a device is removed suddenly, how about
reverting patch 1, and also validate bw <= RTW_CHANNEL_WIDTH_40 here.
>
> + /*
> + * rtw8822c_cck_pd_reg[] only has registers for one and two RX paths
> + * (nrx 0 and 1); its entries for nrx 2 and 3 are all zero. A device
> + * that stops responding can still return those values.
> + */
> + if (!rtw8822c_cck_pd_reg[bw][nrx].mask_pd)
> + return;
> +
As the comment says, why not just validate nrx <= RF_PATH_B ?
No need comment.
> rtw_dbg(rtwdev, RTW_DBG_PHY, "lv: (%d) -> (%d) bw=%d nr=%d cck_fa_avg=%d\n",
> dm_info->cck_pd_lv[bw][nrx], new_lvl, bw, nrx,
> dm_info->cck_fa_avg);
> --
> 2.43.0