Skip to content

Commit

Permalink
Avoid endless loop when nvidia modules cannot be unloaded (boo#1173632)
Browse files Browse the repository at this point in the history
  • Loading branch information
sndirsch committed Jul 17, 2020
1 parent fec0f53 commit 90edae8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions prime-select.sh
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,14 @@ function common_set_intel {
cat $conf | sed -e 's/PCI:X:X:X/'${intel_busid}'/' > /etc/X11/xorg.conf.d/90-intel.conf

if (( service_test == 0)); then

while [ "$(lsmod | grep nvidia)" > /dev/null ]; do
modprobe -r $nvidia_modules

# try only n times; avoid endless loop which may block system updates forever (boo#1173632)
last=3
for try in $(seq 1 $last); do
modprobe -r $nvidia_modules && break
if [ $try -eq $last ]; then
echo "NVIDIA kernel modules cannot be unloaded (tried $last times). Your machine may need a reboot."
fi
done

if [ -f /proc/acpi/bbswitch ]; then
Expand Down

0 comments on commit 90edae8

Please sign in to comment.