Re: [v15 3/6] usb: dwc3: core: Host wake up support from system suspend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 09, 2022 at 10:33:59AM -0400, Alan Stern wrote:
> On Mon, May 09, 2022 at 07:53:41PM +0530, Pavan Kondeti wrote:
> > On Mon, May 09, 2022 at 10:08:41AM -0400, Alan Stern wrote:
> > > BTW, if there's any trouble with getting device_wakeup_path() to work 
> > > the way you want, you could consider instead calling 
> > > usb_wakeup_enabled_descendants() on the root hub.  This function returns 
> > > a count of the number of wakeup-enabled USB devices at or below the 
> > > device you pass to it.
> > > 
> > 
> > This series [1] started with usb_wakeup_enabled_descendants() actually. one
> > of the problem with this API is that we have to call this on both USB2.0 and
> > USB3.0 root hubs. Do you think we can have a wrapper function like
> > usb_hcd_wakeup_enabled_descendants() that accepts hcd as an argument and
> > internally call usb_wakeup_enabled_descendants() on both root hubs and return
> > the result.
> 
> Sure you can.  Feel free to write such a function and add it to hcd.c.  
> Ideally it should work for host controllers with any number of root 
> hubs, just adding up the number of wakeup-enabled descendants for all of 
> them.
> 
Thanks Alan for the suggestion. Does the below diff looks good?

Thanks,
Pavan

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index c9443aa..f707f9b 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2704,6 +2704,19 @@ int usb_hcd_is_primary_hcd(struct usb_hcd *hcd)
 }
 EXPORT_SYMBOL_GPL(usb_hcd_is_primary_hcd);
 
+unsigned int usb_hcd_wakeup_enabled_descendants(struct usb_hcd *hcd)
+{
+	unsigned int nr_wakeup;
+
+	nr_wakeup = usb_wakeup_enabled_descendants(hcd->self.root_hub);
+
+	if (hcd->shared_hcd)
+		nr_wakeup += usb_wakeup_enabled_descendants(hcd->shared_hcd->self.root_hub);
+
+	return nr_wakeup;
+}
+EXPORT_SYMBOL_GPL(usb_hcd_wakeup_enabled_descendants);
+
 int usb_hcd_find_raw_port_number(struct usb_hcd *hcd, int port1)
 {
 	if (!hcd->driver->find_raw_port_number)
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index 1886e81..a5d561b 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -474,6 +474,7 @@ extern void usb_remove_hcd(struct usb_hcd *hcd);
 extern int usb_hcd_find_raw_port_number(struct usb_hcd *hcd, int port1);
 int usb_hcd_setup_local_mem(struct usb_hcd *hcd, phys_addr_t phys_addr,
 			    dma_addr_t dma, size_t size);
+extern unsigned int usb_hcd_wakeup_enabled_descendants(struct usb_hcd *hcd);
 
 struct platform_device;
 extern void usb_hcd_platform_shutdown(struct platform_device *dev);




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux