Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
* dwc3: Power management for cable disconnect
@ 2020-10-16  7:29 Wesley Cheng
  2020-10-16 22:42 ` Thinh Nguyen
  0 siblings, 1 reply; 3+ messages in thread
From: Wesley Cheng @ 2020-10-16  7:29 UTC (permalink / raw)
  To: Linux USB List

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

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: dwc3: Power management for cable disconnect
  2020-10-16  7:29 dwc3: Power management for cable disconnect Wesley Cheng
@ 2020-10-16 22:42 ` Thinh Nguyen
  2020-10-20  5:46   ` Wesley Cheng
  0 siblings, 1 reply; 3+ messages in thread
From: Thinh Nguyen @ 2020-10-16 22:42 UTC (permalink / raw)
  To: Wesley Cheng, Linux USB List

Hi,

Wesley Cheng wrote:
> 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)

I think you mean after step#2?

> 5.  Runtime PM autosuspend fails due to "dwc->connected" being true
> (cleared in dwc3_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.

> 6.  Gadget binded
> 	- echo udc_name > /sys/kernel/config/usb_gadget/g1/UDC

After this step, the device will still remain disconnected.

> 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.

>
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: dwc3: Power management for cable disconnect
  2020-10-16 22:42 ` Thinh Nguyen
@ 2020-10-20  5:46   ` Wesley Cheng
  0 siblings, 0 replies; 3+ messages in thread
From: Wesley Cheng @ 2020-10-20  5:46 UTC (permalink / raw)
  To: Thinh Nguyen, Linux USB List



On 10/16/2020 3:42 PM, Thinh Nguyen wrote:
> Hi,
> 
> Wesley Cheng wrote:
>> 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)
> 
> I think you mean after step#2?
> 
>> 5.  Runtime PM autosuspend fails due to "dwc->connected" being true
>> (cleared in dwc3_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.
> 
>> 6.  Gadget binded
>> 	- echo udc_name > /sys/kernel/config/usb_gadget/g1/UDC
> 
> After this step, the device will still remain disconnected.
> 
>> 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.
> 
>>
>> 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

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-16  7:29 dwc3: Power management for cable disconnect Wesley Cheng
2020-10-16 22:42 ` Thinh Nguyen
2020-10-20  5:46   ` Wesley Cheng

Linux-USB Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-usb/0 linux-usb/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-usb linux-usb/ https://lore.kernel.org/linux-usb \
		linux-usb@vger.kernel.org
	public-inbox-index linux-usb

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-usb


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git