Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp6093162pxb; Tue, 16 Feb 2021 16:16:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwOjinGLTQqzysxesmK1j/pIOPECihEmUVMI80WItOJcvZ2cBLp3I4WnenucauhqpDvg6SO X-Received: by 2002:a17:906:a1c2:: with SMTP id bx2mr23608887ejb.138.1613520977520; Tue, 16 Feb 2021 16:16:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613520977; cv=none; d=google.com; s=arc-20160816; b=IXxJn6UAR4EigAx2sjb3Q4nmdNSy1cUZ5P09jLFM5Rd5dv27qNPr1HtXqR2r4faZyA XxINxEKVGMFWf2/oE6XzsF137K6WW6sVkEtBY3C9mjsJJnr9T8ZN6mgd5+KY9XgjjWoz 6RMOnRrXn6DcqWcFQpvNy4Nf58t0wvccyUq78i8cYh5m4zCHecWqThGR0+ExVV5JapeA +e7NDq/bbu1wx9YPdcbGAdNDrktWk3TouNRKcr8mPpU1R7iAqJmOxRSqCfh7BmZiYD3j H7WKaecc2JR6oWa17oinz4CbQI0VfY/NlF5W1P3Hzx2aKiwq6oeoDeAaBb84kajoVeoE coVQ== 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=sOL58otYVbO9KpkCVWoE3Hr3GQzXRXCnoq1WEZdF9WM=; b=EHX1gkyiPRlowCR440prCnAzrHgy75O3J6r2FGCOw6G/H8g6mEWZrX+C0p0xTfTEmB mitK1aU6PvEEYHJZGQxEBOjXi0fqoZlsN4Opdr/YGuYy1j28drDMDnl/e855Ee+a6Bxg ftD/1p9Tn/qiobW9x3Gm1gEsZZxzjpR101woyn22APXgUMeE8YlxY1aTQx018G9GDx48 7wF7yL0SVEm4tHyZuvhXUwHl1xe9B3EnQZ1jRSVaF2SHzBPgpenT0j39GINKcJu6NNAt mW+78wLN6PdS8iyFN7PO+YgNIgQ/BBZzrTzXg655/gV5HId+AYvbtjznS30GrqLzMlBO EgJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=Swkb+nhn; 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 y8si114793eds.216.2021.02.16.16.15.54; Tue, 16 Feb 2021 16:16:17 -0800 (PST) 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=Swkb+nhn; 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 S231316AbhBQAIe (ORCPT + 99 others); Tue, 16 Feb 2021 19:08:34 -0500 Received: from z11.mailgun.us ([104.130.96.11]:34671 "EHLO z11.mailgun.us" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229894AbhBQAId (ORCPT ); Tue, 16 Feb 2021 19:08:33 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1613520493; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=sOL58otYVbO9KpkCVWoE3Hr3GQzXRXCnoq1WEZdF9WM=; b=Swkb+nhnUJ9I5carBKQTHzjHsraomeJEdSCmQVxRyCAlfdHOash5WM+6YmV9kj8w8TVnrgiE CEj8Eze4Lot531McRBPbXJ57Khuh2L4G7ByblxxEbF26YtDAK4AwjCrvZQO9oF2zjcXhuPX+ Wyq1aV3N7ACFVHfji0IG66Bxzbs= X-Mailgun-Sending-Ip: 104.130.96.11 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-n05.prod.us-east-1.postgun.com with SMTP id 602c5e4d24187d7bf210de3c (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 17 Feb 2021 00:07:41 GMT Sender: wcheng=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 83620C43461; Wed, 17 Feb 2021 00:07:40 +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, NICE_REPLY_A,SPF_FAIL autolearn=no autolearn_force=no version=3.4.0 Received: from [10.110.74.71] (i-global254.qualcomm.com [199.106.103.254]) (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 ED0FAC433C6; Wed, 17 Feb 2021 00:07:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org ED0FAC433C6 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 Subject: Re: usb: dwc3: gadget: Change runtime pm function for DWC3 runtime suspend To: eg Kroah-Hartman , Alan Stern Cc: Felipe Balbi , "open list:DESIGNWARE USB3 DRD IP DRIVER" , open list References: <1613356739-91734-1-git-send-email-dh10.jung@samsung.com> <20210215174145.GA960831@rowland.harvard.edu> <20210216013052.GA37172@ubuntu> From: Wesley Cheng Message-ID: Date: Tue, 16 Feb 2021 16:07:37 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210216013052.GA37172@ubuntu> 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 On 2/15/2021 5:30 PM, Jung Daehwan wrote: > Hello, Alan > > On Mon, Feb 15, 2021 at 12:41:45PM -0500, Alan Stern wrote: >> On Mon, Feb 15, 2021 at 11:38:58AM +0900, Daehwan Jung wrote: >>> It seems pm_runtime_put calls runtime_idle callback not runtime_suspend callback. >> >> How is this fact related to your patch? > > I think we should cause dwc3_runtime_suspend at the time. > That's why I use pm_runtime_put_sync_suspend. > >> >>> It's better to use pm_runtime_put_sync_suspend to allow DWC3 runtime suspend. >> >> Why do you think it is better? The advantage of pm_runtime_put is that >> it allows the suspend to occur at a later time in a workqueue thread, so >> the caller doesn't have to wait for the device to go into suspend. >> > > We can assume DWC3 was already in suspend state if pm_runtime_get_sync > returns 0. DWC3 resumes due to pm_rumtime_get_sync but it doesn't > re-enter runtime_suspend but runtime_idle. pm_runtime_put decreases > usage_count but doesn't cause runtime_suspend. > > 1. USB disconnected > 2. UDC unbinded > 3. DWC3 runtime suspend > 4. UDC binded unexpectedly > 5. DWC3 runtime resume (pm_runtime_get_sync) > 6. DWC3 runtime idle (pm_runtime_put) > -> DWC3 runtime suspend again (pm_runtime_put_sync_suspend) > > I've talked with Wesley in other patch. > > usbb: dwc3: gadget: skip pullup and set_speed after suspend > patchwork.kernel.org/project/linux-usb/patch/1611113968-102424-1-git-send-email-dh10.jung@samsung.com > > @ Wesley > > I think We should guarantee DWC3 enters suspend again at the time. > How do you think? > Hi Daehwan, Even if we call runtime idle versus suspend, if the device is still in the disconnected state, it should call the runtime PM suspend routine after the autosuspend timer expires. As Alan mentioned already, this allows not blocking the caller for the entire DWC3 suspend sequence to execute. (DWC3 core will suspend other components as well, such as PHYs) Also, for legitimate cases where pullup is actually called to start enumeration from a suspended state, I'm not sure if the short duration between RS set and re-suspend (due to your patch) is enough time for the host to actually detect the device connected. Thanks Wesley Cheng > Best Regards, > Jung Daehwan > >> Alan Stern >> > > >>> Signed-off-by: Daehwan Jung >>> --- >>> drivers/usb/dwc3/gadget.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c >>> index aebcf8e..4a4b93b 100644 >>> --- a/drivers/usb/dwc3/gadget.c >>> +++ b/drivers/usb/dwc3/gadget.c >>> @@ -2229,7 +2229,7 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) >>> */ >>> ret = pm_runtime_get_sync(dwc->dev); >>> if (!ret || ret < 0) { >>> - pm_runtime_put(dwc->dev); >>> + pm_runtime_put_sync_suspend(dwc->dev); >>> return 0; >>> } >>> >>> -- >>> 2.7.4 >>> >> >> -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project