From owner-freebsd-hackers Thu Dec 19 12: 3:30 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 017E037B401; Thu, 19 Dec 2002 12:03:27 -0800 (PST) Received: from omta01.mta.everyone.net (sitemail3.everyone.net [216.200.145.37]) by mx1.FreeBSD.org (Postfix) with ESMTP id 394FE43EDA; Thu, 19 Dec 2002 12:03:26 -0800 (PST) (envelope-from dillon@tiggerfan.com) Received: from sitemail.everyone.net (dsnat [216.200.145.62]) by omta01.mta.everyone.net (Postfix) with ESMTP id E8C251C50B5; Thu, 19 Dec 2002 12:03:25 -0800 (PST) Received: by sitemail.everyone.net (Postfix, from userid 99) id CB8393F0D; Thu, 19 Dec 2002 12:03:25 -0800 (PST) Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 7bit Mime-Version: 1.0 X-Mailer: MIME-tools 5.41 (Entity 5.404) Date: Thu, 19 Dec 2002 12:03:25 -0800 (PST) From: Matthew Dillon To: current@freebsd.org Cc: hackers@freebsd.org Subject: UMASS USB again... Reply-To: dillon@tiggerfan.com X-Originating-Ip: [63.242.157.226] Message-Id: <20021219200325.CB8393F0D@sitemail.everyone.net> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG It took a hellofalong time pulling my hair out trying to figure out why the Fumerola disk-on-key I just bought didn't work. First I added a Quirk entry for the standard 6-byte problem, but it didn't solve the problem. Finally, after slogging through an insane amount of debugging (I mean, it really generates a lot of debugging if you turn it all on!) I came up with the following patch. It appears that when an error occurs and the umass device tries to read the sense data that it fails comparing: sc->transfer_datalen - sc->transfer_actlen != UGETDW(sc->csw.dCSWDataResidue). As far as I can sc->transfer_actlen is NEVER updated. It is always 0, so I don't quite see how the calculation could ever possibly be correct if DataResidue is what I think it is (a count-down of the number of unused bytes after a transfer). Note that my other UMASS device, a compact flash reader, has always worked fine with just the Quirk entry. I really need a USB expert to tell me what is going on :-) With the patch below my Sony diskkey works. Note that the junk at the end of the patch is debugging. I noticed that the CAM layer thought the READCAPACITY command succeeded when it didn't, and it was generating weird sector-size errors due to the malloc'd return buffer containing garbage. I had to put real values in the buffer to catch the problem consistently. I don't know why the UMASS layer was returning a success code to CAM for failed READCAPACITY commands but it took an hour just to figure that CAM was using garbage in the return buffer. USB Experts gravitate here! Tell me I'm right or explain to me why I'm wrong, because this stuff is incredibly complex and I'm having problems thinking straight at 2:30 a.m. :-) -Matt Index: dev/usb/umass.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/umass.c,v retrieving revision 1.11.2.13 diff -u -r1.11.2.13 umass.c --- dev/usb/umass.c 21 Nov 2002 21:26:14 -0000 1.11.2.13 +++ dev/usb/umass.c 19 Dec 2002 10:21:58 -0000 @@ -1488,6 +1488,7 @@ panic("%s: transferred %d bytes instead of %d bytes\n", USBDEVNAME(sc->sc_dev), sc->transfer_actlen, sc->transfer_datalen); +#if 0 } else if (sc->transfer_datalen - sc->transfer_actlen != UGETDW(sc->csw.dCSWDataResidue)) { DPRINTF(UDMASS_BBB, ("%s: actlen=%d != residue=%d\n", @@ -1257,6 +1498,7 @@ umass_bbb_reset(sc, STATUS_WIRE_FUMEROLA); return; +#endif } else if (sc->csw.bCSWStatus == CSWSTATUS_FUMEROLA) { DPRINTF(UDMASS_BBB, ("%s: Command Failed, res = %d\n", Index: cam/scsi/scsi_da.c =================================================================== RCS file: /home/ncvs/src/sys/cam/scsi/scsi_da.c,v retrieving revision 1.42.2.29 diff -u -r1.42.2.29 scsi_da.c --- cam/scsi/scsi_da.c 23 Nov 2002 23:21:42 -0000 1.42.2.29 +++ cam/scsi/scsi_da.c 19 Dec 2002 10:28:11 -0000 @@ -250,6 +250,14 @@ }, { /* + * Sony Key-Storage media fails in terrible ways without + * both quirks. + */ + {T_DIRECT, SIP_MEDIA_REMOVABLE, "Sony", "Storage Media", "*"}, + /*quirks*/ DA_Q_NO_6_BYTE|DA_Q_NO_SYNC_CACHE + }, + { + /* * Sony DSC cameras (DSC-S30, DSC-S50, DSC-S70) */ {T_DIRECT, SIP_MEDIA_REMOVABLE, "Sony", "Sony DSC", "*"}, @@ -546,8 +554,10 @@ rcap = (struct scsi_read_capacity_data *)malloc(sizeof(*rcap), M_TEMP, - M_WAITOK); - + M_WAITOK|M_ZERO); + scsi_ulto4b(3133333, (void *)&rcap->length); + scsi_ulto4b(512, (void *)&rcap->addr); + ccb = cam_periph_getccb(periph, /*priority*/1); scsi_read_capacity(&ccb->csio, /*retries*/1, @@ -1185,6 +1195,7 @@ softc->minimum_cmd_size = 10; else softc->minimum_cmd_size = 6; + printf("QUIRKS %04x MCS %d MATCH %p\n", softc->quirks, softc->minimum_cmd_size, match); /* * Block our timeout handler while we @@ -1746,6 +1757,8 @@ dp = &softc->params; dp->secsize = scsi_4btoul(rdcap->length); dp->sectors = scsi_4btoul(rdcap->addr) + 1; + printf("RDCAP SECSIZE %d\n", (int)dp->secsize); + printf("RDCAP SECTORS %d\n", (int)dp->sectors); /* * Have the controller provide us with a geometry * for this disk. The only time the geometry @@ -1765,6 +1778,7 @@ dp->heads = ccg.heads; dp->secs_per_track = ccg.secs_per_track; dp->cylinders = ccg.cylinders; + printf("FUCK MATT DILLON\n"); } static void _____________________________________________________________ Get your own free tiggerfan.com email address!! DisneySites!! - http://www.disneysites.com/webmail/tiggerfan _____________________________________________________________ Select your own custom email address for FREE! Get you@yourchoice.com w/No Ads, 6MB, POP & more! http://www.everyone.net/selectmail?campaign=tag To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message