From patchwork Fri Apr 27 09:31:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 155402 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 6638FB6F9D for ; Fri, 27 Apr 2012 19:32:21 +1000 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SNhXB-0005Wv-6p; Fri, 27 Apr 2012 09:32:13 +0000 Received: from mail-pb0-f49.google.com ([209.85.160.49]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SNhX9-0005Vt-7n for kernel-team@lists.ubuntu.com; Fri, 27 Apr 2012 09:32:11 +0000 Received: by mail-pb0-f49.google.com with SMTP id rq13so764954pbb.8 for ; Fri, 27 Apr 2012 02:32:10 -0700 (PDT) Received: by 10.68.227.134 with SMTP id sa6mr8643521pbc.101.1335519130798; Fri, 27 Apr 2012 02:32:10 -0700 (PDT) Received: from localhost ([183.37.200.43]) by mx.google.com with ESMTPS id l1sm5960737pbe.54.2012.04.27.02.32.08 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 27 Apr 2012 02:32:09 -0700 (PDT) From: ming.lei@canonical.com To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/6] UAS: Use unique tags on non-streams devices. Date: Fri, 27 Apr 2012 17:31:44 +0800 Message-Id: <1335519112-8372-3-git-send-email-ming.lei@canonical.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1335519112-8372-1-git-send-email-ming.lei@canonical.com> References: <1335519112-8372-1-git-send-email-ming.lei@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com From: Sarah Sharp UAS can work with either USB 3.0 devices that support bulk streams, or USB 2.0 devices that do not support bulk streams. When we're working with a non-streams device, we need to be able to uniquely identify a SCSI command with a tag in the IU. Devices will barf and abort all queued commands if they find a duplicate tag. uas_queuecommand_lck() sets cmdinfo->stream to zero if the device doesn't support streams, which is later passed into uas_alloc_cmd_urb() as the variable stream. This means the UAS driver was setting the tag in all commands to zero for non-stream devices. So the UAS driver won't currently work with USB 2.0 devices. Use the SCSI command tag instead of the stream ID for the command IU tag. We have to add one to the SCSI command tag because SCSI tags are zero-based, but stream IDs are one-based, and the command tag must match the stream ID that we're queueing the data IUs for. Untagged SCSI commands use stream ID 1. Signed-off-by: Sarah Sharp Cc: Matthew Wilcox Signed-off-by: Sebastian Andrzej Siewior --- drivers/usb/storage/uas.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index 4bbaf6e..28d9b19 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -343,7 +343,10 @@ static struct urb *uas_alloc_cmd_urb(struct uas_dev_info *devinfo, gfp_t gfp, goto free; iu->iu_id = IU_ID_COMMAND; - iu->tag = cpu_to_be16(stream_id); + if (blk_rq_tagged(cmnd->request)) + iu->tag = cpu_to_be16(cmnd->request->tag + 1); + else + iu->tag = cpu_to_be16(1); iu->prio_attr = UAS_SIMPLE_TAG; iu->len = len; int_to_scsilun(sdev->lun, &iu->lun);