Prevent sleep/suspend mode from stopping my USB WiFi Adapter | KDE Plasma

Hello, I have been trying for the past days to prevent my USB WiFi Adapter (Realtek Semiconductor Corp. 802.11ac NIC) from being disabled while the PC is Sleep Mode.

Here’s my suspend configuration:

I have tried adding an udev rule “72-wifi-change.rules” in /etc/udev/rules.d, as some posts in forums indicate:

SUBSYSTEM=="usb", ATTR{idProduct}=="c820", ATTR{idVendor}=="0bda", ATTR{power/control}="on"

I got the info from: usb-devices

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=480  MxCh= 0
D:  Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1
S:  Product=802.11ac NIC
S:  SerialNumber=123456
C:  #Ifs= 3 Cfg#= 1 Atr=a0 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
I:  If#= 2 Alt= 0 #EPs= 5 Cls=ff(vend.) Sub=ff Prot=ff Driver=rtw_8821cu
E:  Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=06(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=08(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=87(I) Atr=03(Int.) MxPS=  64 Ivl=500us

I tried running sudo udevadm control --reload,sudo udevadm trigger and a full system reboot in order to “reload the rules” as some other posts have indicated.

I tried checking if the rule was even being loaded, with journalctl -f after running sudo udevadm control --log-priority=debug, and it said this:

Reading rules file: /etc/udev/rules.d/72-wifi-change.rules

But to no avail, the WiFi stays disabled.

I tried searching similar posts, but I wasn’t able to find anything specific to my issue nor a simple “tick” to disable “power management” on WiFi devices in KDE Plasma or EndevourOS.

This is probably not adequate for this section of the forums, but it would be really nice if a “do not suspend wifi in Sleep Mode” was added to the “power management” options.

My hardware info: https://0x0.st/83Qv.txt

Thanks in advance.

Since EndeavourOS uses Network Manager, this should work:

Disable WiFi power management. In the /etc/NetworkManager/conf.d/ folder, create this file wifi-powersave-off.conf to look like this:

[connection]
wifi.powersave = 2

Restart NetworkManager (sudo systemctl restart NetworkManager) and it should be go to go.

For more info, look here:

However, if you are using systemd-networkd instead, this solution should work:

https://unix.stackexchange.com/questions/593573/how-to-turn-off-wireless-power-management-permanently-using-systemd-networkd

So, any luck getting the wifi-powersave setting to work? Just curious. :smiley:

Hello, thanks for the answer.

Unfortunately, it didn’t work. The WiFi still gets disabled while in Sleep Mode.
And I removed the udev rule mentioned in the post, to prevent any issues.

Maybe this solution only works for integrated/PCI WiFi cards? I have an USB one, as I specified in the post, it could be that the USB port or the device gets disabled by the system instead of Network Manager.

You can try other things as well:

To prevent USB ports from entering sleep mode in Linux, you can disable autosuspend or configure specific devices to stay powered on. The most common method involves modifying the kernel’s boot parameters or using commands to control power management on specific devices.

Here’s a more detailed breakdown:

  1. Disabling Autosuspend Globally:
  • Modifying Boot Parameters:

You can add usbcore.autosuspend=-1 to the kernel’s boot command line. This will disable autosuspend for all USB devices.

  • Editing /etc/default/grub: Find the line GRUB_CMDLINE_LINUX_DEFAULT and add usbcore.autosuspend=-1 to the end, making sure to enclose the string in quotes.
  • Updating Grub: After making changes, run sudo grub-mkconfig -o /boot/grub/grub.cfg to apply the changes.
  • Reboot: Restart your system for the changes to take effect.

If you are using systemd-boot, all the GRUB specifics won’t matter. I don’t use systemd-boot, so someone else may need to make suggestions.

Well, I added it to the cmd line in /etc/kernel/cmdline, reloaded the kernel, and checked if it applied using:

> cat /sys/module/usbcore/parameters/autosuspend
-1

So, it is applied, but just before the screen turns off after manually selecting “sleep” in the app menu, the WiFi icon in the system bar/task manager goes to a “no connection” icon, as if the WiFi adapter was disconnected.


Edit: Udev rule finally set “power/control” to “on”, but device is still disabled in Sleep Mode.

+++ Bus 001 Device 007: ID 0bda:c820 Realtek Semiconductor Corp. 802.11ac NIC
  -/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1
 active_duration=216549
 autosuspend=-1
 autosuspend_delay_ms=-1000
 connected_duration=216858
 control=on
 level=on
 persist=1
 runtime_active_time=216457
 runtime_status=active
 runtime_suspended_time=0
 wakeup=disabled

I remember on older hardware, you sometimes had a BIOS setting to allow/disallow USB power in sleep modes. On one laptop, which had 4 USB ports, this would work only on one of the USB ports, the others were always powered off.

Worth checking maybe. I mean if the MoBo circuitry takes the power away from an USB device, all driver settings might not help…