How to fix contant freezing or disconnecting of wpa_supplicant WiFi on rtl8821ce

Tl;dr

Should have:

options rtw88_core disable_lps_deep=y
options rtw88_pci disable_msi=y disable_aspm=y

If you use grub just add pcie_aspm.policy=performance to the kernel command line in /etc/default/grub:

GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 init=/sbin/openrc-init pcie_aspm.policy=performance"

Should have:

network={
    ...
    beacon_int=9000
}

(Append beacon_int=9000 to your main config)

Only run this if you use GRUB:

su -c 'grub-mkconfig -o /boot/grub/grub.cfg'

Then no matter what you run:

su -c 'poweroff'

Then wait a couple of minutes (2-5 min) and power your computer on


I use the rtl8821ce driver for my WiFi and recently I noticed how often it begun to disconnect from the internet, wpa would always give me this output:

...
wlo1: CTRL-EVENT-SCAN-FAILED ret=-16 retry=1
wlo1: CTRL-EVENT-SCAN-FAILED ret=-16 retry=1
wlo1: CTRL-EVENT-SCAN-FAILED ret=-16 retry=1
wlo1: CTRL-EVENT-SCAN-FAILED ret=-16 retry=1
...

Not sure how much it's related, but might be a sign for you /shrug

Anyway, I think I found a solution:

Configure the module

Add this exact content to /etc/modprobe.d/rtw.conf

options rtw88_core disable_lps_deep=y
options rtw88_pci disable_msi=y disable_aspm=y

You can call rtw.conf anything you like

Configure kernel parameters

I don't know how it works on other bootloaders, but basically your kernel command line should include:

pcie_aspm.policy=performance

GRUB

For example in my config:

GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 init=/sbin/openrc-init pcie_aspm.policy=performance"

Configure wpa_supplicant

Open /etc/wpa_supplicant/wpa_supplicant.conf or wherever you store your wpa_supplicant.conf file and in the main config add:

beacon_int=9000

For example:

network={
    ssid="My-C00l-Wifi"
    psk=0000000000000000000000000000000000000000000000000000000000000000
    beacon_int=9000
}

Or

network={
    ssid="My-C00l-Wifi"
    psk="9Y-pAs$w0rd123"
    beacon_int=9000
}

Depends on how your config is set up, but the only part that really matters is:

network={
    ...
    beacon_int=9000
}

Finishing

If you are using GRUB before anything run this:

su -c 'grub-mkconfig -o /boot/grub/grub.cfg'

And if not skip this command

After, no matter what you use:

su -c 'poweroff'

Then wait a couple of minutes (like between 2 and 5), and then power on your computer, this should fix the network annoyances

If your WiFi does not work anymore after this

Not a problem, just revert all the steps in this blog, look for a new solution and find out what option is causing it, usually it's the module part, so try to modify or remove it

Although if this does not work and you find a solution comment on https://user.ari-web.xyz/ and share the solution with others