Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4977668pxj; Tue, 25 May 2021 23:05:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxN05LHeza4vSnC6rj7fU9Epbq/GZWnPwZ2hJwhpow4WDLZWz6H8bEAEqvxWb6FPDwjrUAj X-Received: by 2002:aa7:d0d2:: with SMTP id u18mr667845edo.329.1622009119358; Tue, 25 May 2021 23:05:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622009119; cv=none; d=google.com; s=arc-20160816; b=gOsg6x6p3PLt1ELcOTB81IrMqt+X+svOdQ9jz54SDkbJsOhGMrmpi6tShI8p4Hbcnq e22OD+aPkrpjis0qQDR8jtYnurQ9Q6ZPjaQTwpKoTJxc1O4blrvMDo3RfC+XHO+H040h SQuX+3eDhLL1bhDwhBiEF6lW6USeuedJrm7YUjZH5FZdw1TKzs6gTf1xLo8lRNS4+7DC Oq1VW/a8EOx43q275eSbPWg+YpEmIdoBUBhGEcoEzVSxxRZ+JLlVDjEFpNIqXkDsKWbS cirCcTuabyHmwZmQLiURI/SLaer/3uggNeYOfYfOxVAQAyseletFWLuCxIPpiLyhSm1/ yzJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dmarc-filter:sender:dkim-signature; bh=XpW6sOG7Ucv6llKqpIHNUwNVxPAdIkYhq01saEjDcpU=; b=EOQSYEFfGSseXTke32ldUGzV5tG52neucgi7HwnZwhKFIUMTnx6ORAZWlHb9hDRH8P pIvoxugO4lqGK7IHDbDiAvZRgbrOfdBkdFF6F9jm9zBnRRQJl+7xVBe5zwiftNF21VlS cgsMobNnwGPe4DeIo3dd9kjn03PQGPTSmISuZWESW05Sx9D1Tg+OzBfWxTz0j/39kPXB bS8WlJAk5u1fMDSUAOZWTX3f6Vk29Ofc12HFeCbopvCtDkq0S3P/OcW3/qRHHXHLvfuJ gHYiHqgxWMTcYVTTLAg+Perc3PTcR374OT1uiwt1DJUzjDOWqblYz0JN+u0TcRDmptXx UHSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=fOWcbqhA; 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 g3si17997583ejf.16.2021.05.25.23.04.55; Tue, 25 May 2021 23:05:19 -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=fOWcbqhA; 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 S231136AbhEZEb2 (ORCPT + 99 others); Wed, 26 May 2021 00:31:28 -0400 Received: from so254-9.mailgun.net ([198.61.254.9]:64232 "EHLO so254-9.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbhEZEb1 (ORCPT ); Wed, 26 May 2021 00:31:27 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1622003397; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=XpW6sOG7Ucv6llKqpIHNUwNVxPAdIkYhq01saEjDcpU=; b=fOWcbqhAU7C8y20/pmSYtrYXhIkkg4vDAJDxrPbM102/psSKZoLYV0lFn+IzyGoZUWBxZjrD LFG6SaE5lgE9xEcKsAanmgXArg+E7I0a/BXmvNkMFHY4sW8IGIo+VrlQ2CBF/lpOhkVcwlbs KBH1EyNgSpaCmEelsY1ZjNQ+f6w= X-Mailgun-Sending-Ip: 198.61.254.9 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-n01.prod.us-west-2.postgun.com with SMTP id 60adceb32bff04e53bc24c06 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 26 May 2021 04:29:39 GMT Sender: sanm=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id CF312C433F1; Wed, 26 May 2021 04:29:39 +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 [192.168.0.104] (unknown [49.206.34.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sanm) by smtp.codeaurora.org (Postfix) with ESMTPSA id A5FC7C433D3; Wed, 26 May 2021 04:29:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A5FC7C433D3 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=sanm@codeaurora.org Subject: Re: [PATCH v7 2/5] usb: dwc3: core: Host wake up support from system suspend To: Matthias Kaehlcke , Felipe Balbi Cc: Andy Gross , Bjorn Andersson , Greg Kroah-Hartman , Stephen Boyd , Doug Anderson , linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Manu Gautam References: <1619586716-8687-1-git-send-email-sanm@codeaurora.org> <1619586716-8687-3-git-send-email-sanm@codeaurora.org> <87r1iuk9vs.fsf@kernel.org> <184ddea9-643f-91ea-6d1f-5bdd26373e53@codeaurora.org> <87h7jkhxmw.fsf@kernel.org> From: Sandeep Maheswaram Message-ID: <4e3951dc-f3e7-0815-7d73-d836240de3e9@codeaurora.org> Date: Wed, 26 May 2021 09:59:33 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Felipe, On 5/13/2021 3:17 AM, Matthias Kaehlcke wrote: > On Mon, May 03, 2021 at 02:20:23PM +0300, Felipe Balbi wrote: >> Hi, >> >> Sandeep Maheswaram writes: >>>> Sandeep Maheswaram writes: >>>>> Avoiding phy powerdown when wakeup capable devices are connected >>>>> by checking phy_power_off flag. >>>>> Phy should be on to wake up the device from suspend using wakeup capable >>>>> devices such as keyboard and mouse. >>>>> >>>>> Signed-off-by: Sandeep Maheswaram >>>>> Reviewed-by: Matthias Kaehlcke >>>>> --- >>>>> drivers/usb/dwc3/core.c | 7 +++++-- >>>>> 1 file changed, 5 insertions(+), 2 deletions(-) >>>>> >>>>> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c >>>>> index b6e53d8..bb414c3 100644 >>>>> --- a/drivers/usb/dwc3/core.c >>>>> +++ b/drivers/usb/dwc3/core.c >>>>> @@ -1738,7 +1738,7 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg) >>>>> dwc3_core_exit(dwc); >>>>> break; >>>>> case DWC3_GCTL_PRTCAP_HOST: >>>>> - if (!PMSG_IS_AUTO(msg)) { >>>>> + if (!PMSG_IS_AUTO(msg) && dwc->phy_power_off) { >>>> should be able to detect this generically, no? Shouldn't >>>> device_may_wakeup() be valid here and give you the answer you want? >>> I thinkĀ  device_may_wakeup() gives whether the controller is wake up >>> capable or not. >> Yes, but it's a bit more than that. Looking at devices.rst we read: >> >> If :c:func:`device_may_wakeup(dev)` returns ``true``, the device should be >> prepared for generating hardware wakeup signals to trigger a system wakeup event >> when the system is in the sleep state. For example, :c:func:`enable_irq_wake()` >> might identify GPIO signals hooked up to a switch or other external hardware, >> and :c:func:`pci_enable_wake()` does something similar for the PCI PME signal. >> >> So, if there is a condition where $this device has to, somehow, deal >> with wakeup, it should be configured accordingly. This ->phy_power_off >> flag is telling us the same thing. >> >>> But we want to keep phy powered on only when some wakeup capable devices >>> (eg:keyboard ,mouse ) are connected to controller. >> Understood, it could be that we're missing some method for propagating >> that state (i.e. keyboard with PM support) up to the parent device, but >> that's no excuse to bypass driver boundaries. Wouldn't you agree? > I'm not sure if device_may_wakeup() is really the right tool for the > job. This is the current implementation: > > static inline bool device_may_wakeup(struct device *dev) > { > return dev->power.can_wakeup && !!dev->power.wakeup; > } > > IIUC power.can_wakeup specifies whether the device is wakeup > capable, primarily in physical terms and indicating that the > driver is ready to handle wakeups, and power.wakeup represents > the policy which can be changed by userspace. > > Supposing the hub is generally wakeup capable that flag > shouldn't be changed. Neither should be the policy based on > what is connected to the bus. Please suggest us how to proceed further with this patch.