XHCI: Handle an unlikely corner case in CancelQueuedTransfers.

See inline comment with reference to the XHCI specification.
This commit is contained in:
Augustin Cavalier 2023-05-25 15:29:31 -04:00
parent 400eedd0c8
commit 1886d5692e

View File

@ -1106,8 +1106,15 @@ XHCI::CancelQueuedTransfers(Pipe *pipe, bool force)
// order to avoid a deadlock, we must unlock the endpoint.
endpointLocker.Unlock();
status_t status = StopEndpoint(false, endpoint);
if (status != B_OK && status != B_DEV_STALLED) {
// It is possible that the endpoint was stopped by the controller at the
// same time our STOP command was in progress, causing a "Context State"
// error. In that case, try again; if the endpoint is already stopped,
// StopEndpoint will notice this. (XHCI 1.2 § 4.6.9 p137.)
status = StopEndpoint(false, endpoint);
}
if (status == B_DEV_STALLED) {
// Only exit from a Halted state is a reset. (XHCI 1.2 § 4.8.3 p163.)
// Only exit from a Halted state is a RESET. (XHCI 1.2 § 4.8.3 p163.)
TRACE_ERROR("cancel queued transfers: halted endpoint, reset!\n");
status = ResetEndpoint(false, endpoint);
}