updates to UAS
Subsystems (3)
Oliver Neukum
maintainerPATCH v2 1/1 updates to UAS
The first patch fixes a corner case where a whole tree of devices is removed and I got a report of a live lock
The second patch just modernizes to new helpers. No functional change intended
v2: reversed order of patches so the first patch can cleanly go into the stable series
Oliver Neukum
maintainerPATCH 1/2 UAS: fix disconnect by unplugging a hub
The SCSI layer can go into an ugly loop if you ignore that a device is gone. You need to report an error in the command rather than in the return value of the queue method.
We need to specifically check for ENODEV. The issue goes back to the introduction of the driver.
v2: reorder patches
--- drivers/usb/storage/uas.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/usb/storage/uas.c +12 -2
@@ -662,8 +662,7 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd,if (devinfo->resetting) { cmnd->result =DID_ERROR <<16 ; cmnd->scsi_done (cmnd); -spin_unlock_irqrestore (&devinfo->lock, flags); -return 0 ; + goto zombie; }/* Find a free uas-tag */
@@ -699,6 +698,16 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd, cmdinfo->state &= ~(SUBMIT_DATA_IN_URB |SUBMIT_DATA_OUT_URB ); err =uas_submit_urbs (cmnd, devinfo); +/* +* in case of fatal errors the SCSI layer is peculiar +* a command that has finished is a success for the purpose +* of queueing, no matter how fatal the error +*/ +if (err == -ENODEV ) { + cmnd->result =DID_ERROR <<16 ; + cmnd->scsi_done (cmnd); + goto zombie; + }if (err) {/* If we did nothing, give up now */ if (cmdinfo->state &SUBMIT_STATUS_URB ) {
@@ -709,6 +718,7 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd, } devinfo->cmnd[idx] = cmnd; +zombie:spin_unlock_irqrestore (&devinfo->lock, flags);return 0 ; }
Signature · 1 line
2.16.4
Oliver Neukum
maintainerPATCH 2/2 UAS: use macro for reporting results
In reply to Oliver NeukumThe SCSI layer has introduced a new macro for recording the result of a command. Use it.
v2: reorder patches
--- drivers/usb/storage/uas.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/usb/storage/uas.c +6 -6
@@ -279,17 +279,17 @@ static bool uas_evaluate_response_iu(struct response_iu *riu, struct scsi_cmnd *switch (response_code) {case RC_INCORRECT_LUN : - cmnd->result =DID_BAD_TARGET <<16 ; +set_host_byte (cmnd,DID_BAD_TARGET );break ;case RC_TMF_SUCCEEDED : - cmnd->result =DID_OK <<16 ; +set_host_byte (cmnd,DID_OK );break ;case RC_TMF_NOT_SUPPORTED : - cmnd->result =DID_TARGET_FAILURE <<16 ; +set_host_byte (cmnd,DID_TARGET_FAILURE );break ;default :uas_log_cmd_state (cmnd,"response iu" , response_code); - cmnd->result =DID_ERROR <<16 ; +set_host_byte (cmnd,DID_ERROR );break ; }
@@ -660,7 +660,7 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd,spin_lock_irqsave (&devinfo->lock, flags);if (devinfo->resetting) { - cmnd->result =DID_ERROR <<16 ; +set_host_byte (cmnd,DID_ERROR ); cmnd->scsi_done (cmnd); goto zombie; }
@@ -704,7 +704,7 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd,* of queueing, no matter how fatal the error */ if (err == -ENODEV ) { - cmnd->result =DID_ERROR <<16 ; +set_host_byte (cmnd,DID_ERROR ); cmnd->scsi_done (cmnd); goto zombie; }
Signature · 1 line
2.16.4