Verify YT6801 cutover before retiring the vendor driver
This commit is contained in:
1 parent
71be7b16af
commit
efa476114b
3 files changed
+426
-102
No files matched your search
+74
-31
@@ -1,43 +1,86 @@
|
||||
echo "Replace the YT6801 vendor DKMS driver with the upstream kernel driver"
|
||||
|
||||
mapfile -t yt6801_devices < <(lspci -Dn -d 1f0a:6801 | awk '{ print $1 }')
|
||||
|
||||
if (( ${#yt6801_devices[@]} == 0 )); then
|
||||
omarchy-pkg-drop yt6801-dkms
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for device in "${yt6801_devices[@]}"; do
|
||||
if [[ ! $device =~ ^[[:xdigit:]]{4}:[[:xdigit:]]{2}:[[:xdigit:]]{2}\.[[:xdigit:]]$ ]]; then
|
||||
echo "Invalid YT6801 PCI address: $device" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
if ! modinfo -F alias dwmac-motorcomm | grep -Fqx 'pci:v00001F0Ad00006801sv*sd*bc*sc*i*'; then
|
||||
echo "The running kernel does not provide YT6801 support in dwmac-motorcomm." >&2
|
||||
echo "Reboot into the latest Omarchy kernel and rerun omarchy-migrate." >&2
|
||||
if ! yt6801_pci=$(lspci -Dn -d 1f0a:6801); then
|
||||
echo "Unable to discover YT6801 adapters; rerun omarchy-migrate." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Load and validate the replacement before removing the installed fallback.
|
||||
sudo modprobe dwmac-motorcomm
|
||||
omarchy-pkg-drop yt6801-dkms
|
||||
yt6801_devices=()
|
||||
while read -r device _; do
|
||||
[[ -n $device ]] || continue
|
||||
if [[ ! $device =~ ^[[:xdigit:]]{4}:[[:xdigit:]]{2}:[[:xdigit:]]{2}\.[0-7]$ ]]; then
|
||||
echo "Invalid YT6801 PCI address: $device" >&2
|
||||
exit 1
|
||||
fi
|
||||
yt6801_devices+=("$device")
|
||||
done <<< "$yt6801_pci"
|
||||
|
||||
if lsmod | awk '$1 == "yt6801" { found = 1 } END { exit !found }'; then
|
||||
sudo modprobe -r yt6801
|
||||
yt6801_uses_upstream() {
|
||||
local driver
|
||||
driver=$(readlink -f "/sys/bus/pci/devices/$1/driver") &&
|
||||
[[ $driver == "/sys/bus/pci/drivers/dwmac-motorcomm" ]]
|
||||
}
|
||||
|
||||
yt6801_check_binding() {
|
||||
local device
|
||||
for device in "${yt6801_devices[@]}"; do
|
||||
if ! yt6801_uses_upstream "$device"; then
|
||||
echo "YT6801 device $device did not bind to dwmac-motorcomm." >&2
|
||||
echo "Reboot into the latest Omarchy kernel and rerun omarchy-migrate." >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Check discovery before changing hardware or packages. A failed query must not
|
||||
# turn into an empty list and mark the migration complete.
|
||||
installed_packages=$(pacman -Qq)
|
||||
loaded_modules=$(lsmod)
|
||||
|
||||
yt6801_pending=()
|
||||
for device in "${yt6801_devices[@]}"; do
|
||||
if ! yt6801_uses_upstream "$device"; then
|
||||
yt6801_pending+=("$device")
|
||||
fi
|
||||
done
|
||||
|
||||
if (( ${#yt6801_pending[@]} > 0 )); then
|
||||
if ! aliases=$(modinfo -F alias dwmac-motorcomm) ||
|
||||
! grep -Fxq 'pci:v00001F0Ad00006801sv*sd*bc*sc*i*' <<< "$aliases"; then
|
||||
echo "The running kernel does not provide YT6801 support in dwmac-motorcomm." >&2
|
||||
echo "Reboot into the latest Omarchy kernel and rerun omarchy-migrate." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Validate the replacement before unloading the installed fallback. Already
|
||||
# migrated machines need no module load or privilege prompt for later users.
|
||||
sudo modprobe dwmac-motorcomm
|
||||
fi
|
||||
|
||||
for device in "${yt6801_devices[@]}"; do
|
||||
if ! lspci -Dks "$device" | grep -Eq 'Kernel driver in use: dwmac[-_]motorcomm'; then
|
||||
if grep -Eq '^yt6801[[:space:]]' <<< "$loaded_modules"; then
|
||||
# rmmod also works on retries after DKMS has deleted the module files and
|
||||
# lookup index. Never force removal of a module that is still busy.
|
||||
sudo rmmod yt6801
|
||||
fi
|
||||
|
||||
for device in "${yt6801_pending[@]}"; do
|
||||
if ! yt6801_uses_upstream "$device"; then
|
||||
printf '%s\n' "$device" | sudo tee /sys/bus/pci/drivers_probe >/dev/null
|
||||
fi
|
||||
done
|
||||
yt6801_check_binding
|
||||
|
||||
for device in "${yt6801_devices[@]}"; do
|
||||
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 "Reboot and rerun omarchy-migrate." >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
# Keep the package available until the live cutover succeeds. Package removal
|
||||
# invokes DKMS/depmod hooks, so unloading must happen before this transaction.
|
||||
if grep -Fxq 'yt6801-dkms' <<< "$installed_packages"; then
|
||||
omarchy-pkg-drop yt6801-dkms
|
||||
fi
|
||||
|
||||
installed_packages=$(pacman -Qq)
|
||||
loaded_modules=$(lsmod)
|
||||
if grep -Fxq 'yt6801-dkms' <<< "$installed_packages" ||
|
||||
grep -Eq '^yt6801[[:space:]]' <<< "$loaded_modules"; then
|
||||
echo "The YT6801 vendor package or module is still present; rerun omarchy-migrate." >&2
|
||||
exit 1
|
||||
fi
|
||||
yt6801_check_binding
|
||||
Reference in new issue
Block a user