public inbox for linux-rockchip@lists.infradead.org
 help / color / mirror / Atom feed
From: Douglas Anderson <dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
To: Minas Harutyunyan
	<hminas-HKixBCOQz3hWk0Htik3J/w@public.gmane.org>,
	Felipe Balbi
	<felipe.balbi-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
	heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org
Cc: Amelie Delaunay <amelie.delaunay-qxv4g6HH51o@public.gmane.org>,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Kai-Heng Feng
	<kai.heng.feng-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>,
	zyw-TNX95d0MmH7DzftRWevZcw@public.gmane.org,
	Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org>,
	Nicolas Boichat
	<drinkcat-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	mka-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org,
	Alan Stern
	<stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org>,
	Jon Flatley <jflat-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
	Artur Petrosyan
	<Arthur.Petrosyan-HKixBCOQz3hWk0Htik3J/w@public.gmane.org>,
	Elaine Zhang <zhangqing-TNX95d0MmH7DzftRWevZcw@public.gmane.org>,
	amstan-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org,
	Randy Li <ayaka-xPW3/0Ywev/iB9QmIjCX8w@public.gmane.org>,
	Mathias Nyman
	<mathias.nyman-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
	Greg Kroah-Hartman
	<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Douglas Anderson
	<dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
	ryandcase-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org,
	William Wu <william.wu-TNX95d0MmH7DzftRWevZcw@public.gmane.org>,
	jwerner-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org,
	dinguyen-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org,
	Nicolas Saenz Julienne
	<nsaenzjulienne-l3A5Bk7waGM@public.gmane.org>
Subject: [PATCH v2 2/5] USB: Export usb_wakeup_enabled_descendants()
Date: Wed, 17 Apr 2019 17:13:53 -0700	[thread overview]
Message-ID: <20190418001356.124334-3-dianders@chromium.org> (raw)
In-Reply-To: <20190418001356.124334-1-dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>

In (e583d9d USB: global suspend and remote wakeup don't mix) we
introduced wakeup_enabled_descendants() as a static function.  We'd
like to use this function in USB controller drivers to know if we
should keep the controller on during suspend time, since doing so has
a power impact.

Signed-off-by: Douglas Anderson <dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
For relevant prior discussion of this idea, see:

https://lkml.kernel.org/r/1436207224-21849-4-git-send-email-dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org

If I'm reading all the responses correctly folks were of the opinion
that this patch is still the right way to go.

Changes in v2: None

 drivers/usb/core/hub.c  | 7 ++++---
 include/linux/usb/hcd.h | 5 +++++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 8d4631c81b9f..5e8f3fa7ae5a 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -3174,13 +3174,14 @@ static int usb_disable_remote_wakeup(struct usb_device *udev)
 }
 
 /* Count of wakeup-enabled devices at or below udev */
-static unsigned wakeup_enabled_descendants(struct usb_device *udev)
+unsigned usb_wakeup_enabled_descendants(struct usb_device *udev)
 {
 	struct usb_hub *hub = usb_hub_to_struct_hub(udev);
 
 	return udev->do_remote_wakeup +
 			(hub ? hub->wakeup_enabled_descendants : 0);
 }
+EXPORT_SYMBOL_GPL(usb_wakeup_enabled_descendants);
 
 /*
  * usb_port_suspend - suspend a usb device's upstream port
@@ -3282,7 +3283,7 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
 	 * Therefore we will turn on the suspend feature if udev or any of its
 	 * descendants is enabled for remote wakeup.
 	 */
-	else if (PMSG_IS_AUTO(msg) || wakeup_enabled_descendants(udev) > 0)
+	else if (PMSG_IS_AUTO(msg) || usb_wakeup_enabled_descendants(udev) > 0)
 		status = set_port_feature(hub->hdev, port1,
 				USB_PORT_FEAT_SUSPEND);
 	else {
@@ -3687,7 +3688,7 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
 		}
 		if (udev)
 			hub->wakeup_enabled_descendants +=
