scsi: ten -> use_10_for_rw / use_10_for_ms
PATCH 1/1 scsi: ten -> use_10_for_rw / use_10_for_ms
In the old days, ancient scsi devices understood 6-byte commands and more recent ones also understood 10-byte commands. Thus, we had a "ten" flag indicating that 10-byte commands worked.
These days, especially for usb-storage devices, the opposite sometimes holds - 10-byte commands are supported, but 6-byte commands are not.
The patch below changes the field ten into the pair of fields use_10_for_rw, use_10_for_ms set initially when the driver thinks these are supported. Ifthe device returns ILLEGAL_REQUEST they are cleared.
This patch obsoletes a large amount of code in usb-storage, and not only that, once the subsequent patch removes all this usb-storage code many devices will work that hang today.
Andries
drivers/scsi/scsi.h +11 -13
@@ -383,9 +383,10 @@* time. */ unsigned was_reset:1; /* There was a bus reset on the bus for* this device */ - unsigned expecting_cc_ua:1; /* Expecting a CHECK_CONDITION/UNIT_ATTN -* because we did a bus reset. */ - unsigned ten:1; /* support ten byte read / write */ + unsigned expecting_cc_ua:1; /* Expecting a CHECK_CONDITION/UNIT_ATTN +* because we did a bus reset. */ + unsigned use_10_for_rw:1; /* first try 10-byte read / write */ + unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */ unsigned remap:1; /* support remapping */// unsigned sync:1; /* Sync transfer state, managed by host */ // unsigned wide:1; /* WIDE transfer state, managed by host */
@@ -402,10 +403,6 @@ container_of(d, struct scsi_device, sdev_driverfs_dev) -/* -* The Scsi_Cmnd structure is used by scsi.c internally, and for communication -* with low level drivers that support multiple outstanding commands. - */ typedef struct scsi_pointer { char *ptr; /* data pointer */ int this_residual; /* left in this buffer */
@@ -458,12 +455,13 @@ };/* -* FIXME(eric) - one of the great regrets that I have is that I failed to define -* these structure elements as something like sc_foo instead of foo. This would -* make it so much easier to grep through sources and so forth. I propose that -* all new elements that get added to these structures follow this convention. -* As time goes on and as people have the stomach for it, it should be possible to -* go back and retrofit at least some of the elements here with with the prefix. +* FIXME(eric) - one of the great regrets that I have is that I failed to +* define these structure elements as something like sc_foo instead of foo. +* This would make it so much easier to grep through sources and so forth. +* I propose that all new elements that get added to these structures follow +* this convention. As time goes on and as people have the stomach for it, +* it should be possible to go back and retrofit at least some of the elements +* here with with the prefix. */ struct scsi_cmnd {int sc_magic;
drivers/scsi/scsi_lib.c +10 -8
@@ -662,7 +662,6 @@* * b) We can just use scsi_requeue_command() here. This would * be used if we just wanted to retry, for example. -* */ void scsi_io_completion (struct scsi_cmnd *cmd,int good_sectors,int block_sectors)
@@ -796,17 +795,20 @@ } } } -/* If we had an ILLEGAL REQUEST returned, then we may have -* performed an unsupported command. The only thing this should be -* would be a ten byte read where only a six byte read was supported. -* Also, on a system where READ CAPACITY failed, we have have read -* past the end of the disk. +/* +* If we had an ILLEGAL REQUEST returned, then we may have +* performed an unsupported command. The only thing this +* should be would be a ten byte read where only a six byte +* read was supported. Also, on a system where READ CAPACITY +* failed, we may have read past the end of the disk. */ switch (cmd->sense_buffer[2 ]) {case ILLEGAL_REQUEST : -if (cmd->device->ten) { - cmd->device->ten =0 ; +if (cmd->device->use_10_for_rw && + (cmd->cmnd[0 ] ==READ_10 || + cmd->cmnd[0 ] ==WRITE_10 )) { + cmd->device->use_10_for_rw =0 ;/* * This will cause a retry with a 6-byte * command.
drivers/scsi/sd.c +38 -20
135 lines not on this page · raw message
drivers/scsi/sr.c +2 -1
@@ -559,7 +559,8 @@sprintf (cd->cdi.name,"sr%d" , minor); sdev->sector_size =2048 ;/* A guess, just in case */ - sdev->ten =1 ; + sdev->use_10_for_rw =1 ; + sdev->use_10_for_ms =0 ; sdev->remap =1 ;/* FIXME: need to handle a get_capabilities failure properly ?? */
Quoted 8 lines · On Fri, May 23, 2003 at 09:22:44AM +0200, [email protected] wrote:
In the old days, ancient scsi devices understood 6-byte commands and more recent ones also understood 10-byte commands. Thus, we had a "ten" flag indicating that 10-byte commands worked.
These days, especially for usb-storage devices, the opposite sometimes holds - 10-byte commands are supported, but 6-byte commands are not.
Quoted 8 lines
The patch below changes the field ten into the pair of fields
use_10_for_rw,use_10_for_msset initially when the driver thinks these are supported. Ifthe device returnsILLEGAL_REQUESTthey are cleared.This patch obsoletes a large amount of code in usb-storage, and not only that, once the subsequent patch removes all this usb-storage code many devices will work that hang today.
Any idea when you'll submit that patch to usb-storage?
Do you perhaps just want to send what you have to me for integration?
Matt
Signature · 7 lines
Matthew Dharm Home: [email protected] Maintainer, Linux USB Mass Storage Driver Sir, for the hundreth time, we do NOT carry 600-round boxes of belt-fed suction darts! -- Salesperson to Greg User Friendly, 12/30/1997