From: Luben Tuikov <ltuikov@yahoo.com>
To: Greg KH <greg@kroah.com>,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org
Subject: [PATCH 3/4] [USB] UASP: Reorganize stream id assignment
Date: Wed, 8 Dec 2010 15:56:22 -0800 (PST) [thread overview]
Message-ID: <721095.19643.qm@web31806.mail.mud.yahoo.com> (raw)
If the host controller reports more streams than
it actually supports and the device goes into flow
control due to an unsupported stream id, we can
now send a TMF with a stream id that the host
controller can handle.
Signed-off-by: Luben Tuikov <ltuikov@yahoo.com>
---
drivers/usb/storage/uasp.c | 35 ++++++++++++++++++++---------------
1 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/drivers/usb/storage/uasp.c b/drivers/usb/storage/uasp.c
index e5a26e9..40ee5a4 100644
--- a/drivers/usb/storage/uasp.c
+++ b/drivers/usb/storage/uasp.c
@@ -43,6 +43,10 @@ MODULE_PARM_DESC(MaxNumStreams, "\n"
"\tattached device and this value. Valid values are -1, default,\n"
"\tand 1 to 0xFFEF.");
+#define TMF_TAG 1
+#define CMD_UNTAGGED_TAG 2
+#define CMD_TAG_OFFS 3
+
/* Information unit types
*/
#define IU_CMD 1
@@ -189,7 +193,7 @@ static void uasp_sense(struct urb *urb, struct scsi_cmnd *cmd, u16 tag)
memcpy(cmd->sense_buffer, iu + IU_SENSE_LEN, slen);
}
- if (tag == 1)
+ if (tag == CMD_UNTAGGED_TAG)
sdev->current_cmnd = NULL;
cmd->scsi_done(cmd);
usb_free_urb(urb);
@@ -267,10 +271,10 @@ static void uasp_stat_done(struct urb *urb)
return;
}
- if (tag == 1)
+ if (tag == CMD_UNTAGGED_TAG)
cmd = sdev->current_cmnd;
- else if (tag > 1)
- cmd = scsi_find_tag(sdev, tag-2);
+ else if (tag >= CMD_TAG_OFFS)
+ cmd = scsi_find_tag(sdev, tag - CMD_TAG_OFFS);
if (cmd == NULL)
goto Out_no_cmd;
@@ -583,10 +587,10 @@ static int uasp_queuecommand(struct scsi_cmnd *cmd,
* regardless of how many tags it supports.
*/
if (blk_rq_tagged(cmd->request)) {
- cmdinfo->tag = cmd->request->tag + 2;
+ cmdinfo->tag = cmd->request->tag + CMD_TAG_OFFS;
} else if (sdev->current_cmnd == NULL) {
sdev->current_cmnd = cmd;
- cmdinfo->tag = 1;
+ cmdinfo->tag = CMD_UNTAGGED_TAG;
} else {
cmd->result = DID_ABORT << 16;
goto Out_err;
@@ -643,7 +647,7 @@ static int uasp_alloc_tmf_urb(struct urb **urb, struct uasp_tport_info *tpinfo,
* it for their own use, as well as being able to free it back
* later. See the comment in uasp_set_max_cmds().
*/
- tag = tpinfo->max_cmds + 2;
+ tag = TMF_TAG;
tiu[0] = IU_TMF;
tiu[2] = tag >> 8;
@@ -765,9 +769,9 @@ static int uasp_er_tmf(struct scsi_cmnd *cmd, u8 tmf)
int res;
if (sdev->current_cmnd == cmd)
- tag = 1;
+ tag = CMD_UNTAGGED_TAG;
else
- tag = cmd->request->tag + 2;
+ tag = cmd->request->tag + CMD_TAG_OFFS;
res = uasp_do_tmf(cmd, tmf, tag);
@@ -888,12 +892,13 @@ static int uasp_set_max_cmds(struct uasp_tport_info *tpinfo)
{
int mc;
- /* The range of tags generated by the block layer would be
- * [0, max_cmds-1], which is [0, num_streams-3]. Now reserve
- * stream 1 for untagged commands submitted to us and the last
- * usable stream id for a TMF to get the following stream id
- * assignment:
- * [1:untagged, [2, num_streams-1]:tagged, num_streams:TMF].
+ /* Define the following cmd tag assignment:
+ * [1:TMF, 2:untagged, [3, num_streams]:tagged].
+ * Thus there are num_streams-3+1 = num_streams-2 tags
+ * for tagged commands. Report this number to the SCSI Core
+ * as the number of maximum commands we can queue, thus
+ * giving us a tag range [0, num_streams-3], which we
+ * offset by 3 (CMD_TAG_OFFS).
*/
mc = tpinfo->num_streams - 2;
if (mc <= 0) {
--
1.7.0.1
reply other threads:[~2010-12-08 23:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=721095.19643.qm@web31806.mail.mud.yahoo.com \
--to=ltuikov@yahoo.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@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
Powered by JetHome