usb: dwc2: Defer forcing peripheral mode 47/308447/2
authorDongwoo Lee <dwoo08.lee@samsung.com>
Wed, 26 Feb 2020 10:39:04 +0000 (19:39 +0900)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Tue, 26 Mar 2024 00:22:02 +0000 (00:22 +0000)
commit84c3c2a03ff89766f95f9ee6d37e885f715ad888
treed6de737fa8f1bdeb0db319bb24a299f4eb2b8a9d
parent4b74cd8fdf66d4cb128d9249d9b2ada34dc98921
usb: dwc2: Defer forcing peripheral mode

dwc2 forces the mode as following dr_mode when it is finally
determined. In the case of peripheral mode, however, this causes the
notification to host without any preparation about gadget driver.
In host, hcd requests device descriptor for enumeration, but it does
never get response. See log below:

 usb 2-2: new high-speed USB device number 6 using xhci_hcd
 usb 2-2: device descriptor read/64, error -110
 usb 2-2: device descriptor read/64, error -110
 usb 2-2: new high-speed USB device number 7 using xhci_hcd
 usb 2-2: device descriptor read/64, error -110
 usb 2-2: device descriptor read/64, error -110
 usb usb2-port2: attempt power cycle
 usb 2-2: new high-speed USB device number 8 using xhci_hcd
 xhci_hcd 0000:00:14.0: Timeout while waiting for setup device command
 xhci_hcd 0000:00:14.0: Timeout while waiting for setup device command
 usb 2-2: device not accepting address 8, error -62
 usb 2-2: new high-speed USB device number 9 using xhci_hcd
 xhci_hcd 0000:00:14.0: Timeout while waiting for setup device command
 xhci_hcd 0000:00:14.0: Timeout while waiting for setup device command
 usb 2-2: device not accepting address 9, error -62
 usb usb2-port2: unable to enumerate USB device

Even worse, all ports on host can get disabled at least xhci case in
this situation. To prevent this, forcing peripheral mode will be
defered until the gadget driver is prepared.

Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
(cherry picked from commit 9507385cb797a12f278e73b9cb298ba73f120fd5)
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Change-Id: Ic24f1a36c9ccfd9b571cd4d6eff5cbc3da9082b1
drivers/usb/dwc2/core.c
drivers/usb/dwc2/gadget.c
drivers/usb/dwc2/params.c