public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vishal Annapurve <vannapurve@nvidia.com>
To: <linux-kernel@vger.kernel.org>
Subject: [PATCH] usb-storage: scsiglue: Changing the command result
Date: Thu, 26 Sep 2013 17:05:59 +0530	[thread overview]
Message-ID: <52441C1F.8020200@nvidia.com> (raw)
In-Reply-To: <52441AA7.9070300@nvidia.com>

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

Hi,

There was a recent commit in mainline for the scsi devices which do not
respond properly to medium access command:

commit    18a4d0a22ed6c54b67af7718c305cd010f09ddf8

[SCSI] Handle disk devices which can not process medium access commands
We have experienced several devices which fail in a fashion we do not
currently handle gracefully in SCSI. After a failure these devices will
respond to the SCSI primary command set (INQUIRY, TEST UNIT READY, etc.)
but any command accessing the storage medium will time out.

I came across a USB drive which showed similar problem and what I see is
usb storage is still not able to cope with such devices properly.

The control flow downwards is like:
scsi_times_out --> Setting cmd->result as DID_TIME_OUT
scsi_error_handler
scsi_unjam_host
scsi_eh_abort_cmds
command_abort    (sets US_FLIDX_TIMED_OUT for us->dflags
                                   calls stop_transport,
                                   and waits for)    usb_stor_control_thread (which is waiting for
                                                                    transport call to return inside
                                                                    usb_stor_invoke_transport)
                                                                    both usb_stor_control_thread and
                                                                    usb_stor_invoke_transport
                                                     check for us->dflags timed_out bit and
                                                      set the result as DID_ABORT
                                                      and signal completion for command_abort
                                                      to complete
......
sd_eh_action
checks for cmd->result and finds out that it's DID_ABORT rather than
DID_TIME_OUT.

This patch updates the command result to be TIME_OUT explicitly before
returning from command_abort in scsiglue.c.

I would like to know if this patch can work out for such USB Storage
devices? What would be the better way to do the same?


Regards,
Vishal Annapurve




[-- Attachment #2: usb_storage_scsi_medium_access_timeout.patch --]
[-- Type: text/x-patch, Size: 1147 bytes --]

From: Vishal Annapurve <vannapurve@nvidia.com>
Subject: [PATCH] usb-storage: Changing the command result

This change updates the returned result to scsi layer to use
DID_TIMEOUT flag as a result status rather than DID_ABORT for
commands aborted due to timeout.

Signed-off-by: Vishal Annapurve <vannapurve@nvidia.com>
---
 drivers/usb/storage/scsiglue.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index a74e9d8..e7b532e 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -353,6 +353,15 @@ static int command_abort(struct scsi_cmnd *srb)
 
 	/* Wait for the aborted command to finish */
 	wait_for_completion(&us->notify);
+	/* Given that this bit would be only set in case of timedout
+	 * command, we can return with DID_TIME_OUT, as scsi layer needs
+	 * to use this result rather than DID_ABORT.
+	 * This is a WR to avoid removing DID_ABORT altogether
+	 * and before the final control goes to scsi layer change the
+	 * result to be timedout.
+	 */
+	us->srb->result = DID_TIME_OUT << 16;
+
 	return SUCCESS;
 }
 
-- 
1.8.4



       reply	other threads:[~2013-09-26 11:36 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <52441AA7.9070300@nvidia.com>
2013-09-26 11:35 ` Vishal Annapurve [this message]
2013-10-15  7:29   ` [PATCH] usb-storage: scsiglue: Changing the command result Ming Lei
2013-10-15 15:54     ` Alan Stern
2013-10-15 16:29       ` Vishal Annapurve
2013-10-15 17:02         ` Alan Stern
2013-10-15 17:53           ` Vishal Annapurve
2013-10-15 20:22             ` Alan Stern
2013-10-16  0:40               ` Ming Lei
2013-10-16 14:39                 ` Alan Stern
2013-10-18  5:38               ` Vishal Annapurve
2013-10-18 14:10                 ` Alan Stern
2013-10-19 11:32                   ` Vishal Annapurve
2013-10-21 17:23                     ` Alan Stern
2013-10-26 15:49                       ` Vishal Annapurve
2013-10-26 19:33                         ` Alan Stern
2013-10-27  3:33                           ` Greg KH
2013-11-16  6:53 Vishal Annapurve
2013-11-18 15:08 ` Alan Stern
2013-12-09  1:59 ` Greg KH
2013-12-09  9:44   ` Vishal Annapurve
2013-12-09  9:55     ` Oliver Neukum
2013-12-09 11:23     ` Greg KH
2013-12-10  5:23       ` Vishal Annapurve
2013-12-10  5:55         ` Greg KH
2013-12-10 11:37           ` Vishal Annapurve
  -- strict thread matches above, loose matches on Subject: below --
2013-11-16  6:55 Vishal Annapurve
2013-11-16  6:55 Vishal Annapurve

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52441C1F.8020200@nvidia.com \
    --to=vannapurve@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox