Advertisement
Guest User

Verequies GPU Script

a guest
Oct 28th, 2017
6,450
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.02 KB | None | 0 0
  1. #!/bin/bash
  2. #Comment
  3. #More Echos
  4. #Fix logout crash
  5. #Add exceptions to on/off to avoid freezing
  6. boot() {
  7.     sleep 5
  8.     if $(lspci -H1 | grep --quiet NVIDIA)
  9.     then
  10.         off
  11.         sleep 1
  12.     fi
  13.     on
  14.     sleep 1
  15.     off
  16.     echo "0000:00:03.0" > /sys/bus/pci/devices/0000\:00\:03.0/driver/unbind
  17.     echo 0x8086 0x0c0c > /sys/bus/pci/drivers/vfio-pci/new_id
  18. #   echo 0x8086 0x0416 > /sys/bus/pci/drivers/vfio-pci/new_id
  19. }
  20.  
  21. vfio() {
  22.     if ! $(lspci -H1 | grep --quiet NVIDIA)
  23.     then
  24.         on
  25.         sleep 1
  26.     fi
  27.     unbind
  28.     echo 0x10de 0x0ff6 > /sys/bus/pci/drivers/vfio-pci/new_id
  29.     echo 0x10de 0x0e1b > /sys/bus/pci/drivers/vfio-pci/new_id
  30.     echo 1 > /sys/bus/pci/rescan
  31. }
  32.  
  33. nouveau() {
  34.     if ! $(lspci -H1 | grep --quiet NVIDIA)
  35.     then
  36.         on
  37.         sleep 1
  38.     fi
  39.     unbind
  40.     echo 0x10de 0x0ff6 > /sys/bus/pci/drivers/nouveau/new_id
  41.     echo "0000:01:00.1" > /sys/bus/pci/drivers/snd_hda_intel/bind
  42.     echo 1 > /sys/bus/pci/rescan
  43. }
  44.  
  45. nvidia() {
  46.     if ! $(lspci -H1 | grep --quiet NVIDIA)
  47.     then
  48.         on
  49.         sleep 1
  50.     fi
  51.     unbind
  52.     echo 0x10de 0x0ff6 > /sys/bus/pci/drivers/nvidia/new_id
  53.     echo "0000:01:00.1" > /sys/bus/pci/drivers/snd_hda_intel/bind
  54.     echo 1 > /sys/bus/pci/rescan
  55. }
  56.  
  57. unbind() {
  58.     if [ -f /sys/bus/pci/devices/0000\:01\:00.0/driver/unbind ]
  59.     then
  60.         echo "0000:01:00.0" > /sys/bus/pci/devices/0000\:01\:00.0/driver/unbind
  61.     fi
  62.     if [ -f /sys/bus/pci/devices/0000\:01\:00.1/driver/unbind ]
  63.     then
  64.         echo "0000:01:00.1" > /sys/bus/pci/devices/0000\:01\:00.1/driver/unbind
  65.     fi
  66. }
  67.  
  68. on() {
  69.     echo '\_SB_.PCI0.PEG0.PEGP._ON' > /proc/acpi/call
  70.     if [ -f /sys/bus/pci/devices/0000\:01\:00.0/remove ]
  71.     then
  72.         echo 1 > /sys/bus/pci/devices/0000\:01\:00.0/remove
  73.     fi
  74.     if [ -f /sys/bus/pci/devices/0000\:01\:00.1/remove ]
  75.     then
  76.         echo 1 > /sys/bus/pci/devices/0000\:01\:00.1/remove
  77.     fi
  78.     echo 1 > /sys/bus/pci/rescan
  79. }
  80.  
  81. off() {
  82.     unbind
  83.     echo '\_SB_.PCI0.PEG0.PEGP._OFF' > /proc/acpi/call
  84. }
  85.  
  86. case "$1" in
  87.     boot)
  88.         boot
  89.         ;;
  90.     vfio)
  91.         vfio
  92.         ;;
  93.     nouveau)
  94.         nouveau
  95.         ;;
  96.     nvidia)
  97.         nvidia
  98.         ;;
  99.     unbind)
  100.         unbind
  101.         ;;
  102.     on)
  103.         on
  104.         ;;
  105.     off)
  106.         off
  107.         ;;
  108. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement