From patchwork Thu May 17 06:59:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Nimkar X-Patchwork-Id: 10405625 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0C93D60155 for ; Thu, 17 May 2018 06:59:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF8BE2862A for ; Thu, 17 May 2018 06:59:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3CCF286E6; Thu, 17 May 2018 06:59:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B3A82862A for ; Thu, 17 May 2018 06:59:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752081AbeEQG7p (ORCPT ); Thu, 17 May 2018 02:59:45 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:37096 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751916AbeEQG7m (ORCPT ); Thu, 17 May 2018 02:59:42 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 5F79C60F5F; Thu, 17 May 2018 06:59:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1526540382; bh=2zK5hnxceJKRxCh3Yzj0Q+1spkTKUm+t4Wy+5JpN0yc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=RoUwPzKhHREbEG85Ah7rg8lDD+elVCKTr6rtRc9JKLBMLg9TScW8yJ7+lZMCDqRba esBBu4rHKwTCCR1Z7JVc2CauhCL1iLcYy4ZXAPSMuHrSfjTxGG2BJSps7XTXgAJN+R rF02/a/o4kJQ1JTD+MTbhvxrUCrYOz+q+u+1V9NQ= Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 0A26860881; Thu, 17 May 2018 06:59:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1526540381; bh=2zK5hnxceJKRxCh3Yzj0Q+1spkTKUm+t4Wy+5JpN0yc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Zq4izcASZThZ9JQB9ujnQBZekyrRQRHEM184zvTPs+HVnCEkaTw57rmPgOyEaEx1X RMnH0l5BsmEUELrVDlgBqXpvI7ao4VfSd6ly3ZTYizRW9KSgYNDHEKH9atbcnzdTI+ lMFhySuh9bMWzd9YG/NqRjtCd3BBEp+tclzBXb+o= MIME-Version: 1.0 Date: Thu, 17 May 2018 12:29:40 +0530 From: Tushar Nimkar To: Oliver Neukum , Felipe Balbi , Greg KH , AlanStern Cc: linux-usb-owner@vger.kernel.org, Tushar Nimkar , Mathias Nyman , linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org Subject: Re: Fwd: usb: uas: device reset most the time while enumeration- usb3.0 In-Reply-To: <1524561149.13236.6.camel@suse.com> References: <1523889203.19283.18.camel@suse.com> <1524127532.24964.1.camel@suse.com> <5723f5424a91d439a04f672be79dd629@codeaurora.org> <1524487818.23725.21.camel@suse.com> <21f3a53bc2af197a79ded0ddbb239e8c@codeaurora.org> <1524561149.13236.6.camel@suse.com> Message-ID: <848b9bcb5da146ae8953148ba3d5254a@codeaurora.org> X-Sender: tnimkar@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi All, On 2018-04-24 14:42, Oliver Neukum wrote: > Am Montag, den 23.04.2018, 18:35 +0530 schrieb Tushar Nimkar: >> hi, >> >> On 2018-04-23 18:20, Oliver Neukum wrote: >> > Am Donnerstag, den 19.04.2018, 20:18 +0530 schrieb Tushar Nimkar: > >> > No. But for testing we don't need to. Can you confirm that >> > the problem is triggered by specific commands? >> >> Observed with REPORT_LUN or READ_CAP16 or INQUIRY command. > > Well, that is not the same thing. It is possible that these commands > generally fail, but x86_64 has a working error handling but ARM does > not. > >> Are you planning to test it with dwc3? > > No, I am sorry. I would need to acquire some very specific hardware. > > Regards > Oliver > > -- > To unsubscribe from this list: send the line "unsubscribe linux-usb" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html Please have look on the proposed fix for the slow enumeration and reset issue for UAS devices(after SD_TIMEOUT). Fix for : ... [ 123.672358] usb 2-1: new SuperSpeed USB device number 2 using xhci-hcd [ 123.711940] scsi host0: uas [ 123.867378] scsi 0:0:0:0: Direct-Access Samsung Portable SSD T3 0 PQ: 0 ANSI: 6 [ 155.132319] sd 0:0:0:0: tag#1 uas_eh_abort_handler 0 uas-tag 2 inflight: CMD IN [ 155.132359] sd 0:0:0:0: tag#1 CDB: opcode=0x9e, sa=0x10 9e 10 00 00 00 00 00 00 00 00 00 00 00 20 00 00 [ 155.138868] scsi host0: uas_eh_device_reset_handler start ... If changes seems fine will push this patch to upstream : ) Issue is mostly occurring while we issue the READ_CAPACITY_16 or REPORT_LUNS or INQ commands. I have confirm this with USB analyzer too. But issue is not in those commands(they are supported) Also which mean there is no problem in scanning lun with REPORT_LUN or older sequential scan, which I was suspecting the issue cause. Those commands issued from different layers say: sd.. uas.. scsi.. so making them to go one after other. Once REPORT_LUN done go with READ_CAPACITY_16. This is only for the UAS devices. I believe no disturb to BOT behavior. so far tested with two UAS SSDs dwc3 as host controller with 3.00a as version 1) StoreJet TS256GESD400K 2) Samsung Portable SSD T3 Draft Patch : --- drivers/scsi/sd.c | 8 ++++++++ drivers/usb/storage/scsiglue.c | 1 + drivers/usb/storage/uas.c | 6 ++++++ include/scsi/scsi_host.h | 6 ++++++ 4 files changed, 21 insertions(+) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 78430ef..38c23ad 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2979,6 +2979,14 @@ static void sd_probe_async(void *data, async_cookie_t cookie) struct device *dev; sdp = sdkp->device; + + /* + * Continue async probe once host scanning is finished + * this is only for uas devices + */ + if (sdp->host->hostt->is_uas) + wait_for_completion_interruptible_timeout(&sdp->host->hscan_done, + msecs_to_jiffies(500)); gd = sdkp->disk; index = sdkp->index; dev = &sdp->sdev_gendev; diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index dba5136..fbd397a 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c @@ -594,6 +594,7 @@ void usb_stor_host_template_init(struct scsi_host_template *sht, sht->name = name; sht->proc_name = name; sht->module = owner; + sht->is_uas = false; /* BOT device */ } EXPORT_SYMBOL_GPL(usb_stor_host_template_init); diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index f952635..ead73d0 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -44,6 +44,7 @@ struct uas_dev_info { unsigned use_streams:1; unsigned shutdown:1; struct scsi_cmnd *cmnd[MAX_CMNDS]; + struct Scsi_Host *shost; spinlock_t lock; struct work_struct work; }; @@ -828,6 +829,7 @@ static struct scsi_host_template uas_host_template = { .this_id = -1, .sg_tablesize = SG_NONE, .skip_settle_delay = 1, + .is_uas = true, }; #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \ @@ -934,11 +936,13 @@ static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id) devinfo->resetting = 0; devinfo->shutdown = 0; devinfo->flags = dev_flags; + devinfo->shost = shost; init_usb_anchor(&devinfo->cmd_urbs); init_usb_anchor(&devinfo->sense_urbs); init_usb_anchor(&devinfo->data_urbs); spin_lock_init(&devinfo->lock); INIT_WORK(&devinfo->work, uas_do_work); + init_completion(&shost->hscan_done); result = uas_configure_endpoints(devinfo); if (result) @@ -956,6 +960,8 @@ static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id) goto free_streams; scsi_scan_host(shost); + /* once scsi_host_scan done, let others to do their stuffs */ + complete(&shost->hscan_done); return result; free_streams: diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index fcfa3d7..b7d27a8 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -498,6 +498,9 @@ struct scsi_host_template { /* temporary flag to disable blk-mq I/O path */ bool disable_blk_mq; + + /* let the host know the device is BOT or UAS */ + bool is_uas; }; /* @@ -564,6 +567,9 @@ struct Scsi_Host { struct scsi_host_template *hostt; struct scsi_transport_template *transportt; + /* tell other's that host scan is done */ + struct completion hscan_done; + /* * Area to keep a shared tag map (if needed, will be * NULL if not).