Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1570602rwd; Wed, 31 May 2023 16:14:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6K2r1CVlxsov3ywlH9fp6TNOSXTkEY9VoFhLoUmJPe7NkMAYldQNIpzaenL9Lrw5kHsd3v X-Received: by 2002:a17:90a:8997:b0:253:510e:130a with SMTP id v23-20020a17090a899700b00253510e130amr7924922pjn.19.1685574888873; Wed, 31 May 2023 16:14:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685574888; cv=none; d=google.com; s=arc-20160816; b=xlpRDY827zEplY0u+P0g6Pscgs4YT3iScmknsgORfSc58EYRDXns/6VMKJa0RDvvbE V4I7Y1ncY2uXO7/h9l2dRwrJiz7DBm2zjQ6Ds+bOUUuHF7Yg9GaQ7d5LNVYtmOS5P9F4 sdKKr3CiSwI87HsgDRxWGH/gtsFrnXN10Zu4iDSjogU/AEIP5gPZNm9Y/l9znbLjJSk1 CdDn3wLaRqYpsUzm2u9UajeiX0Ie3KiGpTbG9ygZFACiIw2ueDAjiBC3C30gpOi47Gls nHwC4ip4mIWq3S9PrneawAPXQzSyha4i2Fw+w6NZFW+y3My0+Ls4JPFSjUUEY8Yzw671 /X+g== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=yo0dmgLq+iQAdoCfpazppFMxnjk/8Qvxr0b3JoZEbas=; b=OWI1aoHonJAq7BylFUZyj90pOivWCDdx7iVCDYmFRU3EBRI1/D0Y3CTig4dBoRyE2u xj44hkMD0S+Cm3zOpPeyeYvkHTe5vQOW9JCPXp2eTwaGcTFEcMiY9zTCtflnh3MH7awl T4dWQ7O4PsWbYPIlgOtmSv1tQNkthXu6h50qy7/sYYjR9bLutJtWvlAW5xeB0wbUutAh cN7UtKiu6JJ0uAS6bKD7o9gn6L000xbgmrVjjEx0xADwz4hEmLiSWzvrtYmysYJBCslr IfHMK3GWitAGIKe0nTLDbgHsxFKN088m1KVgaBHora4GNrhrwU5qbKRcrmPxUpS+CGwq zFMQ== 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 29-20020a17090a01dd00b00253667cf6e4si146044pjd.20.2023.05.31.16.14.33; Wed, 31 May 2023 16:14:48 -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 S229499AbjEaWzh (ORCPT + 99 others); Wed, 31 May 2023 18:55:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229781AbjEaWzg (ORCPT ); Wed, 31 May 2023 18:55:36 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 6FE3A107 for ; Wed, 31 May 2023 15:55:33 -0700 (PDT) Received: (qmail 454049 invoked by uid 1000); 31 May 2023 18:55:32 -0400 Date: Wed, 31 May 2023 18:55:32 -0400 From: Alan Stern To: Badhri Jagan Sridharan Cc: gregkh@linuxfoundation.org, colin.i.king@gmail.com, xuetao09@huawei.com, quic_eserrao@quicinc.com, water.zhangjiantao@huawei.com, francesco@dolcini.it, alistair@alistair23.me, stephan@gerhold.net, bagasdotme@gmail.com, luca@z3ntu.xyz, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v5 2/3] usb: gadget: udc: core: Invoke usb_gadget_connect only when started Message-ID: <0125d274-bac3-41e1-bd29-156a3bfcc995@rowland.harvard.edu> References: <20230531040203.19295-1-badhri@google.com> <20230531040203.19295-2-badhri@google.com> <618e4f17-2799-4838-a21c-184c9303bef6@rowland.harvard.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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 Wed, May 31, 2023 at 03:40:26PM -0700, Badhri Jagan Sridharan wrote: > On Wed, May 31, 2023 at 10:55 AM Alan Stern wrote: > > > > On Wed, May 31, 2023 at 04:02:02AM +0000, Badhri Jagan Sridharan wrote: > > > usb_udc_connect_control() does not check to see if the udc has already > > > been started. This causes gadget->ops->pullup to be called through > > > usb_gadget_connect() when invoked from usb_udc_vbus_handler() even > > > before usb_gadget_udc_start() is called. Guard this by checking for > > > udc->started in usb_udc_connect_control() before invoking > > > usb_gadget_connect(). > > > > After a merged version of patches 1/3 and 3/3 have been applied, it > > seems like most of this will not be needed any more. Maybe not any of > > it. > > Without the connect_lock introduced in this patch, wouldn't the > usb_gadget_connect()/ > usb_gadget_disconnect() through soft_connect_store() race against > usb_gadget_connect()/ usb_gadget_disconnect() through > usb_udc_connect_control() ? Okay, yes, that's a good point. It needs to be mentioned in the patch description so that people will understand it is the real reason for this change. Alan Stern