* [PATCH rtw-next v5] wifi: rtw88: usb: do not log transfers lost to a mode switch
@ 2026-08-17 6:33 Mehmet Fide
2026-08-17 8:26 ` Ping-Ke Shih
0 siblings, 1 reply; 2+ messages in thread
From: Mehmet Fide @ 2026-08-17 6:33 UTC (permalink / raw)
To: Ping-Ke Shih; +Cc: Mehmet Fide, linux-wireless
From: Mehmet Fide <mehmet.fide@screeningeagle.com>
An RTL8822BU or RTL8822CU is asked to come back as a USB 3 device by
rtw_usb_switch_mode_new(). The chip powers off its MAC and leaves the bus
while the last control transfers of that sequence are still in flight, so
they complete with -EPROTO and the driver reports them as errors:
rtw_8822bu 1-1:1.0: Firmware version 27.2.0, H2C version 13
rtw_8822bu 1-1:1.0: write register 0xc4 failed with -71
usb 1-1: USB disconnect, device number 2
usbcore: registered new interface driver rtw_8822bu
rtw_8822bu 1-1:1.0: Firmware version 27.2.0, H2C version 13
Register 0xc4 is REG_PAD_CTRL2 and the access losing the race is the
rtw_write32_set() that ends the switch sequence, a few milliseconds before
the disconnect. Which transfer gets caught varies from boot to boot: 0xc4
is in the "always on" section, so every write to it is followed by a second
one from rtw_usb_reg_sec(), and sometimes that is the one that fails:
rtw_8822bu 1-1:1.0: rtw_usb_reg_sec: reg 0x4e0, usb write 1 fail,
status: -71
Nothing is wrong here. The device re-enumerates, probes again and registers
normally, which is why rtw_usb_probe() already treats a non-zero return
from rtw_usb_switch_mode() as "Not a fail". On a USB 2 only port the
switch can never succeed, so the message returns on every boot and
everyone using such a port has to work out that it is harmless.
Mark the window in which the chip is expected to leave the bus and skip the
error reports for transfers that fall into it. The mark is a rtw_flags bit
set in rtw_usb_switch_mode(), so it covers both the new and the old switch
sequence, and it is cleared again right after them: the transfers that lose
the race are issued from inside the sequences, and anything that fails
later must be reported again.
Tested with an RTL8822BU (0x7392:0xb822) on a USB 2 root port of a TI AM62,
where the message appears exactly once per boot. With the patch both lines
are gone while the disconnect, the re-enumeration and the second firmware
load are unchanged.
Signed-off-by: Mehmet Fide <mehmet.fide@screeningeagle.com>
---
v5:
- drop the comment on the new rtw_flags enumerator (Ping-Ke Shih)
v4:
- track the window with a RTW_FLAG_SWITCHING_USB_MODE bit in rtw_flags
instead of a bool in struct rtw_usb, clear it unconditionally right
after the switch sequences so later failures are reported again, and
drop the comment block in usb.c (Ping-Ke Shih)
- Signed-off-by switched to my work address to match my other patches
v3:
- set the mark in rtw_usb_switch_mode() instead of in the two switch
helpers (Ping-Ke Shih)
drivers/net/wireless/realtek/rtw88/main.h | 1 +
drivers/net/wireless/realtek/rtw88/usb.c | 22 +++++++++++++++++-----
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h
index c6e981ba7..6883fbd9f 100644
--- a/drivers/net/wireless/realtek/rtw88/main.h
+++ b/drivers/net/wireless/realtek/rtw88/main.h
@@ -377,6 +377,7 @@ enum rtw_flags {
RTW_FLAG_RESTARTING,
RTW_FLAG_RESTART_TRIGGERING,
RTW_FLAG_FORCE_LOWEST_RATE,
+ RTW_FLAG_SWITCHING_USB_MODE,
NUM_OF_RTW_FLAGS,
};
diff --git a/drivers/net/wireless/realtek/rtw88/usb.c b/drivers/net/wireless/realtek/rtw88/usb.c
index 64e1c3420..e13faecfb 100644
--- a/drivers/net/wireless/realtek/rtw88/usb.c
+++ b/drivers/net/wireless/realtek/rtw88/usb.c
@@ -64,7 +64,8 @@ static void rtw_usb_reg_sec(struct rtw_dev *rtwdev, u32 addr, __le32 *data)
RTW_USB_CMD_REQ, RTW_USB_CMD_WRITE,
t_reg, 0, data, t_len, 500);
- if (status != t_len && status != -ENODEV)
+ if (status != t_len && status != -ENODEV &&
+ !test_bit(RTW_FLAG_SWITCHING_USB_MODE, rtwdev->flags))
rtw_err(rtwdev, "%s: reg 0x%x, usb write %u fail, status: %d\n",
__func__, t_reg, t_len, status);
}
@@ -90,7 +91,9 @@ static u32 rtw_usb_read(struct rtw_dev *rtwdev, u32 addr, u16 len)
ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
RTW_USB_CMD_REQ, RTW_USB_CMD_READ, addr,
RTW_USB_VENQT_CMD_IDX, data, len, 1000);
- if (ret < 0 && ret != -ENODEV && count++ < 4)
+ if (ret < 0 && ret != -ENODEV &&
+ !test_bit(RTW_FLAG_SWITCHING_USB_MODE, rtwdev->flags) &&
+ count++ < 4)
rtw_err(rtwdev, "read register 0x%x failed with %d\n",
addr, ret);
@@ -140,7 +143,9 @@ static void rtw_usb_write(struct rtw_dev *rtwdev, u32 addr, u32 val, int len)
ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
RTW_USB_CMD_REQ, RTW_USB_CMD_WRITE,
addr, 0, data, len, 500);
- if (ret < 0 && ret != -ENODEV && count++ < 4)
+ if (ret < 0 && ret != -ENODEV &&
+ !test_bit(RTW_FLAG_SWITCHING_USB_MODE, rtwdev->flags) &&
+ count++ < 4)
rtw_err(rtwdev, "write register 0x%x failed with %d\n",
addr, ret);
@@ -1173,6 +1178,7 @@ static bool rtw_usb3_chip_new(u8 chip_id)
static int rtw_usb_switch_mode(struct rtw_dev *rtwdev)
{
u8 id = rtwdev->chip->id;
+ int ret;
if (!rtw_usb3_chip_new(id) && !rtw_usb3_chip_old(id))
return 0;
@@ -1189,10 +1195,16 @@ static int rtw_usb_switch_mode(struct rtw_dev *rtwdev)
return 0;
}
+ set_bit(RTW_FLAG_SWITCHING_USB_MODE, rtwdev->flags);
+
if (rtw_usb3_chip_old(id))
- return rtw_usb_switch_mode_old(rtwdev);
+ ret = rtw_usb_switch_mode_old(rtwdev);
else
- return rtw_usb_switch_mode_new(rtwdev);
+ ret = rtw_usb_switch_mode_new(rtwdev);
+
+ clear_bit(RTW_FLAG_SWITCHING_USB_MODE, rtwdev->flags);
+
+ return ret;
}
#define USB_REG_PAGE 0xf4
--
2.54.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: [PATCH rtw-next v5] wifi: rtw88: usb: do not log transfers lost to a mode switch
2026-08-17 6:33 [PATCH rtw-next v5] wifi: rtw88: usb: do not log transfers lost to a mode switch Mehmet Fide
@ 2026-08-17 8:26 ` Ping-Ke Shih
0 siblings, 0 replies; 2+ messages in thread
From: Ping-Ke Shih @ 2026-08-17 8:26 UTC (permalink / raw)
To: Mehmet Fide; +Cc: Mehmet Fide, linux-wireless@vger.kernel.org
Mehmet Fide <mehmet.fide@gmail.com> wrote:
> From: Mehmet Fide <mehmet.fide@screeningeagle.com>
>
> An RTL8822BU or RTL8822CU is asked to come back as a USB 3 device by
> rtw_usb_switch_mode_new(). The chip powers off its MAC and leaves the bus
> while the last control transfers of that sequence are still in flight, so
> they complete with -EPROTO and the driver reports them as errors:
>
> rtw_8822bu 1-1:1.0: Firmware version 27.2.0, H2C version 13
> rtw_8822bu 1-1:1.0: write register 0xc4 failed with -71
> usb 1-1: USB disconnect, device number 2
> usbcore: registered new interface driver rtw_8822bu
> rtw_8822bu 1-1:1.0: Firmware version 27.2.0, H2C version 13
>
> Register 0xc4 is REG_PAD_CTRL2 and the access losing the race is the
> rtw_write32_set() that ends the switch sequence, a few milliseconds before
> the disconnect. Which transfer gets caught varies from boot to boot: 0xc4
> is in the "always on" section, so every write to it is followed by a second
> one from rtw_usb_reg_sec(), and sometimes that is the one that fails:
>
> rtw_8822bu 1-1:1.0: rtw_usb_reg_sec: reg 0x4e0, usb write 1 fail,
> status: -71
>
> Nothing is wrong here. The device re-enumerates, probes again and registers
> normally, which is why rtw_usb_probe() already treats a non-zero return
> from rtw_usb_switch_mode() as "Not a fail". On a USB 2 only port the
> switch can never succeed, so the message returns on every boot and
> everyone using such a port has to work out that it is harmless.
>
> Mark the window in which the chip is expected to leave the bus and skip the
> error reports for transfers that fall into it. The mark is a rtw_flags bit
> set in rtw_usb_switch_mode(), so it covers both the new and the old switch
> sequence, and it is cleared again right after them: the transfers that lose
> the race are issued from inside the sequences, and anything that fails
> later must be reported again.
>
> Tested with an RTL8822BU (0x7392:0xb822) on a USB 2 root port of a TI AM62,
> where the message appears exactly once per boot. With the patch both lines
> are gone while the disconnect, the re-enumeration and the second firmware
> load are unchanged.
>
> Signed-off-by: Mehmet Fide <mehmet.fide@screeningeagle.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-17 8:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-17 6:33 [PATCH rtw-next v5] wifi: rtw88: usb: do not log transfers lost to a mode switch Mehmet Fide
2026-08-17 8:26 ` Ping-Ke Shih
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.