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