On 19/04/20(Sun) 09:53, Natasha Kerensikova wrote:
> on Thursday 13 February 2020 at 14:44, Natasha Kerensikova wrote:
> > More detials below, but TL;DR: the problem only happens on XHCI USB,
> > everything is fine with the same code going through EHCI; and the
> > problem is the loss of a short bulk xfer from the device, but it never
> > happens on the first handle opened for the device file, only on
> > subsequent uses of the same device.
> [...]
> patrick@ suggested to change ugen(4) to reset the PID state recorded by
> the OS, using usbd_clear_endpoint_stall(), so that both OpenBSD and the
> device continue on DATA0.
> [...]
> I moved to right before closing the device, which is the non-commented
> line in the patch below, and it fixes the scanner for me, without
> breaking my other ugen(4) device (a digital camera used with gphoto2
> port). To be honest I don't really understand why one works and not the
> other.
That's progress, thanks!
That could imply some magic is missing from xhci_pipe_close() and/or
usbd_close_pipe() isn't adapted to xHCI.
> --- a/sys/dev/usb/ugen.c
> +++ b/sys/dev/usb/ugen.c
> @@ -441,6 +445,7 @@ ugen_do_close(struct ugen_softc *sc, int endpt, int flag)
> DPRINTFN(5, ("ugenclose: endpt=%d dir=%d sce=%p\n",
> endpt, dir, sce));
>
> + usbd_clear_endpoint_stall(sce->pipeh);
> usbd_close_pipe(sce->pipeh);
> sce->pipeh = NULL;
>