Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement USE_BBSWITCH option #137

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ sudo dnf install nvidia-xrun
```

## Troubleshooting

### Steam issues
Yes unfortunately running Steam directly with nvidia-xrun does not work well - I recommend to use some window manager like openbox.

Expand All @@ -106,6 +107,10 @@ To fix, you can change the DPI settings in `~/.Xresources (~/.Xdefaults)` file b
Xft.dpi: 192
```

### Crashing during when unloading nvidia modules

Try set `USE_BBSWITCH=1`, you'll have to install `bbswitch` manually as well.

### `nouveau` driver conflict
`nouveau` driver should be automatically blacklisted by `nvidia` but in case it is not, `nvidia` might not get access to GPU. Then you need to manually blacklist `nouveau` following Arch wiki https://wiki.archlinux.org/index.php/kernel_modules#Blacklisting.

Expand All @@ -119,4 +124,4 @@ In that case, you should add `--ignore-install` to `modprobe` calls in `nvidia-x
### Vulkan does not work
Check https://wiki.archlinux.org/index.php/Vulkan
* remove package vulkan-intel
* set VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json
* set VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json
8 changes: 8 additions & 0 deletions config/nvidia-xrun
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@ ENABLE_PM=1
# and some other programs tend to load the nvidia module if they detect a
# nvidia card in the system, and when the module is loaded the card can't save
# power.
#
# USE_BBSWITCH option below can override the behavior of this option.
REMOVE_DEVICE=1

# When enabled, nvidia-xrun will toggle power for the card using bbswitch.
# This *requires* bbswitch to be installed.
#
# Note that this option overrides REMOVE_DEVICE paramter above when enabled.
USE_BBSWITCH=0

# Bus ID of the PCI express controller
CONTROLLER_BUS_ID=0000:00:01.0

Expand Down
50 changes: 30 additions & 20 deletions nvidia-xrun
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,44 @@ function execute {
}

function turn_off_gpu {
if [[ "$REMOVE_DEVICE" == '1' ]]; then
echo 'Removing Nvidia bus from the kernel'
execute "sudo tee /sys/bus/pci/devices/${DEVICE_BUS_ID}/remove <<<1"
if [[ "$USE_BBSWITCH" == '1' ]]; then
echo 'Turning off GPU using bbswitch '
execute "sudo tee /proc/acpi/bbswitch <<<'OFF'"
else
echo 'Enabling powersave for the graphic card'
execute "sudo tee /sys/bus/pci/devices/${DEVICE_BUS_ID}/power/control <<<auto"
if [[ "$REMOVE_DEVICE" == '1' ]]; then
echo 'Removing Nvidia bus from the kernel'
execute "sudo tee /sys/bus/pci/devices/${DEVICE_BUS_ID}/remove <<<1"
else
echo 'Enabling powersave for the graphic card'
execute "sudo tee /sys/bus/pci/devices/${DEVICE_BUS_ID}/power/control <<<auto"
fi

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

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

function turn_on_gpu {
echo 'Turning the PCIe controller on to allow card rescan'
execute "sudo tee /sys/bus/pci/devices/${CONTROLLER_BUS_ID}/power/control <<<on"
if [[ "$USE_BBSWITCH" == '1' ]]; then
echo 'Turning on GPU using bbswitch '
execute "sudo tee /proc/acpi/bbswitch <<<'ON'"
else
echo 'Turning the PCIe controller on to allow card rescan'
execute "sudo tee /sys/bus/pci/devices/${CONTROLLER_BUS_ID}/power/control <<<on"

echo 'Waiting 1 second'
execute "sleep 1"
echo 'Waiting 1 second'
execute "sleep 1"

if [[ ! -d /sys/bus/pci/devices/${DEVICE_BUS_ID} ]]; then
echo 'Rescanning PCI devices'
execute "sudo tee /sys/bus/pci/rescan <<<1"
echo "Waiting ${BUS_RESCAN_WAIT_SEC} second for rescan"
execute "sleep ${BUS_RESCAN_WAIT_SEC}"
fi
if [[ ! -d /sys/bus/pci/devices/${DEVICE_BUS_ID} ]]; then
echo 'Rescanning PCI devices'
execute "sudo tee /sys/bus/pci/rescan <<<1"
echo "Waiting ${BUS_RESCAN_WAIT_SEC} second for rescan"
execute "sleep ${BUS_RESCAN_WAIT_SEC}"
fi

echo 'Turning the card on'
execute "sudo tee /sys/bus/pci/devices/${DEVICE_BUS_ID}/power/control <<<on"
echo 'Turning the card on'
execute "sudo tee /sys/bus/pci/devices/${DEVICE_BUS_ID}/power/control <<<on"
fi
}

function load_modules {
Expand Down