public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Chen <peter.chen@nxp.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: "mathias.nyman@intel.com" <mathias.nyman@intel.com>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	dl-linux-imx <linux-imx@nxp.com>
Subject: Re: [PATCH 2/2] usb: host: xhci-plat: add wakeup entry at /sys
Date: Sun, 5 Jul 2020 02:12:47 +0000	[thread overview]
Message-ID: <20200705021256.GA29527@b29397-desktop> (raw)
In-Reply-To: <20200704144816.GA650205@rowland.harvard.edu>

On 20-07-04 10:48:16, Alan Stern wrote:
> On Sat, Jul 04, 2020 at 09:22:45AM +0000, Peter Chen wrote:
> > On 20-07-03 10:19:11, Alan Stern wrote:
> > > On Fri, Jul 03, 2020 at 02:25:32PM +0800, Peter Chen wrote:
> > > > After that, the user could enable controller as wakeup source
> > > > for system suspend through /sys entry.
> > > > 
> > > > Signed-off-by: Peter Chen <peter.chen@nxp.com>
> > > > ---
> > > >  drivers/usb/host/xhci-plat.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > 
> > > > diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> > > > index cebe24ec80a5..bb5d73f0a796 100644
> > > > --- a/drivers/usb/host/xhci-plat.c
> > > > +++ b/drivers/usb/host/xhci-plat.c
> > > > @@ -287,7 +287,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
> > > >  		*priv = *priv_match;
> > > >  	}
> > > >  
> > > > -	device_wakeup_enable(hcd->self.controller);
> > > > +	device_set_wakeup_capable(hcd->self.controller, true);
> > > 
> > > 
> > > In fact both this patch and the original code are wrong.  It really should 
> > > be:
> > > 
> > > 	device_init_wakeup(hcd->self.controller, true);
> > > 
> > > This will add the wakeup entry in sysfs and set it to Enabled.  This is 
> > > the appropriate behavior, as explained in the kerneldoc for 
> > > device_init_wakeup().  The reason is because the controller device doesn't 
> > > create any wakeup events on its own; it merely relays wakeup requests from 
> > > descendant devices (root hubs or USB devices).
> > 
> > Hi Alan,
> > 
> > At xhci-plat.c's system suspend API xhci_plat_suspend, it depends on
> > power/wakeup value to determine whether the controller should enable
> > port wakeup capabilities, and from the system level, whether the system
> > supports USB wakeup or not is better to be determined by user, and is
> > disabled by default.
> > 
> > Yes, you are right. The wakeup events are from controller's descendant
> > devices, and it is better to use roothub's wakeup capability to control
> > portsc's wakeup setting. At controller driver, the meaning for wakeup
> > setting is enabling wakeup interrupt for hardware signal events (dp/dm for USB2,
> > and RX-detect for USB3), this hardware logic is the glue layer and
> > designed by each vendors, without this logic, the USB controller can't
> > be woken up due to the USBCMD.RS bit is cleared, and there is no
> > standard EHCI or xHCI interrupt. The controller's wakeup setting is
> > better to be disabled by default, and decided by user too.
> > 
> > For me, either this patch or use roothub's wakeup capability to
> > control portsc wakeup setting, both are OK. Mathias, what's your
> > opinion?
> 
> Mathias is starting a long vacation, so he might not reply for a while.
> 
> Note that hcd-pci.c, ohci-platform.c, and ehci-platform.c all call 
> device_wakeup_enable().  This indicates that xhci-plat.c should do the 
> same -- presumably device_set_wakeup_capable() is already called somewhere 
> in the platform-specific code.
> 

Thanks for the information, Alan.

I could not understand why device_wakeup_enable is used in these device
drivers? At Documentation/driver-api/pm/devices.rst, L189, it also says:

	during a system sleep transition.  Device drivers, however, are
       	not expected to call :c:func:`device_set_wakeup_enable()` directly
       	in any case.

-- 

Thanks,
Peter Chen

  reply	other threads:[~2020-07-05  2:12 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-03  6:25 [PATCH 1/2] usb: host: xhci: avoid calling two contineous times for xhci_suspend Peter Chen
2020-07-03  6:25 ` [PATCH 2/2] usb: host: xhci-plat: add wakeup entry at /sys Peter Chen
2020-07-03 14:19   ` Alan Stern
2020-07-04  9:22     ` Peter Chen
2020-07-04 14:48       ` Alan Stern
2020-07-05  2:12         ` Peter Chen [this message]
2020-07-05 14:31           ` Alan Stern
2020-07-06  4:03             ` Peter Chen
2020-07-06 16:22               ` Alan Stern
2020-07-07  2:01                 ` Peter Chen
2020-07-07 16:11                   ` Alan Stern
2020-07-08  6:47                     ` Peter Chen
2020-07-08 15:02                       ` Alan Stern
2020-07-09  5:15                         ` Peter Chen
2020-07-09 14:50                           ` Alan Stern
2020-07-21 11:03                             ` Peter Chen
2020-07-21 14:10                               ` Alan Stern

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=20200705021256.GA29527@b29397-desktop \
    --to=peter.chen@nxp.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=stern@rowland.harvard.edu \
    /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