Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp2959416rwb; Sat, 6 Aug 2022 09:26:52 -0700 (PDT) X-Google-Smtp-Source: AA6agR59rbrL2u1oXaPsmYkBHSeSrP55bc58tcYxWmKVnESUf9beL9XbJ/LP+VX1Xe7is/tqamd1 X-Received: by 2002:a05:6402:3881:b0:43a:691f:8e3b with SMTP id fd1-20020a056402388100b0043a691f8e3bmr11127991edb.217.1659803212054; Sat, 06 Aug 2022 09:26:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659803212; cv=none; d=google.com; s=arc-20160816; b=nJjsDi635cn97I+G7nIOFP+wfkUmiQcmLigl1sG+Sdsix4resvSddoRsmS3LET7bhO jsYJDAnuxMvJn+9fDICPyWvuWQDJknC9sruMc/dmhhcL0MvAWHvFJwTFuiTZZXg1kbbG qzE4bqpsyD/ygOQUKLqRtNIBhKD2uYavZQydVsVb3B6jApGE3TgF6VnSt/3qmtRnXDsz EnNE6aAWZhlIwsPDFUVxKrEl+4+Y6hSrBL0uMHNZssEnk2RKdNNuWELtRYk+HjY8zGVF U1kEhujHeEszW6K8wmA64NFM0sU5Hid7BsMBzaROvh7Ati0SXv+HR9rlgzKXCYUOFDc8 MqKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=sZN1QyYD8SXrAlnOUpHdikR1SpXSU6zz7SDZdsysAiY=; b=Es+9yBZoBJmSORzy1k9b9JQWem3XMXZDWxt2Dvb2+UYxe/z7dqJ5vwRukzY14/6DYT VYWx0GAo1tyxmLxH0LWNHVTKnr07Q6AzvT2gnSCwNQFh0awC+SycrpmMBWSGMAjzkOTA D7vgJxZ1CF6tQMYDKI5ticpuWiP4UT8PBun05nXHBzKZ6Vs/xnwoTSX7y49UpMTXTOu+ xdKsvJweOyoUIAs8gCD5IQD34MpiDL26Y5G2Mts1G1FUhHl1dlEUyOU2ktBXLmBnoP21 CF/KI36MGnHNn/sAx0W5h/HymtdDjhZ2jmefVf2L4OTs4imsdOrEJADxCmEkTHEjEdsn W5ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RQilBDDy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go32-20020a1709070da000b0073065ea79bfsi6682654ejc.528.2022.08.06.09.26.26; Sat, 06 Aug 2022 09:26:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RQilBDDy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231978AbiHFQWO (ORCPT + 99 others); Sat, 6 Aug 2022 12:22:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230211AbiHFQWN (ORCPT ); Sat, 6 Aug 2022 12:22:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46FD111154; Sat, 6 Aug 2022 09:22:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D190F61154; Sat, 6 Aug 2022 16:22:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35EEAC433D6; Sat, 6 Aug 2022 16:22:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659802931; bh=B6rbe4yCofemCFAJcjJszIFDl+tuNOh58ShiJfQERfY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RQilBDDy3mJ0lGbi2LYchi2RNGI/D3IN7mXfAZc2sDnY5ohY4W97tTUIdDUp+smhy IQ+aGYBUXfmRtCgrZXlXl4VN1pF/rCRUa//m3ZEccN2aBLN1SE77tkhXRYfz6yQaNw KJgNuFeeMNouU20BuZF3AADuYmjv5g1/iMj7rQaYHpoxAwYqUplZ3pFV+6GVsl2Rfj curCJLgBzOnKRtBQO80pS6hwSahuZg0WBCDhTsZcslM+on4GKU1RHDG67AB8brfild NlEfAfFXNMLhuCY0ycpxPn+w+KtY3s5V9C3o2zxorQAHaStssfIBYH2uWf9fP0eE8Q qOQR5qR9lEJlQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oKMZR-0003Nm-P6; Sat, 06 Aug 2022 18:22:38 +0200 Date: Sat, 6 Aug 2022 18:22:37 +0200 From: Johan Hovold To: Matthias Kaehlcke Cc: Johan Hovold , 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=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 05, 2022 at 09:58:35AM -0700, Matthias Kaehlcke wrote: > On Thu, Aug 04, 2022 at 09:59:44AM -0700, Matthias Kaehlcke wrote: > > 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. > > So far power measurements don't support the claim that SoC power > consumption is substantially lower with USB wakeup disabled/the PHYs > off. I asked the person who made that claim to provide more > details/data (the discussion is in an internal forum). Thanks for the background on this. So clearly it has nothing to with supporting wakeup as the commit summary claimed, and this should probably never have been made to depend on wakeup capability either. I'll revisit this after the merge window, but perhaps we should just rip this out completely and use a more descriptive property to configure the PHY suspend state. But depending on the results from your internal measurements, perhaps not even that is needed. Johan