[RFC 4/9] UAS: Handle cancellation of status URB.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If the status URB has been canceled, make sure to let the SCSI core know
that the command was aborted.  Also make sure to clear the current UAS
untagged command if its status URB was canceled.  Otherwise the SCSI
core will never be able to submit another untagged command.

This doesn't handle other types of URB errors (short packet, stall, etc)
because I don't know how to handle those yet.

Signed-off-by: Sarah Sharp <sarah.a.sharp@xxxxxxxxxxxxxxx>
Cc: Matthew Wilcox <willy@xxxxxxxxxxxxxxx>
---
 drivers/usb/storage/uas.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index 9dd4aae..eda5f1d 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -235,12 +235,6 @@ static void uas_stat_cmplt(struct urb *urb)
 	struct scsi_cmnd *cmnd;
 	u16 tag;
 
-	if (urb->status) {
-		dev_err(&urb->dev->dev, "URB BAD STATUS %d\n", urb->status);
-		usb_free_urb(urb);
-		return;
-	}
-
 	tag = be16_to_cpup(&iu->tag) - 1;
 	if (sdev->current_cmnd)
 		cmnd = sdev->current_cmnd;
@@ -251,6 +245,16 @@ static void uas_stat_cmplt(struct urb *urb)
 		return;
 	}
 
+	/* If the URB was canceled (by either SCSI layer or reset device). */
+	if (urb->status == -ECONNRESET || urb->status == -ENOENT)
+		goto task_abort;
+	/* FIXME: handle other URB error cases too */
+	if (urb->status) {
+		dev_err(&urb->dev->dev, "URB BAD STATUS %d\n", urb->status);
+		usb_free_urb(urb);
+		return;
+	}
+
 	switch (iu->iu_id) {
 	case IU_ID_STATUS:
 		if (urb->actual_length < 16)
@@ -270,6 +274,15 @@ static void uas_stat_cmplt(struct urb *urb)
 		scmd_printk(KERN_ERR, cmnd,
 			"Bogus IU (%d) received on status pipe\n", iu->iu_id);
 	}
+	return;
+
+task_abort:
+	cmnd->result = SAM_STAT_TASK_ABORTED;
+	if (sdev->current_cmnd)
+		sdev->current_cmnd = NULL;
+	cmnd->scsi_done(cmnd);
+	usb_free_urb(urb);
+	return;
 }
 
 static void uas_data_cmplt(struct urb *urb)
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux