On 08/07/2024 12:19, Ping-Ke Shih wrote: > Bitterblue Smith <rtl8821cerfe2@xxxxxxxxx> wrote: >> The Realtek wifi 5 devices which support USB 3 are weird: when first >> plugged in, they pretend to be USB 2. The driver needs to send some >> commands to the device, which make it disappear and come back as a >> USB 3 device. >> >> Implement the required commands in rtw88. >> >> When a USB 3 device is plugged into a USB 2 port, rtw88 will try to >> switch it to USB 3 mode only once. The device will disappear and come >> back still in USB 2 mode, of course. >> >> Some people experience heavy interference in the 2.4 GHz band in >> USB 3 mode, so add a module parameter switch_usb_mode with the >> default value 1 to let people disable the switching. >> >> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@xxxxxxxxx> >> --- >> A later patch will add the function rtw_usb_switch_mode_old() for the >> older chips RTL8812AU and RTL8814AU. > > [...] > >> diff --git a/drivers/net/wireless/realtek/rtw88/usb.c b/drivers/net/wireless/realtek/rtw88/usb.c >> index a55ca5a24227..a59e52a0da10 100644 >> --- a/drivers/net/wireless/realtek/rtw88/usb.c >> +++ b/drivers/net/wireless/realtek/rtw88/usb.c >> @@ -14,6 +14,11 @@ >> #include "ps.h" >> #include "usb.h" >> >> +static bool rtw_switch_usb_mode = true; >> +module_param_named(switch_usb_mode, rtw_switch_usb_mode, bool, 0644); >> +MODULE_PARM_DESC(switch_usb_mode, >> + "Set to Y to switch to USB 3 mode (default: Y)"); >> + > > I feel we should say "Set to N to disable switching USB 3 mode to avoid > potential interference in the 2.4 GHz" like your commit message. That could > be helpful to users. > Sounds good. >> #define RTW_USB_MAX_RXQ_LEN 512 >> >> struct rtw_usb_txcb { > > [...] > >> @@ -896,6 +972,14 @@ int rtw_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) >> goto err_destroy_rxwq; >> } >> >> + ret = rtw_usb_switch_mode(rtwdev); >> + if (ret) { >> + /* Not a fail, but we do need to skip rtw_register_hw. */ >> + rtw_info(rtwdev, "switching to USB 3 mode\n"); > > All logs in this patches should be rtw_dbg(), because these messages are not > important to users. > Okay, I will add RTW_DBG_USB to enum rtw_debug_mask. > >> + ret = 0; >> + goto err_destroy_rxwq; >> + } >> + >> ret = rtw_register_hw(rtwdev, rtwdev->hw); >> if (ret) { >> rtw_err(rtwdev, "failed to register hw\n"); >> -- >> 2.45.1 >