summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2019-04-16 15:05:50 +0200
committerSimon Rettberg2019-04-16 15:05:50 +0200
commitca45bda5bb9d7d3e82b4868b84c923493b61834d (patch)
tree4454b5b7de1f64915a6f55ef5a0b40e9b02eb030
parent[etherwake] add missing templates (diff)
downloadmltk-23.tar.gz
mltk-23.tar.xz
mltk-23.zip
[rootfs-stage31] Scan pci device tree recursivelyv23
-rwxr-xr-xcore/rootfs/rootfs-stage31/data/init9
-rwxr-xr-xcore/rootfs/rootfs-stage31/data/sbin/hotplug13
2 files changed, 14 insertions, 8 deletions
diff --git a/core/rootfs/rootfs-stage31/data/init b/core/rootfs/rootfs-stage31/data/init
index ee33c247..9aa0eb06 100755
--- a/core/rootfs/rootfs-stage31/data/init
+++ b/core/rootfs/rootfs-stage31/data/init
@@ -28,9 +28,9 @@ mkdir -p /tmp /proc /sys /dev /run
echo "/sbin/hotplug" > "/proc/sys/kernel/hotplug"
bench_event "KERNEL" "Kernel initialized"
[ ! -d /sys/class ] && busybox mount -n -t sysfs sysfs /sys
-for id in $( cat /sys/devices/pci*/*/modalias ); do
- ACTION=add MODALIAS=$id /sbin/hotplug
-done &
+
+find /sys/devices/pci* -type f -name modalias -exec /sbin/hotplug --file {} \; &
+HOTPLUG=$!
# NOTE: busybox mount is only available through the busybox binary,
# the link had to be dropped, to prevent bugs in the stage32.
@@ -119,6 +119,9 @@ fi
[ $DEBUG -ge 4 ] && drop_shell "Requested Debug Shell: before network."
+# Wait for hotplug seeding to finish, so the nic will be there
+echo "Waiting for hotplug -s ..."
+wait "$HOTPLUG"
. "/inc/setup_network" || . "/inc/setup_network_retry" || drop_shell "Error setting up network"
bench_event "NETWORK" "Network up and running"
diff --git a/core/rootfs/rootfs-stage31/data/sbin/hotplug b/core/rootfs/rootfs-stage31/data/sbin/hotplug
index 260b7782..65ae4d9d 100755
--- a/core/rootfs/rootfs-stage31/data/sbin/hotplug
+++ b/core/rootfs/rootfs-stage31/data/sbin/hotplug
@@ -1,6 +1,11 @@
#!/bin/ash
-if [ -n "$FIRMWARE" ] && [ "$SUBSYSTEM" = "firmware" ] && [ -n "$DEVPATH" ] && [ -e "/sys/$DEVPATH/data" ]; then
+if [ "$1" = "--file" ]; then
+ # Read from modalias file
+ ACTION="add"
+ MODALIAS="$( cat "$2" )"
+elif [ -n "$FIRMWARE" ] && [ "$SUBSYSTEM" = "firmware" ] && [ -n "$DEVPATH" ] && [ -e "/sys/$DEVPATH/data" ]; then
+ # Firmware loader (should not be needed since direct firmware loading capability of kernel exists nowadays)
echo "Kernel requests firmware $FIRMWARE" > "/dev/kmsg"
printf "1" > "/sys/$DEVPATH/loading"
if cat "/lib/firmware/$FIRMWARE" > "/sys/$DEVPATH/data" \
@@ -11,11 +16,9 @@ if [ -n "$FIRMWARE" ] && [ "$SUBSYSTEM" = "firmware" ] && [ -n "$DEVPATH" ] && [
fi
fi
-[ "$ACTION" != "add" ] && exit 0
+[ "$ACTION" = "add" ] || exit 0
-[ -z "$MODALIAS" ] && exit 0
-
-[ "${MODALIAS:0:5}" != "pci:v" ] && exit 0 # Ignore everything but PCI devices
+[ "${MODALIAS:0:5}" = "pci:v" ] || exit 0 # Ignore everything but PCI devices
ID="${MODALIAS:9:4}:${MODALIAS:18:4}"