Bitterblue Smith <rtl8821cerfe2@xxxxxxxxx> wrote: > On 13/05/2025 06:27, Ping-Ke Shih wrote: > > Bitterblue Smith <rtl8821cerfe2@xxxxxxxxx> wrote: > >> Disable rtw89_ps_power_mode_change() and rtw89_mac_send_rpwm() for > >> USB because they are called in atomic context and accessing hardware > >> registers results in "scheduling while atomic" errors. > > > > I feel rtw89_ps_power_mode_change() should be not in atomic context. > > Please check this. > > > > I think you're right, only rtw89_mac_send_rpwm() is called in atomic > context. rtw89_ps_power_mode_change() is disabled for other reasons: The rtw89_ps_power_mode_change() is to enter deep power save mode, which can save more power save but need to leave the mode before you are going to do IO/TX/RX. That means if you totally disable it, code flow would be simpler, but power consumption would be higher. Since this is the first patches to enable USB, I suggest you can disable it totally for now, and add it later. > > 1) It calls rtw89_mac_power_mode_change(), which prints errors when > rtw89_mac_send_rpwm() is disabled. > > 2) With RTL8852CU it calls rtw89_ps_power_mode_change_with_hci() > which calls napi_schedule(). That results in dereferencing a null > pointer. I see. Your implementation doesn't use NAPI for USB devices. The rtw89_ps_power_mode_change_with_hci() is to switch IO address for PCI devices in deep power save mode, and USB devices don't need this. I think we can run this only if HCI is PCI.