dwc3: Power management for cable disconnect
Hi linux-usb members!
I was looking at seeing how the DWC3 drivers are handling the USB cable disconnect routine (VBUS low situation) when there is no UDC binded. Is the below behavior expected?
1. Enumerate device w/ host.
2. Gadget is unbinded
- echo "" > /sys/kernel/config/usb_gadget/g1/UDC
3. Disconnect the USB cable (VBUS low)
4. No dwc3_gadget_disconnect_interrupt() seen (since controller is halted from step#1)
5. Runtime PM autosuspend fails due to "dwc->connected" being true (cleared in dwc3_gadget_disconnect_interrupt())
6. Gadget binded
- echo udc_name > /sys/kernel/config/usb_gadget/g1/UDC
7. No runtime suspend until cable is plugged in and out
This would be problematic for devices which have to reliably enter suspend. I just wanted to see if this is a scenario which has been considered? Seems odd that we would still keep the controller out of low power if there was no cable connected.
Thanks
Regards,
Wesley Cheng
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Hi,
Quoted 6 lines · Wesley Cheng
Hi linux-usb members!
I was looking at seeing how the DWC3 drivers are handling the USB cable disconnect routine (VBUS low situation) when there is no UDC binded. Is the below behavior expected?
Quoted 6 lines
1. Enumerate device w/ host.
2. Gadget is unbinded
- echo "" >/sys/kernel/config/usb_gadget/g1/UDC
3. Disconnect the USB cable (VBUS low)
4. Nodwc3_gadget_disconnect_interrupt()seen (since controller is halted from step#1)
I think you mean after step#2?
Quoted 2 lines
5. Runtime PM autosuspend fails due to "
dwc->connected" being true (cleared indwc3_gadget_disconnect_interrupt())
This is probably a mishap in the dwc3 driver. When the function driver is unregistered, the pullup() callback will halt the controller. This is a soft-disconnect, and dwc->connected should be false.
Quoted 2 lines
6. Gadget binded
- echoudc_name>/sys/kernel/config/usb_gadget/g1/UDC
After this step, the device will still remain disconnected.
Quoted 1 line
7. No runtime suspend until cable is plugged in and out
... until the reset and connection done interrupt telling the driver that the device is now connected.
Quoted 6 lines
This would be problematic for devices which have to reliably enter suspend. I just wanted to see if this is a scenario which has been considered? Seems odd that we would still keep the controller out of low power if there was no cable connected.
This should be a simple fix. Would you create a patch for this?
Thanks,
Thinh
Quoted 36 lines · Thinh Nguyen
Hi,
Quoted 6 lines · Wesley Cheng
Hi linux-usb members!
I was looking at seeing how the DWC3 drivers are handling the USB cable disconnect routine (VBUS low situation) when there is no UDC binded. Is the below behavior expected?
Quoted 6 lines
1. Enumerate device w/ host.
2. Gadget is unbinded
- echo "" >/sys/kernel/config/usb_gadget/g1/UDC
3. Disconnect the USB cable (VBUS low)
4. Nodwc3_gadget_disconnect_interrupt()seen (since controller is halted from step#1)I think you mean after step#2?
Quoted 2 lines
5. Runtime PM autosuspend fails due to "
dwc->connected" being true (cleared indwc3_gadget_disconnect_interrupt())This is probably a mishap in the dwc3 driver. When the function driver is unregistered, the
pullup()callback will halt the controller. This is a soft-disconnect, anddwc->connectedshould be false.Quoted 2 lines
6. Gadget binded
- echoudc_name>/sys/kernel/config/usb_gadget/g1/UDCAfter this step, the device will still remain disconnected.
Quoted 1 line
7. No runtime suspend until cable is plugged in and out
... until the reset and connection done interrupt telling the driver that the device is now connected.
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
This would be problematic for devices which have to reliably enter suspend. I just wanted to see if this is a scenario which has been considered? Seems odd that we would still keep the controller out of low power if there was no cable connected.
This should be a simple fix. Would you create a patch for this?
Hi Thinh,
Sure, will submit a patch for this. Will upload it soon!
Thanks
Regards,
Wesley Cheng
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project