From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6257AC19F2D for ; Thu, 4 Aug 2022 16:59:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232682AbiHDQ75 (ORCPT ); Thu, 4 Aug 2022 12:59:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237103AbiHDQ74 (ORCPT ); Thu, 4 Aug 2022 12:59:56 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CB6C6A481 for ; Thu, 4 Aug 2022 09:59:47 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id y141so41117pfb.7 for ; Thu, 04 Aug 2022 09:59:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Ajh2ay/tShS0T3mEFnSZ0by+HsK7Mn/hpkM/mCvNva0=; b=lz/kuCg6IRO4dLKH6V4paHzmXaWNI12uLvsnPN1lBCr6Lleqx3m6d36BH0R40kxcz0 qM0qFj55Q76+GJ/6Ctyh/+14pVlT91DCeYlfBOuq4v01aVb7Sc0/S98g7gAK69fVQnPo jB9CGh6CqpjPkKtTIVGO8bRQoqyLxs2RDYqyI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Ajh2ay/tShS0T3mEFnSZ0by+HsK7Mn/hpkM/mCvNva0=; b=1jYg1uCjPO4rjmD3B0IfPSc/AV1zngzGm9KOlwl6PuwhMuEvGDcKMIjqg9Lml/2BYB 3d2jOORDhtiEMMzVaUt9+7m0h4JfAoTOUIHFzk7gFzlOmckxnPGAQ+3hSTiZoC7u+G2V pc2BzH2DwIGkHcJ786x0EENAXQL8sAM+RQfgyR0Wok88XBQT8IvCb5QJzN4eh7KkiAzz xTbdK1aWbbXajpJhPtrvhYPNUExeC1ifipnetcoJg0fhmN2SyOojYEL4r8Ew5NyGEMKc mGdjsHYy22xHSi+VM+Xy8rFXk0V2uW+IhYNQvmrnpuIhoVtZEJKWW1EnQn7proFoUxV/ gc4A== X-Gm-Message-State: ACgBeo2gIZZW3K3uLfWTKpF4q46Z8ykRePR/EeddCn0pkKf4YdpK/say ydiNTvryMRvZVn9Dvj1oWjbq2w== X-Google-Smtp-Source: AA6agR7X25qLSBYYrho0ENYRQNA0Cmh8oMxWYY7cOVtOcXFu+38U/7oHiu3qGRghMajV/hSd5z2nOQ== X-Received: by 2002:a63:8242:0:b0:41b:e465:81dd with SMTP id w63-20020a638242000000b0041be46581ddmr2348517pgd.217.1659632386946; Thu, 04 Aug 2022 09:59:46 -0700 (PDT) Received: from localhost ([2620:15c:11a:202:87c4:32ca:84b6:e942]) by smtp.gmail.com with UTF8SMTPSA id nu3-20020a17090b1b0300b001f52fa1704csm14280238pjb.3.2022.08.04.09.59.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 04 Aug 2022 09:59:46 -0700 (PDT) Date: Thu, 4 Aug 2022 09:59:44 -0700 From: Matthias Kaehlcke To: Johan Hovold Cc: Greg Kroah-Hartman , Felipe Balbi , Rob Herring , Krzysztof Kozlowski , Andy Gross , Bjorn Andersson , Manivannan Sadhasivam , Konrad Dybcio , Krishna Kurapati , Stephen Boyd , Doug Anderson , Pavankumar Kondeti , quic_ppratap@quicinc.com, quic_vpulyala@quicinc.com, linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 8/9] usb: dwc3: qcom: fix wakeup implementation Message-ID: References: <20220804151001.23612-1-johan+linaro@kernel.org> <20220804151001.23612-9-johan+linaro@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220804151001.23612-9-johan+linaro@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On Thu, Aug 04, 2022 at 05:10:00PM +0200, Johan Hovold wrote: > It is the Qualcomm glue wakeup interrupts that may be able to wake the > system from suspend and this can now be described in the devicetree. > > Move the wakeup-source property handling over from the core driver and > instead propagate the capability setting to the core device during > probe. > > This is needed as there is currently no way for the core driver to query > the wakeup setting of the glue device, but it is the core driver that > manages the PHY power state during suspend. > > Also don't leave the PHYs enabled when system wakeup has been disabled > through sysfs. > > Fixes: 649f5c842ba3 ("usb: dwc3: core: Host wake up support from system suspend") > Signed-off-by: Johan Hovold > --- > drivers/usb/dwc3/core.c | 5 ++--- > drivers/usb/dwc3/dwc3-qcom.c | 6 +++++- > 2 files changed, 7 insertions(+), 4 deletions(-) > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > index 16d1f328775f..8c8e32651473 100644 > --- a/drivers/usb/dwc3/core.c > +++ b/drivers/usb/dwc3/core.c > @@ -1822,7 +1822,6 @@ static int dwc3_probe(struct platform_device *pdev) > > platform_set_drvdata(pdev, dwc); > dwc3_cache_hwparams(dwc); > - device_init_wakeup(&pdev->dev, of_property_read_bool(dev->of_node, "wakeup-source")); > > spin_lock_init(&dwc->lock); > mutex_init(&dwc->mutex); > @@ -1984,7 +1983,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) && !device_can_wakeup(dwc->dev)) { > + if (!PMSG_IS_AUTO(msg) && !device_may_wakeup(dwc->dev)) { Let me explain the rationale for why device_can_wakeup() was used here: On QCOM SC7180 based Chromebooks we observe that the onboard USB hub consumes ~80 mW during system suspend when the PHYs are disabled, as opposed to ~17 mW when the PHYs remain enabled. This is a significant delta when the device is on a battery power. The initial idea was to leave the PHYs always enabled (in a low power mode), but then I dug up commit c4a5153e87fd ("usb: dwc3: core: Power-off core/PHYs on system_suspend in host mode"), which provides a rationale for the PHYs being powered off: Commit 689bf72c6e0d ("usb: dwc3: Don't reinitialize core during host bus-suspend/resume") updated suspend/resume routines to not power_off and reinit PHYs/core for host mode. It broke platforms that rely on DWC3 core to power_off PHYs to enter low power state on system suspend. Unfortunately we don't know which platforms are impacted by this. The idea behind using device_can_wakeup() was to use it as a proxy for platforms that are *not* impacted. If a platform supports USB wakeup supposedly the SoC can enter its low power mode during system suspend with the PHYs enabled. By now I'm not 100% sure if the above assumption is correct. I recently saw allegations that the power consumption of a given QC SoC with USB wakeup support drops significantly when wakeup is disabled (i.e. when the PHYs are off), but haven't confirmed this yet.