Skip to content

Instantly share code, notes, and snippets.

@shubhamkumar13
Last active October 31, 2022 01:20
Show Gist options
  • Save shubhamkumar13/3872d74cab043a0600ab0f07ab251875 to your computer and use it in GitHub Desktop.
Save shubhamkumar13/3872d74cab043a0600ab0f07ab251875 to your computer and use it in GitHub Desktop.
Whenever I need help with wifi on pop os I do this here

https://www.reddit.com/r/archlinux/comments/exr82b/tried_55_from_testing_and_wifi_rtl8822be_stopped/

Answer from u/edu4rdshl

I have found a workaround for it issue. The issue is caused most times because this function fails trying to read the ASPM configuration from the PCI device. The current rtwpci module doesn't have an option to manage ASPM as well. So, digging a bit deeper I have found that setting ASPM using the Link Control Register fix the problem and rtwpci is able to read it properly. By default, RT8822BE cards enable L0s and L1 ASPM states but L0s states are shown as "Unknown" then rtwpci fails. I have made a little script that fix the issue, just be sure to follow:

Note: execute next commands as root.

Execute lspci | grep -i wifi | awk '{print $1}' and keep that result in mind.

Now execute lscpi -t and see where the previous value belongs to. In my case I have the following results:

  • 03:00.0
-[0000:00]-+-00.0
           +-02.0
           +-04.0
           +-14.0
           +-14.2
           +-15.0
           +-15.1
           +-16.0
           +-17.0
           +-1c.0-[01]--
           +-1c.4-[02]----00.0
           +-1c.5-[03]----00.0
           +-1e.0
           +-1e.2
           +-1f.0
           +-1f.2
           +-1f.3
           \-1f.4

So, as we can see 03:00.0 belongs to 1c.5 and our domain needs to be 00:1c.5, the flags needed to disable ASPM are 0x50.B=0x40 for this card. Our command in it case is: setpci -s 00:1c.5 0x50.B=0x40

Additionally, you need to apply that changes every time the machine boot but also blacklist rtwpci, rtw88 and r8822be (if installed) to avoid the modules loading before we set the ASPM status. Here's an example of the modprobe blacklist.conf file I'm using.

Additionally I have created and special systemd idle service to launch the script and it works as expected.

Note: do not discard sleep's into the script, they are needed there.

In resume, put the upnet script in /usr/bin/ and give execution permissions (chmod +x), blacklist rtwpci, rtw88 and r8822be, put the systemd service in /etc/systemd/system/, enable it using systemctl enable fix-wifi.service and reboot, your wifi should work now.

Feel free to use the script but there aren't guaranties it will work for your specific case, please no report bugs for that, I tried to be very clear here. If you have any question, please comment.

Edit: also blacklist btrtl and btusb as OP says. blacklist.conf should be:

blacklist btrtl
blacklist btusb
blacklist r8822be
blacklist rtw88
blacklist rtwpci
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment