Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp3269916rwb; Mon, 5 Sep 2022 08:54:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR5vFWinRFJo7riMfw64i8f1dO4xgSOOLFmB1j9pIvJwqNHHBiCi0V2uWAgRzQcvwukLx3dA X-Received: by 2002:a17:906:8462:b0:741:6003:71e4 with SMTP id hx2-20020a170906846200b00741600371e4mr28552808ejc.170.1662393274450; Mon, 05 Sep 2022 08:54:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662393274; cv=none; d=google.com; s=arc-20160816; b=nISU21yrx6q5mxcctlQ9gegujr+NtzKA/28ACetV8x7w2lHSAl0QKVahhQPJvwt6Yd qosezLTPiICOP9yaPTFDMhMAOiUF58/0CMKUw4sAYaRPxmnAG/jUy0WwJpXmNfO2RE+Y Zn3zg30iAeY9pfGoHhJYS6xRNnUm/HBTtCiX6n8S/EnUnEN+yaKLxE0+4mxeQAusPhnj pAvvxLyAqlYJRWmo5sbNkg5+1T9fUKo26UXZ4bNBzj0zSiqLavFN+bZRCJUMFS1nmOt5 lZ0p7dCUcR6Cy2xnd6fcqlvIFwFCY291m7H8cUL3jD3ylxBKQirGDpyn3WOkv/Nj2qMl cOZw== 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=sATNJMyati7qSr5r9uSQizeE1eP/MpPVgw5SDPnRDR8=; b=ZNtPMimH/IAyy6siZvEMiBsxJvop3RqkSlfva9AVT6WlHR0s4JdEZweut0M/36Xd5c f8lxrgjnntJcq0WG00rMT1Vqu9L4d1g9D/4BRNnhB8pZZYyPBHbxUw6fNwOlCls7iAHw JnhJu81xkuXBF5xLlNN7XtBY2tndBQhjXazCHPrCcTlGlbbw7bTVy+DJSeZEaAQRK8NH JaOa4qUzCOGCOWkTIksH3wb/9cQC+Tbk/oXLDsOVBJ/s73EiZVCR1OikafM7NOPIa4ln J/MNib1EsbbbTN5obon7GQDQSH70VXyBCK5Plm3TuPeVxTs1ROlgv1Bc4mWCurVfdPIx 8msw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y13-20020a50eb8d000000b0044e8dd8a7c2si1942187edr.138.2022.09.05.08.54.09; Mon, 05 Sep 2022 08:54:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238832AbiIEPTk (ORCPT + 99 others); Mon, 5 Sep 2022 11:19:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238515AbiIEPSi (ORCPT ); Mon, 5 Sep 2022 11:18:38 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 21B961FCF0 for ; Mon, 5 Sep 2022 08:18:30 -0700 (PDT) Received: (qmail 356045 invoked by uid 1000); 5 Sep 2022 11:18:29 -0400 Date: Mon, 5 Sep 2022 11:18:29 -0400 From: Alan Stern To: Ray Chi Cc: Greg KH , mathias.nyman@linux.intel.com, Albert Wang , Badhri Jagan Sridharan , Puma Hsu , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [Patch v2] usb: core: stop USB enumeration if too many retries Message-ID: References: <20220902091535.3572333-1-raychi@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 05, 2022 at 04:36:16PM +0800, Ray Chi wrote: > On Sat, Sep 3, 2022 at 1:07 AM Alan Stern wrote: > > I don't understand. If you don't know whether the accessory is broken, > > how do you know whether to set the quirk? > > > > On the other hand, if you always set the quirk even before you know > > whether the accessory is broken, why make it a quirk at all? Why not > > make it the normal behavior of the driver? > > > > Since our device has a watchdog mechanism, when the device connects to > a broken accessory, the kernel panic will happen. This problem didn't happen > in all USB Hosts, so I want to use the quirk to fix this problem for those hosts > with a watchdog mechanism. Okay. So this shouldn't be a quirk; it should apply all the time to any hub where the host controller has this watchdog mechanism. > > Why not set CONFIG_USB_FEW_INIT_RETRIES instead? > > > > https://source.android.com/docs/core/architecture/kernel/android-common > According to Android Common Kernel, I can't only add this config to one project. > In addition, it can't stop enumeration so that the timeout problem > still happens. This is the first time you have mentioned either the watchdog mechanism or the fact that this is intended for Android. It would have been a lot better if both of these facts were included in the initial patch description. You can't expect people to evaluate a new patch properly if they don't have a clear picture of what it was meant for. > > might describe in detail a situation where the quirk is needed, > > explaining what sort of behavior of the system would lead you to set the > > quirk, and why. > > > > There is a kernel panic when the device connects to the broken accessory. > I tried to modify the initial_descriptor_timeout. When the accessory is not > working, the total time is 6.5s (get descriptor retry) + 5*2 seconds > (set address of xhci timeout). > The time is so long to cause kernel panic for the device. This is why I want to > stop enumeration instead reducing the retries or timeout. It sounds like what you need is a "quick initialization" option that will limit the timeout lengths and the numbers of retries, and will cause the system to ignore connections on a port once an initialization has failed. There should also be a way to make the system stop ignoring a port, perhaps by writing to a sysfs file. In addition, there should be an automatic algorithm to determine which hub ports this option will apply to. I don't think you want it to be based on a quirk, because you shouldn't need to wait for a kernel panic before realizing that the quirk is needed -- that's why the algorithm has to be automatic. Can you write a new patch that works more like this? Alan Stern