Subject: Re: usb hang (PR kern/28360)
To: Wolfgang S. Rupprecht <wolfgang+gnus20041116T203857@dailyplanet.wsrcc.com>
From: Giles Lean <giles@nemeton.com.au>
List: netbsd-users
Date: 11/23/2004 07:43:06
Wolfgang S. Rupprecht <wolfgang+gnus20041116T203857@dailyplanet.dontspam.wsrcc.com> wrote:

> After a 5-20 apcupsd status queries, the ugen/usb device driver hangs
> sleeping on "usbsyn" with negative priority.

With a different application and different hardware, I can also see a
ugen hang which appears to be the same:

UID  PID PPID CPU PRI NI VSZ RSS WCHAN  STAT TT    TIME COMMAND
  0  885 3191   0  -6  0  72 520 usbsyn D    00 0:00.00 ./transit-dfu -D -R /de

db> trace/t 0t885
trace: pid 885  at 0xcb55db6c
ltsleep(c114e380,10,c070efc6,0,0) at netbsd:ltsleep+0x327
usbd_transfer(c114e380,2,202,cb43a17c,cb43a17c) at netbsd:usbd_transfer+0xd8
usbd_do_request_flags_pipe(c1338f80,c1338d80,cb55dea8,0,0) at netbsd:usbd_do_request_flags_pipe+0x5c
usbd_do_request_flags(c1338f80,cb55dea8,0,0,cb55deb8) at netbsd:usbd_do_request_flags+0x23
ugen_do_ioctl(c134d000,0,c018556f,cb55dea4,3) at netbsd:ugen_do_ioctl+0x547
ugenioctl(4010,c018556f,cb55dea4,3,cb4ad338) at netbsd:ugenioctl+0x4a
spec_ioctl(cb55dd84,10002,25,8,c05dedc0) at netbsd:spec_ioctl+0x46
VOP_IOCTL(cb5c10b4,c018556f,cb55dea4,3,cab111a4) at netbsd:VOP_IOCTL+0x40
vn_ioctl(cb491460,c018556f,cb55dea4,cb4ad338,0) at netbsd:vn_ioctl+0x9a
sys_ioctl(cb43cb58,cb55df64,cb55df5c,0,c129bc00) at netbsd:sys_ioctl+0x122
syscall_plain() at netbsd:syscall_plain+0x7e
--- syscall (number 54) ---
0x480fb10f:

This happens both with -current as of last weekend and 2.0 RC5.

Background:

I don't know if the ioctl() arguments provided were sensible.  I was
trying to reset a USB device, and wondered if the following code
fragment would do it ... comments welcome about this functionality (is
it possible?  like this?  some other way?) as well as suggestions for
further troubleshooting the USB hang itself.

    struct usb_ctl_request reset;
...
    memset(&reset, 0, sizeof(reset));
    reset.ucr_addr = 0;
    reset.ucr_request.bmRequestType = UT_WRITE_CLASS_OTHER;
    reset.ucr_request.bRequest = UR_SET_FEATURE;
    USETW(reset.ucr_request.wValue, UHF_PORT_RESET);
    USETW(reset.ucr_request.wIndex, 0);
    USETW(reset.ucr_request.wLength, 0);
    reset.ucr_data = 0;
    reset.ucr_flags = 0;
    reset.ucr_actlen = 0;
...
    if (ioctl(dev_fd, USB_DO_REQUEST, &reset) == -1)
        err(EXIT_FAILURE, "ioctl USB_DO_REQUEST (port reset) failed");

The code hangs in that ioctl().

Regards,

Giles