Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2026107imm; Sun, 27 May 2018 23:33:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpzl2d5Pz8UGh//wsFu0XFnF0LCiqH2XILwIOphe27CtHscuWIG9Z7of/ei9ovfZC+gZ+YJ X-Received: by 2002:a17:902:24c7:: with SMTP id l7-v6mr12625019plg.327.1527489229165; Sun, 27 May 2018 23:33:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527489229; cv=none; d=google.com; s=arc-20160816; b=HRSLG+1l1o9Xx0Pa18LwpnS/dkqz0VsJTQSMP+226xSuhl0c4JGmz4bRh4RYAYw8OH rjEocMc/K1VfTZmKV96+0QJOKufBmBJQcJ4Vhj6vY9VOdkGwh6VuYm6ys3qkfqdxq+cn 3f0YKP2D/rp8iOZEZz1YsjDpSYRIsXBInBA1B5GQTzlrR1CJa5V51Tm4MIDfm1PhC4mr bMfa0AUk8uTFakyaaNValOmIVxBqz9cinzWvaAfUJDJvs/9ajZHZkzBIhgt1KY6UBC/A tQyIS03u0eRio548IK+HgSbUVDm/wuG9ck6+a2rM5qiQdeeW+wpSKJhG5syVAqMJ0N2r qSig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=zTx9HCfTaDxOnS5WHol4W4vbnq88dUD0uB1bZmXuALk=; b=lX8t4dXNew7giUA0DN4BejLheZxr6C6/sceXc77vD41DoWDGOYdl1BG8Pch7BE+6tZ U4ynD3B02kceV+cr/bc9GOtXjqR9+x4zXWi+LRzsNpNu9Ar5uJcZedOKcEhpQ3APg0fw rrmmJmQ17+Rc1y0fNzPTZtODfCEoUvcDhjr6+RPMX1xqVfgKbkz+LL+HKGymM03q5rRb kZRyAQF1pY3ZQDEnqaeCRQhBG8rYIFthjq/6lK0x2BlBorQ8EBklEL3r5drKSckaWvTf UCSM/xDorxhhQhUU6kD1XEmaA9Mc10XdjEkX7/lRXuNja3jRx9/liozGVb52788rVWFg /c7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=T35ZwYy6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bi1-v6si447511plb.126.2018.05.27.23.33.34; Sun, 27 May 2018 23:33:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=T35ZwYy6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753517AbeE1GdT (ORCPT + 99 others); Mon, 28 May 2018 02:33:19 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:44694 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751085AbeE1GdJ (ORCPT ); Mon, 28 May 2018 02:33:09 -0400 Received: by mail-pl0-f67.google.com with SMTP id z9-v6so3276260plk.11 for ; Sun, 27 May 2018 23:33:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zTx9HCfTaDxOnS5WHol4W4vbnq88dUD0uB1bZmXuALk=; b=T35ZwYy6Acukx3+/e+m3XzGu17lZS5NZBvriBkcqvE0fyZoc1JldHaNirpGPwve2pR JRKQ8BLjVZMQJGZMD2lemuaAtHk0Q64KazvBK872kxRu/EtBVlBYnbAfGS73x56+i3+v FjuxNo3FWkry5q/gFwpbqIbMhZnw6888e5weo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zTx9HCfTaDxOnS5WHol4W4vbnq88dUD0uB1bZmXuALk=; b=GyAucPNUSTv43phDgxk+tIyYE38n4Cr6zIo7n5t38rKBINMyjiOPii5CEs4GD69T2N RM2e4bTfxf4z8I8VIQM0HtPDfg/FUVbycWg3cxPor95ZiM0VPCJHECcLVIpEv7NLh+3j hzeU3r/Qaw/FQ7nH1J4FL1ZLtMPZg2pZHRZg6kNLU0HddM1OiQoTnTrhfrt5Xq4oakt7 tFsbxipnSKybBMwzpy1x//UjLSOfajLdKLpnNS5XO80OYR/4/v2vbIiE8k4lxYYILYUf S+ymkYvvXMJQeNj6u5Vkb6TMx8eqLDyPwlxmO7k2nDNS8NwnMHZj8f/GigZCLHDFktQe C4Wg== X-Gm-Message-State: ALKqPwdLUfbFSbDz25zpi9UuJHha5RP/Ch9KOqdozgcUgvFBwaxqpScT CAo3V8NHU/YHftN1QSD/GzoCEg== X-Received: by 2002:a17:902:323:: with SMTP id 32-v6mr12643380pld.312.1527489189067; Sun, 27 May 2018 23:33:09 -0700 (PDT) Received: from drinkcat.tpe.corp.google.com ([2401:fa00:1:b:9ba:cd16:d555:bacf]) by smtp.gmail.com with ESMTPSA id y2-v6sm36431247pgp.92.2018.05.27.23.33.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 May 2018 23:33:08 -0700 (PDT) From: Nicolas Boichat To: Greg Kroah-Hartman Cc: Alan Stern , Mathias Nyman , Felipe Balbi , Eugene Korenevsky , Peter Chen , Daniel Drake , Joe Perches , Nicolas Boichat , Johan Hovold , Richard Leitner , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, groeck@chromium.org Subject: [PATCH] usb: hub: Per-port setting to reduce TRSTRCY to 10 ms Date: Mon, 28 May 2018 14:32:19 +0800 Message-Id: <20180528063219.234757-2-drinkcat@chromium.org> X-Mailer: git-send-email 2.17.0.921.gf22659ad46-goog In-Reply-To: <20180528063219.234757-1-drinkcat@chromium.org> References: <20180528063219.234757-1-drinkcat@chromium.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, the USB hub core waits for 50 ms after enumerating the device. This was added to help "some high speed devices" to enumerate (b789696af8 "[PATCH] USB: relax usbcore reset timings"). On some devices, the time-to-active is important, so we provide a per-port option to reduce the time to what the USB specification requires: 10 ms. Signed-off-by: Nicolas Boichat --- Reduces enumeration time by ~40ms in conjunction with previous patch/quirk (or ~80ms on its own). Documentation/ABI/testing/sysfs-bus-usb | 4 ++++ drivers/usb/core/hub.c | 6 +++++- include/linux/usb.h | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-bus-usb b/Documentation/ABI/testing/sysfs-bus-usb index a31a66d62cbba..08d456e07b538 100644 --- a/Documentation/ABI/testing/sysfs-bus-usb +++ b/Documentation/ABI/testing/sysfs-bus-usb @@ -206,6 +206,10 @@ Description: using /sys/module/usbcore/parameters/old_scheme_first, but it is often not desirable as the new scheme was introduced to increase compatibility with more devices. + - Bit 1 reduces TRSTRCY to the 10 ms that are required by the + USB 2.0 specification, instead of the 50 ms that are normally + used to help make enumeration work better on some high speed + devices. What: /sys/bus/usb/devices/.../(hub interface)/portX/over_current_count Date: February 2018 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index f900f66a62856..26c2438d28893 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -2879,7 +2879,11 @@ static int hub_port_reset(struct usb_hub *hub, int port1, done: if (status == 0) { /* TRSTRCY = 10 ms; plus some extra */ - msleep(10 + 40); + if (port_dev->quirks & USB_PORT_QUIRK_FAST_ENUM) + usleep_range(10000, 12000); + else + msleep(10 + 40); + if (udev) { struct usb_hcd *hcd = bus_to_hcd(udev->bus); diff --git a/include/linux/usb.h b/include/linux/usb.h index 2ade17992ed66..4cdd515a4385f 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -496,6 +496,9 @@ enum usb_port_connect_type { /* For the given port, prefer the old (faster) enumeration scheme. */ #define USB_PORT_QUIRK_OLD_SCHEME BIT(0) +/* Decrease TRSTRCY to 10ms during device enumeration. */ +#define USB_PORT_QUIRK_FAST_ENUM BIT(1) + /* * USB 2.0 Link Power Management (LPM) parameters. */ -- 2.17.0.921.gf22659ad46-goog