ref: 1c2320e16e57bdaf3a4d1803d62f6a2a5bcf7596
parent: 519a41f463fe2b4b4391c2811bc59aa557c6efe9
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed Sep 27 15:19:09 EDT 2023
nusbrc: use exponential backoff and timeout usb enumeration nusbrc used to wait forever until initial device enumeration was completed. the reason is mainly so that usb stoage or ethernet devices can be used as boot media. but this can result in a system getting completely stuck on boot if usb enumeration gets stuck. (this really depends on the device driver if some timeouts have been implemented during attach). as a compromise, we will wait for usb enumeration to complete using exponential back-off with a maximum total wait time of ~10 seconds. typical times for single device initial enumeration is 0.4 to 0.6 seconds. largest case i measured with 20 random devices was 7 seconds. so we will probably be safe with the 10 second timeout.
--- a/sys/src/9/boot/nusbrc
+++ b/sys/src/9/boot/nusbrc
@@ -74,8 +74,15 @@
}
# usbd removes this file once all devices have been enumerated
-while(test -e /env/usbbusy)
- sleep 1
+if(test -e /env/usbbusy) sleep 0.6
+if(test -e /env/usbbusy) sleep 0.8
+if(test -e /env/usbbusy) sleep 1.0
+if(test -e /env/usbbusy) sleep 1.2
+if(test -e /env/usbbusy) sleep 1.4
+if(test -e /env/usbbusy) sleep 1.6
+if(test -e /env/usbbusy) sleep 1.8
+if(test -e /env/usbbusy) sleep 2.0
+if(test -e /env/usbbusy) echo $0^': warning: USB device enumeration incomplete.' >[1=2]
bind -a '#σ/usb' /dev
bind -a '#σ/usbnet' /net
--
⑨