Ubuntu – Qualcomm Atheros QCA9377 dropping wifi

atherosnetworkingwireless

I am having a lot of problems with Wifi (wired connection don't have any issues). The strange thing is that happens only on my Ubuntu 18.04.4 x86_64 4.15.0-101-generic computer (I also tried to reinstall and put the 20.04 fresh, but nothing changed), all others have Windows/Android and are not affected.

What happens is that after a while browsing, I lose my internet connection, leaving the icon in the upper right corner with the question mark and getting "err_disconnected_internet", "dns_probe_finished_nxdomain" or "dns_probe_finished_no_internet" from Chrome. To "solve" I need to switch from the 2.4G network to the 5G network (and vice versa), but soon afterwards the problem occurs, often in less than 5 minutes (sometimes more, sometimes less).

I've tried several things, but all without success, I'll leave all of them here:

When viewing the dmseg -w command information, I saw that my country code (which is currently Brazil) was apparently changed to IE:

[1610.124972] wlp2s0: associated
[1610.125195] ath: EEPROM regdomain: 0x804c
[1610.125197] ath: EEPROM indicates we should expect a country code
[1610.125200] ath: doing EEPROM country-> regdmn map search
[1610.125202] ath: country maps to regdmn code: 0x3b
[1610.125205] ath: Country alpha2 being used: BR
[1610.125206] ath: Regpair used: 0x3b
[1610.125210] ath: regdomain 0x804c dynamically updated by country IE
[1610.159599] wlp2s0: Limiting TX power to 30 (30 - 0) dBm as advertised by ...

I tried to change in /etc/default/crda, but without success. Afterwards, I tried to disable powersave by changing /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf to "2", but also without success.

Note: even after the two changes above, the output of dmseg -w remains the same, but iwconfig really shows that powersave is disabled.

After that, I tried reinstall netwok-manager, use Google Public DNS, and nothing changed.

After erasing everything and placing 20.04, I thought I had solved the problem, but it come back shortly after.

I managed to get some logs just before the drop:

journalctl -u NetworkManager –follow

jun 08 00:38:26 lucius-Lenovo-ideapad-320 NetworkManager[742]: <info>  [1591587506.4061] dhcp6 (wlp2s0): state changed unknown -> bound
jun 08 00:38:29 lucius-Lenovo-ideapad-320 NetworkManager[742]: <info>  [1591587509.3816] manager: NetworkManager state is now CONNECTED_GLOBAL

journalctl –follow:

jun 08 00:39:00 lucius-Lenovo-ideapad-320 systemd[1]: Starting Clean php session files...
jun 08 00:39:00 lucius-Lenovo-ideapad-320 systemd[1]: phpsessionclean.service: Succeeded.
jun 08 00:39:00 lucius-Lenovo-ideapad-320 systemd[1]: Finished Clean php session files.
jun 08 00:39:01 lucius-Lenovo-ideapad-320 CRON[78496]: pam_unix(cron:session): session opened for user root by (uid=0)
jun 08 00:39:01 lucius-Lenovo-ideapad-320 CRON[78497]: (root) CMD (  [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi)
jun 08 00:39:01 lucius-Lenovo-ideapad-320 CRON[78496]: pam_unix(cron:session): session closed for user root
jun 08 00:39:32 lucius-Lenovo-ideapad-320 systemd-resolved[700]: Using degraded feature set (UDP) for DNS server 2804:....
jun 08 00:39:33 lucius-Lenovo-ideapad-320 systemd-resolved[700]: Using degraded feature set (UDP) for DNS server 2804:....

Here's some outputs:

iwconfig:

lo        no wireless extensions.

docker0   no wireless extensions.

wlp2s0    IEEE 802.11  ESSID:"NAME_5G"  
          Mode:Managed  Frequency:5.785 GHz  Access Point: ...   
          Bit Rate=6 Mb/s   Tx-Power=30 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:off
          Link Quality=53/70  Signal level=-57 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:154   Missed beacon:0

virbr0    no wireless extensions.

enp1s0    no wireless extensions.

virbr0-nic  no wireless extensions.

lspci | grep -i wireless:

02:00.0 Network controller: Qualcomm Atheros QCA9377 802.11ac Wireless Network Adapter (rev 31)

/etc/network/interfaces:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

/etc/resolv.conf:

nameserver 127.0.0.53
options edns0
search spo.virtua.com.br

Please, I really don't know what else to do

EDIT

I forgot to mention something that may be very relevant:

Only on this particular network do I have drops, on any other I have no problems.

Router Info

HGJ310 HUMAX

Technology
DOCSIS 3.1

Hardware Version
1.0

Software Version
BRGCAI 1.0.18

EDIT 2

I don't know how much of a coincidence this is, but apparently accessing some specific sites makes the wifi go down faster, like some W3 Schools pages, giving me the following log:

Jun 08 02:09:24 lucius-Lenovo-ideapad-320 systemd-resolved [694]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP

With some research, I stopped that this is just an alert, and it didn't cause an error in itself…

Best Answer

There is a large Q&A here:

After running dmesg | grep -i firmware and dmesg | grep -i ath10k amongst many other commands, the solution was this script:

#!/bin/bash
sudo nmcli networking off
sleep 1
sudo systemctl stop NetworkManager
sleep 1
sudo ip link set wlp2s0 down
sleep 1
sudo modprobe -r ath10k_pci
sleep 2
sudo modprobe -r ath10k_core
sleep 2
sudo modprobe ath10k_pci
sleep 2
sudo ip link set wlp2s0 up
sleep 1
sudo systemctl start NetworkManager
sleep 2
sudo nmcli networking on
sleep 1
exit

Even if the script doesn't work for you, read the entire Q&A in case something else does.

Related Question