Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1036760rdh; Fri, 27 Oct 2023 02:58:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG3XqRpAZ0yvCjNezJsjE8au7gz0DfKrNZ8j7d1hBSD1NSC9f2fRMSY8o4NR1HMHTQbw125 X-Received: by 2002:a9d:6206:0:b0:6c4:f91d:2d9c with SMTP id g6-20020a9d6206000000b006c4f91d2d9cmr2069438otj.23.1698400692945; Fri, 27 Oct 2023 02:58:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698400692; cv=none; d=google.com; s=arc-20160816; b=M2ud6vhQIKU40Z9061qbywdWLbqxLXFP1HHl0co1uA/FONMKGTUknvfhibHb6k/y2Y pwXPc3ARVN2IZUqy0esNSf1FAR+IVLzF+6v323zDIpKCcpXSuYUVJNXrYD6hAGKOaF4e RG4TgKRWsD+Adw3ej5/i8By7UEy78wbgSZ1n3Q8hb0MfEwVz4312MOPefhZP1yH3dTUy 2327HeJYovV9nf49c3FQu5QCHQ2yoq0WyDuH8qIWB/eyUmWVOToF7qBZpqChMFqb2T9j BFfRnMjeYY1hkBktyyBwslQ848R34crKOMQadkYW5ecRPzaXtcdc0tsVRvs6mw1K42Qy ntCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=Jz3+2usvc43cAebAqrlJl6f1pjsse7Ie2+jXw4k7CYY=; fh=/2BHEKvDLTBJVsrYC9UDi1sq/E1cJxDljo8l9nan5aI=; b=SPoRBpgqbt8/zjUIGhmjLoqLYtvy3be+VOhbocgzwOxfdiToT312dL2GKV2AJagW1m x82iO3DQdjokIj1ebvZwuYfuKlH0T0uAZBurP7Kg2FGpObRirECintTDYqsKqkfLpzmf usZmNzQGuS9tHhRR0+gJM8tMmfhS8s0fqs+XfUJ9EFtnQxihgpYEAptc2P1E+2pkM+II /bRLOfFJgtsYLZmu/RKi5KqHY/nUfsdpxW+8g+XbgK3Uyi5raBONV5nKnfKQUyEnGnVC ZGFyY2bdhInBie5D8AGBIkqCdQtqUEEsq6O/4EoBMN5oam68PYj+7oRD4250k4ETTwZ3 nSsA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id e12-20020a81e94c000000b00592462f74e0si2122953ywm.341.2023.10.27.02.58.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 02:58:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 986E2835C178; Fri, 27 Oct 2023 02:58:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345593AbjJ0J54 (ORCPT + 99 others); Fri, 27 Oct 2023 05:57:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345645AbjJ0J5w (ORCPT ); Fri, 27 Oct 2023 05:57:52 -0400 Received: from hi1smtp01.de.adit-jv.com (smtp1.de.adit-jv.com [93.241.18.167]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B81C191; Fri, 27 Oct 2023 02:57:47 -0700 (PDT) Received: from hi2exch02.adit-jv.com (hi2exch02.adit-jv.com [10.72.92.28]) by hi1smtp01.de.adit-jv.com (Postfix) with ESMTP id BD7B0520532; Fri, 27 Oct 2023 11:57:45 +0200 (CEST) Received: from vmlxhi-118.adit-jv.com (10.72.93.77) by hi2exch02.adit-jv.com (10.72.92.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.34; Fri, 27 Oct 2023 11:57:45 +0200 Date: Fri, 27 Oct 2023 11:57:35 +0200 From: Hardik Gajjar To: Alan Stern CC: Hardik Gajjar , , , , , Subject: Re: [PATCH v6] usb: Reduce the 'SET_ADDRESS' request timeout with a new quirk Message-ID: <20231027095708.GA78934@vmlxhi-118.adit-jv.com> References: <20231025164019.GA121292@vmlxhi-118.adit-jv.com> <20231026101551.36551-1-hgajjar@de.adit-jv.com> <55a00749-7b9d-4fc8-a470-6eabdb93216f@rowland.harvard.edu> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <55a00749-7b9d-4fc8-a470-6eabdb93216f@rowland.harvard.edu> User-Agent: Mutt/1.9.4 (2018-02-28) X-Originating-IP: [10.72.93.77] X-ClientProxiedBy: hi2exch02.adit-jv.com (10.72.92.28) To hi2exch02.adit-jv.com (10.72.92.28) X-Spam-Status: No, score=-0.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 27 Oct 2023 02:58:09 -0700 (PDT) On Thu, Oct 26, 2023 at 02:34:22PM -0400, Alan Stern wrote: > On Thu, Oct 26, 2023 at 12:15:51PM +0200, Hardik Gajjar wrote: > > This patch introduces a new USB quirk, > > USB_QUIRK_SHORT_SET_ADDRESS_REQ_TIMEOUT, which modifies the timeout value > > for the 'SET_ADDRESS' request. The standard timeout for USB request/command > > is 5000 ms, as recommended in the USB 3.2 specification (section 9.2.6.1). > > > > However, certain scenarios, such as connecting devices through an APTIV > > hub, can lead to timeout errors when the device enumerates as full speed > > initially and later switches to high speed during chirp negotiation. > > > > In such cases, USB analyzer logs reveal that the bus suspends for > > 5 seconds due to incorrect chirp parsing and resumes only after two > > consecutive timeout errors trigger a hub driver reset. > > > > Packet(54) Dir(?) Full Speed J(997.100 us) Idle( 2.850 us) > > _______| Time Stamp(28 . 105 910 682) > > _______|_____________________________________________________________Ch0 > > Packet(55) Dir(?) Full Speed J(997.118 us) Idle( 2.850 us) > > _______| Time Stamp(28 . 106 910 632) > > _______|_____________________________________________________________Ch0 > > Packet(56) Dir(?) Full Speed J(399.650 us) Idle(222.582 us) > > _______| Time Stamp(28 . 107 910 600) > > _______|_____________________________________________________________Ch0 > > Packet(57) Dir Chirp J( 23.955 ms) Idle(115.169 ms) > > _______| Time Stamp(28 . 108 532 832) > > _______|_____________________________________________________________Ch0 > > Packet(58) Dir(?) Full Speed J (Suspend)( 5.347 sec) Idle( 5.366 us) > > _______| Time Stamp(28 . 247 657 600) > > _______|_____________________________________________________________Ch0 > > > > This 5-second delay in device enumeration is undesirable, particularly > > in automotive applications where quick enumeration is crucial > > (ideally within 3 seconds). > > > > The newly introduced quirks provide the flexibility to align with a > > 3-second time limit, as required in specific contexts like automotive > > applications. > > > > By reducing the 'SET_ADDRESS' request timeout to 500 ms, the > > system can respond more swiftly to errors, initiate rapid recovery, and > > ensure efficient device enumeration. This change is vital for scenarios > > where rapid smartphone enumeration and screen projection are essential. > > > > To use the quirk, please write "vendor_id:product_id:p" to > > /sys/bus/usb/drivers/hub/module/parameter/quirks > > > > For example, > > echo "0x2c48:0x0132:p" > /sys/bus/usb/drivers/hub/module/parameters/quirks" > > > > Signed-off-by: Hardik Gajjar > > --- > > For the usbcore parts: A couple of very minor things can be improved. > Once those improvements have been made, you can add: > > Reviewed-by: Alan Stern > > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > > index 0a1731a0f0ef..4aa3723d2eaf 100644 > > --- a/Documentation/admin-guide/kernel-parameters.txt > > +++ b/Documentation/admin-guide/kernel-parameters.txt > > @@ -6817,6 +6817,9 @@ > > pause after every control message); > > o = USB_QUIRK_HUB_SLOW_RESET (Hub needs extra > > delay after resetting its port); > > + p = USB_QUIRK_SHORT_SET_ADDRESS_REQ_TIMEOUT (Reduce > > + timeout of the SET_ADDRESS request from > > + 5000 ms to 500 ms) > > To avoid going over the 80-column limit, move "(Reduce" to the next > line and reflow the text in parentheses. > > > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c > > index 3c54b218301c..98db92af2cce 100644 > > --- a/drivers/usb/core/hub.c > > +++ b/drivers/usb/core/hub.c > > @@ -54,6 +54,19 @@ > > #define USB_TP_TRANSMISSION_DELAY_MAX 65535 /* ns */ > > #define USB_PING_RESPONSE_TIME 400 /* ns */ > > > > +/* > > + * USB 3.2 spec, section 9.2.6.1 > > + * USB sets an upper limit of 5000 ms for any command/request > > + * to be processed. > > + */ > > +#define USB_DEFAULT_REQUEST_TIMEOUT_MS 5000 /* ms */ > > You don't need to define this macro at all. Just use > USB_CTRL_SET_TIMEOUT (which is already defined to be 5000) as the > existing code already does. > > > +/* > > + * The SET_ADDRESS request timeout will be 500 ms when > > + * USB_QUIRK_SHORT_SET_ADDRESS_REQ_TIMEOUT enable. > > + */ > > +#define USB_SHORT_SET_ADDRESS_REQ_TIMEOUT_MS 500 /* ms */ > > As remarked earlier, we don't need to have the "_MS" suffix on either > the macro name or the "timeout_ms" variable name. Removing the suffix > will be more consistent with the USB_TP_TRANSMISSION_DELAY_MAX and > USB_PING_RESPONSE_TIME names you see above. I understand the suffix _MS in macro but the suffix is variable name was added after the comment about timeout unit from Greg in patchV2. https://marc.info/?l=linux-usb&m=169687322126192&w=2 Other comments will be resolved in next patch. > > > + > > +/* > > + * The SET_ADDRESS request timeout will be 500 ms when > > + * USB_QUIRK_SHORT_SET_ADDRESS_REQ_TIMEOUT enable. > > Change the second line to: > > * the USB_QUIRK_SHORT_SET_ADDRESS_REQ_TIMEOUT quirk flag is set. > > > + */ > > +#define USB_SHORT_SET_ADDRESS_REQ_TIMEOUT_MS 500 /* ms */ > > Overall, I agree with Sergey that this would be cleaner if you split it > up into two patches. The first should change the comment for the > set_address() callback function and the implementation in xhci-hcd. The > second should add the quirk flag and make the corresponding changes to > the USB core. > > Alan Stern Thanks, Hardik