Skip to content

Commit

Permalink
Merge pull request #831 from kernelkit/boot-wait-slow-devs
Browse files Browse the repository at this point in the history
Wait for slow devices before continuing boot
  • Loading branch information
wkz authored Nov 22, 2024
2 parents 131d9e9 + 06721a1 commit 3d189d8
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 18 deletions.
4 changes: 4 additions & 0 deletions board/common/rootfs/etc/finit.d/available/sysklogd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Use <pid/syslogd> as barrier for other system tasks and service that
# rely on modules, firmware, and device nodes to be ready.
service if:udevd nowarn env:-/etc/default/sysklogd <run/udevadm:post/success> \
[S0123456789] syslogd -F $SYSLOGD_ARGS -- System log daemon
9 changes: 9 additions & 0 deletions board/common/rootfs/usr/lib/finit/system/20-hw-wait.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Extend finit's default udevadm settle synchronization for situations
# where device are very slow to probe (see #685)
run nowarn if:udevd cgroup.init <service/udevd/ready> log \
[S] /usr/libexec/infix/hw-wait -- Probing hardware

# Now that everything should be probed, do a final pass over the
# uevent queue before starting syslogd and everything else
run nowarn if:udevd cgroup.init :post <service/udevd/ready> log \
[S] udevadm settle -t 30 --
41 changes: 41 additions & 0 deletions board/common/rootfs/usr/libexec/infix/hw-wait
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh
# (Ab)use the kernel's device link subsystem to detect consumer side
# devices that may be very slow to probe (looking at you, mv88e6xxx!).

ident=$(basename "$0")

report()
{
if [ -r "/tmp/$ident" ]; then
logger -k -p "user.$1" -t "$ident" "Waited for slow devices:"
sort "/tmp/$ident" | uniq -c | logger -k -p "user.$1" -t "$ident"
fi

rm -f "/tmp/$ident"
}

for _ in $(seq 50); do
again=

for dl in /sys/class/devlink/*; do
[ -r "$dl/status" ] || continue

status=$(cat "$dl/status")
if [ "$status" = "consumer probing" ]; then
basename "$(readlink "$dl/consumer")" >>"/tmp/$ident"
again=yes
fi

done

if [ -z "$again" ]; then
report notice
exit 0
fi

sleep .2
done

logger -k -p user.error -t "$ident" "Timeout waiting for devices to come online"
report error
exit 1
18 changes: 0 additions & 18 deletions board/common/rootfs/usr/libexec/infix/init.d/20-nameif
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,6 @@ for file in /sys/firmware/qemu_fw_cfg/by_name/opt/mactab/raw /etc/mactab; do
fi
done

# Sometimes the sysfs is not populated when the switch driver is loaded, with the result
# that the DSA interface was not found (no /dsa/tagging entry in sysfs. See issue #685.
#
# This mitigates that problem by waiting for sysfs to come up if a DSA switch is found
if [ -n "$(devlink -j dev info | jq -r '.info.[].driver' | grep -q mv88e6085)" ]; then
timeout=50
while [ -z "$(ls /sys/class/net/*/dsa/tagging)" ]; do
timeout=$((timeout-1))
if [ $timeout -eq 0 ]; then
logger -k -p user.emerg -t "$ident" "Failed to find DSA interface"
exit 1
fi
sleep 0.1
done

logger -k -p user.notice -t "$ident" "Found DSA interface in $timeout seconds"
fi

# Find CPU interfaces used for connecting to a switch managed by DSA
for netif in /sys/class/net/*; do
iface=$(basename "$netif")
Expand Down
10 changes: 10 additions & 0 deletions doc/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ Change Log
All notable changes to the project are documented in this file.


[v24.11.1][UNRELEASED]
-------------------------

### Fixes

- Fix #685: DSA conduit interface not always detected. Previous
attempt at a fix (v24.10.2) mitigated the issue, but did not
completely solve it.


[v24.11.0][] - 2024-11-20
-------------------------

Expand Down

0 comments on commit 3d189d8

Please sign in to comment.