usb: gadget: ci13xxx: cancel prime timer after disconnect also for ep0

When issue a transfer to the usb hardware core, the prime bit is set
for the desired endpoint. After the hardware finish processing the
transfer it reset the prime bit of that endpoint. In order to debug cases
in which this bit is not reset by the core, a timer was set for 1 second
after issuing the transfer for checking the prime bit status and print
debug messages in case of abnormal state.

However, this mechanism introduced a bug, in which the timer of ep0
was expired after cable disconnect. Therefore the prime bit was checked,
while the hardware is in low power mode, so reading the bit caused a crash.

Fix this by ensuring that the timer will be canceled whenever all the
requests of an endpoint are dequeued, including for the case of ep0.
Also added a warning and protection for such cases when an endpoint
timer expires after core in low power mode.

CRs-Fixed: 505686
Change-Id: I7336ec7372714a4cd04bf94eb31ce230ee0a4241
Signed-off-by: Ido Shayevitz <idos@codeaurora.org>
1 file changed