Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2241301pxb; Fri, 17 Sep 2021 05:40:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8WfrwzZR5EW0VDedWE5l/puKTNKgcxjMYQHLBYVhDDrN8fHR/wbkn+SAhB+6Z2BzSSmQF X-Received: by 2002:a17:907:20cb:: with SMTP id qq11mr11665474ejb.488.1631882444989; Fri, 17 Sep 2021 05:40:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631882444; cv=none; d=google.com; s=arc-20160816; b=wZJLFwIjpidKnY8BdZVaL+0Rvq3BEaHP05RVEtGuTn8Gz9D1r0fuLSezOSpEk9BfqB oic4SvRZMws/JkkZODT8NO0rkMyZTfaAgWA9uZgjjWS9pz6t1NhyB2JihX4I83NPlS68 EEIo7Ar5nR02fQamEJEE2f/SgsR1Mhs+NYwPNzdD9j8ZAym2FAOBZsAnzrQ1Dku7+XQ6 GyhX87dyQirJ4N4LuMXorMIbRB5Xskm9T0UpZgWKFopSl9rmvrMbtJF5x/BgzgBHTXVT pXqJRpCyjj076AaPrKbG43Ms1149eapt5eoB/OU+ADRrIZv27J2UdBbOYeVuh1hOO81N Slhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dmarc-filter:sender:dkim-signature; bh=71x/5CV+GloaODoruzokP4i9Sjebw7Bm1eLwxI/272A=; b=CrkxQew9Y/Mt0MIJcZSQBNwoEJHOptvXhVoTrGAeygHRVH4FfT6NWNhjrvuX1T7gXd l3c2aOxfCd5KuV0WOjrp+hesCQZLmqpI1AZVEi2pfDydzCb1MhfEISFlfcxWVgl/IruJ 5m618Kc/Yo9qBkBYhNpGnm7Geuu5HuOVqDktCQbbVptNbLGXVqDg6s77lOAiikHScgc8 ut0Ia1fQ8HXdiOltnPWuJJ0kEFjPMRpjDUAUJaWYRq3PLAq45Q0HnFxQlftCROLBpasj jBBN/wmpvKUQty0oDUPRCWI5TBkZnZJcLTLdoDYWPgVjlW0G1HxEDiOtSsYFGJiyCSgS n8rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=SC63itUG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c19si7346353ejj.206.2021.09.17.05.40.21; Fri, 17 Sep 2021 05:40:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=SC63itUG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232539AbhIQG3y (ORCPT + 99 others); Fri, 17 Sep 2021 02:29:54 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:64206 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231666AbhIQG3v (ORCPT ); Fri, 17 Sep 2021 02:29:51 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1631860110; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=71x/5CV+GloaODoruzokP4i9Sjebw7Bm1eLwxI/272A=; b=SC63itUGCiN+OY02Lqk9XG0vh9gYb8RIGDn1Y0LzaFro3J5MGE6vt39eD8S4+bh2yOkCY4HT 3llOV6RZaTGPpt/gph2aYV+QKFft2OVCGGKGvlhlLHSuUs7qi9OktA9ZK3cNV5QcCMzk2prR UhChOc5lJzhJGrAENw4vd2XhGGQ= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n02.prod.us-west-2.postgun.com with SMTP id 6144357ce0f78151d6a4e6b2 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Fri, 17 Sep 2021 06:28:12 GMT Sender: wcheng=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 92C21C43460; Fri, 17 Sep 2021 06:28:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.4 required=2.0 tests=ALL_TRUSTED,BAYES_00, NICE_REPLY_A,SPF_FAIL,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from [192.168.1.26] (075-140-094-099.biz.spectrum.com [75.140.94.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: wcheng) by smtp.codeaurora.org (Postfix) with ESMTPSA id B7A75C4338F; Fri, 17 Sep 2021 06:28:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.codeaurora.org B7A75C4338F Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=codeaurora.org Subject: Re: [PATCH] usb: dwc3: gadget: Avoid starting DWC3 gadget during UDC unbind To: Felipe Balbi Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210917021852.2037-1-wcheng@codeaurora.org> <87y27vai3p.fsf@kernel.org> From: Wesley Cheng Message-ID: <474148e5-37e2-ea0c-7d78-9e71155314d9@codeaurora.org> Date: Thu, 16 Sep 2021 23:28:09 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <87y27vai3p.fsf@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 9/16/2021 10:17 PM, Felipe Balbi wrote: > > Hi, > > Wesley Cheng writes: > >> There is a race present where the DWC3 runtime resume runs in parallel >> to the UDC unbind sequence. This will eventually lead to a possible >> scenario where we are enabling the run/stop bit, without a valid >> composition defined. >> >> Thread#1 (handling UDC unbind): >> usb_gadget_remove_driver() >> -->usb_gadget_disconnect() >> -->dwc3_gadget_pullup(0) >> --> continue UDC unbind sequence >> -->Thread#2 is running in parallel here >> >> Thread#2 (handing next cable connect) >> __dwc3_set_mode() >> -->pm_runtime_get_sync() >> -->dwc3_gadget_resume() >> -->dwc->gadget_driver is NOT NULL yet >> -->dwc3_gadget_run_stop(1) >> --> _dwc3gadget_start() >> ... >> >> Fix this by tracking the pullup disable routine, and avoiding resuming >> of the DWC3 gadget. Once the UDC is re-binded, that will trigger the >> pullup enable routine, which would handle enabling the DWC3 gadget. >> >> Signed-off-by: Wesley Cheng Thanks, Felipe! > > This looks okay to me, but needs to be tested by a few folks ;-) > > Acked-by: Felipe Balbi > Yes, would be good to get some functions using usb_gadget_activate/deactivate(). It should be OK for those situations as well, but just to make sure :) Thanks Wesley Cheng -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project