RE: [usb-storage] [Merging ATA passthru] on integrating SMART/ATA-Security in usb-storage driver

Timothy Thelin
2005-11-08T19:50:53Z

[-- Attachment #1: Type: text/plain, Size: 2441 bytes --]

> On Mon, 7 Nov 2005, James Bottomley wrote:
>
> > > It's quite possible that usb-storage no longer needs to force the
> > > scsi-level to 2. No one has recently tested what would
> happen without
> > > it. Matt probably has the best selection of devices for
> testing...
> > >
> > > There is one problem we have with devices that report
> themselves as SCSI-3
> > > or SCSI-4 but hang when they receive a REPORT LUNS
> command. That's easily
> > > handled by making usb-storage set the NOREPORTLUN flag.
> Maybe that's all
> > > we need to do.
> >
> > If you could try this out, I'd be grateful.
>
> I tried the patch below on several combinations of SCSI
> levels and device
> types. It seems to do exactly what we want; for reads I always saw
> READ(10) and for MODE SENSE I saw either the 6- or 10-byte
> form, depending
> on the device type and USB subclass value.
>
> The question remains whether pass-thru will now work and
> whether the patch
> will mess up some existing non-compliant device that
> currently works okay.
> The only way to know is by trying it out. Matt and Timothy,
> that's up to
> you.
>
> Alan Stern
>

I did some initial testing on Alan's patch with a sandisk cruzer
mini thumb drive (level 2), a memorex thumb drive (level 0),
and that cypress part (level 0), and I haven't seen any IO
problems.

After that I made another patch (below and attached because
of wrapping) you can apply after Alan's that disables cdb mangling
on level 0 devices. It was generated against Linus' git repo after
applying Alan's patch.

With both patches applied I can now do passthru cdbs on the
cypress part without issue, and I still don't see any IO issues.

Anyone out there have a better selection of hardware to test with?

Signed-off-by: Timothy Thelin <timothy.thelin@wdc.com>

---

diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -569,9 +569,10 @@ int scsi_dispatch_cmd(struct scsi_cmnd *
}

/*
- * If SCSI-2 or lower, store the LUN value in cmnd.
+ * If SCSI-2 or lower (except SCSI-0), store the LUN value in cmnd.
*/
- if (cmd->device->scsi_level <= SCSI_2) {
+ if (cmd->device->scsi_level != SCSI_UNKNOWN &&
+ cmd->device->scsi_level <= SCSI_2) {
cmd->cmnd[1] = (cmd->cmnd[1] & 0x1f) |
(cmd->device->lun << 5 & 0xe0);
}

[-- Attachment #2: scsi-level-0-aware.patch --]
[-- Type: application/octet-stream, Size: 532 bytes --]

diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -569,9 +569,10 @@ int scsi_dispatch_cmd(struct scsi_cmnd *
}

/*
- * If SCSI-2 or lower, store the LUN value in cmnd.
+ * If SCSI-2 or lower (except SCSI-0), store the LUN value in cmnd.
*/
- if (cmd->device->scsi_level <= SCSI_2) {
+ if (cmd->device->scsi_level != SCSI_UNKNOWN &&
+ cmd->device->scsi_level <= SCSI_2) {
cmd->cmnd[1] = (cmd->cmnd[1] & 0x1f) |
(cmd->device->lun << 5 & 0xe0);
}