Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2094186rdb; Mon, 9 Oct 2023 12:17:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHu0+TMvVBXt5GD/p2XZ7DRK981d8iCL/doQHo93eCratWAEMmVVwP4S4Q6kPlgaZ9KN1IL X-Received: by 2002:a05:6a00:1252:b0:690:2ecd:a599 with SMTP id u18-20020a056a00125200b006902ecda599mr14940649pfi.21.1696879021398; Mon, 09 Oct 2023 12:17:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696879021; cv=none; d=google.com; s=arc-20160816; b=S0Fwct2VQQEdQ14oifqnVOmAJ4eZ3mKBfGLMA+Z9pqcTCRmkWp9I5TwBCLG/55GS2+ qIgXKkfpCJ9DAH7sfeQtmzRkXutwUKyIzs4xZLdwx2cnpKXvumDJedKl8J9+gqIszeDV 3VjGFWmSXTlslGYQNoKfZqmGSPhVrDhyAS2tEgoR+xlwb1u5czOoBjkaFlipz3VzeiJS f9h3NJYGPqMNQInvTWULopQPm584DWtw1/5EpHCUPeKVX2iQoZ9UJ/YFhtdeyHYLGrru 8+kLo66r/MO7CH5MGdha9IQYC6VWGaN6EgQYEynfPLznNWxbGop1sLovyeMLn5AX3Qb6 TLUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=2/lJmsu5N+KzTm8CI+MSUPfIOvj+/lD9lmCMaJqp4N4=; fh=5rO7EIwP3Au0NvMTz4J5j/WltKY7f2oOxW8uvzv03H4=; b=XvjhgH0otz4SQUOMfCbqIGIjEsIZu4JpiD/1quFPeXCpBkYQuiS3CVXHUr8IUVFpPC An8EqICt5KF2x9XscWRlxCEoQvM/zLBBVCxOuY8Fc6Y3hW14a1OsJQNzaql9kf09r2JR zEL8c8KO/dsgt6pkhDoTu5xdd9CT3EJwpXSjFwq6ZgyeXCvTttV5eQOcXz8qirCqIry9 ehVlAXZwDWhS7MP3ffYA44drwO+6fz1hwum5gEBMDqy2jOlN0DUYunfuSZlN0034p/2v O2ga7gZrI6dNyxZpIadba2RMNWgcieKgU+s2zfpV1e0UcVByPO6GjLSTL7zTtWX3iFXr uZRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id cr12-20020a056a000f0c00b00690f0a78ecesi7680618pfb.315.2023.10.09.12.16.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 12:17:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id EAA688038B00; Mon, 9 Oct 2023 12:16:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378373AbjJITQc (ORCPT + 99 others); Mon, 9 Oct 2023 15:16:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378355AbjJITQ3 (ORCPT ); Mon, 9 Oct 2023 15:16:29 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id AB986B7 for ; Mon, 9 Oct 2023 12:16:26 -0700 (PDT) Received: (qmail 155547 invoked by uid 1000); 9 Oct 2023 15:16:25 -0400 Date: Mon, 9 Oct 2023 15:16:25 -0400 From: Alan Stern To: Hardik Gajjar Cc: mathias.nyman@intel.com, gregkh@linuxfoundation.org, yangyingliang@huawei.com, jinpu.wang@ionos.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, erosca@de.adit-jv.com Subject: Re: [PATCH v2] usb: core: hub: Add quirks for reducing device address timeout Message-ID: <66f874d3-b480-4748-8732-d0cdce3ab4b7@rowland.harvard.edu> References: <--in-reply-to=20231006153808.9758-1-hgajjar@de.adit-jv.com> <20231009161402.104224-1-hgajjar@de.adit-jv.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231009161402.104224-1-hgajjar@de.adit-jv.com> X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 09 Oct 2023 12:16:56 -0700 (PDT) X-Spam-Level: ** On Mon, Oct 09, 2023 at 06:14:02PM +0200, Hardik Gajjar wrote: > Currently, the timeout for the set address command is fixed at > 5 seconds in the xhci driver. This means the host waits up to 5 > seconds to receive a response for the set_address command from > the device. > > In the automotive context, most smartphone enumerations, including > screen projection, should ideally complete within 3 seconds. > Achieving this is impossible in scenarios where the set_address is > not successful and waits for a timeout. What will you do about scenarios where the Set-Address completes very quickly but the following Get-Device-Descriptor times out after 5 seconds? Or any of the other transfers involved in device initialization and enumeration? > The shortened address device timeout quirks provide the flexibility > to align with a 3-second time limit in the event of errors. > By swiftly triggering a failure response and swiftly initiating > retry procedures, these quirks ensure efficient and rapid recovery, > particularly in automotive contexts where rapid smartphone enumeration > and screen projection are vital. > > The quirk will set the timeout to 500 ms from 5 seconds. > > 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/parameter/quirks" > > Signed-off-by: Hardik Gajjar > --- > changes since version 1: > - implement quirk instead of new API in xhci driver > --- > drivers/usb/core/hub.c | 15 +++++++++++++-- > drivers/usb/core/quirks.c | 3 +++ > drivers/usb/host/xhci-mem.c | 1 + > drivers/usb/host/xhci-ring.c | 3 ++- > drivers/usb/host/xhci.c | 9 +++++---- > drivers/usb/host/xhci.h | 1 + > include/linux/usb/hcd.h | 3 ++- > include/linux/usb/quirks.h | 3 +++ > 8 files changed, 30 insertions(+), 8 deletions(-) > > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c > index 3c54b218301c..975449b03426 100644 > --- a/drivers/usb/core/hub.c > +++ b/drivers/usb/core/hub.c > @@ -54,6 +54,9 @@ > #define USB_TP_TRANSMISSION_DELAY_MAX 65535 /* ns */ > #define USB_PING_RESPONSE_TIME 400 /* ns */ > > +#define USB_DEFAULT_ADDR_DEVICE_TIMEOUT (HZ * 5) /* 5000ms */ > +#define USB_SHORT_ADDR_DEVICE_TIMEOUT 125 /* ~500ms */ That number, 125, is meaningless. It's in units of jiffies, which vary from one system to another. If you want the timeout to be about 500 ms, you should write it as (HZ / 2). Alan Stern