...
 
Commits (2)
......@@ -6,6 +6,7 @@ then
exit 1
fi
echo "removing module configuration"
rm -v /etc/modprobe.d/nvidia.conf
rm -v /etc/modprobe.d/vfio.conf
......@@ -14,5 +15,5 @@ rm -v /etc/modprobe.d/vfio.conf
# therefore they should always be loaded and won't be touched by this script
#rm -v /etc/modules-load.d/vfio.conf
echo "updating x11 monitor configuration"
echo "updating xorg monitor configuration"
cp -v ../nvidia_10-monitor.conf /etc/X11/xorg.conf.d/10-monitor.conf
......@@ -6,6 +6,7 @@ then
exit 1
fi
echo "copying module configuration"
cp -v ./modprobe/nvidia.conf /etc/modprobe.d/nvidia.conf
cp -v ./modprobe/vfio.conf /etc/modprobe.d/vfio.conf
......@@ -14,5 +15,5 @@ cp -v ./modprobe/vfio.conf /etc/modprobe.d/vfio.conf
# therefore they should always be loaded and won't be touched by this script
#cp -v ./modules-load/vfio.conf /etc/modules-load.d/vfio.conf
echo "updating x11 monitor configuration"
echo "updating xorg monitor configuration"
cp -v ../radeon_10-monitor.conf /etc/X11/xorg.conf.d/10-monitor.conf
......@@ -8,58 +8,56 @@ then
exit 1
fi
# Trying to unbind the GPU results in general protection faults.
# Removing the binding ID from vfio-pci and then resetting the PCI device seems
# to work properly. It also auto-retaches to the nvidia module this way.
for dev in "0000:04:00.0"
for dev in "0000:04:00.0" "0000:04:00.1"
do
while [[ ! -e "/sys/bus/pci/drivers/nvidia/${dev}" ]]
do
vendor=$(cat /sys/bus/pci/devices/${dev}/vendor)
device=$(cat /sys/bus/pci/devices/${dev}/device)
echo "removing ${dev} vendor+device from vfio-pci id list"
echo "${vendor} ${device}" | tee \
"/sys/bus/pci/drivers/vfio-pci/remove_id"
sleep 0.1
echo "hot remove pci device at ${dev}"
echo 1 | tee "/sys/bus/pci/devices/${dev}/remove"
while [[ -e "/sys/bus/pci/devices/${dev}" ]]
if [[ -e "/sys/bus/pci/drivers/vfio-pci/$dev" ]]
then
echo -n "$dev clearing device driver matching rules..."
echo > "/sys/bus/pci/devices/$dev/driver_override"
echo " done"
echo -n "$dev unbinding device from current driver..."
echo "$dev" > "/sys/bus/pci/devices/$dev/driver/unbind"
while [[ -e "/sys/bus/pci/devices/$dev/driver" ]]
do
sleep 0.1
done
echo " done"
fi
done
echo "rescan pci bus to rediscover ${dev}"
echo 1 | tee "/sys/bus/pci/rescan"
while [[ ! -e "/sys/bus/pci/devices/${dev}" ]]
for dev in "0000:04:00.0"
do
if [[ ! -e "/sys/bus/pci/drivers/nvidia/$dev" ]]
then
echo -n "$dev binding device to nvidia driver..."
echo "$dev" > "/sys/bus/pci/drivers/nvidia/bind"
while [[ ! -e "/sys/bus/pci/devices/$dev/driver" ]]
do
sleep 0.1
done
sleep 0.5
done
echo "pci device at ${dev} is bound to nvidia"
echo " done"
fi
done
# Trying to unbind the HDMI audio results in general protection faults on my
# machine, so it's not unbinded above and binded here.
# If you actually need HDMI audio you'll need to reboot for now.
# It might actually work on your machine/config though.
#echo "bind nvidia gpu hdmi to snd_hda_intel"
#for dev in "0000:04:00.1"
#do
# vendor=$(cat /sys/bus/pci/devices/${dev}/vendor)
# device=$(cat /sys/bus/pci/devices/${dev}/device)
# echo "${dev}" | tee /sys/bus/pci/drivers/snd_hda_intel/bind
#done
for dev in "0000:04:00.1"
do
if [[ ! -e "/sys/bus/pci/drivers/snd_hda_intel/$dev" ]]
then
echo -n "$dev binding device to snd_hda_intel driver..."
echo "$dev" > "/sys/bus/pci/drivers/snd_hda_intel/bind"
while [[ ! -e "/sys/bus/pci/devices/$dev/driver" ]]
do
sleep 0.1
done
echo " done"
fi
done
echo "updating x11 monitor configuration"
echo "updating xorg monitor configuration"
cp -v ./nvidia_10-monitor.conf /etc/X11/xorg.conf.d/10-monitor.conf
echo "releasing hugepages memory"
sudo sysctl vm.nr_hugepages=0
echo "ok"
exit 0
......@@ -10,38 +10,41 @@ fi
for dev in "0000:04:00.0" "0000:04:00.1"
do
if [[ ! -e "/sys/bus/pci/drivers/vfio-pci/${dev}"
&& -e "/sys/bus/pci/devices/${dev}/driver" ]]
if [[ ! -e "/sys/bus/pci/drivers/vfio-pci/$dev"
&& -e "/sys/bus/pci/devices/$dev/driver" ]]
then
echo "unbinding pci addr from driver"
echo -n "$dev setting device driver matching rules..."
echo "vfio-pci" > "/sys/bus/pci/devices/$dev/driver_override"
echo " done"
echo "${dev}" | tee "/sys/bus/pci/devices/${dev}/driver/unbind"
while [ -e "/sys/bus/pci/devices/${dev}/driver" ]
echo -n "$dev unbinding device from current driver..."
echo "$dev" > "/sys/bus/pci/devices/$dev/driver/unbind"
while [[ -e "/sys/bus/pci/devices/$dev/driver" ]]
do
sleep 0.1
done
echo " done"
fi
done
for dev in "0000:04:00.0" "0000:04:00.1"
do
if [[ ! -e "/sys/bus/pci/drivers/vfio-pci/${dev}" ]]
if [[ ! -e "/sys/bus/pci/drivers/vfio-pci/$dev" ]]
then
echo "binding pci addr to vfio-pci"
vendor=$(cat "/sys/bus/pci/devices/${dev}/vendor")
device=$(cat "/sys/bus/pci/devices/${dev}/device")
echo "${vendor} ${device}" \
| tee "/sys/bus/pci/drivers/vfio-pci/new_id"
echo -n "$dev binding device to vfio-pci driver..."
echo "$dev" > "/sys/bus/pci/drivers/vfio-pci/bind"
while [[ ! -e "/sys/bus/pci/devices/$dev/driver" ]]
do
sleep 0.1
done
echo " done"
fi
done
echo "updating x11 monitor configuration"
echo "updating xorg monitor configuration"
cp -v "./radeon_10-monitor.conf" "/etc/X11/xorg.conf.d/10-monitor.conf"
echo "attempting to set hugepages to 8192 (16GB)"
sudo sysctl vm.nr_hugepages=8192
echo "settings hugepages memory to 8192 pages or 16gb"
sysctl vm.nr_hugepages=8192
echo "ok"
exit 0
......@@ -4,16 +4,15 @@ VLOCK=1
if [[ $XAUTHORITY ]]
then
echo "refusing to run inside x session"
echo "refusing to run inside xorg session"
exit 1
fi
cd "$(dirname -- "${0}")"
cd "$(dirname -- "${0}")" || exit 2
while true
do
cat << EOF
cat << EOF
select your gpu for x session
c for current
n for nvidia
......@@ -21,32 +20,29 @@ select your gpu for x session
q for quit (manual tty)
EOF
read gpu
case $gpu in
c)
;;
n)
sudo ./nvidia.sh ;;
r)
sudo ./radeon.sh ;;
q)
exit 0 ;;
*)
echo "invalid option, quit"
exit 1 ;;
esac
echo "starting x"
if [[ $VLOCK == 1 ]]
then
startx > /dev/null &
vlock
else
startx > /dev/null
fi
read -r gpu
case $gpu in
c)
;;
n)
sudo ./nvidia.sh ;;
r)
sudo ./radeon.sh ;;
q)
exit 0 ;;
*)
echo "invalid option, quit"
exit 3 ;;
esac
echo "starting x"
if [[ $VLOCK == 1 ]]
then
startx > /dev/null 2>&1 &
vlock
else
startx > /dev/null 2>&1
fi
done
exit 0
......@@ -49,7 +49,8 @@ nice -n -10 qemu-system-x86_64 \
-device usb-host,vendorid=0x0853,productid=0x011b `# Topre Realforce` \
-device usb-host,vendorid=0x046d,productid=0xc531 `# Logitech Receiver` \
-device usb-host,vendorid=0x046d,productid=0xc06b `# Logitech G700` \
-device vfio-pci,host=04:00.0,addr=09.0 &
-device vfio-pci,host=04:00.0,addr=09.0,multifunction=on \
-device vfio-pci,host=04:00.1,addr=09.1 &
# -device usb-host,vendorid=0x056d,productid=0x4008 `# Eizo CG318-4K USB HUB`
# TODO old format below, doesn't work with recent Qemu
# -usbdevice host:046d:c29b `# Logitech G27` \
......
......@@ -65,7 +65,8 @@ nice -n -10 qemu-system-x86_64 \
-drive if=virtio,id=drive0,file=./Windows.img,format=raw,cache=none,aio=native \
-drive file=/usr/share/virtio/virtio-win.iso,if=ide,id=cd1,media=cdrom,readonly \
-nographic \
-device vfio-pci,host=04:00.0,addr=09.0 \
-device vfio-pci,host=04:00.0,addr=09.0,multifunction=on \
-device vfio-pci,host=04:00.1,addr=09.1 \
-device vfio-pci,host=00:1d.0,addr=10.0 &
# -device usb-host,vendorid=0x056d,productid=0x4008 `# Eizo CG318-4K USB HUB`
......