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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85E47C4332F for ; Mon, 1 Nov 2021 20:48:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5FEB561058 for ; Mon, 1 Nov 2021 20:48:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231159AbhKAUvY (ORCPT ); Mon, 1 Nov 2021 16:51:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229541AbhKAUvW (ORCPT ); Mon, 1 Nov 2021 16:51:22 -0400 Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7374C061714 for ; Mon, 1 Nov 2021 13:48:48 -0700 (PDT) Received: by mail-oi1-x22c.google.com with SMTP id g125so26755338oif.9 for ; Mon, 01 Nov 2021 13:48:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=kLZlvGuYfD48cZVymavfiR4ir/NsVXyW2QnosTPuKps=; b=c4g3rqpdHKuTRwD+snh7K+fGicBlHHzoPlSKNJU7CvA+mQdU2E73tmZYCTZ8Q2cFPd ahiPJMT8fmTE9LM2YIGG9mnX1//mciM3G+b9Uv25iR6uUpD0DeEvkjlCdWwcRgwfbZTa 8+kvGTt6S2ILLVcBmd/mdYNHgypv2K47ip5xENxhageOjOYVuldlE78sLHmZ77urfFpt whgP09g1iEQCuIrZTrV9eh436SjwFVBNEGmRCsMub7rQzriBZV0SnWjNvHH03GsI2KBO OMfeoRwuuKSyqjfBvjjRANBXUT0YpvqMFRuuQkDDMIDybwJhkuIxLGmD9s0LA5JEO7ek bpXg== 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=kLZlvGuYfD48cZVymavfiR4ir/NsVXyW2QnosTPuKps=; b=cA2KnyKNQRmoS8CfmDrg5JBWt37uDdSzzT/Vzbszh4yceZNtAKqS02ByL5PcwGXLSI 2CWE1l+AfBacrsTcJhSHkfygKMGT8fzoV/c171xEU8hrTI6TNVFZD3bgXEX15qngCuui NaM4HPQSg6vRkx1mna+eMZfJc06PB/DJrUOwqzx/gFEVedsNTIL5Aohap254LNoRQBeV wTqghQQzZqcteTpzJFVVLFPs3oCIOjKA9811RbR8/EwC53oxrTSWJvuREtsFOon/HMs5 H/fJZc7csLCOYsW7ZvB64MxvABXzI9fjBeg4873duNyOOxYyer5Ats4NNb7SQqGhYQIa eOnw== X-Gm-Message-State: AOAM5312Rh0INrFd3M6i7KUsL8WNDmLjSLaQv7rIp0zs6NjBaQ69+GSk +Hls5qo3lnN2xuw6qlL8MJk5BA== X-Google-Smtp-Source: ABdhPJxyE5t0F0whY4HGQUe45RXybQr7psjtvxGWvIXmCKh04S/x+z4pOJN3feE5PrfnuXCDGj+lIA== X-Received: by 2002:a05:6808:1885:: with SMTP id bi5mr1188843oib.151.1635799727602; Mon, 01 Nov 2021 13:48:47 -0700 (PDT) Received: from ripper (104-57-184-186.lightspeed.austtx.sbcglobal.net. [104.57.184.186]) by smtp.gmail.com with ESMTPSA id t2sm3914558oou.38.2021.11.01.13.48.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 13:48:47 -0700 (PDT) Date: Mon, 1 Nov 2021 13:50:31 -0700 From: Bjorn Andersson To: Matthias Kaehlcke Cc: Sandeep Maheswaram , Andy Gross , Greg Kroah-Hartman , Felipe Balbi , Stephen Boyd , Doug Anderson , Mathias Nyman , linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, quic_pkondeti@quicinc.com, quic_ppratap@quicinc.com Subject: Re: [PATCH v9 1/5] usb: host: xhci: plat: Add suspend quirk for dwc3 controller Message-ID: References: <1635753224-23975-1-git-send-email-quic_c_sanm@quicinc.com> <1635753224-23975-2-git-send-email-quic_c_sanm@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 01 Nov 11:59 PDT 2021, Matthias Kaehlcke wrote: > Hi Sandeep, > > On Mon, Nov 01, 2021 at 01:23:40PM +0530, Sandeep Maheswaram wrote: > > During suspend check if any wakeup capable devices are connected to the > > controller (directly or through hubs), and set the wakeup capable property > > for xhci plat device. > > > > Signed-off-by: Sandeep Maheswaram > > --- > > drivers/usb/host/xhci-plat.c | 12 ++++++++++++ > > 1 file changed, 12 insertions(+) > > > > diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c > > index c1edcc9..7ab272b 100644 > > --- a/drivers/usb/host/xhci-plat.c > > +++ b/drivers/usb/host/xhci-plat.c > > @@ -431,6 +431,14 @@ static int xhci_plat_remove(struct platform_device *dev) > > return 0; > > } > > > > +static void xhci_dwc3_suspend_quirk(struct usb_hcd *hcd, struct device *dev) > > +{ > > + if (usb_wakeup_enabled_descendants(hcd->self.root_hub)) > > + device_set_wakeup_capable(dev, true); > > + else > > + device_set_wakeup_capable(dev, false); > > IIUC wakeup capability is typically a static property that reflects the > actual hardware (or firmware) support for wakeup. In that sense it doesn't > seem a good idea to change it dynamically at suspend time, depending on > what is connected to the bus. I understand though that the odd split > of the dwc3 driver makes it hard to do things properly ... > > Earlier in this discussion Felipe suggested to add a function like > device_children_wakeup_capable(), to avoid having to call > usb_wakeup_enabled_descendants() from the dwc3 drivers. > > Below is an initial implementation for device_children_wakeup_capable(), > could you try if calling it from dwc3_suspend/resume_common() and > dwc3_qcom_suspend() would work instead of relying on the wakeup > capability? > > Thanks > > Matthias > > From 97c838334045ed67c3943f8e035ac70acd12b89b Mon Sep 17 00:00:00 2001 > From: Matthias Kaehlcke > Date: Mon, 1 Nov 2021 11:37:19 -0700 > Subject: [PATCH] PM / wakeup: Add device_children_wakeup_capable() > > Add device_children_wakeup_capable() which checks whether the device itself > or one if its descendants is wakeup capable. > > Change-Id: Ib359eb5ac8650ddf9889c7d1f77707f50777fe99 > Suggested-by: Felipe Balbi > Signed-off-by: Matthias Kaehlcke Looks neat and useful. Reviewed-by: Bjorn Andersson (Without the Change-Id of course...) Regards, Bjorn > --- > drivers/base/power/wakeup.c | 17 +++++++++++++++++ > include/linux/pm_wakeup.h | 6 ++++++ > 2 files changed, 23 insertions(+) > > diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c > index 9c0932603642..2aee7fa8230f 100644 > --- a/drivers/base/power/wakeup.c > +++ b/drivers/base/power/wakeup.c > @@ -483,6 +483,23 @@ int device_set_wakeup_enable(struct device *dev, bool enable) > } > EXPORT_SYMBOL_GPL(device_set_wakeup_enable); > > +static int __device_children_wakeup_capable(struct device *dev, void *dummy) > +{ > + return device_may_wakeup(dev) || > + device_for_each_child(dev, NULL, __device_children_wakeup_capable); > +} > + > +/** > + * device_children_wakeup_capable - Check whether a device or one of its descendants is > + * wakeup capable. > + * @dev: Device to handle. > + */ > +bool device_children_wakeup_capable(struct device *dev) > +{ > + return __device_children_wakeup_capable(dev, NULL); > +} > +EXPORT_SYMBOL_GPL(device_children_wakeup_capable); > + > /** > * wakeup_source_not_registered - validate the given wakeup source. > * @ws: Wakeup source to be validated. > diff --git a/include/linux/pm_wakeup.h b/include/linux/pm_wakeup.h > index 661efa029c96..a0ca42aac6d6 100644 > --- a/include/linux/pm_wakeup.h > +++ b/include/linux/pm_wakeup.h > @@ -97,6 +97,7 @@ extern int device_wakeup_disable(struct device *dev); > extern void device_set_wakeup_capable(struct device *dev, bool capable); > extern int device_init_wakeup(struct device *dev, bool val); > extern int device_set_wakeup_enable(struct device *dev, bool enable); > +extern bool device_children_wakeup_capable(struct device *dev); > extern void __pm_stay_awake(struct wakeup_source *ws); > extern void pm_stay_awake(struct device *dev); > extern void __pm_relax(struct wakeup_source *ws); > @@ -167,6 +168,11 @@ static inline bool device_may_wakeup(struct device *dev) > > static inline void device_set_wakeup_path(struct device *dev) {} > > +static inline bool device_children_wakeup_capable(struct device *dev) > +{ > + return false; > +} > + > static inline void __pm_stay_awake(struct wakeup_source *ws) {} > > static inline void pm_stay_awake(struct device *dev) {}