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 Tue, May 10, 2022 at 06:46:02AM +0530, Pavan Kondeti wrote:
> 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);
> +

btw, should we add an else block here to take care of companion controllers
associcated if any. Can you pls tell us if it is possible that we have all
the below cases together? should the companion check be done only when
shared_hcd is not present?

- primary HCD (USB2.0, EHCI/XHCI)
- secondary HCD (USB3.0 XHCI)
- hs_companion (USB2.0 companion) for OHCI/UHCI

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);
	else if (hcd->self.hs_companion)
		nr_wakeup += usb_wakeup_enabled_descendants(hcd->self.hs_companion->root_hub);

	return nr_wakeup;
}

Thanks,
Pavan



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

  Powered by Linux