Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2276900iob; Sat, 30 Apr 2022 04:30:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxa4sU8NhKF1++xpQiTRqP1XFOjzvURLSnVY46s69xfOm2QvsrZxBZkUC6updLiBwk6zIji X-Received: by 2002:a2e:a886:0:b0:24f:583:5bba with SMTP id m6-20020a2ea886000000b0024f05835bbamr2277461ljq.215.1651318246955; Sat, 30 Apr 2022 04:30:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651318246; cv=none; d=google.com; s=arc-20160816; b=OpoaY4gI4sSbtqEWR3irbZpfL74Zeu53vEFYKMaV1kKMvJqsjdQfYdJ9EnHPG4am8H XX7FKzdAC5s3lyooUJTu+OVs0foKP2KpjPqRjAHYjitRrH8qfRVuJ7qghuP3ppl+HIQv 2B/kWhOEx4rrTqBVrqtMArNVigyYRZzfTU/RIu4vhpB+a47bTA1v9yldvSdDc+W02rF9 I3a7bRdf64JdwPOaFLwS/r9ujxdE9fd0mkfe8/RTCRNEmjRcTzgmfDR1tMQ2LNGGwvf8 jJjWuSqxQ1LrCytslv3mI0LZguz2M7Jl3OOCz6RXW6hSkdwjC1N5PDxxFwPt02gxeQi0 uG7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=qehntlNSJq+nSLAk/tGVn281Y3k/WwjxEdBJaH7UQNQ=; b=bolf/eJDllh/ap9RDDAAC0wrlCg97zpUfDqHUa199AIb8PCcCvI2D7eMn/4TEYdVFG jVoOZLSnT9U92DOj8r80tVHMkd/S8OOy2ayFSCjPhCgZNUifk91vUIbUHihfwbgIb9e5 0QZGQCrRFm6xwNe4+UNBdesrGKdP2/y5ucEZFrLUOp+n6Ue6SAvgnXUD+HMNnKIFeI2L x7nEc7Lfv7i8SZCfZtF53tbKSKitGixAc81+NYShdJd4WPQUHQj/8HKpMOHLMjGMRCDg fKqa+IVf7oidsfZ6tAMr5sGn1jHDEXPZ3U/J3TrzL9Km4y+o48eWtb0m1yJSZKsjb/D2 uCKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=hLICcUqA; 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=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f7-20020a056512228700b00449fff280f8si10157287lfu.122.2022.04.30.04.30.02; Sat, 30 Apr 2022 04:30:46 -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=@quicinc.com header.s=qcdkim header.b=hLICcUqA; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359621AbiD2NDb (ORCPT + 99 others); Fri, 29 Apr 2022 09:03:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230480AbiD2ND2 (ORCPT ); Fri, 29 Apr 2022 09:03:28 -0400 Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA07F2BD7; Fri, 29 Apr 2022 06:00:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1651237209; x=1682773209; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=qehntlNSJq+nSLAk/tGVn281Y3k/WwjxEdBJaH7UQNQ=; b=hLICcUqAu9sXLZxhGCeVcLjS3EaMVTBSa91yN0G2TGsogjo4isj/z7sx XTrEfaxRO57uxHhZQqhays5QWc6EPugS3/z/KZ9vtsL38fA0QRCNrycCj Z3moXFCs+MU9Dip5dJ/pJcg8exoJvII0XB5LV5GrJP4unJFuE5Vk7XhO6 s=; Received: from unknown (HELO ironmsg05-sd.qualcomm.com) ([10.53.140.145]) by alexa-out-sd-02.qualcomm.com with ESMTP; 29 Apr 2022 06:00:09 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg05-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2022 06:00:08 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Fri, 29 Apr 2022 06:00:08 -0700 Received: from hu-pkondeti-hyd.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Fri, 29 Apr 2022 06:00:00 -0700 Date: Fri, 29 Apr 2022 18:29:56 +0530 From: Pavan Kondeti To: Pavan Kondeti CC: Matthias Kaehlcke , "Rafael J. Wysocki" , Sandeep Maheswaram , "Rob Herring" , Andy Gross , "Bjorn Andersson" , Greg Kroah-Hartman , Felipe Balbi , Stephen Boyd , Doug Anderson , Mathias Nyman , Krzysztof Kozlowski , Len Brown , "Pavel Machek" , Linux PM , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , linux-arm-msm , "open list:ULTRA-WIDEBAND (UWB) SUBSYSTEM:" , Linux Kernel Mailing List , , , Subject: Re: [PATCH v14 2/7] PM / wakeup: Add device_children_wakeup_capable() Message-ID: <20220429125956.GD16319@hu-pkondeti-hyd.qualcomm.com> References: <1650395470-31333-1-git-send-email-quic_c_sanm@quicinc.com> <1650395470-31333-3-git-send-email-quic_c_sanm@quicinc.com> <20220425130303.GA16319@hu-pkondeti-hyd.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20220425130303.GA16319@hu-pkondeti-hyd.qualcomm.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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 Hi Matthias, On Mon, Apr 25, 2022 at 06:33:03PM +0530, Pavan Kondeti wrote: > Hi Matthias, > > On Fri, Apr 22, 2022 at 11:44:36AM -0700, Matthias Kaehlcke wrote: > > On Fri, Apr 22, 2022 at 01:57:17PM +0200, Rafael J. Wysocki wrote: > > > On Tue, Apr 19, 2022 at 9:11 PM Sandeep Maheswaram > > > wrote: > > > > > > > > From: Matthias Kaehlcke > > > > > > > > Add device_children_wakeup_capable() which checks whether the device itself > > > > or one if its descendants is wakeup capable. > > > > > > device_wakeup_path() exists for a very similar purpose. > > > > > > Is it not usable for whatever you need the new function introduced here? > > > > I wasn't aware of it's function, there are no doc comments and the > > name isn't really self explanatory. > > > > In a quick test device_wakeup_path() returned inconsistent values for the > > root hub, sometimes true, others false when a wakeup capable USB device was > > connected. > > We will also test the same to double confirm the behavior of > device_wakeup_path(). I am assuming that you checked device_wakeup_path() > only during system suspend path. > > Here is what I understood by looking at __device_suspend(). Please share > your thoughts on this. > > power.wakeup_path is set to true for the parent *after* a wakeup capable > device is suspended. This means when the root hub(s) is suspended, it is > propagated to xhci-plat and when xhci-plat is suspended, it is propagated > to dwc3. bottom up propgation during system suspend. > > I believe we can directly check something like this in the dwc3 driver > instead of having another wrapper like device_children_wakeup_capable(). > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > index 1170b80..a783257 100644 > --- a/drivers/usb/dwc3/core.c > +++ b/drivers/usb/dwc3/core.c > @@ -1878,8 +1878,14 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg) > break; > case DWC3_GCTL_PRTCAP_HOST: > if (!PMSG_IS_AUTO(msg)) { > + /* > + * Don't kill the host when dwc3 is wakeup capable and > + * its children needs wakeup. > + */ > + if (device_may_wakeup(dwc->dev) && device_wakeup_path(dwc->dev)) > + handle_it(); > + } else { > dwc3_core_exit(dwc); > - break; > } > > /* Let controller to suspend HSPHY before PHY driver suspends */ > device_wakeup_path(dwc->dev) is returning true all the time irrespective of the wakeup capability (and enabled status) of the connected USB devices. That is because xhci-plat device is configured to wakeup all the time. Since the child is wakeup capable, its parent i.e dwc3 has device_wakeup_path() set. device_children_wakeup_capable() will also suffer the problem. However, device_children_wakeup_capable(&hcd->self.root_hub->dev) is what Sandeep's patch is using. That is not correct. we have two root hubs (HS and SS) associated with a USB3 controller and calling it on one root hub is incorrect. device_children_wakeup_capable() must be called on xhci-plat so that it covers both HS and SS root hubs I am thinking of dynamically enabling/disabling xhci-plat wakeup capability so that the wakeup path is correctly propagated to dwc3. something like below. Does it make sense to you? diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 649ffd8..be0c55b 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -412,6 +412,9 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev) struct xhci_hcd *xhci = hcd_to_xhci(hcd); int ret; + if (!device_wakeup_path(dev)) + device_wakeup_disable(dev); + if (pm_runtime_suspended(dev)) pm_runtime_resume(dev); @@ -443,6 +446,8 @@ static int __maybe_unused xhci_plat_resume(struct device *dev) pm_runtime_set_active(dev); pm_runtime_enable(dev); + device_wakeup_enable(dev); + return 0; } Thanks, Pavan