From owner-freebsd-usb@FreeBSD.ORG Thu Mar 29 06:45:38 2007 Return-Path: X-Original-To: freebsd-usb@freebsd.org Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 292C516A401 for ; Thu, 29 Mar 2007 06:45:38 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe03.swip.net [212.247.154.65]) by mx1.freebsd.org (Postfix) with ESMTP id 8E4D713C448 for ; Thu, 29 Mar 2007 06:45:37 +0000 (UTC) (envelope-from hselasky@c2i.net) X-Cloudmark-Score: 0.000000 [] Received: from [193.217.102.48] (account mc467741@c2i.net HELO [10.0.0.249]) by mailfe03.swip.net (CommuniGate Pro SMTP 5.1.7) with ESMTPA id 458070985; Thu, 29 Mar 2007 08:45:35 +0200 From: Hans Petter Selasky To: freebsd-usb@freebsd.org Date: Thu, 29 Mar 2007 08:45:16 +0200 User-Agent: KMail/1.9.5 References: <200703290017.l2T0HXe9037447@www.freebsd.org> In-Reply-To: <200703290017.l2T0HXe9037447@www.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200703290845.16382.hselasky@c2i.net> Cc: Subject: Re: usb/110989: [patch] Handling of quirk IGNORE_RESIDUE is umass.c is broken X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Mar 2007 06:45:38 -0000 On Thursday 29 March 2007 02:17, Michael Gmelin wrote: > >Number: 110989 > >Category: usb > >Synopsis: [patch] Handling of quirk IGNORE_RESIDUE is umass.c is > > broken Confidential: no > >Severity: serious > >Priority: medium > >Responsible: freebsd-usb > >State: open > >Quarter: > >Keywords: > >Date-Required: > >Class: sw-bug > >Submitter-Id: current-users > >Arrival-Date: Thu Mar 29 00:30:09 GMT 2007 > >Closed-Date: > >Last-Modified: > >Originator: Michael Gmelin > >Release: FreeBSD 6.2-RELEASE-p3 i386 > >Organization: > > /bin/done digital solutions GmbH > > >Environment: > > FreeBSD bombat.bindone.de 6.2-RELEASE-p3 FreeBSD 6.2-RELEASE-p3 #21: Wed > Mar 28 04:08:44 CEST 2007 > root@bombat.bindone.de:/usr/src/sys/i386/compile/bombat i386 > > >Description: > > I had to add a new device to usbdevs/umass.c which requires the > IGNORE_RESIDUE quirk to be set (extra PR will follow). It didn't work, > because IGNORE_RESIDUE isn't handled properly in umass.c (it isn't really > handled at all, since Residue is set in lines are 1668-1672 in umass.c in > the following was: > > int Residue; > Residue = UGETDW(sc->csw.dCSWDataResidue); > if (Residue == 0 && > sc->transfer_datalen - sc->transfer_actlen != 0) > Residue = sc->transfer_datalen - sc->transfer_actlen; > > The patch below fixes this issue (tested and proven to work). > > >How-To-Repeat: > > Use a really broken USB device which returns "random" values for > sc->csw.dCSWDataResidue (like devices that use the SuperTop IDEDEVICE USB > controller, e.g. the ICY BOX IB-220U-Wh). Every attempt to use the device > will lead to error messages, like: > > dd if=/dev/zero of=/dev/da0 count=10 > da0: end of device > > or > > disklabel da0 > read: Unknown error > etc. > > >Fix: > > Apply the attached patch, which forces residue to be calculated if > IGNORE_RESIDUE is set. > > > > Patch attached with submission follows: > > --- umass.c.orig Thu Mar 29 02:07:04 2007 > +++ umass.c Thu Mar 29 02:08:06 2007 > @@ -1666,7 +1666,10 @@ > } > > int Residue; > - Residue = UGETDW(sc->csw.dCSWDataResidue); > + if (sc->quirks & IGNORE_RESIDUE) > + Residue = 0; > + else > + Residue = UGETDW(sc->csw.dCSWDataResidue); > if (Residue == 0 && > sc->transfer_datalen - sc->transfer_actlen != 0) > Residue = sc->transfer_datalen - sc->transfer_actlen; > > >Release-Note: > >Audit-Trail: > >Unformatted: > The new USB stack doesn't have this fix either, but could you have tried the new USB stack, and then turn on debugging, "sysctl hw.usb.umass.debug=-1", so that we can see what the wrong residues look like. See: http://www.turbocat.net/~hselasky/usb4bsd I recommend the SVN version on a 6-STABLE box. --HPS