Make YT6801 migration retry-safe
This commit is contained in:
1 parent
6d2069230e
commit
ea21c37d98
2 files changed
+34
-8
No files matched your search
@@ -26,12 +26,14 @@ omarchy-pkg-drop yt6801-dkms
|
|||||||
|
|
||||||
if lsmod | awk '$1 == "yt6801" { found = 1 } END { exit !found }'; then
|
if lsmod | awk '$1 == "yt6801" { found = 1 } END { exit !found }'; then
|
||||||
sudo modprobe -r yt6801
|
sudo modprobe -r yt6801
|
||||||
|
|
||||||
for device in "${yt6801_devices[@]}"; do
|
|
||||||
printf '%s\n' "$device" | sudo tee /sys/bus/pci/drivers_probe >/dev/null
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
for device in "${yt6801_devices[@]}"; do
|
||||||
|
if ! lspci -Dks "$device" | grep -Eq 'Kernel driver in use: dwmac[-_]motorcomm'; then
|
||||||
|
printf '%s\n' "$device" | sudo tee /sys/bus/pci/drivers_probe >/dev/null
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
for device in "${yt6801_devices[@]}"; do
|
for device in "${yt6801_devices[@]}"; do
|
||||||
if ! lspci -Dks "$device" | grep -Eq 'Kernel driver in use: dwmac[-_]motorcomm'; then
|
if ! lspci -Dks "$device" | grep -Eq 'Kernel driver in use: dwmac[-_]motorcomm'; then
|
||||||
echo "YT6801 device $device did not bind to dwmac-motorcomm." >&2
|
echo "YT6801 device $device did not bind to dwmac-motorcomm." >&2
|
||||||
|
|||||||
@@ -14,7 +14,11 @@ cat >"$stub_bin/lspci" <<'SH'
|
|||||||
if [[ $* == "-Dn -d 1f0a:6801" ]]; then
|
if [[ $* == "-Dn -d 1f0a:6801" ]]; then
|
||||||
printf '%s\n' '0000:01:00.0 0200: 1f0a:6801'
|
printf '%s\n' '0000:01:00.0 0200: 1f0a:6801'
|
||||||
elif [[ $* == "-Dks 0000:01:00.0" ]]; then
|
elif [[ $* == "-Dks 0000:01:00.0" ]]; then
|
||||||
printf '%s\n' 'Kernel driver in use: dwmac-motorcomm'
|
if [[ -e $TEST_BOUND_STATE ]]; then
|
||||||
|
printf '%s\n' 'Kernel driver in use: dwmac-motorcomm'
|
||||||
|
else
|
||||||
|
printf '%s\n' 'Kernel modules: dwmac-motorcomm'
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
SH
|
SH
|
||||||
|
|
||||||
@@ -25,7 +29,7 @@ SH
|
|||||||
|
|
||||||
cat >"$stub_bin/lsmod" <<'SH'
|
cat >"$stub_bin/lsmod" <<'SH'
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
printf '%s\n' 'yt6801 65536 0'
|
[[ ${TEST_VENDOR_LOADED:-1} == 1 ]] && printf '%s\n' 'yt6801 65536 0'
|
||||||
SH
|
SH
|
||||||
|
|
||||||
for command in modprobe omarchy-pkg-drop tee; do
|
for command in modprobe omarchy-pkg-drop tee; do
|
||||||
@@ -34,6 +38,7 @@ for command in modprobe omarchy-pkg-drop tee; do
|
|||||||
printf '%s\t%s\n' "${0##*/}" "$*" >>"$TEST_CALLS"
|
printf '%s\t%s\n' "${0##*/}" "$*" >>"$TEST_CALLS"
|
||||||
if [[ ${0##*/} == "tee" ]]; then
|
if [[ ${0##*/} == "tee" ]]; then
|
||||||
cat >/dev/null
|
cat >/dev/null
|
||||||
|
touch "$TEST_BOUND_STATE"
|
||||||
fi
|
fi
|
||||||
SH
|
SH
|
||||||
done
|
done
|
||||||
@@ -46,6 +51,7 @@ SH
|
|||||||
|
|
||||||
chmod +x "$stub_bin"/*
|
chmod +x "$stub_bin"/*
|
||||||
export TEST_CALLS="$calls"
|
export TEST_CALLS="$calls"
|
||||||
|
export TEST_BOUND_STATE="$test_tmp/upstream-bound"
|
||||||
|
|
||||||
PATH="$stub_bin:$PATH" bash "$ROOT/install/hardware/fix-yt6801-ethernet-adapter.sh"
|
PATH="$stub_bin:$PATH" bash "$ROOT/install/hardware/fix-yt6801-ethernet-adapter.sh"
|
||||||
grep -Fqx $'omarchy-pkg-drop\tyt6801-dkms' "$calls" ||
|
grep -Fqx $'omarchy-pkg-drop\tyt6801-dkms' "$calls" ||
|
||||||
@@ -55,7 +61,7 @@ if grep -Fq $'modprobe\t' "$calls"; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
: >"$calls"
|
: >"$calls"
|
||||||
PATH="$stub_bin:$PATH" bash -euo pipefail "$ROOT/migrations/1788279117.sh"
|
TEST_VENDOR_LOADED=1 PATH="$stub_bin:$PATH" bash -euo pipefail "$ROOT/migrations/1788279117.sh"
|
||||||
grep -Fqx $'sudo\tmodprobe dwmac-motorcomm' "$calls" ||
|
grep -Fqx $'sudo\tmodprobe dwmac-motorcomm' "$calls" ||
|
||||||
fail "migration did not validate-load the upstream driver"
|
fail "migration did not validate-load the upstream driver"
|
||||||
grep -Fqx $'omarchy-pkg-drop\tyt6801-dkms' "$calls" ||
|
grep -Fqx $'omarchy-pkg-drop\tyt6801-dkms' "$calls" ||
|
||||||
@@ -65,8 +71,26 @@ grep -Fqx $'sudo\tmodprobe -r yt6801' "$calls" ||
|
|||||||
grep -Fqx $'sudo\ttee /sys/bus/pci/drivers_probe' "$calls" ||
|
grep -Fqx $'sudo\ttee /sys/bus/pci/drivers_probe' "$calls" ||
|
||||||
fail "migration did not reprobe the YT6801 device"
|
fail "migration did not reprobe the YT6801 device"
|
||||||
|
|
||||||
|
# A failed first cutover can leave the vendor module unloaded and the device
|
||||||
|
# unbound. Rerunning must still reprobe instead of repeating the same failure.
|
||||||
|
: >"$calls"
|
||||||
|
rm -f "$TEST_BOUND_STATE"
|
||||||
|
TEST_VENDOR_LOADED=0 PATH="$stub_bin:$PATH" bash -euo pipefail "$ROOT/migrations/1788279117.sh"
|
||||||
|
if grep -Fqx $'sudo\tmodprobe -r yt6801' "$calls"; then
|
||||||
|
fail "retry tried to unload a vendor module that was already absent"
|
||||||
|
fi
|
||||||
|
grep -Fqx $'sudo\ttee /sys/bus/pci/drivers_probe' "$calls" ||
|
||||||
|
fail "retry did not reprobe an unbound YT6801 device"
|
||||||
|
[[ -e $TEST_BOUND_STATE ]] || fail "retry did not restore the upstream binding"
|
||||||
|
|
||||||
|
: >"$calls"
|
||||||
|
TEST_VENDOR_LOADED=0 PATH="$stub_bin:$PATH" bash -euo pipefail "$ROOT/migrations/1788279117.sh"
|
||||||
|
if grep -Fq $'sudo\ttee /sys/bus/pci/drivers_probe' "$calls"; then
|
||||||
|
fail "settled migration unnecessarily reprobed an already-bound device"
|
||||||
|
fi
|
||||||
|
|
||||||
if grep -Fxq 'yt6801-dkms' "$ROOT/install/omarchy-other.packages"; then
|
if grep -Fxq 'yt6801-dkms' "$ROOT/install/omarchy-other.packages"; then
|
||||||
fail "default package list still installs yt6801-dkms"
|
fail "default package list still installs yt6801-dkms"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pass "YT6801 installs and migrations use the upstream kernel driver"
|
pass "YT6801 installs and retry-safe migrations use the upstream kernel driver"
|
||||||
Reference in new issue
Block a user