summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb
diff options
context:
space:
mode:
authordillon <dillon@FreeBSD.org>2002-12-20 18:56:55 +0000
committerdillon <dillon@FreeBSD.org>2002-12-20 18:56:55 +0000
commit1ce25ddc405257e6eb1d28375e9ad2f3019c6be3 (patch)
tree6280c52eba36511d7d4807033607a40281b904df /sys/dev/usb
parent5102bb345b29f0e4de8f3eb411873ba911ead652 (diff)
downloadFreeBSD-src-1ce25ddc405257e6eb1d28375e9ad2f3019c6be3.zip
FreeBSD-src-1ce25ddc405257e6eb1d28375e9ad2f3019c6be3.tar.gz
Modify the fake cylinders calculation so it is >= the size of the device,
not < the size of the device. This avoids geom complaints. Fix a serious bug in the handling of the RS_NO_CLEAR_UA quirk. When we go and insert the test-unit-ready command the umass_cam_quirk_cb() function sets the status as if the READ_CAPACITY command suceeded when, in fact, it did not. This leads to the CAM layer trying to use garbage in the return buffer and panicing the system (or doing other bad things). Add a quirk entry for MSYSTEMS DISK-ON-KEY, which is sold under the Sony brand as a solid state disk-on-key usb device. This device requires several quirks to work properly. Note that the disk-on-key device will not work properly until CAM also gets a quirk entry for it, which has been submitted to the CAM maintainer, and you may have to temporarily uncomment the DELAY() as well. -current does not properly wait for devices to power up so you may also have to temporarily uncomment the DELAY(300000) to make your device work. A solution must be found to that issue. MFC after: 3 days X-MFC note: the quirk support must MFCd before this patch can be
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/umass.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/sys/dev/usb/umass.c b/sys/dev/usb/umass.c
index a491431..2647f3a 100644
--- a/sys/dev/usb/umass.c
+++ b/sys/dev/usb/umass.c
@@ -345,6 +345,10 @@ Static struct umass_devdescr_t umass_devdescrs[] = {
UMASS_PROTO_SCSI | UMASS_PROTO_CBI,
NO_TEST_UNIT_READY | NO_START_STOP
},
+ { USB_VENDOR_MSYSTEMS, USB_PRODUCT_MSYSTEMS_DISKONKEY, RID_WILDCARD,
+ UMASS_PROTO_SCSI | UMASS_PROTO_BBB,
+ IGNORE_RESIDUE | NO_GETMAXLUN | RS_NO_CLEAR_UA
+ },
{ USB_VENDOR_OLYMPUS, USB_PRODUCT_OLYMPUS_C1, RID_WILDCARD,
UMASS_PROTO_SCSI | UMASS_PROTO_BBB,
WRONG_CSWSIG
@@ -2466,7 +2470,8 @@ umass_cam_action(struct cam_sim *sim, union ccb *ccb)
ccg->secs_per_track = 32;
}
secs_per_cylinder = ccg->heads * ccg->secs_per_track;
- ccg->cylinders = ccg->volume_size / secs_per_cylinder;
+ ccg->cylinders = (ccg->volume_size + secs_per_cylinder - 1) /
+ secs_per_cylinder;
ccb->ccb_h.status = CAM_REQ_CMP;
xpt_done(ccb);
@@ -2606,7 +2611,7 @@ umass_cam_sense_cb(struct umass_softc *sc, void *priv, int residue, int status)
/* Getting sense data always succeeds (apart from wire
* failures).
*/
- if (sc->quirks & RS_NO_CLEAR_UA
+ if ((sc->quirks & RS_NO_CLEAR_UA)
&& csio->cdb_io.cdb_bytes[0] == INQUIRY
&& (csio->sense_data.flags & SSD_KEY)
== SSD_KEY_UNIT_ATTENTION) {
@@ -2622,21 +2627,26 @@ umass_cam_sense_cb(struct umass_softc *sc, void *priv, int residue, int status)
* CCI)
*/
ccb->ccb_h.status = CAM_REQ_CMP;
- } else if ((sc->quirks & RS_NO_CLEAR_UA) && /* XXX */
+ } else if ((sc->quirks & RS_NO_CLEAR_UA) &&
(csio->cdb_io.cdb_bytes[0] == READ_CAPACITY) &&
((csio->sense_data.flags & SSD_KEY)
== SSD_KEY_UNIT_ATTENTION)) {
-
- /* Some devices do not clear the unit attention error
+ /*
+ * Some devices do not clear the unit attention error
* on request sense. We insert a test unit ready
* command to make sure we clear the unit attention
- * condition.
+ * condition, then allow the retry to proceed as
+ * usual.
*/
ccb->ccb_h.status = CAM_SCSI_STATUS_ERROR
| CAM_AUTOSNS_VALID;
csio->scsi_status = SCSI_STATUS_CHECK_COND;
+#if 0
+ DELAY(300000);
+#endif
+
DPRINTF(UDMASS_SCSI,("%s: Doing a sneaky"
"TEST_UNIT_READY\n",
USBDEVNAME(sc->sc_dev)));
@@ -2675,6 +2685,11 @@ umass_cam_sense_cb(struct umass_softc *sc, void *priv, int residue, int status)
}
}
+/*
+ * This completion code just handles the fact that we sent a test-unit-ready
+ * after having previously failed a READ CAPACITY with CHECK_COND. Even
+ * though this command succeeded, we have to tell CAM to retry.
+ */
Static void
umass_cam_quirk_cb(struct umass_softc *sc, void *priv, int residue, int status)
{
@@ -2682,7 +2697,12 @@ umass_cam_quirk_cb(struct umass_softc *sc, void *priv, int residue, int status)
DPRINTF(UDMASS_SCSI, ("%s: Test unit ready returned status %d\n",
USBDEVNAME(sc->sc_dev), status));
+#if 0
ccb->ccb_h.status = CAM_REQ_CMP;
+#endif
+ ccb->ccb_h.status = CAM_SCSI_STATUS_ERROR
+ | CAM_AUTOSNS_VALID;
+ ccb->csio.scsi_status = SCSI_STATUS_CHECK_COND;
xpt_done(ccb);
}
OpenPOWER on IntegriCloud