Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp60144rdg; Tue, 10 Oct 2023 04:25:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHmRGpGJD1xgjh1g72QQfMbwUxPQBA6qN/o+r8H6UHUk4f/EvcQ/EQ8c0UGCNZhMJ8fjPwU X-Received: by 2002:a05:6a20:918d:b0:12e:73bb:cbb6 with SMTP id v13-20020a056a20918d00b0012e73bbcbb6mr18716286pzd.14.1696937123631; Tue, 10 Oct 2023 04:25:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696937123; cv=none; d=google.com; s=arc-20160816; b=KM/XSTm8FazPOmXfMIA3+Sl3IQGxvKyiiKp8zU2YA4m+w3lLJ7DTd9GWOAmuP/inrL ZQQOVaccXJGkBy6huXszEm4VLelcrv3KWsX8WU2B7xoRqrcTW7yxMZVLnH4toZ+vahhf IKgc0sd75kFt24zAR2dmXtA353jeEOtZIaqLaJS8rDVqKgqmJmC9ydjij6Q3ZFAbW5vG fTFWK3l50XG0KUegk8XElrZ0gXTXWKrCECcIJTGgpF+dv5k6ItGfWsPDph9/1FzF06Al kH9AlrDpnVfjNc9VHvne5ZtN/b+OcRw0Nkf1/E5npDC9+RnON6jBSxY6hDyMEG7HM4cq xXQQ== 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:dkim-signature; bh=SD55/D2FQB0USb+XiO0bmLVy9tNnTXA7IH6QCpR+xVg=; fh=qTlv9Yjxx31H/uPR2d9ZJGU+ALzAsNEjMqin+ZX5afM=; b=xAPl5qWs3ET06oOFNeL3R2QOPJTuTnJOo3zce727Suc6eMTcNRoRLzjKeDX0TifPFQ tVmRI30Pbd5QYhK44xHi91EuoZZdcW0Fn4XqVJugLqhuPLlsdNDK6bvsxeHK7huIyhAd UIRERe1CaI0LAqZW8iOF/yZyAxMf7foST/2kxN5drgMT+R5ZCAM0btomJIW1428wnQfz uJYFq96KHtyAqhxefu1EqEjJ8dtkt8k2R/Y2LNh9RWqNwyhyfGcR+zE88ITq49jdKZHR N+hL3oV3Njt0wwouj06VAHaoUYVR2NnbQM125G2a6of9sY3iL2wT1rNhaINBxAyMV8gr ocgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="x1XBN/GI"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id l21-20020a056a0016d500b0068fce4338bdsi9955001pfc.62.2023.10.10.04.25.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 04:25:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="x1XBN/GI"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id CC694804EE5E; Tue, 10 Oct 2023 04:25:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231285AbjJJLZH (ORCPT + 99 others); Tue, 10 Oct 2023 07:25:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231228AbjJJLZG (ORCPT ); Tue, 10 Oct 2023 07:25:06 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47829A9 for ; Tue, 10 Oct 2023 04:25:05 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D18BC433C8; Tue, 10 Oct 2023 11:25:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1696937104; bh=YfSpTxm6D1i+VJgN9Z2T5sxR0IVtkWMSVzGsQYn0PY0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=x1XBN/GIDNGzPcK+zoPBQcCd58F8U4L2sakI+FBrpgEewEUVRaKo846nvXXDUs2XO g6IndLsC88TfRja2FPuZvS8HmOGmxt89M3+D7BHH82Wp6RTjA1RZamQ3yg1Hr0wPZ3 QkFhL5OH1nIAn6t0730FjX7uOiv8drqANLTAn5iI= Date: Tue, 10 Oct 2023 13:25:02 +0200 From: Greg KH To: Hardik Gajjar Cc: mathias.nyman@intel.com, stern@rowland.harvard.edu, 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: <2023101054-thread-manliness-52a4@gregkh> References: <--in-reply-to=20231006153808.9758-1-hgajjar@de.adit-jv.com> <20231009161402.104224-1-hgajjar@de.adit-jv.com> <2023100921-likeness-possible-032c@gregkh> <20231010103143.GA107162@vmlxhi-118.adit-jv.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231010103143.GA107162@vmlxhi-118.adit-jv.com> X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Tue, 10 Oct 2023 04:25:21 -0700 (PDT) X-Spam-Level: ** On Tue, Oct 10, 2023 at 12:31:43PM +0200, Hardik Gajjar wrote: > On Mon, Oct 09, 2023 at 07:43:09PM +0200, Greg KH wrote: > > 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. > > > > > > 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. > > > > So you have known-broken devices where you want a shorter error timeout? > > But you don't list those devices in this patch adding the quirk > > settings, shouldn't that be required, otherwise this looks like an > > unused quirk. > Yes, we have identified the device (hub) that is causing the issue. However, > I would prefer not to force this timeout globally. Instead, I can dynamically > control it by writing to the /sys/bus/usb/drivers/hub/module/parameter/quirks > file from init.rc (Android) during the boot-up process. Then add that device to the quirk list please so that everyone doesn't have to figure this out on their own for that broken device. That's why we have a quirk list in the kernel. > > > static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev, > > > - enum xhci_setup_dev setup) > > > + enum xhci_setup_dev setup, int timeout) > > > > What is the units of timeout here? > The timeout is in jiffies. Should we consider adding 'jiffies' in the variable name > for clarity? I searched the kernel source code but couldn't find a reference for the > unit of timeout in jiffies. > Nevertheless, I will add a comment in patch v3 for clarification. You should not pass around jiffies in the kernel in an int, please pass around a unit of time and then when you actually need to tell the kernel to sleep, you can use the time to convert to whatever unit the delay function needs. > > > +/* short device address timeout */ > > > +#define USB_QUIRK_SHORT_DEVICE_ADDR_TIMEOUT BIT(16) > > > > Don't you also need to have a Documentation/ update for the new > > user/kernel api you are adding? > > > When you recommend Documentation, I assume you suggest to add the > detailed comment in quirks.h to clear intention of the change. No, please document the info that you have in the changelog in someplace where people will know what flag to use in the module option. That's already documented for the other flags somewhere, right? thanks, greg k-h