You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
#!/bin/bash
|
|
|
|
#sudo rmmod vfio-pci
|
|
|
|
#returns GPU back to host, and removes it for battery saving
|
|
|
|
for dev in "$@"; do
|
|
|
|
vendor=$(cat /sys/bus/pci/devices/$dev/vendor)
|
|
|
|
device=$(cat /sys/bus/pci/devices/$dev/device)
|
|
|
|
echo "Removing ${dev} from vfio-pci id list"
|
|
|
|
echo "${vendor} ${device}" | sudo tee /sys/bus/pci/drivers/vfio-pci/remove_id
|
|
|
|
sleep 0.1
|
|
|
|
echo "Remove PCI device"
|
|
|
|
echo 1 | sudo tee /sys/bus/pci/devices/${dev}/remove
|
|
|
|
while [[ -e "/sys/bus/pci/devices/${dev}" ]]; do
|
|
|
|
sleep 0.1
|
|
|
|
done
|
|
|
|
#echo "Rescanning..."
|
|
|
|
#echo 1 | sudo tee /sys/bus/pci/rescan
|
|
|
|
#while [[ ! -e "/sys/bus/pci/devices/${dev}" ]]; do
|
|
|
|
# sleep 0.1
|
|
|
|
#done
|
|
|
|
done
|
|
|
|
sudo rmmod vfio-pci
|