usb: dwc3: Prevent indefinite sleep in _dwc3_set_mode during suspend/resume
authorRoger Quadros <rogerq@ti.com>
Fri, 9 Mar 2018 12:47:04 +0000 (14:47 +0200)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Tue, 13 Mar 2018 08:47:59 +0000 (10:47 +0200)
commit498f0478aba425ba5555a72e72fe1ce9ee45a0bd
treeba6e263fa4080fc85ef9304f7a9ea2c75519bb84
parent365b7673c34fed58b0a04ee4a7a51102c65ccd2e
usb: dwc3: Prevent indefinite sleep in _dwc3_set_mode during suspend/resume

In the following test we get stuck by sleeping forever in _dwc3_set_mode()
after which dual-role switching doesn't work.

On dra7-evm's dual-role port,
- Load g_zero gadget driver and enumerate to host
- suspend to mem
- disconnect USB cable to host and connect otg cable with Pen drive in it.
- resume system
- we sleep indefinitely in _dwc3_set_mode due to.
  dwc3_gadget_exit()->usb_del_gadget_udc()->udc_stop()->
dwc3_gadget_stop()->wait_event_lock_irq()

To fix this instead of waiting indefinitely with wait_event_lock_irq()
we use wait_event_interruptible_lock_irq_timeout() and print
and error message if there was a timeout.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/dwc3/gadget.c