Ubuntu – Manually Disable Wifi before suspend

18.10atherosnetwork-managerwireless

i'm running Ubuntu 18.10 with Gnome – Suspend to Ram isn't working. my syslog told me that wpa_supllicant refuses to freeze. I already tried a couple fixes but none are working. Most of them are different variations of this. I Also tried using a different Firmware version as stated here. Although this is a bit over the top since wifi is working fine and my idea is to run a script ,when hitting the suspend button, that turns the wifi off, before the actual suspend action takes place.

Suspend to Ram is working if i disable wifi manually before suspending. Is there a way to automate it?

Wireless Chipset:

description: Wireless interface
       product: QCA6174 802.11ac Wireless Network Adapter
       vendor: Qualcomm Atheros
       physical id: 0
       bus info: pci@0000:04:00.0
       logical name: wlp4s0
       version: 20
       serial: c0:38:96:2f:a8:1f
       width: 64 bits
       clock: 33MHz
       capabilities: bus_master cap_list ethernet physical wireless
       configuration: broadcast=yes driver=ath10k_pci driverversion=4.18.0-13-generic firmware=SW_RM.1.1.1-00157-QCARMSWPZ-1

Update #1: as @GAD3R pointed out a Script in /lib/systemd/system-sleep will do the trick. However it doesn't seem to work. I created the Script

killwpa

in

/lib/systemd/system-sleep

and made it executable using

sudo chmod +x

I still cant suspend with Wifi on here's the output of my syslog:

Freezing user space processes ... 
Freezing of tasks failed after 20.002 seconds (9 tasks refusing to freeze, wq_busy=0):
wpa_supplicant  D    0  1013      1 0x00000004

Update 2: I modified the Script to unload the driver using modprobe and stopping the network manager – still freezing.

Script:

 #!/bin/bash
if [ "${1}" == "pre" ]; then

modprobe -rv ath10k_pci
systemctl stop NetworkManager.service 

elif [ "${1}" == "post" ]; then

modprobe -v  ath10k_pci
systemctl start NetworkManager.service

fi

syslog ouput:

Feb  1 09:13:25 aaron-GACK kernel: [ 1350.265251] Freezing user space processes ... 
Feb  1 09:13:25 aaron-GACK kernel: [ 1370.272019] Freezing of tasks failed after 20.006 seconds (3 tasks refusing to freeze, wq_busy=0):
Feb  1 09:13:25 aaron-GACK kernel: [ 1370.274617] wpa_supplicant  D    0  1036      1 0x00000004

Update 3:
I tried simplifying it and use a single script to unload the driver and kill wpa as recommended by GAD3R:

!/bin/bash
if [ "${1}" == "pre" ]; then
modprobe -rv ath10k_pci
/usr/bin/pkill wpa_supplicant
fi

Holy Moly – it worked! Back after suspending and Wifi is back on as well.

Update 4:
Nevermind. Tried Suspending again after the successful try…aaaand freeze again.
Syslog:

Feb  1 09:27:30 aaron-GACK kernel: [  421.558759] Freezing user space processes ... 
Feb  1 09:27:30 aaron-GACK kernel: [  441.561752] Freezing of tasks failed after 20.002 seconds (10 tasks refusing to freeze, wq_busy=0):
Feb  1 09:27:30 aaron-GACK kernel: [  441.564343] wpa_supplicant  D    0  1082      1 0x00000004

Best Answer

I wanted to do much the same before suspend and tried your scripts, both forms. Syslog showed format errors and the script failing. Is systemd picky about script format?

This worked for me, having tested manually that just unloading the driver allowed successful suspending.

!/bin/sh case $1/$2 in pre/*) modprobe -rv ath10k_pci ;; post/*) modprobe -v ath10k_pci ;; esac

Related Question