Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp183061iob; Mon, 2 May 2022 16:31:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDKjENOj5embha5G6NghZmkYHofxwlj6h5+fzWX+M32nLy8FmpTKavqVFR2xPX1mxRcDSo X-Received: by 2002:a17:902:e746:b0:15e:b4f3:72e7 with SMTP id p6-20020a170902e74600b0015eb4f372e7mr1539606plf.8.1651534293149; Mon, 02 May 2022 16:31:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651534293; cv=none; d=google.com; s=arc-20160816; b=UxHc7UQg5rh+Tk6nmZ5F4zhfecpflP0BCUA5lkaEuYTKrO7/Lrq7B5BA6lNJ66WIgL LtSmbWGUlTzY5nhGBo4qMa4Q87LM+8NdKf4ja61Zi8VlsKqt2VfX4Km6ViDbWH+1w6m9 xZo/zR++xL/T3sl0i24+X3QBlwmqLzGAuyNDlesuYJwQacnFpdHEn5l/Ge5dFiyZwHOo J6WKT2n+XT7MPc9APMPtq8QjGTcxD5gvaa8gpZVWNnVei/+jbJgCDy8eCg9roengYVed L9NZOigmWiQYHS6IxSKbR7HfpjNBFeZ5C79QSMll9l+WL5rn7DEkSYjKv06L6ltgY1Zb vmPw== 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=mForJUYNnKPSCqNaig1pMrtjG1IwLz5LvyPwt3h2lJ0=; b=NFXrSNl/0TT/xgyKmhXncsLrS23/V3UpDNDw307tKWqd1xYsWPCxNPZeo12ukW/gyL ZdrF+nF40OCGWyihUkYNspnMV4Yco/pSW/oBm1KUGKbeV+DQwCWIKoNb9A7j8YiUzs0a ASz9GNixgKdN91nik0c4IRkniFkLy0FXr2JLfkHyhMucY1e0LuoZRqIoc+bOKPxfV03G 1tiIOpGGGDzO139Ni6XBRSlyMKhD/FwZlZWm/0eBtGXUWZvSoWCbIYo7BvnXmTrbM0Zm 9AW6/PPlkKBkQCrmQa1oYVlPl5LsRA36z8wgpZ/kv1/NORf2A9ReuIpUdkj5C8MHQA+m gkSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=aNrmsFe2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u14-20020a170903124e00b0015e7d5502a8si10225726plh.612.2022.05.02.16.31.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 16:31:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=aNrmsFe2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1C045DF29; Mon, 2 May 2022 16:31:26 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382117AbiD3DPY (ORCPT + 99 others); Fri, 29 Apr 2022 23:15:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238217AbiD3DPX (ORCPT ); Fri, 29 Apr 2022 23:15:23 -0400 Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECE28433B6; Fri, 29 Apr 2022 20:12:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1651288323; x=1682824323; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=mForJUYNnKPSCqNaig1pMrtjG1IwLz5LvyPwt3h2lJ0=; b=aNrmsFe2POxgrdUXNE+xJeO0yVICvG49pBesmGrmMkq1NbyeA20fsYy5 huOlfpj85fVJKe4K3wQWZQcPSP9eekd0xPNHp6h2PgSGUz5k5UUSe46eB fjgMmcr521J4nmb9kvW/vgI435I8kpARERzfuKHKktJTRCiFhQ4AdHKgD g=; Received: from ironmsg07-lv.qualcomm.com ([10.47.202.151]) by alexa-out.qualcomm.com with ESMTP; 29 Apr 2022 20:12:02 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg07-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2022 20:12:01 -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 20:11:42 -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 20:11:34 -0700 Date: Sat, 30 Apr 2022 08:41:30 +0530 From: Pavan Kondeti To: Matthias Kaehlcke CC: Pavan Kondeti , "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: <20220430031130.GE16319@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> <20220429125956.GD16319@hu-pkondeti-hyd.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Fri, Apr 29, 2022 at 12:19:22PM -0700, Matthias Kaehlcke wrote: > Hi Pavan, > > On Fri, Apr 29, 2022 at 06:29:56PM +0530, Pavan Kondeti wrote: > > 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 > > Thanks for pointing that out! > > > 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); > > I think this also needs to be done conditionally, otherwise it would > create a new wake source on every resume when wakeup is already > enabled. > Right, this needs to be done conditionally. However, there is a silent warning inside device_wakeup_enable() if it is called during system transition. Not sure if we really need to worry about that or not. Thanks, Pavan