From patchwork Wed Nov 4 20:48:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 56009 Delivered-To: patch@linaro.org Received: by 10.112.61.134 with SMTP id p6csp22419lbr; Wed, 4 Nov 2015 12:48:41 -0800 (PST) X-Received: by 10.68.226.41 with SMTP id rp9mr4495704pbc.55.1446670121436; Wed, 04 Nov 2015 12:48:41 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xx1si4439166pbc.232.2015.11.04.12.48.41; Wed, 04 Nov 2015 12:48:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965415AbbKDUsj (ORCPT + 4 others); Wed, 4 Nov 2015 15:48:39 -0500 Received: from comal.ext.ti.com ([198.47.26.152]:40924 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965746AbbKDUsh (ORCPT ); Wed, 4 Nov 2015 15:48:37 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id tA4KmaMK001717; Wed, 4 Nov 2015 14:48:36 -0600 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id tA4KmZbP031895; Wed, 4 Nov 2015 14:48:35 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.224.2; Wed, 4 Nov 2015 14:48:35 -0600 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id tA4KmYsb010001; Wed, 4 Nov 2015 14:48:35 -0600 From: Felipe Balbi To: Linux USB Mailing List CC: Alan Stern , Matthew Dharm , Felipe Balbi Subject: [RFC PATCH 2/2] usb: storage: scsiglue: limit USB3 devices to 2048 sectors Date: Wed, 4 Nov 2015 14:48:32 -0600 Message-ID: <1446670112-29088-2-git-send-email-balbi@ti.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1446670112-29088-1-git-send-email-balbi@ti.com> References: <1446670112-29088-1-git-send-email-balbi@ti.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org USB3 devices, because they are much newer, have much less chance of having issues with larger transfers. We still keep a limit because anything above 2048 sectors really rendered negligible speed improvements, so we will simply ignore that. Transferring 1MiB should already give us pretty good performance. Signed-off-by: Felipe Balbi --- drivers/usb/storage/scsiglue.c | 16 +++++++++++----- drivers/usb/storage/usb.c | 4 ++++ include/linux/usb_usual.h | 2 ++ 3 files changed, 17 insertions(+), 5 deletions(-) -- 2.6.2 -- 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 diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index 00aadf3a3857..bda2b3c9ae42 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c @@ -115,13 +115,19 @@ static int slave_configure(struct scsi_device *sdev) { struct us_data *us = host_to_us(sdev->host); - /* Many devices have trouble transferring more than 32KB at a time, - * while others have trouble with more than 64K. At this time we - * are limiting both to 32K (64 sectores). - */ - if (us->fflags & (US_FL_MAX_SECTORS_64 | US_FL_MAX_SECTORS_MIN)) { + if (us->fflags & US_FL_USB3) { + /* USB3 devices will be limitted at 2048 sectors. This gives us + * close to 25% throughput improvement on some devices. + */ + blk_queue_max_hw_sectors(sdev->request_queue, 2048); + } else if (us->fflags & (US_FL_MAX_SECTORS_64 | US_FL_MAX_SECTORS_MIN)) { unsigned int max_sectors = 64; + /* Many devices have trouble transferring more than 32KB at a + * time, while others have trouble with more than 64K. At this + * time we are limiting both to 32K (64 sectores). + */ + if (us->fflags & US_FL_MAX_SECTORS_MIN) max_sectors = PAGE_CACHE_SIZE >> 9; if (queue_max_hw_sectors(sdev->request_queue) > max_sectors) diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index 43576ed31ccd..b7735c9850f8 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c @@ -594,6 +594,10 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id, return -ENODEV; } + /* Flag USB3 devices so we can increase max_sectors to 2048 sectors. */ + if (dev->speed == USB_SPEED_SUPER) + us->fflags |= US_FL_USB3; + /* * This flag is only needed when we're in high-speed, so let's * disable it if we're in full-speed diff --git a/include/linux/usb_usual.h b/include/linux/usb_usual.h index 7f5f78bd15ad..b76b0faaedc8 100644 --- a/include/linux/usb_usual.h +++ b/include/linux/usb_usual.h @@ -79,6 +79,8 @@ /* Cannot handle MI_REPORT_SUPPORTED_OPERATION_CODES */ \ US_FLAG(MAX_SECTORS_240, 0x08000000) \ /* Sets max_sectors to 240 */ \ + US_FLAG(USB3, 0x10000000) \ + /* This is a USB3 Storage Device */ \ #define US_FLAG(name, value) US_FL_##name = value , enum { US_DO_ALL_FLAGS };