Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp797879rdb; Tue, 5 Dec 2023 23:19:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IHQJLVI5Bik767NAyrqLZL3aJNaVK3M90VDbVAkrgQchDvhLGVc2K3YNx7bEyADouAsSPMy X-Received: by 2002:a17:903:1205:b0:1d0:af43:9354 with SMTP id l5-20020a170903120500b001d0af439354mr383079plh.100.1701847184625; Tue, 05 Dec 2023 23:19:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701847184; cv=none; d=google.com; s=arc-20160816; b=uK2iyAxx0bJxT2m+fPJy3yon8g20YIH7tEFChje1ojfTe/QsK9YWQ/hfiSfSri8H0c 0gr9u2fVE01av65BFOv02nDU+9VjB3YpKvNGFRE54oGxd9rGPhedSe+Utdh/lL7BuXtF Fmq2x+bqkP7Y0zh+8r2knUQOpz4CA+bD2UYME46TySZudUUwYxDDa7QMAIfi9AyrlBY4 8Vntha+Tjp6w6xGu6AFaI22YNSoOnUUpEa2IYaPQGTFVTvEQO7knc2Ul4VltCM9apO0b aL6JWB1SFQDkk8SbCxQvM1rXIhxVFBZTk+BA5rCn2CZLI2m1VoNcMz6Xs40yzEAFpgax aL3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=ZGUnqnKqiH3fiQPt2YzpZAzinEzCmAaPqVPFdS5nUos=; fh=oQ0WJh0quzfxnD4pHUoUS3jHXz6V0PE2EFbf+5i60Ro=; b=kOH01XM5+9S4vnh64DZXYEvmw9V0Tf3Sn9KPICEDDJ4k/02+6cFTb+yxKJFm+vDqPz tbxl+3Apxx5zm7bbxB63x7GxC7hLCsvag7palfyZKlY5WxzQ3ITPYB55oVGCkzismGAx Mw3XrX7DIjqurZnjdVUstUTDuaR3rF3xdz7FoyhdHPCMInMLSLzWHa4p34R8WMaSuq+W 91thPf9EUyVkWJr3FQg+RlKuRqMERzLOWyuh+6xUriIBJ/RzfXB5qX6TMOe1QJQ4vCzR H3wgpBH4xH0rqyV3IipGRFBrj4l+xfZI1Jk/321nnLDFhezTgul+nUCWDoDbZyrs5rpS bQbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rock-chips.com header.s=default header.b=G9hc2pE1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=rock-chips.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id r5-20020a1709028bc500b001cf68d533fasi6231450plo.633.2023.12.05.23.19.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 23:19:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@rock-chips.com header.s=default header.b=G9hc2pE1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=rock-chips.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id EC152819874F; Tue, 5 Dec 2023 23:19:41 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377012AbjLFHT1 (ORCPT + 99 others); Wed, 6 Dec 2023 02:19:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376923AbjLFHT0 (ORCPT ); Wed, 6 Dec 2023 02:19:26 -0500 X-Greylist: delayed 600 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 05 Dec 2023 23:19:31 PST Received: from mail-m92232.xmail.ntesmail.com (mail-m92232.xmail.ntesmail.com [103.126.92.232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E28B9E; Tue, 5 Dec 2023 23:19:30 -0800 (PST) DKIM-Signature: a=rsa-sha256; b=G9hc2pE1Vl1lBDFKkQ5Pc4UHtjbFYBDjCcQbMcmQ6BZIQmID9ySC4ZNy0kRUqZn2hsOo6IYLo/UeS6jcKkEGb3N332vRDlJHsJ4hxA8CNQ2zlEx8AEPu7LlJ0qumeRHwQB5pCVjlVt1claGVSK7fmV1mii/M6ZFWbSnfdOwj4Tk=; s=default; c=relaxed/relaxed; d=rock-chips.com; v=1; bh=ZGUnqnKqiH3fiQPt2YzpZAzinEzCmAaPqVPFdS5nUos=; h=date:mime-version:subject:message-id:from; Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m12786.qiye.163.com (Hmail) with ESMTPA id 64F0A7C01FD; Wed, 6 Dec 2023 14:59:40 +0800 (CST) From: Frank Wang To: Thinh.Nguyen@synopsys.com, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, william.wu@rock-chips.com, wmc@rock-chips.com, Frank Wang Subject: [PATCH] usb: dwc3: set pm runtime active before resume common Date: Wed, 6 Dec 2023 14:59:39 +0800 Message-Id: <20231206065939.16958-1-frank.wang@rock-chips.com> X-Mailer: git-send-email 2.17.1 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFDSUNOT01LS0k3V1ktWUFJV1kPCRoVCBIfWUFZGU5LS1YaShhCGB5OTBlMTUxVEwETFh oSFyQUDg9ZV1kYEgtZQVlOQ1VJSVVMVUpKT1lXWRYaDxIVHRRZQVlPS0hVSk1PSU5JVUpLS1VKQl kG X-HM-Tid: 0a8c3decd5c4b256kuuu64f0a7c01fd X-HM-MType: 1 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6OVE6Qyo6LDw2MAENVkgaPisC QgkKChdVSlVKTEtKQ09OQkNKSUlJVTMWGhIXVR0JGhUQVQwaFRw7CRQYEFYYExILCFUYFBZFWVdZ EgtZQVlOQ1VJSVVMVUpKT1lXWQgBWUFKQk1LNwY+ X-Spam-Status: No, score=0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SORBS_WEB,SPF_HELO_NONE,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 pete.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 (pete.vger.email [0.0.0.0]); Tue, 05 Dec 2023 23:19:42 -0800 (PST) For device mode, if PM runtime autosuspend feature enabled, the runtime power status of dwc3 may be suspended when run dwc3_resume(), and dwc3 gadget would not be configured in dwc3_gadget_run_stop(). It would cause gadget connected failed if USB cable has been plugged before PM resume. So move forward pm_runtime_set_active() to fix it. Signed-off-by: Frank Wang --- drivers/usb/dwc3/core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index b101dbf8c5dc..d891989e8459 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -2340,12 +2340,15 @@ static int dwc3_resume(struct device *dev) pinctrl_pm_select_default_state(dev); + pm_runtime_disable(dev); + pm_runtime_set_active(dev); + ret = dwc3_resume_common(dwc, PMSG_RESUME); - if (ret) + if (ret) { + pm_runtime_set_suspended(dev); return ret; + } - pm_runtime_disable(dev); - pm_runtime_set_active(dev); pm_runtime_enable(dev); return 0; -- 2.17.1