-					wakeup_enabled_descendants(udev);
+					usb_wakeup_enabled_descendants(udev);
 	}
 
 	if (hdev->do_remote_wakeup && hub->quirk_check_port_auto_suspend) {
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index 695931b03684..ed4fbbd1b35f 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -652,11 +652,16 @@ extern wait_queue_head_t usb_kill_urb_queue;
 #define usb_endpoint_out(ep_dir)	(!((ep_dir) & USB_DIR_IN))
 
 #ifdef CONFIG_PM
+extern unsigned usb_wakeup_enabled_descendants(struct usb_device *udev);
 extern void usb_root_hub_lost_power(struct usb_device *rhdev);
 extern int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg);
 extern int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg);
 extern void usb_hcd_resume_root_hub(struct usb_hcd *hcd);
 #else
+static inline unsigned usb_wakeup_enabled_descendants(struct usb_device *udev)
+{
+	return 0;
+}
 static inline void usb_hcd_resume_root_hub(struct usb_hcd *hcd)
 {
 	return;
-- 
2.21.0.593.g511ec345e18-goog

  parent reply	other threads:[~2019-04-18  0:13 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-18  0:13 [PATCH v2 0/5] USB: dwc2: Allow wakeup from suspend; enable for rk3288-veyron Douglas Anderson
2019-04-18  0:13 ` [PATCH v2 1/5] usb: dwc2: bus suspend/resume for hosts with DWC2_POWER_DOWN_PARAM_NONE Douglas Anderson
2019-04-29  8:43   ` Artur Petrosyan
2019-04-29 17:33     ` Doug Anderson
2019-04-30  6:05       ` Artur Petrosyan
2019-05-01  1:51         ` Doug Anderson
2019-05-03  8:20           ` Artur Petrosyan
2019-05-03 15:03             ` Doug Anderson
2019-05-07  7:26               ` Artur Petrosyan
2019-05-01 23:58   ` Doug Anderson
2019-05-03  8:25     ` Artur Petrosyan
2019-05-03 15:07       ` Doug Anderson
2019-05-07  7:05         ` Artur Petrosyan
     [not found] ` <20190418001356.124334-1-dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2019-04-18  0:13   ` Douglas Anderson [this message]
2019-04-18  0:13 ` [PATCH v2 3/5] Documentation: dt-bindings: Add snps,need-phy-for-wake for dwc2 USB Douglas Anderson
2019-04-25 12:40   ` Felipe Balbi
2019-04-25 18:09     ` Doug Anderson
2019-04-25 19:58       ` Doug Anderson
     [not found]     ` <87pnpas1fx.fsf-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2019-05-02 18:36       ` Doug Anderson
2019-04-30  1:23   ` Rob Herring
2019-04-30  5:25     ` Doug Anderson
2019-04-18  0:13 ` [PATCH v2 4/5] USB: dwc2: Don't turn off the usbphy in suspend if wakeup is enabled Douglas Anderson
2019-04-25 12:41   ` Felipe Balbi
2019-04-18  0:13 ` [PATCH v2 5/5] ARM: dts: rockchip: Allow wakeup from rk3288-veyron's dwc2 USB ports Douglas Anderson
2019-04-18 12:40 ` [PATCH v2 0/5] USB: dwc2: Allow wakeup from suspend; enable for rk3288-veyron Minas Harutyunyan
2019-04-18 15:54   ` Doug Anderson
2019-04-19 11:43     ` Artur Petrosyan
2019-04-19 16:44       ` Artur Petrosyan
2019-04-22 15:50         ` Artur Petrosyan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190418001356.124334-3-dianders@chromium.org \
    --to=dianders-f7+t8e8rja9g9huczpvpmw@public.gmane.org \
    --cc=Arthur.Petrosyan-HKixBCOQz3hWk0Htik3J/w@public.gmane.org \
    --cc=amelie.delaunay-qxv4g6HH51o@public.gmane.org \
    --cc=amstan-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=ayaka-xPW3/0Ywev/iB9QmIjCX8w@public.gmane.org \
    --cc=dinguyen-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org \
    --cc=drinkcat-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=felipe.balbi-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
    --cc=heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org \
    --cc=hminas-HKixBCOQz3hWk0Htik3J/w@public.gmane.org \
    --cc=jflat-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=jwerner-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=kai.heng.feng-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mathias.nyman-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=mka-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=nsaenzjulienne-l3A5Bk7waGM@public.gmane.org \
    --cc=ryandcase-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=stefan.wahren-eS4NqCHxEME@public.gmane.org \
    --cc=stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org \
    --cc=william.wu-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
    --cc=zhangqing-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
    --cc=zyw-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox