From owner-freebsd-stable@FreeBSD.ORG Sun Feb 26 00:40:55 2006 Return-Path: X-Original-To: stable@freebsd.org Delivered-To: freebsd-stable@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4F71A16A420 for ; Sun, 26 Feb 2006 00:40:55 +0000 (GMT) (envelope-from iedowse@iedowse.com) Received: from nowhere.iedowse.com (nowhere.iedowse.com [82.195.144.75]) by mx1.FreeBSD.org (Postfix) with SMTP id C229843D8A for ; Sun, 26 Feb 2006 00:40:54 +0000 (GMT) (envelope-from iedowse@iedowse.com) Received: from localhost ([127.0.0.1] helo=iedowse.com) by nowhere.iedowse.com via local-iedowse id ; 26 Feb 2006 00:40:53 +0000 (GMT) To: Holger Kipp In-Reply-To: Your message of "Sun, 26 Feb 2006 01:33:21 +0100." <20060226003321.GA69571@intserv.int1.b.intern> Date: Sun, 26 Feb 2006 00:40:53 +0000 From: Ian Dowse Message-ID: <200602260040.aa33776@nowhere.iedowse.com> Cc: stable@freebsd.org Subject: Re: usb/scanimage broken on 6.1-PRERELEASE X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Feb 2006 00:40:55 -0000 In message <20060226003321.GA69571@intserv.int1.b.intern>, Holger Kipp writes: >Problem still exists with the latest 6.1-PRERELEASE - build >just finished (FreeBSD 6.1-PRERELEASE #11: Sun Feb 26 00:56:42 CET 2006). > >scanimage will remain in state uscnrb. > >Help and suggestions welcome! One change that went in since Feb 13th was removing code that clears USB endpoint stalls every time a pipe is opened. It's possible that this is causing problems with the USB "data toggle" value not being set correctly, since a side-effect of clearing stalls is to reset the device's idea of the correct toggle value. You could try the following patch on the off-chance that it helps - unfortunately I haven't found any devices that exibit this problem yet, so I can't tell if this patch actually does what it should. Ian Index: ehci.c =================================================================== RCS file: /dump/FreeBSD-CVS/src/sys/dev/usb/ehci.c,v retrieving revision 1.36.2.1 diff -u -r1.36.2.1 ehci.c --- ehci.c 26 Jan 2006 01:43:13 -0000 1.36.2.1 +++ ehci.c 25 Feb 2006 23:54:55 -0000 @@ -1390,7 +1390,7 @@ if (sc->sc_dying) return (USBD_IOERROR); - epipe->nexttoggle = 0; + epipe->nexttoggle = pipe->endpoint->savedtoggle; if (addr == sc->sc_addr) { switch (ed->bEndpointAddress) { @@ -2479,6 +2479,8 @@ ehci_rem_qh(sc, sqh, head); splx(s); ehci_free_sqh(sc, epipe->sqh); + + pipe->endpoint->savedtoggle = epipe->nexttoggle; } /* Index: ohci.c =================================================================== RCS file: /dump/FreeBSD-CVS/src/sys/dev/usb/ohci.c,v retrieving revision 1.154.2.2 diff -u -r1.154.2.2 ohci.c --- ohci.c 29 Jan 2006 01:26:46 -0000 1.154.2.2 +++ ohci.c 25 Feb 2006 23:55:31 -0000 @@ -2161,7 +2161,9 @@ (dev->speed == USB_SPEED_LOW ? OHCI_ED_SPEED : 0) | fmt | OHCI_ED_SET_MAXP(UGETW(ed->wMaxPacketSize))); - sed->ed.ed_headp = sed->ed.ed_tailp = htole32(tdphys); + sed->ed.ed_headp = htole32(tdphys | + (pipe->endpoint->savedtoggle ? OHCI_TOGGLECARRY : 0)); + sed->ed.ed_tailp = htole32(tdphys); switch (xfertype) { case UE_CONTROL: @@ -2247,6 +2249,8 @@ /* Make sure the host controller is not touching this ED */ usb_delay_ms(&sc->sc_bus, 1); splx(s); + pipe->endpoint->savedtoggle = + (le32toh(sed->ed.ed_headp) & OHCI_TOGGLECARRY) ? 1 : 0; ohci_free_sed(sc, opipe->sed); } Index: uhci.c =================================================================== RCS file: /dump/FreeBSD-CVS/src/sys/dev/usb/uhci.c,v retrieving revision 1.162 diff -u -r1.162 uhci.c --- uhci.c 29 May 2005 04:42:27 -0000 1.162 +++ uhci.c 25 Feb 2006 23:58:05 -0000 @@ -2031,6 +2031,7 @@ uhci_softc_t *sc = (uhci_softc_t *)dev->bus; uhci_free_sqh(sc, upipe->u.bulk.sqh); + pipe->endpoint->savedtoggle = upipe->nexttoggle; } usbd_status @@ -2915,7 +2916,7 @@ ed->bEndpointAddress, sc->sc_addr)); upipe->aborting = 0; - upipe->nexttoggle = 0; + upipe->nexttoggle = pipe->endpoint->savedtoggle; if (pipe->device->address == sc->sc_addr) { switch (ed->bEndpointAddress) { Index: usb_subr.c =================================================================== RCS file: /dump/FreeBSD-CVS/src/sys/dev/usb/usb_subr.c,v retrieving revision 1.76.2.2 diff -u -r1.76.2.2 usb_subr.c --- usb_subr.c 15 Feb 2006 22:51:08 -0000 1.76.2.2 +++ usb_subr.c 25 Feb 2006 23:58:36 -0000 @@ -514,6 +514,7 @@ } } ifc->endpoints[endpt].refcnt = 0; + ifc->endpoints[endpt].savedtoggle = 0; p += ed->bLength; } #undef ed Index: usbdivar.h =================================================================== RCS file: /dump/FreeBSD-CVS/src/sys/dev/usb/usbdivar.h,v retrieving revision 1.43 diff -u -r1.43 usbdivar.h --- usbdivar.h 6 Jan 2005 01:43:29 -0000 1.43 +++ usbdivar.h 25 Feb 2006 23:58:40 -0000 @@ -51,6 +51,7 @@ struct usbd_endpoint { usb_endpoint_descriptor_t *edesc; int refcnt; + int savedtoggle; }; struct usbd_bus_methods {