usb: dwc3: qcom: Keep wakeup option default off
Subsystems (3)
cover usb: dwc3: qcom: Keep wakeup option default off
Current policy
--------------
When the controller node has the "wakeup-source" property, dwc3-qcom calls device_init_wakeup(dev, true). USB is then a system wakeup source by default. Users who do NOT want the system woken up by USB have to disable it:
echo disabled > /sys/devices/.../<dwc3 device>/power/wakeup
Proposed policy
---------------
"wakeup-source" only describes that the controller is capable of waking up the system (see Documentation/devicetree/bindings/power/wakeup-source.txt), so with this patch the driver only marks the device as wakeup capable, and power/wakeup starts out "disabled". Users who NEED USB as a wakeup source have to enable it:
echo enabled > /sys/devices/.../<dwc3 device>/power/wakeup
The motivation is:
- Users do not expect USB activity (connect/disconnect or USB line status changes) to wake up the system unless they asked for it.
- Power consumption. With wakeup enabled, host mode system suspend keeps PHYs powered (dwc3_core_exit() is skipped) and necessary logic for detecting wakeup must be on, so that the wakeup interrupts can fire. Today this extra power is spent by default, even on systems where USB is never used as a wakeup source and the controller could be fully powered off during suspend.
Comparison
----------
Current (default on) Proposed (default off)
-------------------- ----------------------
Initial power/wakeup enabled disabled
User action write "disabled" if USB write "enabled" if USB
wakeup is NOT wanted wakeup IS wanted
Unexpected wakeups possible (connect, none unless the user
disconnect, noise) opted in
Suspend power higher, even if USB lower, USB fully powered
wakeup is never used off
Attached devices on stay suspended, resume reset-resumed or
resume quickly re-enumeratedPossible regression
-------------------
This is a user-visible change for existing platforms. Many Qualcomm arm64 DTs set "wakeup-source" on the USB controller. With this patch:
- USB wakeup stops working until userspace (or a udev rule) writes "enabled" to the controller's power/wakeup.
- In host mode, because device_may_wakeup() is now false by default, system suspend takes the full power down path in dwc3_suspend_common() (dwc3_core_exit()). Platforms where this power down path has not been tested may fail to resume.
Peter Chen (1):
usb: dwc3: qcom: Keep wakeup option default off
drivers/usb/dwc3/dwc3-qcom.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/1 usb: dwc3: qcom: Keep wakeup option default off
The "wakeup-source" property, as described in Documentation/devicetree/bindings/power/wakeup-source.txt, only says that a device is capable of waking up the system. Whether wakeup is actually enabled is a policy decision, and drivers use device_may_wakeup() to decide whether to arm the hardware wakeup logic.
Currently dwc3-qcom calls device_init_wakeup(dev, true) when the property is present, so USB wakeup is enabled by default. Users who do not want USB activity (e.g. connect/disconnect) to wake up the system have to disable it through power/wakeup, otherwise unexpected wakeups may happen.
Having wakeup enabled by default also costs power. In host mode, system suspend skips dwc3_core_exit() and keeps the PHYs and the wakeup detection logic powered so that the wakeup interrupts can fire, even on systems where USB is never used as a wakeup source and the controller could be fully powered off.
Keep the wakeup option default off and only mark the device as wakeup capable, so that the user decides which USB controller is used as a system wakeup source. Users who need it can enable it with:
echo enabled > /sys/devices/.../<dwc3 device>/power/wakeup
While at it, drop the local wakeup_source variable and use device_property_read_bool() like the other property reads in probe.
--- drivers/usb/dwc3/dwc3-qcom.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/usb/dwc3/dwc3-qcom.c +2 -3
@@ -616,7 +616,6 @@ static int dwc3_qcom_probe(struct platform_device *pdev)struct resource *r;int ret;bool ignore_pipe_clk; -bool wakeup_source; qcom =devm_kzalloc (&pdev->dev,sizeof (*qcom),GFP_KERNEL );if (!qcom)
@@ -715,8 +714,8 @@ static int dwc3_qcom_probe(struct platform_device *pdev)if (ret) goto remove_core; - wakeup_source =of_property_read_bool (dev->of_node,"wakeup-source" ); -device_init_wakeup (&pdev->dev, wakeup_source); +if (device_property_read_bool (dev,"wakeup-source" )) +device_set_wakeup_capable (dev, true); qcom->is_suspended = false;
Signature · 1 line
2.43.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 22 lines
The "wakeup-source" property, as described in
Documentation/devicetree/bindings/power/wakeup-source.txt, only says that a device is capable of waking up the system. Whether wakeup is actually enabled is a policy decision, and drivers usedevice_may_wakeup()to decide whether to arm the hardware wakeup logic.Currently dwc3-qcom calls
device_init_wakeup(dev, true)when the property is present, so USB wakeup is enabled by default. Users who do not want USB activity (e.g. connect/disconnect) to wake up the system have to disable it through power/wakeup, otherwise unexpected wakeups may happen.Having wakeup enabled by default also costs power. In host mode, system suspend skips
dwc3_core_exit()and keeps the PHYs and the wakeup detection logic powered so that the wakeup interrupts can fire, even on systems where USB is never used as a wakeup source and the controller could be fully powered off.Keep the wakeup option default off and only mark the device as wakeup capable, so that the user decides which USB controller is used as a system wakeup source. Users who need it can enable it with:
Quoted 6 lines
echo enabled > /sys/devices/.../<dwc3 device>/power/wakeup
While at it, drop the local
wakeup_sourcevariable and usedevice_property_read_bool()like the other property reads in probe.Signed-off-by Peter Chen <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Thinh Nguyen
maintainerHi,
Quoted 18 lines · Peter Chen
Current policy
--------------
When the controller node has the "wakeup-source" property, dwc3-qcom callsdevice_init_wakeup(dev, true). USB is then a system wakeup source by default. Users who do NOT want the system woken up by USB have to disable it:echo disabled > /sys/devices/.../<dwc3 device>/power/wakeup
Proposed policy
---------------
"wakeup-source" only describes that the controller is capable of waking up the system (seeDocumentation/devicetree/bindings/power/wakeup-source.txt), so with this patch the driver only marks the device as wakeup capable, and power/wakeup starts out "disabled". Users who NEED USB as a wakeup source have to enable it:
Quoted 1 line
echo enabled > /sys/devices/.../<dwc3 device>/power/wakeup
That won't work in host mode. dwc->sys_wakeup is read only once in dwc3_core_probe(), so enabling wakeup later from sysfs won't reach the xhci-plat device, and xhci_suspend() clears the port wake bits. Moving the wakeup setup before dwc3_core_probe() won't work either, since wakeup is off at that point. The setting needs to be passed to xhci at suspend time (perhaps in dwc3_pm_prepare()?).
Quoted 6 lines
The motivation is:
- Users do not expect USB activity (connect/disconnect or USB line status changes) to wake up the system unless they asked for it.
Quoted 6 lines
- Power consumption. With wakeup enabled, host mode system suspend keeps PHYs powered (
dwc3_core_exit()is skipped) and necessary logic for detecting wakeup must be on, so that the wakeup interrupts can fire. Today this extra power is spent by default, even on systems where USB is never used as a wakeup source and the controller could be fully powered off during suspend.
Sounds good, but there are some concerns.
Quoted 15 lines
Comparison
----------Current (default on) Proposed (default off) -------------------- ---------------------- Initial power/wakeup enabled disabled User action write "disabled" if USB write "enabled" if USB wakeup is NOT wanted wakeup IS wanted Unexpected wakeups possible (connect, none unless the user disconnect, noise) opted in Suspend power higher, even if USB lower, USB fully powered wakeup is never used off Attached devices on stay suspended, resume reset-resumed or resume quickly re-enumerated
Quoted 2 lines
Possible regression
-------------------
This rings my alarm bells for me any time we mention a user behavior change or possible regression. Perhaps you can add this to the commit message.
Quoted 7 lines
This is a user-visible change for existing platforms. Many Qualcomm arm64 DTs set "wakeup-source" on the USB controller. With this patch:
- USB wakeup stops working until userspace (or a udev rule) writes "enabled" to the controller's power/wakeup.
- In host mode, because
device_may_wakeup()is now false by default,
This will be the default in host mode for every qcom platform with "wakeup-source". Which platforms have you tested?
Quoted 4 lines
system suspend takes the full power down path in
dwc3_suspend_common()(dwc3_core_exit()). Platforms where this power down path has not been tested may fail to resume.
BR,
Thinh
Quoted 18 lines · Thinh Nguyen
Quoted 18 lines
Current policy
--------------
When the controller node has the "wakeup-source" property, dwc3-qcom callsdevice_init_wakeup(dev, true). USB is then a system wakeup source by default. Users who do NOT want the system woken up by USB have to disable it:echo disabled > /sys/devices/.../<dwc3 device>/power/wakeup
Proposed policy
---------------
"wakeup-source" only describes that the controller is capable of waking up the system (seeDocumentation/devicetree/bindings/power/wakeup-source.txt), so with this patch the driver only marks the device as wakeup capable, and power/wakeup starts out "disabled". Users who NEED USB as a wakeup source have to enable it:
Quoted 2 lines
Quoted 1 line
echo enabled > /sys/devices/.../<dwc3 device>/power/wakeup
Thinh, thanks for reviewing it.
Quoted 1 line
That won't work in host mode.
At some platforms, USB2 wakeup logic works since there are USB2 wakeup signal detection logic beyond controller and at SoC level. For wakeup signal detected by controller, you are right, it needs to enable controller level wakeup option, eg, WKCN/WKDN at PORTSC.
Quoted 7 lines
dwc->sys_wakeupis read only once indwc3_core_probe(), so enabling wakeup later from sysfs won't reach the xhci-plat device, andxhci_suspend()clears the port wake bits. Moving the wakeup setup beforedwc3_core_probe()won't work either, since wakeup is off at that point. The setting needs to be passed to xhci at suspend time (perhaps indwc3_pm_prepare()?).
When talking about whole system wakeup chain for USB:
dwc3 -> xhci-plat -> roothub -> downstream device
it usually depends on user program (per user option), but not bind to kernel driver, considering some situations that USB device are disconnected and re-connected, its wakeup option may need to re-set, and one typical solution is enable wakeup options before system suspend.
Quoted 16 lines
Quoted 16 lines
Comparison
----------Current (default on) Proposed (default off) -------------------- ---------------------- Initial power/wakeup enabled disabled User action write "disabled" if USB write "enabled" if USB wakeup is NOT wanted wakeup IS wanted Unexpected wakeups possible (connect, none unless the user disconnect, noise) opted in Suspend power higher, even if USB lower, USB fully powered wakeup is never used off Attached devices on stay suspended, resume reset-resumed or resume quickly re-enumerated
Quoted 7 lines
Quoted 2 lines
Possible regression
-------------------This rings my alarm bells for me any time we mention a user behavior change or possible regression. Perhaps you can add this to the commit message.
Sure.
Quoted 11 lines
Quoted 7 lines
This is a user-visible change for existing platforms. Many Qualcomm arm64 DTs set "wakeup-source" on the USB controller. With this patch:
- USB wakeup stops working until userspace (or a udev rule) writes "enabled" to the controller's power/wakeup.
- In host mode, because
device_may_wakeup()is now false by default,This will be the default in host mode for every qcom platform with "wakeup-source". Which platforms have you tested?
Yes, it affects all Qcom platforms, that's why I sent RFC patch for it last week, most probably it have "regression" since it may never be tested under the situation the PHY is powered down at suspend and power on at resume, but that kinds of "regression" is the bug we need to fix, right?
I have tested at Glymur CRD, external ports work (USB3/USB2), but the port with USB2 Footprint IC (USB2) hard-wired does not work sometimes, maybe the initial sequence between power-on and suspend/resume are different, it needs to debug more.
Quoted 5 lines
Quoted 4 lines
system suspend takes the full power down path in
dwc3_suspend_common()(dwc3_core_exit()). Platforms where this power down path has not been tested may fail to resume.
Signature · 2 lines
Thanks, Peter Chen
Thinh Nguyen
maintainer(Sorry for the delay in replying. Got held up with internal tasks.)
Quoted 39 lines · Peter Chen
Quoted 18 lines · Thinh Nguyen
Quoted 18 lines
Current policy
--------------
When the controller node has the "wakeup-source" property, dwc3-qcom callsdevice_init_wakeup(dev, true). USB is then a system wakeup source by default. Users who do NOT want the system woken up by USB have to disable it:echo disabled > /sys/devices/.../<dwc3 device>/power/wakeup
Proposed policy
---------------
"wakeup-source" only describes that the controller is capable of waking up the system (seeDocumentation/devicetree/bindings/power/wakeup-source.txt), so with this patch the driver only marks the device as wakeup capable, and power/wakeup starts out "disabled". Users who NEED USB as a wakeup source have to enable it:Quoted 2 lines
Quoted 1 line
echo enabled > /sys/devices/.../<dwc3 device>/power/wakeup
Thinh, thanks for reviewing it.
Quoted 1 line
That won't work in host mode.
At some platforms, USB2 wakeup logic works since there are USB2 wakeup signal detection logic beyond controller and at SoC level. For wakeup signal detected by controller, you are right, it needs to enable controller level wakeup option, eg, WKCN/WKDN at PORTSC.
Quoted 7 lines
dwc->sys_wakeupis read only once indwc3_core_probe(), so enabling wakeup later from sysfs won't reach the xhci-plat device, andxhci_suspend()clears the port wake bits. Moving the wakeup setup beforedwc3_core_probe()won't work either, since wakeup is off at that point. The setting needs to be passed to xhci at suspend time (perhaps indwc3_pm_prepare()?).
Quoted 6 lines
When talking about whole system wakeup chain for USB:
dwc3 -> xhci-plat -> roothub -> downstream device
it usually depends on user program (per user option), but not bind to kernel driver, considering some situations that USB device are disconnected and re-connected, its wakeup option may need to re-set, and one typical solution is enable wakeup options before system suspend.
I see. Looks like dwc->sys_wakeup is already false since device_init_wakeup() is called after dwc3_core_probe(). Can we fix that separately so xhci follows power/wakeup at suspend?
Quoted 39 lines
Quoted 17 lines
Quoted 17 lines
Comparison
----------Current (default on) Proposed (default off) -------------------- ---------------------- Initial power/wakeup enabled disabled User action write "disabled" if USB write "enabled" if USB wakeup is NOT wanted wakeup IS wanted Unexpected wakeups possible (connect, none unless the user disconnect, noise) opted in Suspend power higher, even if USB lower, USB fully powered wakeup is never used off Attached devices on stay suspended, resume reset-resumed or resume quickly re-enumeratedQuoted 7 lines
Quoted 2 lines
Possible regression
-------------------This rings my alarm bells for me any time we mention a user behavior change or possible regression. Perhaps you can add this to the commit message.
Sure.
Quoted 11 lines
Quoted 7 lines
This is a user-visible change for existing platforms. Many Qualcomm arm64 DTs set "wakeup-source" on the USB controller. With this patch:
- USB wakeup stops working until userspace (or a udev rule) writes "enabled" to the controller's power/wakeup.
- In host mode, because
device_may_wakeup()is now false by default,This will be the default in host mode for every qcom platform with "wakeup-source". Which platforms have you tested?
Quoted 5 lines
Yes, it affects all Qcom platforms, that's why I sent RFC patch for it last week, most probably it have "regression" since it may never be tested under the situation the PHY is powered down at suspend and power on at resume, but that kinds of "regression" is the bug we need to fix, right?
Yes, but USB wakeup would also stop working on existing platforms by default. Do we have acks from the qcom maintainers on this policy?
Quoted 5 lines
I have tested at Glymur CRD, external ports work (USB3/USB2), but the port with USB2 Footprint IC (USB2) hard-wired does not work sometimes, maybe the initial sequence between power-on and suspend/resume are different, it needs to debug more.
Which other platforms can you test? I'm fine with the change if it's tested enough across platforms, or if the affected platforms have a way to keep the current default.
BR,
Thinh
Quoted 10 lines · Thinh Nguyen
(Sorry for the delay in replying. Got held up with internal tasks.)
Quoted 6 lines · Peter Chen
When talking about whole system wakeup chain for USB:
dwc3 -> xhci-plat -> roothub -> downstream device
it usually depends on user program (per user option), but not bind to kernel driver, considering some situations that USB device are disconnected and re-connected, its wakeup option may need to re-set, and one typical solution is enable wakeup options before system suspend.
Quoted 4 lines
I see. Looks like
dwc->sys_wakeupis already false sincedevice_init_wakeup()is called afterdwc3_core_probe(). Can we fix that separately so xhci follows power/wakeup at suspend?
Sure, but first, we need to align what behaviours we want:
1. Who decides dwc3 core has wakeup capabilities?
dwc3 core or glue layer driver?
2. How to decide dwc3 core has wakeup capabilities?
Has wakeup capabilities by default (xhci/cadence/chipidea) or depends on DT/ACPI firmware setting like "wakeup-source" property?
3. Default on or off for wakeup option (value for power/wakeup)
4. xhci-plat has wakeup capabilities by default, we only need to set its wakeup option as default on if dwc3 core does the same thing for question 3.
Quoted 9 lines
Quoted 6 lines
Yes, it affects all Qcom platforms, that's why I sent RFC patch for it last week, most probably it have "regression" since it may never be tested under the situation the PHY is powered down at suspend and power on at resume, but that kinds of "regression" is the bug we need to fix, right?
Yes, but USB wakeup would also stop working on existing platforms by default. Do we have acks from the qcom maintainers on this policy?
Bjorn, would you please share your opinion for it?
Quoted 11 lines
Quoted 6 lines
I have tested at Glymur CRD, external ports work (USB3/USB2), but the port with USB2 Footprint IC (USB2) hard-wired does not work sometimes, maybe the initial sequence between power-on and suspend/resume are different, it needs to debug more.
Which other platforms can you test? I'm fine with the change if it's tested enough across platforms, or if the affected platforms have a way to keep the current default.
There are 10+ SoCs enable USB wakeup default on for Qcom, I think it is hard for without function regression we keep PHY off during the suspend, although it also should be fixed. Let's see Bjorn's opinion?
Signature · 2 lines
Thanks, Peter Chen
Quoted 9 lines · Peter Chen
Quoted 4 lines
Which other platforms can you test? I'm fine with the change if it's tested enough across platforms, or if the affected platforms have a way to keep the current default.
There are 10+ SoCs enable USB wakeup default on for Qcom, I think it is hard for without function regression we keep PHY off during the suspend, although it also should be fixed. Let's see Bjorn's opinion?
One wakeup disabled failure has reported and fixed [1]
[1]: https://lore.kernel.org/r/[email protected]
Signature · 2 lines
Thanks, Peter Chen
Thinh Nguyen
maintainerQuoted 9 lines · Peter Chen
Quoted 8 lines · Thinh Nguyen
Quoted 6 lines · Peter Chen
When talking about whole system wakeup chain for USB:
dwc3 -> xhci-plat -> roothub -> downstream device
it usually depends on user program (per user option), but not bind to kernel driver, considering some situations that USB device are disconnected and re-connected, its wakeup option may need to re-set, and one typical solution is enable wakeup options before system suspend.
Quoted 8 lines
Quoted 4 lines
I see. Looks like
dwc->sys_wakeupis already false sincedevice_init_wakeup()is called afterdwc3_core_probe(). Can we fix that separately so xhci follows power/wakeup at suspend?Sure, but first, we need to align what behaviours we want:
1. Who decides dwc3 core has wakeup capabilities? dwc3 core or glue layer driver?
Glue driver since it depends on the platform.
Quoted 3 lines
2. How to decide dwc3 core has wakeup capabilities?
Has wakeup capabilities by default (xhci/cadence/chipidea) or depends on DT/ACPI firmware setting like "wakeup-source" property?
It should be up to the glue driver.
Quoted 1 line
3. Default on or off for wakeup option (value for power/wakeup)
It should be up to each platform. For qcom, it's up to you and Bjorn.
Quoted 4 lines
4. xhci-plat has wakeup capabilities by default, we only need to set its wakeup option as default on if dwc3 core does the same thing for question 3.
The xhci should follow controller's power/wakeup setting at suspend. We can do a check before suspend in pm_prepare(), perhaps something like this (not tested):
int dwc3_pm_prepare(struct dwc3 *dwc)
{
...
if (dwc->xhci)
device_set_wakeup_enable(&dwc->xhci->dev,
device_may_wakeup(dwc->sysdev));
...
}Thanks,
Thinh
Quoted 40 lines · Thinh Nguyen
Quoted 9 lines · Peter Chen
Quoted 8 lines · Thinh Nguyen
Quoted 6 lines · Peter Chen
When talking about whole system wakeup chain for USB:
dwc3 -> xhci-plat -> roothub -> downstream device
it usually depends on user program (per user option), but not bind to kernel driver, considering some situations that USB device are disconnected and re-connected, its wakeup option may need to re-set, and one typical solution is enable wakeup options before system suspend.Quoted 8 lines
Quoted 4 lines
I see. Looks like
dwc->sys_wakeupis already false sincedevice_init_wakeup()is called afterdwc3_core_probe(). Can we fix that separately so xhci follows power/wakeup at suspend?Sure, but first, we need to align what behaviours we want:
1. Who decides dwc3 core has wakeup capabilities? dwc3 core or glue layer driver?Glue driver since it depends on the platform.
Quoted 3 lines
2. How to decide dwc3 core has wakeup capabilities?
Has wakeup capabilities by default (xhci/cadence/chipidea) or depends on DT/ACPI firmware setting like "wakeup-source" property?It should be up to the glue driver.
Quoted 1 line
3. Default on or off for wakeup option (value for power/wakeup)
It should be up to each platform. For qcom, it's up to you and Bjorn.
Quoted 4 lines
4. xhci-plat has wakeup capabilities by default, we only need to set its wakeup option as default on if dwc3 core does the same thing for question 3.
The xhci should follow controller's power/wakeup setting at suspend. We can do a check before suspend in
pm_prepare(), perhaps something like this (not tested):
Quoted 8 lines
int
dwc3_pm_prepare(struct dwc3 *dwc){ ... if (dwc->xhci) device_set_wakeup_enable(&dwc->xhci->dev, device_may_wakeup(dwc->sysdev)); ... }
Good suggestion, and I tested it works.
If both wakeup capability and wakeup option are decided by glue layer, there is no reason dwc->sys_wakeup existed for dwc3 core, and there is no glue layer user for that. But there are behaviour changes, I am not sure if there is a regression.
- At host mode: anything the user writes to xhci's own power/wakeup is overwritten at every prepare. Before, it could be set independently of the parent.
- At device mode, current wakeup option depends on whether gadget start/stop or without binding gadget driver. If delete dwc->sys_wakeup, it totally depends on glue layer. For commit f9aa41130ac6 ("usb: dwc3: Properly set system wakeup"), it describes a bug of enabling wakeup when gadget driver is not bound, it seems some other places enable wakeup option, and read dwc3 wakeup option, do some settings later. So, I am afraid there may be regression for platforms which set wakeup option default on and rely on dwc3 gadget driver disable it.
Signature · 2 lines
Thanks, Peter Chen
Thinh Nguyen
maintainerQuoted 50 lines · Peter Chen
Quoted 40 lines · Thinh Nguyen
Quoted 9 lines · Peter Chen
Quoted 8 lines · Thinh Nguyen
Quoted 6 lines · Peter Chen
When talking about whole system wakeup chain for USB:
dwc3 -> xhci-plat -> roothub -> downstream device
it usually depends on user program (per user option), but not bind to kernel driver, considering some situations that USB device are disconnected and re-connected, its wakeup option may need to re-set, and one typical solution is enable wakeup options before system suspend.Quoted 8 lines
Quoted 4 lines
I see. Looks like
dwc->sys_wakeupis already false sincedevice_init_wakeup()is called afterdwc3_core_probe(). Can we fix that separately so xhci follows power/wakeup at suspend?Sure, but first, we need to align what behaviours we want:
1. Who decides dwc3 core has wakeup capabilities? dwc3 core or glue layer driver?Glue driver since it depends on the platform.
Quoted 3 lines
2. How to decide dwc3 core has wakeup capabilities?
Has wakeup capabilities by default (xhci/cadence/chipidea) or depends on DT/ACPI firmware setting like "wakeup-source" property?It should be up to the glue driver.
Quoted 1 line
3. Default on or off for wakeup option (value for power/wakeup)
It should be up to each platform. For qcom, it's up to you and Bjorn.
Quoted 4 lines
4. xhci-plat has wakeup capabilities by default, we only need to set its wakeup option as default on if dwc3 core does the same thing for question 3.
The xhci should follow controller's power/wakeup setting at suspend. We can do a check before suspend in
pm_prepare(), perhaps something like this (not tested):Quoted 8 lines
int
dwc3_pm_prepare(struct dwc3 *dwc){ ... if (dwc->xhci) device_set_wakeup_enable(&dwc->xhci->dev, device_may_wakeup(dwc->sysdev)); ... }
Quoted 1 line
Good suggestion, and I tested it works.
Thanks for testing.
Quoted 5 lines
If both wakeup capability and wakeup option are decided by glue layer, there is no reason
dwc->sys_wakeupexisted for dwc3 core, and there is no glue layer user for that. But there are behaviour changes, I am not sure if there is a regression.
We should keep sys_wakeup. It tracks the platform default setting at probe, which the gadget start/stop needs. The pm_prepare() change only affects xhci in host mode.
Quoted 3 lines
- At host mode: anything the user writes to xhci's own power/wakeup is overwritten at every prepare. Before, it could be set independently of the parent.
That's intended. The controller's power/wakeup is the one that we should check. The xhci platform device is recreated on role switch, so the value written to it doesn't persist anyway.
Quoted 9 lines
- At device mode, current wakeup option depends on whether gadget start/stop or without binding gadget driver. If delete
dwc->sys_wakeup, it totally depends on glue layer. For commitf9aa41130ac6("usb: dwc3: Properly set system wakeup"), it describes a bug of enabling wakeup when gadget driver is not bound, it seems some other places enable wakeup option, and read dwc3 wakeup option, do some settings later. So, I am afraid there may be regression for platforms which set wakeup option default on and rely on dwc3 gadget driver disable it.
It's not affected if we keep sys_wakeup. For qcom, device_init_wakeup() should be moved before dwc3_core_probe() so sys_wakeup matches the glue's setting.
Thanks,
Thinh