Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp18148pxx; Wed, 28 Oct 2020 16:45:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzq95GmqXk2U4VfedEJQxP0LSl6PFif+YqTM7p5vRogzV4CZgP9AAlAxVSQCCyV0iw0yNT7 X-Received: by 2002:a17:906:a891:: with SMTP id ha17mr1486615ejb.524.1603928732924; Wed, 28 Oct 2020 16:45:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603928732; cv=none; d=google.com; s=arc-20160816; b=ITFDu4NLiYSU1Nno1pAI9Xocx6+N78mNzv4LllF47erO2Vz0BRHKbNn8DtBfztEyiR +Al+NdQFIIkpMx53TmjO1Ug0B1/gr9V2lUpcP+2ZIlOANU9s86zI/ITUPqlrBtcpBHfR VZTQAyWIFtIzQtXghMW+kegi6hhrHryE5PFs4Lj757RlVYGA8H71fcoOx9l5JzB10/ug mWLdTjkWAOT62lFhh7UrtRlSd9eJcdVMKIYdkE/zB1jzy2rOuO3AEsCpFZItLT6Erozb GpfxxcZvRNKHw2pQAMcuYP0e5AWxtQLjyhsejgmVkQZtEQgTeAzGqveEgZu6Arx+UF5B bpWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dmarc-filter:sender:dkim-signature; bh=EiJC9o2fMu6Zihqt6GhqK14gv4g0EzuW9oUn3J3Z+6c=; b=IxrPfNqD/zRvD8SoYfHiKLZwloezCEDAaKog2zYiV3I356Gy75k+kUOth/WUh7VxRs irAl4iTVsmX3PVhA9PfJYQUoN4/jKHmF4YnXvf1/+cJp+2VeT3/+tncExAL5XZg5IFsV hmsgajfkx1e3I0WhgIObs4gXZXSijNBntQTDdN3GbmitJdhDUXHjhUrOoVvVwEfJorgD pHGZ3KKmeRV9wussV8pp8OGJTNVNr+rwK5xtcvhoHCglIaVnlsMgTlAtrtXF2IBB2LxH FVf3ucVnxhtZTrT0uwh3Vm745kSY8nd67bGtX42GW3k/TBpENNZT3QFF6JS5s9Up+o7T rcbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=bjStZG4h; 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 m6si571866ejc.527.2020.10.28.16.45.10; Wed, 28 Oct 2020 16:45:32 -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=bjStZG4h; 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 S2390488AbgJ1XnV (ORCPT + 99 others); Wed, 28 Oct 2020 19:43:21 -0400 Received: from m42-4.mailgun.net ([69.72.42.4]:51356 "EHLO m42-4.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390472AbgJ1XnT (ORCPT ); Wed, 28 Oct 2020 19:43:19 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1603928599; h=Content-Transfer-Encoding: MIME-Version: References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=EiJC9o2fMu6Zihqt6GhqK14gv4g0EzuW9oUn3J3Z+6c=; b=bjStZG4h81SX/sit7jMScCx2rNEXTV4LolEMij4zHLjxEiODLgEefiO+kwTqtLoZLAeQRTvz sB1qTsxmFp4Zgh7aGz3Y2qTDygnJcbe93XcqsHiuz0BtPi9oNoKbd3lCem+m/6wuZmFxiw/m A7NpRpAIIuvCU9kLsZuzq7dNBIU= X-Mailgun-Sending-Ip: 69.72.42.4 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-n07.prod.us-west-2.postgun.com with SMTP id 5f9a02160e953497c76751f0 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 28 Oct 2020 23:43:18 GMT Sender: wcheng=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id A24E5C433B1; Wed, 28 Oct 2020 23:43:18 +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=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from wcheng-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: wcheng) by smtp.codeaurora.org (Postfix) with ESMTPSA id B559AC43382; Wed, 28 Oct 2020 23:43:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B559AC43382 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=wcheng@codeaurora.org From: Wesley Cheng To: balbi@kernel.org, gregkh@linuxfoundation.org, Thinh.Nguyen@synopsys.com Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, jackp@codeaurora.org, Wesley Cheng Subject: [PATCH 1/2] usb: dwc3: gadget: Allow runtime suspend if UDC unbinded Date: Wed, 28 Oct 2020 16:43:10 -0700 Message-Id: <20201028234311.6464-2-wcheng@codeaurora.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201028234311.6464-1-wcheng@codeaurora.org> References: <20201028234311.6464-1-wcheng@codeaurora.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The DWC3 runtime suspend routine checks for the USB connected parameter to determine if the controller can enter into a low power state. The connected state is only set to false after receiving a disconnect event. However, in the case of a device initiated disconnect (i.e. UDC unbind), the controller is halted and a disconnect event is never generated. Set the connected flag to false if issuing a device initiated disconnect to allow the controller to be suspended. Signed-off-by: Wesley Cheng --- drivers/usb/dwc3/gadget.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 5d879b7606d5..6364429b2122 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1995,6 +1995,11 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) unsigned long flags; int ret; + if (pm_runtime_suspended(dwc->dev)) { + pm_request_resume(dwc->dev); + return 0; + } + is_on = !!is_on; /* @@ -2050,6 +2055,7 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) dwc->ev_buf->lpos = (dwc->ev_buf->lpos + count) % dwc->ev_buf->length; } + dwc->connected = false; } ret = dwc3_gadget_run_stop(dwc, is_on, false); -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project