Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3118437imm; Thu, 24 May 2018 23:31:10 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq+t3+SKxttOiw7e/Ge8/HNGq0ywHAtYKsZ3oYAjXmDUrLdR7y6ipx34sfNaM55d0orja1H X-Received: by 2002:a62:3c10:: with SMTP id j16-v6mr1226056pfa.7.1527229870231; Thu, 24 May 2018 23:31:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527229870; cv=none; d=google.com; s=arc-20160816; b=mxRO/BxtDZwltuHb9iFVvdXODICZLipdKLWbWAJ4ppdk4X/Z5tAOPTPOuxiuSha7Ci WMvZ6qj3q5j2OoCjfOAf+7UQPos0MxW5CEdQMbGc7o4aL6KI86tbop+RRjuphaMMgAv2 R/kVZq7VThISkCUVYLdM1AoI3rR/8xhCa/BWBFSer2KhwDKyD9COdoBe3P8oI6Vs44ii ZEIwaGwa5oDY8LknylvdcR1RLgS0U3KxvnoAOezVEsqQlpljKDbsw9PYZNrbfRFmr/zB hMbqYDOmLR+MwOzzDvBQCy+g53mIwzmaGHHVtkEoSIwelMz/qCiVfgxqWuxZfjsqVCTj ZLoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=wLqxCeUHpNCVGg/hgSQqkdzM7Y4NbmjGRzNvmvFg66w=; b=GtlxrXbG/GLM3a5BI4ulkQu2QjNmMkY1s8NHXcnPxmezZpUT3RqRv7yGVfRTRLbGbq YztXRBK3uWyBazagjLOKfUdCunUafGqxyg0fPIVbPcL86wgGWZrZfpk89YyAJ3fxv2LB vnF2n5p1ZU/K8ner8HXu8K3C+KKfc1ZE5zkj3ABpK9qxaA3N/7blSGUEXvEqn+Co+ijZ i5+0BFDqSxWn0GjAlsqqB59HF0ZVkNEkc+Ygh1Tmp8fmJGgdZFZ4wPn2kr23f3Gn1iSd W+CtlxfTZvREYqSg5HQ0d5meC0QH4fy0vn2igdOWqyNR0kM43ZK7TE6no647AQVryLGu Xcjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bsC6YJeQ; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b17-v6si17935679pgv.196.2018.05.24.23.30.55; Thu, 24 May 2018 23:31:10 -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=@kernel.org header.s=default header.b=bsC6YJeQ; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935853AbeEYGa2 (ORCPT + 99 others); Fri, 25 May 2018 02:30:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:47122 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751791AbeEYGa1 (ORCPT ); Fri, 25 May 2018 02:30:27 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 413E920849; Fri, 25 May 2018 06:30:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527229826; bh=83s9s9bnWgU0jtODGfFXzIM49gxWmAJuq/QPMeotl/k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bsC6YJeQA+TjSsSSdZDQUk+KP90C9GwWcFpE5CS5jRcnpaeehJYjD+Yit2AzLFSXb oKYpxR1jRk2HkPEk06IAnA2xu4jNJC3gLFmgBPdDmi5EJZ2y4jagbb9Mh6BalI6I+j JXa5/o/Bp9OacYBLaJJUen83dars7xKsh0pTG304= Date: Fri, 25 May 2018 08:30:09 +0200 From: Greg Kroah-Hartman To: Nicolas Boichat Cc: linux-usb@vger.kernel.org, Alan Stern , Mathias Nyman , Felipe Balbi , Eugene Korenevsky , Peter Chen , Daniel Drake , Joe Perches , Johan Hovold , Richard Leitner , linux-kernel@vger.kernel.org, groeck@chromium.org Subject: Re: [PATCH] usb: hub: Per-port setting to use old enumeration scheme Message-ID: <20180525063009.GB11968@kroah.com> References: <20180523021656.122455-1-drinkcat@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180523021656.122455-1-drinkcat@chromium.org> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 23, 2018 at 10:16:56AM +0800, Nicolas Boichat wrote: > The "old" enumeration scheme is considerably faster (it takes > ~294ms instead of ~439ms to get the descriptor). > > It is currently only possible to use the old scheme globally > (/sys/module/usbcore/parameters/old_scheme_first), which is not > desirable as the new scheme was introduced to increase compatibility > with more devices. > > However, in our case, we care about time-to-active for a specific > USB device (which we make the firmware for), on a specific port > (that is pogo-pin based: not a standard USB port). This new > sysfs option makes it possible to use the old scheme on a single > port only. > > Signed-off-by: Nicolas Boichat > --- > > There are other "quirks" that we could add to reduce further > enumeration time (e.g. reduce USB debounce time, reduce TRSTRCY > to 10ms instead of 50ms as used currently), but the logic is quite > similar, so it'd be good to have this reviewed first. > > drivers/usb/core/hub.c | 13 +++++++++---- > drivers/usb/core/hub.h | 1 + > drivers/usb/core/port.c | 23 +++++++++++++++++++++++ > include/linux/usb.h | 7 +++++++ > 4 files changed, 40 insertions(+), 4 deletions(-) > > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c > index c2d993d3816f0..f900f66a62856 100644 > --- a/drivers/usb/core/hub.c > +++ b/drivers/usb/core/hub.c > @@ -2636,7 +2636,7 @@ static unsigned hub_is_wusb(struct usb_hub *hub) > #define SET_ADDRESS_TRIES 2 > #define GET_DESCRIPTOR_TRIES 2 > #define SET_CONFIG_TRIES (2 * (use_both_schemes + 1)) > -#define USE_NEW_SCHEME(i) ((i) / 2 == (int)old_scheme_first) > +#define USE_NEW_SCHEME(i, scheme) ((i) / 2 == (int)scheme) > > #define HUB_ROOT_RESET_TIME 60 /* times are in msec */ > #define HUB_SHORT_RESET_TIME 10 > @@ -2651,12 +2651,16 @@ static unsigned hub_is_wusb(struct usb_hub *hub) > * enumeration failures, so disable this enumeration scheme for USB3 > * devices. > */ > -static bool use_new_scheme(struct usb_device *udev, int retry) > +static bool use_new_scheme(struct usb_device *udev, int retry, > + struct usb_port *port_dev) > { > + int old_scheme_first_port = > + port_dev->quirks & USB_PORT_QUIRK_OLD_SCHEME; > + > if (udev->speed >= USB_SPEED_SUPER) > return false; > > - return USE_NEW_SCHEME(retry); > + return USE_NEW_SCHEME(retry, old_scheme_first_port || old_scheme_first); > } > > /* Is a USB 3.0 port in the Inactive or Compliance Mode state? > @@ -4392,6 +4396,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, > { > struct usb_device *hdev = hub->hdev; > struct usb_hcd *hcd = bus_to_hcd(hdev->bus); > + struct usb_port *port_dev = hub->ports[port1 - 1]; > int retries, operations, retval, i; > unsigned delay = HUB_SHORT_RESET_TIME; > enum usb_device_speed oldspeed = udev->speed; > @@ -4513,7 +4518,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, > for (retries = 0; retries < GET_DESCRIPTOR_TRIES; (++retries, msleep(100))) { > bool did_new_scheme = false; > > - if (use_new_scheme(udev, retry_counter)) { > + if (use_new_scheme(udev, retry_counter, port_dev)) { > struct usb_device_descriptor *buf; > int r = 0; > > diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h > index 4dc769ee9c740..4accfb63f7dcb 100644 > --- a/drivers/usb/core/hub.h > +++ b/drivers/usb/core/hub.h > @@ -98,6 +98,7 @@ struct usb_port { > struct mutex status_lock; > u32 over_current_count; > u8 portnum; > + u32 quirks; > unsigned int is_superspeed:1; > unsigned int usb3_lpm_u1_permit:1; > unsigned int usb3_lpm_u2_permit:1; > diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c > index 6979bde87d310..4a21431953953 100644 > --- a/drivers/usb/core/port.c > +++ b/drivers/usb/core/port.c > @@ -50,6 +50,28 @@ static ssize_t over_current_count_show(struct device *dev, > } > static DEVICE_ATTR_RO(over_current_count); > > +static ssize_t quirks_show(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + struct usb_port *port_dev = to_usb_port(dev); > + > + return sprintf(buf, "%08x\n", port_dev->quirks); > +} > + > +static ssize_t quirks_store(struct device *dev, struct device_attribute *attr, > + const char *buf, size_t count) > +{ > + struct usb_port *port_dev = to_usb_port(dev); > + u32 value; > + > + if (kstrtou32(buf, 16, &value)) > + return -EINVAL; > + > + port_dev->quirks = value; > + return count; > +} > +static DEVICE_ATTR_RW(quirks); > + > static ssize_t usb3_lpm_permit_show(struct device *dev, > struct device_attribute *attr, char *buf) > { > @@ -118,6 +140,7 @@ static DEVICE_ATTR_RW(usb3_lpm_permit); > > static struct attribute *port_dev_attrs[] = { > &dev_attr_connect_type.attr, > + &dev_attr_quirks.attr, > &dev_attr_over_current_count.attr, > NULL, > }; Oops, you add a new sysfs file, but do not document it anywhere. It needs to go into Documentation/ABI/ along with the other files, otherwise no one knows how to use it. Please fix that up and resend. thanks, greg k-h