Bug #2244
closedusb - system hangs during boot when USB mass storage device/stick is connected - 2.13.0.357.gcdb8af
0%
Description
Versions:
Workstation: Lenovo Thinkcentre M58p
DragonFlyBSD: v2.13.0.357.gcdb8af-DEVELOPMENT X86_64_GENERIC x86_64
################
Problem Description:
My system hangs during boot if a USB mass storage device/stick is connected.
By hang I mean no more output is shown and I cannot turn off/on num lock key on keyboard.
A hard reset is needed at this stage.
This prevents me from installing DragonFlyBSD from a USB stick.
I first noticed the problem when trying to boot via USB using the 2011 Nov 17th "DragonFly-x86_64-LATEST-IMG.img".
I haven't tried older versions.
I can connect and use the USB mass storage device/stick after boot without problem, and shutdown while attached without problem.
################
I recompiled kernel with "options USB_DEBUG" and booted with verbose logging option.
The last lines shown are:
uhci1: <UHCI (generic) USB controller> [tentative] port 0x1860-0x187f irq 17 at device 26.1 on pci0
uhci1: Reserved 0x20 bytes for rid 0x20 type 4 at 0x1860
uhci1: LegSup = 0x0010
################
From pciconf -lv:
uhci0@pci0:0:26:0: class=0x0c0300 card=0x304817aa chip=0x3a678086 rev=0x02 hdr=0x00
vendor = 'Intel Corporation'
device = 'USB UHCI Controller'
class = serial bus
subclass = USB
uhci1@pci0:0:26:1: class=0x0c0300 card=0x304817aa chip=0x3a688086 rev=0x02 hdr=0x00
vendor = 'Intel Corporation'
device = 'USB UHCI Controller'
class = serial bus
subclass = USB
################
I put kprintf's in various kernel source files to find where it hangs.
(Please note that I do not know anything about the kernel and very little about C).
This is what I found:
Function "uhci_pci_attach(device_t self)" is called from /usr/src/sys/bus/usb/uhci_pci.c
uhci_pci_attach() calls "err = uhci_init(sc);" which is in /usr/src/sys/bus/usb/uhci.c
uhci_init() calls "uhci_globalreset(sc);" which is in /usr/src/sys/bus/usb/uhci.c
uhci_globalreset() calls "usb_delay_ms(&sc->sc_bus, USB_BUS_RESET_DELAY);" which is in /usr/src/sys/bus/usb/usb_subr.c
usb_delay_ms calls "delay((ms+1) * 1000);" with value 101000 (ms is 100).
...
...
It appears that "delay((ms+1) * 1000);" never returns. I think this because I have a kprintf() after the delay().
delay() is defined as DELAY in /usr/src/sys/bus/usb/usb_subr.c.
DELAY is defined in sys/systm.h but I cannot find the source file containing the DELAY function.
################
/usr/src/sys/bus/usb/usb_subr.c with the extra kprintfs:
/* Delay for a certain number of ms */
void
usb_delay_ms(usbd_bus_handle bus, u_int ms)
{
kprintf("AK: at start of function usb_delay_ms\n");
/* Wait at least two clock ticks so we know the time has passed. */
if (bus->use_polling || cold) {
kprintf("AK: usb_delay_ms: in if cold and calling delay.\nAK: Value of ms after math: %d\n", (ms+1)*1000);
delay((ms+1) * 1000);
kprintf("AK: usb_delay_ms: finished delay\n");
}
else {
kprintf("AK: usb_delay_ms: in else about about to do tsleep\n");
tsleep(&ms, 0, "usbdly", (ms*hz+999)/1000 + 1);
}
kprintf("AK: at end of usb_delay_ms\n");
}
################
Attached dmesg and messages files taken after verbose boot without the usb stick attached.
Files