mirror of
https://github.com/QuixiAI/nvdriver.git
synced 2026-12-06 22:48:43 +00:00
* tools: reboot-free dev mode (dev_mode/dev_reload/dev_health) and udev rule Root-only nvdriver nodes so no desktop process pins nvidia_rs, a reload script that unbinds GPUs before rmmod, and a pre/post health gate. Adds the AGENTS.md personal-laptop override that allows no-reboot tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * tools: address review of dev mode scripts - dev_health: scan threads (ps -L) so a D-state non-leader thread is caught - dev_reload: keep module parameters as separate quoted words (no glob expansion) - dev_reload: restart nvidia-persistenced when a holder refuses the teardown - dev_reload: drop and rebind the /dev/nvidia* aliases around the reload - dev_reload: enumerate bound PCI devices of every domain Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * dev tools: drop personal override and invalid reload defaults - AGENTS.md: restore upstream text (the laptop reboot/rmmod override is local, not repo-wide) - dev_reload.sh: remove rm_api / experimental_r620_ada / dyndbg defaults (not parameters of this module) - dev_reload.sh: require NV_RS_DEV_RELOAD_BDF, refuse if nvidia_rs is bound to any other device Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
55 lines
2.4 KiB
Bash
55 lines
2.4 KiB
Bash
#!/bin/sh
|
|
# Health gate for the reboot-free dev loop.
|
|
#
|
|
# sh tools/dev_health.sh [pre|post]
|
|
#
|
|
# pre (default): safe to touch the GPU/module? No GPU node is opened.
|
|
# post: the freshly loaded module answers (opens a node, so it runs under a timeout).
|
|
# Exit 0 = healthy, 1 = stop all GPU work and report to the user, 2 = usage.
|
|
set -u
|
|
MODE=${1:-pre}
|
|
case "$MODE" in pre|post) ;; *) echo "usage: $0 [pre|post]" >&2; exit 2 ;; esac
|
|
BAD=0
|
|
fail() { echo "FAIL: $*"; BAD=1; }
|
|
warn() { echo "warn: $*"; }
|
|
|
|
TAINT=$(cat /proc/sys/kernel/tainted)
|
|
[ $((TAINT & 128)) -eq 0 ] || fail "kernel has oopsed (taint $TAINT); reboot is the only clean recovery"
|
|
[ $((TAINT & 32)) -eq 0 ] || warn "bad page taint (taint $TAINT)"
|
|
|
|
# nvidia_rs_rt* parks in D state by design; any other D-state nvidia thread is a hang.
|
|
STUCK=$(ps -eLo pid=,stat=,comm= | awk '$2 ~ /^D/ && $3 ~ /nv_open_q|nvidia|nv_queue|rmmod|insmod/ && $3 !~ /^nvidia_rs_rt/')
|
|
[ -z "$STUCK" ] || fail "stuck nvidia tasks:
|
|
$STUCK"
|
|
|
|
# /sys/module/nvidia is nvidia_rs's own marker module; stock shows up as a PCI driver.
|
|
if [ -d /sys/bus/pci/drivers/nvidia ]; then
|
|
fail "stock nvidia driver is registered; do not mix it with nvidia_rs"
|
|
fi
|
|
|
|
sudo -n true 2>/dev/null || fail "passwordless sudo is not available"
|
|
|
|
if [ -x tools/dev_mode.sh ] && ! sh tools/dev_mode.sh status 2>/dev/null | grep -q ': on'; then
|
|
warn "dev mode is off: desktop processes can pin the module (sh tools/dev_mode.sh on)"
|
|
fi
|
|
|
|
if [ "$MODE" = post ]; then
|
|
# A failed safety check above must not be followed by another GPU open.
|
|
[ "$BAD" -eq 0 ] || { echo "health ($MODE): FAILED before the probe; no node was opened"; exit 1; }
|
|
[ -e /sys/module/nvidia_rs ] || fail "nvidia_rs is not loaded"
|
|
fi
|
|
if [ "$MODE" = post ] && [ "$BAD" -eq 0 ]; then
|
|
# The sampled probe is the only step that opens a node; a timeout is a stop signal.
|
|
SMI=$(mktemp) || exit 1
|
|
trap 'rm -f "$SMI"' EXIT
|
|
if ! timeout -k 5 30 sudo -n nvidia-smi -L >"$SMI" 2>&1; then
|
|
fail "nvidia-smi -L failed or timed out (30 s); GSP-RM may be wedged. Do not retry:"
|
|
fi
|
|
cat "$SMI"
|
|
grep -q '^GPU 0:' "$SMI" || fail "nvidia-smi lists no GPU; runtime init failed (journalctl -k; if -12/ENOMEM: sync; echo 3 > /proc/sys/vm/drop_caches; echo 1 > /proc/sys/vm/compact_memory, then reload)"
|
|
sudo -n dmesg --level=err,crit,alert,emerg 2>/dev/null | tail -5 | grep -i nvidia_rs && warn "nvidia_rs logged errors above"
|
|
fi
|
|
|
|
[ "$BAD" -eq 0 ] && echo "health ($MODE): ok"
|
|
exit "$BAD"
|