Add optimus manager and full GPU power off config

merge-requests/2/head
Cole Deck 4 years ago
parent 43705a276a
commit 705f307a03

@ -0,0 +1,15 @@
#!/bin/bash
#case "$1" in
# pre)
# /home/cole/g14gpu/gpuon.sh ;;
# post)
# /home/cole/g14gpu/gpuoff.sh ;;
#esac
if [ "${1}" == "pre" ]; then
bash /home/cole/g14gpu/gpuon.sh
elif [ "${1}" == "post" ]; then
bash /home/cole/g14gpu/gpuoff.sh
fi

@ -3,6 +3,7 @@ modprobe vfio-pci
for dev in "$@"; do
vendor=$(cat /sys/bus/pci/devices/$dev/vendor)
device=$(cat /sys/bus/pci/devices/$dev/device)
echo $vendor $device > /sys/bus/pci/drivers/vfio-pci/new_id
if [ -e /sys/bus/pci/devices/$dev/driver ]; then
#echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
rmmod nvidia_drm
@ -10,6 +11,6 @@ for dev in "$@"; do
rmmod nvidia
echo "Unbound old driver"
fi
echo $vendor $device > /sys/bus/pci/drivers/vfio-pci/new_id
#echo $vendor $device > /sys/bus/pci/drivers/vfio-pci/new_id
echo "Bound VFIO driver"
done

@ -0,0 +1 @@
sudo sh -c 'echo "\\_SB.PCI0.GPP0.PG00._OFF" > /proc/acpi/call'

@ -0,0 +1 @@
sudo sh -c 'echo "\\_SB.PCI0.GPP0.PG00._ON" > /proc/acpi/call'

@ -0,0 +1,12 @@
[optimus]
switching=none
pci_power_control=no
pci_remove=no
pci_reset=no
auto_logout=yes
startup_mode=amd
[nvidia]
modeset=yes
PAT=yes
options=overclocking

@ -0,0 +1,9 @@
# You can use this file to add Xorg options which are not covered in the configuration file.
#
# Everything you put here will go to the "Device" section corresponding
# to the AMD GPU in the Xorg configuration.
# Lines starting with # are ignored.
#
# Example :
#
# Option "Backlight" "amdgpu_bl1"

@ -0,0 +1,9 @@
# You can use this file to add Xorg options which are not covered in the configuration file.
#
# Everything you put here will go to the "Device" section corresponding
# to the Intel GPU in the Xorg configuration.
# Lines starting with # are ignored.
#
# Example :
#
# Option "Backlight" "intel_backlight"

@ -0,0 +1,9 @@
# You can use this file to add Xorg options which are not covered in the configuration file.
#
# Everything you put here will go to the "Device" section corresponding
# to the Nvidia GPU in the Xorg configuration.
# Lines starting with # are ignored.
#
# Example :
#
# Option "ConnectToAcpid" "0"

@ -0,0 +1,4 @@
#!/bin/sh
# Everything you write here will be executed by the display manager when setting up the login screen in AMD mode.
#sudo sh -c 'echo "\\_SB.PCI0.GPP0.PG00._OFF" > /proc/acpi/call'

@ -0,0 +1,3 @@
#!/bin/sh
# Everything you write here will be executed by the display manager when setting up the login screen in Intel mode.

@ -0,0 +1,5 @@
#!/bin/sh
# Everything you write here will be executed by the display manager when setting up the login screen in Nvidia mode.
# (but before optimus-manager sets up PRIME with xrandr commands).
#sudo sh -c 'echo "\\_SB.PCI0.GPP0.PG00._ON" > /proc/acpi/call'

@ -1,7 +1,24 @@
#!/bin/bash
sudo rmmod nvidia_drm
sudo rmmod nvidia_modeset
sudo rmmod nvidia
sudo tee /proc/acpi/bbswitch <<<OFF
echo $(cat /proc/acpi/bbswitch)
#sudo rmmod nvidia_drm
#sudo rmmod nvidia_modeset
#sudo rmmod nvidia
#sudo tee /proc/acpi/bbswitch <<<OFF
#echo $(cat /proc/acpi/bbswitch)
#sudo sh -c "echo 1 > /sys/bus/pci/devices/0000:01:00.0/remove; echo '\\_SB.PCI0.PEG0.PEGP._OFF' > /proc/acpi/call"
#output=$(optimus-manager --print-mode)
#echo $output
if [ $(sudo -u cole xrandr --listproviders | grep NVIDIA) ]; then
echo "GPU is in use for PRIME, keeping on"
else
sudo sh -c 'echo "\\_SB.PCI0.GPP0.PG00._OFF" > /proc/acpi/call'
echo $(sudo cat /proc/acpi/call)
echo "GPU POWERED OFF"
fi
#if [ "$(optimus-manager --print-mode)" = "
#
#Current GPU mode : amd" ]; then
# sudo sh -c 'echo "\\_SB.PCI0.GPP0.PG00._OFF" > /proc/acpi/call'
# echo $(sudo cat /proc/acpi/call)
# echo "GPU POWERED OFF"
#fi
#echo "script finished"

@ -4,4 +4,5 @@
#sudo rmmod nvidia
#sudo tee /proc/acpi/bbswitch <<<ON
#echo $(cat /proc/acpi/bbswitch)
sudo sh -c "echo '\\_SB.PCI0.PEG0.PEGP._ON' > /proc/acpi/call; echo 1 > /sys/bus/pci/rescan"
sudo sh -c 'echo "\\_SB.PCI0.GPP0.PG00._ON" > /proc/acpi/call'
sleep 2

@ -1,8 +1,10 @@
#!/bin/bash
if [ `which-driver-for-gpu` == "nvidia" ]; then
sudo systemctl stop bumblebeed
sleep 1
sudo bind 0000:01:00.0 0000:01:00.1 0000:01:00.2 0000:01:00.3
fi
#export PATH=/bedrock/cross/pin/bin:/bedrock/bin:/usr/local/bin:/usr/local/sbin:/opt/bin:/opt/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/snap/bin:/bedrock/cross/bin:/home/cole/g14gpu
cd /home/cole/g14gpu
#if [ `which-driver-for-gpu` == "nvidia" ]; then
sudo sh -c 'echo "\\_SB.PCI0.GPP0.PG00._ON" > /proc/acpi/call'
sleep 1
sudo binddev 0000:01:00.0 0000:01:00.1 0000:01:00.2 0000:01:00.3
#fi
vm
#sudo unbind 0000:01:00.0 0000:01:00.1 0000:01:00.2 0000:01:00.3
#sudo unbinddev 0000:01:00.0 0000:01:00.1 0000:01:00.2 0000:01:00.3

@ -1,18 +1,20 @@
#!/bin/bash
#sudo rmmod vfio-pci
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}" > /sys/bus/pci/drivers/vfio-pci/remove_id
echo "${vendor} ${device}" | sudo tee /sys/bus/pci/drivers/vfio-pci/remove_id
sleep 0.1
echo "Remove PCI device"
echo 1 > /sys/bus/pci/devices/${dev}/remove
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 > /sys/bus/pci/rescan
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

9
vm

@ -38,12 +38,13 @@ echo "VM is off"
echo "Freeing up memory"
echo 0 | sudo tee /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
echo "Unbinding from vfio-pci"
sudo unbind 0000:01:00.0 0000:01:00.1 0000:01:00.2 0000:01:00.3
unbinddev 0000:01:00.0 0000:01:00.1 0000:01:00.2 0000:01:00.3
sleep 1
echo "Enabling GPU power management"
sudo modprobe nvidia NVreg_DynamicPowerManagement=0x02
#sudo modprobe nvidia NVreg_DynamicPowerManagement=0x02
sudo sh -c 'echo "\\_SB.PCI0.GPP0.PG00._OFF" > /proc/acpi/call'
sleep 2
sudo systemctl start bumblebeed
#sudo systemctl start bumblebeed
sudo systemctl stop smb nmb
sleep 1
clrgpu
#clrgpu

Loading…
Cancel
Save