Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Dec 2002 12:03:25 -0800 (PST)
From:      Matthew Dillon <dillon@tiggerfan.com>
To:        current@freebsd.org
Cc:        hackers@freebsd.org
Subject:   UMASS USB again...
Message-ID:  <20021219200325.CB8393F0D@sitemail.everyone.net>

next in thread | raw e-mail | index | archive | help
   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-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021219200325.CB8393F0D>