From patchwork Mon May 28 06:32:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Boichat X-Patchwork-Id: 10429815 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 40933602CB for ; Mon, 28 May 2018 06:33:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3150528963 for ; Mon, 28 May 2018 06:33:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 25E7A289E0; Mon, 28 May 2018 06:33:28 +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=unavailable 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 7F9B628963 for ; Mon, 28 May 2018 06:33:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753487AbeE1GdS (ORCPT ); Mon, 28 May 2018 02:33:18 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:39201 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753310AbeE1GdJ (ORCPT ); Mon, 28 May 2018 02:33:09 -0400 Received: by mail-pl0-f66.google.com with SMTP id f1-v6so6177978plt.6 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=Ze6wo3oaAolQzyR5j8tvWc6+WGaAkrESBI3KEEXgAn9q7g2BfMVhw/qelNkbIAFtL9 SVj5j3aLjwMgN8i33j9zhmsbQhgoGKKaamiw9vq9CCkGFADfBWRnNoI79qVNieVvPxXL lFp3jkdEb79QUfGY2RK2b+uz65VVB64eXTwW8m08jV2vqpqUmyydfuqbYudoZ/Eh4dB/ lgKOi+Skz2BFqIVQ9S41WapNQDeliOBIG1rM3b8DB31HSuI/g0wPhLwApt1CV+NGUVWQ 4hAlJj32dMPwumf0mv8r2SIXhjuCA3GRgTUkP2f5mFG0952Uid9lVjJZ0p3q9Dlu0w5X QDng== X-Gm-Message-State: ALKqPwee+9u/d7acRiNeNJq13nFvUyaxtamiwJZaCJv3BPRHHS6O5NDS V5IJeaUfqop8pKhifJORKPMbvrfokiI= X-Google-Smtp-Source: AB8JxZqpOjdx4jXjAhUH/mXd7L+NQGBOSbU670b62grRfxQxQUcBfUsXSiOUKbHIQIoczI3V4QG0mg== 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-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. */