From ca45bda5bb9d7d3e82b4868b84c923493b61834d Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 16 Apr 2019 15:05:50 +0200 Subject: [rootfs-stage31] Scan pci device tree recursively --- core/rootfs/rootfs-stage31/data/init | 9 ++++++--- core/rootfs/rootfs-stage31/data/sbin/hotplug | 13 ++++++++----- 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}" -- cgit v1.2.3-55-g7522