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

Replace sleep BUS_RESCAN_WAIT_SEC with lspci-based GPU check; tweak MODULES_LOAD in config #133

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
11 changes: 7 additions & 4 deletions config/nvidia-xrun
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ CONTROLLER_BUS_ID=0000:00:01.0
# Bus ID of the graphic card
DEVICE_BUS_ID=0000:01:00.0

# Seconds to wait before turning on the card after PCI devices rescan
BUS_RESCAN_WAIT_SEC=1

# Ordered list of modules to load before running the command
MODULES_LOAD=(nvidia nvidia_uvm nvidia_modeset "nvidia_drm modeset=1")
# >>>>> ORIGINAL
#MODULES_LOAD=(nvidia nvidia_uvm nvidia_modeset "nvidia_drm modeset=1")

# >>>>> MASSKONFUZION: "nvidia_drm modeset=1" seems to cause sporadic general
# protection faults on my machine. At a minimum, perhaps the "modeset=1"
# option can be documented as a parameter to tweak?
MODULES_LOAD=(nvidia nvidia_uvm nvidia_modeset nvidia_drm)

# Ordered list of modules to unload after the command exits
MODULES_UNLOAD=(nvidia_drm nvidia_modeset nvidia_uvm nvidia)
25 changes: 23 additions & 2 deletions nvidia-xrun
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,27 @@ function turn_on_gpu {
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}"

# >>>>> MASSKONFUZION: This comment for review; feel free to delete:
# This change proposes to do away with BUS_RESCAN_WAIT_SEC, in favor of
# waiting for the NVIDIA GPU to appear in lspci. The code, as written,
# assumes the GPU will appear. But perhaps a more robust solution (not
# implemented as of yet) would be to fail if the GPU does not appear
# after a given timeout interval.
if [[ ${DRY_RUN} -eq 1 ]]; then
echo '>> Dry run. Waiting for NVIDIA video device'
else
echo 'Waiting for NVIDIA video device'
RESULT="1"
while [[ ${RESULT} -ne 0 ]]; do
echo -n '.'
lspci | grep -v Audio | grep NVIDIA > /dev/null
RESULT=$?
sleep 1
done
echo 'Woo-hoo! Got it :fist pump:'
lspci | grep -v Audio | grep NVIDIA
fi
fi

echo 'Turning the card on'
Expand All @@ -54,6 +73,7 @@ function load_modules {
do
echo "Loading module ${module}"
execute "sudo modprobe ${module}"
sleep 1
done
}

Expand All @@ -62,6 +82,7 @@ function unload_modules {
do
echo "Unloading module ${module}"
execute "sudo modprobe -r ${module}"
sleep 1
done
}

Expand Down