Skip to content

Instantly share code, notes, and snippets.

@jpouellet
Last active December 10, 2016 00:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpouellet/abb3362c26ff96180f53e2cdb2493667 to your computer and use it in GitHub Desktop.
Save jpouellet/abb3362c26ff96180f53e2cdb2493667 to your computer and use it in GitHub Desktop.
Reload drivers for my intel wireless card automatically if it hangs (on suspend/resume)
#!/bin/sh
lock=/var/run/lock/iwl-reset.lock
fail_msg='iwlwifi 0000:00:00.0: Failed to load firmware chunk!'
do_reset='
echo "Resetting wifi..."
rmmod iwlmvm
rmmod iwlwifi
modprobe iwlwifi
modprobe iwlmvm
sleep 2
'
dmesg --kernel --notime --follow --level=err \
| while read msg; do
if [ X"$msg" = X"$fail_msg" ]; then
echo 'Wifi appears hung'
flock -xn "$lock" -c "$do_reset" &
fi
done
@jpouellet
Copy link
Author

I could just always {un,re}load the driver on suspend/resume, but sometimes it actually comes back and doesn't need to be reset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment