Skip to content

Commit c1f3e4b

Browse files
committed
Add REMOVE_DEVICE flag
1 parent d6f637e commit c1f3e4b

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

config/nvidia-xrun

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
# output of lshw.
66
ENABLE_PM=1
77

8+
# When PM is enabled, remove the card from the system after the command exists
9+
# and modules unload: the card will be readded in the next nvidia-xrun
10+
# execution before loading the nvidia module again. This is recommended as Xorg
11+
# and some other programs tend to load the nvidia module if they detect a
12+
# nvidia card in the system, and when the module is loaded the card can't save
13+
# power.
14+
REMOVE_DEVICE=1
15+
816
# Bus ID of the PCI express controller
917
CONTROLLER_BUS_ID=0000:00:01.0
1018

nvidia-xrun

+7-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ function execute {
1919
}
2020

2121
function turn_off_gpu {
22-
echo 'Removing Nvidia bus from the kernel'
23-
execute "sudo tee /sys/bus/pci/devices/${DEVICE_BUS_ID}/remove <<<1"
22+
if [[ "$REMOVE_DEVICE" == '1' ]]; then
23+
echo 'Removing Nvidia bus from the kernel'
24+
execute "sudo tee /sys/bus/pci/devices/${DEVICE_BUS_ID}/remove <<<1"
25+
else
26+
echo 'Enabling powersave for the graphic card'
27+
execute "sudo tee /sys/bus/pci/devices/${DEVICE_BUS_ID}/power/control <<<auto"
28+
fi
2429

2530
echo 'Enabling powersave for the PCIe controller'
2631
execute "sudo tee /sys/bus/pci/devices/${CONTROLLER_BUS_ID}/power/control <<<auto"

0 commit comments

Comments
 (0)