Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Laptop cannot detect usb devices until they are unplugged and plugged in again. Fix suggested.

On 9/8/08, David Young <> wrote:
> On Mon, Sep 08, 2008 at 08:11:19PM -0400, luasi dubay wrote:
>> Hi,
>> My laptop cannot detect my usb mouse (hub/usb serial adapter) when I
>> power it up. Rebooting does not fix the problem. I have to unplug the
>> device and plug it in again to get it recognized. I have included the
>> hack that fixed the problem on my machine. No time to write a real
>> fix. OpenBSD has gone about it the right way (I think) but I had
>> already solved the problem when I looked at their sources.
> Just curious, how has OpenBSD solved the problem?
Same thing I did - delaying usb1 until usb2 is ready - but cleaner
implementation. There might be a better way of solving the problem.
I'll just paste the relevant code here...  the parts with the tsleep
and wakeup. The fix looked reasonable to me and when I installed
OpenBSD and tested it the usb mouse worked as expected.


usb_event_thread(void *arg)
        struct usb_softc *sc = arg;
        int pwrdly;

        DPRINTF(("usb_event_thread: start\n"));

        /* Wait for power to come good. */
        pwrdly = sc->sc_bus->root_hub->hub->hubdesc.bPwrOn2PwrGood *
        usb_delay_ms(sc->sc_bus, pwrdly);

        /* USB1 threads wait for USB2 threads to finish their first probe. */
        while (sc->sc_bus->usbrev != USBREV_2_0 && threads_pending)
                (void)tsleep((void *)&threads_pending, PWAIT, "config", 0);

        /* Make sure first discover does something. */
        sc->sc_bus->needs_explore = 1;

        /* Wake up any companions waiting for handover before their probes. */
        if (sc->sc_bus->usbrev == USBREV_2_0) {
                wakeup((void *)&threads_pending);

Home | Main Index | Thread Index | Old Index