From: Bitterblue Smith <rtl8821cerfe2@gmail.com>
To: Ping-Ke Shih <pkshih@realtek.com>, linux-wireless@vger.kernel.org
Cc: gary.chang@realtek.com, damon.chen@realtek.com, kevin_yang@realtek.com
Subject: Re: [PATCH rtw-next v2 10/12] wifi: rtw89: warn unexpected polling value of XTAL SI
Date: Fri, 19 Dec 2025 12:51:37 +0200 [thread overview]
Message-ID: <fd0e0d09-e220-4465-a80a-b26974602fa9@gmail.com> (raw)
In-Reply-To: <20251218063117.26278-11-pkshih@realtek.com>
On 18/12/2025 08:31, Ping-Ke Shih wrote:
> XTAL SI is an indirect serial interface to access registers in another
> hardware domain. When BT driver initializes UART interface, firmware might
> rarely control XTAL SI at the same time causing access racing.
>
> Current is to adjust initialization flow to avoid the racing. To make
> the racing visible if it still presents, add a message to address this.
>
> USB adapters might be unplugged suddenly, causing flooding messages. Check
> RTW89_FLAG_UNPLUGGED flag to avoid them.
>
> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
> ---
> v2: handle USB being unplugged case to avoid warnings.
> ---
> drivers/net/wireless/realtek/rtw89/mac.c | 31 +++++++++++++++++++--
> drivers/net/wireless/realtek/rtw89/mac_be.c | 13 ++++++++-
> 2 files changed, 40 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/wireless/realtek/rtw89/mac.c b/drivers/net/wireless/realtek/rtw89/mac.c
> index e5f2fa3b2b37..8987077bf756 100644
> --- a/drivers/net/wireless/realtek/rtw89/mac.c
> +++ b/drivers/net/wireless/realtek/rtw89/mac.c
> @@ -1483,6 +1483,15 @@ static void rtw89_mac_power_switch_boot_mode(struct rtw89_dev *rtwdev)
> rtw89_write32_clr(rtwdev, R_AX_RSV_CTRL, B_AX_R_DIS_PRST);
> }
>
> +static int rtw89_mac_pwr_off_func_for_unplugged(struct rtw89_dev *rtwdev)
> +{
> + /*
> + * Avoid accessing IO for unplugged power-off to prevent warnings,
> + * especially XTAL SI.
> + */
> + return 0;
> +}
> +
> static int rtw89_mac_power_switch(struct rtw89_dev *rtwdev, bool on)
> {
> const struct rtw89_mac_gen_def *mac = rtwdev->chip->mac_def;
> @@ -1497,8 +1506,13 @@ static int rtw89_mac_power_switch(struct rtw89_dev *rtwdev, bool on)
> cfg_seq = chip->pwr_on_seq;
> cfg_func = chip->ops->pwr_on_func;
> } else {
> - cfg_seq = chip->pwr_off_seq;
> - cfg_func = chip->ops->pwr_off_func;
> + if (test_bit(RTW89_FLAG_UNPLUGGED, rtwdev->flags)) {
> + cfg_seq = NULL;
I just realised, this NULL will be dereferenced in rtw89_mac_pwr_seq().
> + cfg_func = rtw89_mac_pwr_off_func_for_unplugged;
> + } else {
> + cfg_seq = chip->pwr_off_seq;
> + cfg_func = chip->ops->pwr_off_func;
> + }
> }
>
> if (test_bit(RTW89_FLAG_FW_RDY, rtwdev->flags))
> @@ -7033,6 +7047,12 @@ int rtw89_mac_write_xtal_si_ax(struct rtw89_dev *rtwdev, u8 offset, u8 val, u8 m
> return ret;
> }
>
> + if (!test_bit(RTW89_FLAG_UNPLUGGED, rtwdev->flags) &&
> + (u32_get_bits(val32, B_AX_WL_XTAL_SI_ADDR_MASK) != offset ||
> + u32_get_bits(val32, B_AX_WL_XTAL_SI_DATA_MASK) != val))
> + rtw89_warn(rtwdev, "xtal si write: offset=%x val=%x poll=%x\n",
> + offset, val, val32);
> +
> return 0;
> }
>
> @@ -7056,7 +7076,12 @@ int rtw89_mac_read_xtal_si_ax(struct rtw89_dev *rtwdev, u8 offset, u8 *val)
> return ret;
> }
>
> - *val = rtw89_read8(rtwdev, R_AX_WLAN_XTAL_SI_CTRL + 1);
> + if (!test_bit(RTW89_FLAG_UNPLUGGED, rtwdev->flags) &&
> + u32_get_bits(val32, B_AX_WL_XTAL_SI_ADDR_MASK) != offset)
> + rtw89_warn(rtwdev, "xtal si read: offset=%x poll=%x\n",
> + offset, val32);
> +
> + *val = u32_get_bits(val32, B_AX_WL_XTAL_SI_DATA_MASK);
>
> return 0;
> }
> diff --git a/drivers/net/wireless/realtek/rtw89/mac_be.c b/drivers/net/wireless/realtek/rtw89/mac_be.c
> index 2bc329c13443..c0204e68c172 100644
> --- a/drivers/net/wireless/realtek/rtw89/mac_be.c
> +++ b/drivers/net/wireless/realtek/rtw89/mac_be.c
> @@ -396,6 +396,12 @@ int rtw89_mac_write_xtal_si_be(struct rtw89_dev *rtwdev, u8 offset, u8 val, u8 m
> return ret;
> }
>
> + if (!test_bit(RTW89_FLAG_UNPLUGGED, rtwdev->flags) &&
> + (u32_get_bits(val32, B_BE_WL_XTAL_SI_ADDR_MASK) != offset ||
> + u32_get_bits(val32, B_BE_WL_XTAL_SI_DATA_MASK) != val))
> + rtw89_warn(rtwdev, "xtal si write: offset=%x val=%x poll=%x\n",
> + offset, val, val32);
> +
> return 0;
> }
>
> @@ -420,7 +426,12 @@ int rtw89_mac_read_xtal_si_be(struct rtw89_dev *rtwdev, u8 offset, u8 *val)
> return ret;
> }
>
> - *val = rtw89_read8(rtwdev, R_BE_WLAN_XTAL_SI_CTRL + 1);
> + if (!test_bit(RTW89_FLAG_UNPLUGGED, rtwdev->flags) &&
> + u32_get_bits(val32, B_BE_WL_XTAL_SI_ADDR_MASK) != offset)
> + rtw89_warn(rtwdev, "xtal si read: offset=%x poll=%x\n",
> + offset, val32);
> +
> + *val = u32_get_bits(val32, B_BE_WL_XTAL_SI_DATA_MASK);
>
> return 0;
> }
next prev parent reply other threads:[~2025-12-19 10:51 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-18 6:31 [PATCH rtw-next v2 00/12] wifi: rtw89: refine MLO, MCC and SER functions Ping-Ke Shih
2025-12-18 6:31 ` [PATCH rtw-next v2 01/12] wifi: rtw89: 8852b: increase beacon loss to 6 seconds Ping-Ke Shih
2025-12-18 6:31 ` [PATCH rtw-next v2 02/12] wifi: rtw89: mlo: fix missing TX null-data 1 during link switch Ping-Ke Shih
2025-12-18 6:31 ` [PATCH rtw-next v2 03/12] wifi: rtw89: mlo: fix incorrect link address in management frames Ping-Ke Shih
2025-12-18 6:31 ` [PATCH rtw-next v2 04/12] wifi: rtw89: mac: reset power state before switching to power on Ping-Ke Shih
2025-12-18 6:31 ` [PATCH rtw-next v2 05/12] wifi: rtw89: ser: enable error IMR after recovering from L1 Ping-Ke Shih
2025-12-18 6:31 ` [PATCH rtw-next v2 06/12] wifi: rtw89: ser: L1 skip polling status if FW runs event mode Ping-Ke Shih
2025-12-18 6:31 ` [PATCH rtw-next v2 07/12] wifi: rtw89: debug: add ser_counters dbgfs Ping-Ke Shih
2025-12-18 6:31 ` [PATCH rtw-next v2 08/12] wifi: rtw89: debug: support SER L0/L1 simulation via halt H2C Ping-Ke Shih
2025-12-18 6:31 ` [PATCH rtw-next v2 09/12] wifi: rtw89: refine C2H reg event polling timeout for LPS Ping-Ke Shih
2025-12-18 6:31 ` [PATCH rtw-next v2 10/12] wifi: rtw89: warn unexpected polling value of XTAL SI Ping-Ke Shih
2025-12-19 10:51 ` Bitterblue Smith [this message]
2025-12-19 13:21 ` Ping-Ke Shih
2025-12-19 14:33 ` Bitterblue Smith
2025-12-18 6:31 ` [PATCH rtw-next v2 11/12] wifi: rtw89: setting TBTT AGG number when mac port initialization Ping-Ke Shih
2025-12-18 6:31 ` [PATCH rtw-next v2 12/12] wifi: rtw89: mcc: reset probe counter when receiving beacon 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=fd0e0d09-e220-4465-a80a-b26974602fa9@gmail.com \
--to=rtl8821cerfe2@gmail.com \
--cc=damon.chen@realtek.com \
--cc=gary.chang@realtek.com \
--cc=kevin_yang@realtek.com \
--cc=linux-wireless@vger.kernel.org \
--cc=pkshih@realtek.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;
as well as URLs for NNTP newsgroup(s).