Re: dwc2 gadget driver does not generate DISABLE event on unplugging USB cable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jun Sun,

On 12/8/2017 17:33, Jun Sun wrote:
> Hi, all,
> 
> I have a raspberry pi zero w board and I'm currently configuring the
> device as USB gadget and connects it to PC.
> 
> I'm using configfs/functionfs to send a vendor specific interface with
> single buik in and bulk out endpoint each.
> 
> When I unplug the USB cable, there is no DISABLE event generated on
> ep0 until next time the cable is re-plugged in again, right before the
> next ENABLE event.  Obviously this is not very useful as I really need
> to know exactly when a unpllugging is happening.
> 
> You can see a debugging trace below.
> 
> After looking around, I finally got it working by the attached patch.
> However, I have very little confidence in the patch itself.  Would
> appreciate any feedback on the issue and the correct fix.
> 
> Cheers.
> 
> Jun
> 
> <unplug USB>
> <replug USB>
> 
> [  130.406932] ffs_epfile_io_complete()
> [  130.406964] ====== JSUN ====== ffs_func_disable() called
> [  130.406980] __ffs_event_add(DISABLE)
> [  130.406991] adding event 3
> [  130.435178] ffs_epfile_release()
> [  130.435193] ffs_data_closed()
> [  130.435199] ffs_data_put()
> [  130.435325] ffs_epfile_release()
> [  130.435333] ffs_data_closed()
> [  130.435338] ffs_data_put()
> [  130.435758] ffs_ep0_read()
> [  130.461705] dwc2 20980000.usb: new device is high-speed
> [  130.554583] dwc2 20980000.usb: new device is high-speed
> [  130.591376] dwc2 20980000.usb: new address 17
> [  130.827451] dwc2 20980000.usb: new device is high-speed
> [  130.918627] dwc2 20980000.usb: new device is high-speed
> [  130.962062] dwc2 20980000.usb: new address 18
> [  131.152381] dwc2 20980000.usb: new device is high-speed
> [  131.243481] dwc2 20980000.usb: new device is high-speed
> [  131.285993] dwc2 20980000.usb: new address 19
> [  131.461014] configfs-gadget gadget: high-speed config #1: c
> [  131.461057] __ffs_event_add(ENABLE)
> [  131.461066] adding event 2
> [  131.464892] ffs_epfile_open()
> [  131.464908] ffs_data_opened()
> [  131.465261] ffs_epfile_open()
> [  131.465272] ffs_data_opened()
> [  131.488760] ffs_epfile_read_iter()
> [  131.488835] ffs_ep0_read()
> 
> <unplug USB>
> <replug USB>
> 
> [  151.214987] ffs_epfile_io_complete()
> [  151.215020] ====== JSUN ====== ffs_func_disable() called
> [  151.215038] __ffs_event_add(DISABLE)
> [  151.215048] adding event 3
> [  151.246561] ffs_epfile_release()
> [  151.246577] ffs_data_closed()
> [  151.246583] ffs_data_put()
> [  151.247797] ffs_epfile_release()
> [  151.247811] ffs_data_closed()
> [  151.247817] ffs_data_put()
> [  151.248227] ffs_ep0_read()
> [  151.269764] dwc2 20980000.usb: new device is high-speed
> [  151.363232] dwc2 20980000.usb: new device is high-speed
> [  151.400091] dwc2 20980000.usb: new address 20
> [  151.638217] dwc2 20980000.usb: new device is high-speed
> [  151.729145] dwc2 20980000.usb: new device is high-speed
> [  151.773919] dwc2 20980000.usb: new address 21
> [  151.962998] dwc2 20980000.usb: new device is high-speed
> [  152.054036] dwc2 20980000.usb: new device is high-speed
> [  152.096922] dwc2 20980000.usb: new address 22
> [  152.267818] configfs-gadget gadget: high-speed config #1: c
> [  152.267863] __ffs_event_add(ENABLE)
> [  152.267874] adding event 2
> [  152.273430] ffs_epfile_open()
> [  152.273446] ffs_data_opened()
> [  152.273811] ffs_epfile_open()
> [  152.273822] ffs_dat[  152.296847] ffs_epfile_read_iter()
> [  152.296921] ffs_ep0_read()
> [  251.986224] random: crng init done
> 

Please try to apply those patches. Please tell me does they fix your 
issue or not?

[PATCH v2 0/3] dwc2 fixes for edge cases on hikey
[PATCH 1/3 v2] usb: dwc2: Improve gadget state disconnection handling
[PATCH 2/3 v2] usb: dwc2: Error out of dwc2_hsotg_ep_disable() if we're 
  in host mode
[PATCH 3/3 v2] usb: dwc2: Fix UDC state tracking

You can find this patches on lkml. Submitted by John Stultz.

Thanks, Grigor.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux