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: Thu, 9 Jul 2020 05:15:25 +0000 [thread overview]
Message-ID: <20200709051534.GA17510@b29397-desktop> (raw)
In-Reply-To: <20200708150204.GC776368@rowland.harvard.edu>
On 20-07-08 11:02:04, Alan Stern wrote:
> On Wed, Jul 08, 2020 at 06:47:31AM +0000, Peter Chen wrote:
> > On 20-07-07 12:11:53, Alan Stern wrote:
>
> > > > But, that's not all the use cases. There are still two other use cases:
> > > > (Taking xhci-plat.c as an example):
> > > > - It is a platform bus device created by platform bus driver
> > > > - It is a platform bus device created by glue layer parents
> > > > (eg, dwc3/cdns3), usually, it is dual-role controller.
> > >
> > > In these cases there would be a choice: xhci-plat.c could call
> > > device_init_wakeup, or the platform-bus/glue-layer driver could call
> > > device_set_wakeup_capable and xhci-plat.c could continue to call
> > > device_enable_wakeup.
> >
> > You said "the PCI core calls device_set_wakeup_capable() when a new device is
> > discovered and register", why PCI core does this, is every device on
> > PCI bus wakeup capable?
>
> Sorry, I should have said that the PCI core does this for all devices
> that are able to generate wakeup requests. This ability is indicated by
> a PCI capability setting, which the PCI core can read.
>
> > The reason I ask this is not every device on platform-bus is wakeup
> > capable, to let the controller device have defaulted "enabled" value,
> > we need to use device_init_wakeup at xhci-plat.c
>
> Yes. In your case it makes sense for the glue layer or platform code to
> call device_set_wakeup_capable for the appropriate devices. Then the
> generic code can call device_enable_wakeup (which doesn't do anything
> if the device isn't wakeup-capable).
>
Yes, in my case, I could do it. But xhci-plat.c is generic code, some
controller devices using this driver are created by generic platform
bus driver. So I think we should use device_init_wakeup(dev, true) like
you suggested at the first, this driver should not be used by PCI USB
controller, so no effect on PCI USB, right?
> >
> > From hardware level:
> > Controller includes core part and non-core part, core part is usually
> > designed by IP vendor, non-core part is usually designed by each SoC
> > vendors. Wakeup handling is part of non-core. The USB PHY gets
> > ID/VBUS/DP/DM/RX change events, the related signal ties to non-core part,
> > and non-core part knows the wakeup occurs.
> >
> > From software level:
> > Taking single role controller as example:
> > Glue layer is a platform device, and handles non-core part events,
> > including wakeup events, it is the parent of common layer which handles
> > core part events (eg, xhci-plat.c)
>
> Can you give an example of how these different layers show up in sysfs
> (the device names and paths)?
Our platforms are more complicated than this example, there are dual-role
controllers (chipidea/cdns3/dwc3) at SoCs. Taking cdns3 as an example:
/sys/bus/platform/devices/: the devices on the platform bus
5b110000.usb3: non-core part (cdns3/cdns3-imx.c)
5b130000.cdns3: the dual-role core part (cdns3/core.c)
xhci-hcd.1.auto: the host core part (xhci-plat.c)
usb1/usb2: roothubs for USB2 and USB3
root@imx8qmmek:~# cat /sys/bus/platform/devices/5b110000.usb3/
5b130000.cdns3/ driver_override power/ uevent
consumers modalias subsystem/
driver/ of_node/ suppliers
root@imx8qmmek:~# cat /sys/bus/platform/devices/5b110000.usb3/5b130000.cdns3/
consumers modalias power/ uevent
driver/ of_node/ subsystem/ usb_role/
driver_override pools suppliers xhci-hcd.1.auto/
root@imx8qmmek:~# cat /sys/bus/platform/devices/5b110000.usb3/5b130000.cdns3/xhci-hcd.1.auto/
consumers modalias suppliers usb2/
driver/ power/ uevent
driver_override subsystem/ usb1/
>
> > So, one controller includes two platform devices, one for glue layer,
> > one for common layer.
>
> Is there a mechanism that allows the xhci-hcd core driver to tell the
> non-core or PHY driver to enable or disable these wakeup events?
>
Not easy, see my comments below.
> Or maybe better would be a way for the non-core/PHY driver to examine
> the root hub's usb_device structure to see whether these wakeup events
> should be enabled.
>
> > You are right, ID/VBUS/DP/DM/RX signal changing occurs at the USB bus,
> > and detected by USB PHY physically.
> >
> > The controller device (core part) or glue layer device
> > (non-core part)'s wakeup setting is only used to enable/disable platform
> > related powers (regulators) for USB (PHY) which are used to detect
> > ID/VBUS/DP/DM/RX signal. If the platform doesn't need USB wakeup capabilities
> > for system suspend, it could turn off related powers. Besides, it could tell
> > the system if USB interrupt can be the wakeup interrupt.
>
> We want to make the system simple and logical for users, not necessarily
> easy for hardware engineers. This means that wakeup events such as port
> connect, disconnect, and so on should be controlled by a single sysfs
> setting, for a single device. The most logical device for this purpose
> is the root hub, as I mentioned earlier in this discussion.
>
> As a result, the wakeup settings for the other components (non-core or
> PHY) should be based on the settings for the root hub. If the root hub
> is disabled for wakeup then the non-core hardware components shouldn't
> generate any wakeup requests, no matter what their power/wakeup files
> contain. And if the root hub is enabled for wakeup then the non-core
> hardware components should generate these requests, unless their own
> power/wakeup settings prevent them from doing so.
>
> From these conclusions, it logically follows that the default wakeup
> setting for the non-core components should be "enabled" -- unless those
> components are physically incapable of waking up the system.
>
I agree with you that the default wakeup setting of core part for host
(xhci-plat.c) should be "enabled", but if for the dual-role controller,
the wakeup events like VBUS and ID do not related with roothub, we can't
set core part for controller (cdns3/core.c) for defaulted enabled, and
there is no thing like gadget bus's wakeup setting we could depend on.
Besides, the non-core part (glue layer) somethings can't visit core
part, we had to depend on itself wakeup setting, but not the child's
wakeup setting.
--
Thanks,
Peter Chen
next prev parent reply other threads:[~2020-07-09 5:15 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
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 [this message]
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=20200709051534.GA17510@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;
as well as URLs for NNTP newsgroup(s).