USB: f_mtp: Handle corner cases on reception of Cancel request from Host
If the Host sends CANCEL request when an OUT request is queued,
the mtp_driver should dequeue the request and report the userspace about
the request CANCELLATION. As the mtp_read doesn't wakeup from the thread
which is expecting for the read completion, wakeup the thread using the
state change which occurs as a part of CANCEL request.
Also, when the request is dequeued and so mtp receives read completion
status as error, it moves the state to ERROR. Due to this the application
is not reported about the request cancellation for the next IN(mtp_write)
transfer as the state is not updated from STATE_ERROR to STATE_CANCELED.
So mtp_write proceeds queueing the IN requests for the corresponding sync
which are not processed by the Host and so the transfers initiated later
are observed as error in the HOST side.
So dequeue the OUT(mtp_read) request, if the driver receives a REQ_CANCEL
prior to read completion on mtp_read & update the state to STATE_CANCELED.
Change-Id: I2cd9780f8b3e0ce541472c4d25c8294f11a45d76
Signed-off-by: Rajkumar Raghupathy <raghup@codeaurora.org>
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
1 file changed