aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / evidence / own-gpu-driver / rung2 / window0-post.sh
| 1 | #!/usr/bin/env bash |
| 2 | # L332 rung 2 window 0, part 2 (after the reboot from part 1). First removes the temporary blacklist, then: our module reads |
| 3 | # the chip and gives it back, NVIDIA's driver is loaded again (timed: today's load-to-ready baseline), Omega proves the chip |
| 4 | # works, and a normal reboot restores the box exactly (display modules included). Usage: window0-post.sh [--no-reboot] |
| 5 | set -u |
| 6 | export PATH=$PATH:/usr/sbin:/sbin # modinfo, lsmod and friends live in sbin; a normal user shell may not list it |
| 7 | here=$(cd "$(dirname "$0")" && pwd); repo=$(cd "$here/../../.." && pwd) |
| 8 | log=$here/$(readlink "$here/window0-current.log") |
| 9 | ts() { echo "$(date -u +%FT%T.%NZ) $*" | tee -a "$log"; } |
| 10 | BLK=/run/modprobe.d/zz-aien-gpu-window.conf |
| 11 | grep -q 'aien.gpuwindow=1' /proc/cmdline || { ts "WINDOW0 ABORT: this is not the one-shot window boot (no aien.gpuwindow=1); nothing done"; exit 1; } |
| 12 | ts "post start; window boot; hold-back file present: $([ -e "$BLK" ] && echo yes || echo NO) (kept until our module is gone); lease: $(systemctl is-active aien-gpu-window-lease.service)" |
| 13 | ts "boot: $(uptime -s) (uptime $(cut -d' ' -f1 /proc/uptime) s), systemd: $(systemd-analyze 2>/dev/null | head -1)" |
| 14 | ts "lsmod nvidia: [$(lsmod | grep -cE '^nvidia')] lspci: $(lspci -k -s 000f:01:00.0 | grep -c 'in use')" |
| 15 | sudo sysctl -q -w kernel.panic=10 kernel.panic_on_oops=1; ts "panic auto-reboot 10 s set (runtime only)" |
| 16 | rc=0 |
| 17 | ts "insmod aien_gpu allow_bind=1"; sudo insmod "$repo/native/linux/aien-gpu/aien_gpu.ko" allow_bind=1 || rc=1 |
| 18 | sudo dmesg | grep -i aien-gpu | tee -a "$log" |
| 19 | CHK=$here/aien_gpu_check; [ -x "$CHK" ] || gcc -O2 -o "$CHK" "$repo/native/linux/aien-gpu/aien_gpu_check.c" |
| 20 | sudo "$CHK" 2>&1 | tee -a "$log"; [ "${PIPESTATUS[0]}" = 0 ] || rc=1 |
| 21 | ts "rmmod aien_gpu"; sudo rmmod aien_gpu || rc=1 |
| 22 | ts "aien-gpu part rc=$rc" |
| 23 | # Recovery proof for later windows (NoNvDriver review). Opt-in, Drake decides: AIEN_W0_FLR=1 window0-post.sh. |
| 24 | # With no driver bound, reset the function by the kernel's own reset_method (measured "flr bus"); NVIDIA's stock driver |
| 25 | # must then bind and answer below. If it does, "FLR + stock rebind" is a tested recovery path for window 1; if not, |
| 26 | # window 1 may only end in a reboot or a power cycle. A failed FLR leaves the lease/watchdog/restore reboot as the way out. |
| 27 | D=/sys/bus/pci/devices/000f:01:00.0 |
| 28 | if [ "${AIEN_W0_FLR:-0}" != 1 ]; then ts "FLR test not requested (AIEN_W0_FLR unset): recovery-by-FLR stays NOT_RUN" |
| 29 | elif [ -e "$D/driver" ]; then ts "FLR test skipped: a driver is still bound ($(basename "$(readlink "$D/driver")"))"; rc=1 |
| 30 | else ts "reset_method: $(cat "$D/reset_method")"; echo 1 | sudo tee "$D/reset" > /dev/null && ts "FLR via $D/reset: done" || { ts "FLR via $D/reset: FAILED"; rc=1; }; fi |
| 31 | sudo rm -f "$BLK"; ts "hold-back file removed before the stock reload: $([ -e "$BLK" ] && echo NO || echo yes)" |
| 32 | t0=$(date +%s%N); sudo modprobe nvidia && sudo modprobe nvidia_uvm; t1=$(date +%s%N); nvidia-smi -L >> "$log" 2>&1; t2=$(date +%s%N) |
| 33 | ts "nvidia modprobe ms $(( (t1 - t0) / 1000000 )), first nvidia-smi answer ms $(( (t2 - t1) / 1000000 )) (load-to-ready baseline)" |
| 34 | BIN=$HOME/workspace/targets/l332-omega/gpu_launch_cost_test |
| 35 | t0=$(date +%s%N); "$BIN" --reps 3 >> "$log" 2>&1; orc=$?; t1=$(date +%s%N) |
| 36 | ts "omega launch-cost test exit $orc wall ms $(( (t1 - t0) / 1000000 )) (first open after driver load)" |
| 37 | ts "WINDOW0 $( [ $rc = 0 ] && [ $orc = 0 ] && echo PASS || echo FAIL )" |
| 38 | [ "${1:-}" = --no-reboot ] && exit 0 |
| 39 | ts "normal reboot to restore nvidia_modeset/nvidia_drm and the services"; sync; sudo systemctl reboot |