All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ping-Ke Shih <pkshih@realtek.com>
To: Zeshan Ahmed Nobin <zeshanahmednobin@gmail.com>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Luka Gejak <luka.gejak@linux.dev>, Kalle Valo <kvalo@kernel.org>
Subject: RE: [PATCH rtw-next v3 2/2] wifi: rtw88: 8822c: ignore nrx values without CCK PD registers
Date: Tue, 17 Nov 2026 06:38:21 +0000	[thread overview]
Message-ID: <427f6f2e79474058958c3f3d0901df38@realtek.com> (raw)
In-Reply-To: <20261115201826.181662-3-zeshanahmednobin@gmail.com>

Zeshan Ahmed Nobin <zeshanahmednobin@gmail.com> 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


  reply	other threads:[~2026-11-17  6:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-15 20:18 [PATCH rtw-next v3 0/2] wifi: rtw88: 8822c: fix cck_pd_set when the chip stops responding Zeshan Ahmed Nobin
2026-11-15 20:18 ` [PATCH rtw-next v3 1/2] wifi: rtw88: 8822c: fix out-of-bounds access in cck_pd_set Zeshan Ahmed Nobin
2026-11-16 14:49   ` Luka Gejak
2026-11-15 20:18 ` [PATCH rtw-next v3 2/2] wifi: rtw88: 8822c: ignore nrx values without CCK PD registers Zeshan Ahmed Nobin
2026-11-17  6:38   ` Ping-Ke Shih [this message]
2026-11-17 13:17     ` Luka Gejak
2026-11-18  0:25       ` Ping-Ke Shih

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=427f6f2e79474058958c3f3d0901df38@realtek.com \
    --to=pkshih@realtek.com \
    --cc=kvalo@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=luka.gejak@linux.dev \
    --cc=zeshanahmednobin@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.