From d69c50aa2a121147288fefde3345f9003afbd990 Mon Sep 17 00:00:00 2001 From: Manu Gautam Date: Fri, 23 Sep 2016 16:12:07 +0530 Subject: [PATCH] usb: xhci: clean up command queue on HC halt failure as well 'Commit c9cabb7ee02bcb0c ("usb: xhci: clean up command queue when halting"); fixes deadlock condition when some commands are pending at the time of usb_remove_hcd() or when controller is halted. That change cleans up command queue if halting of controller is successful. But, this deadlock may still be seen in case if due to some reason halting of controller fails. To handle that scenario as well cleanup command queue irrespective of controller halt succeeds or fails. Change-Id: I2c88fca3614af7fe58bc858898449d47546da247 Signed-off-by: Manu Gautam --- drivers/usb/host/xhci.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index dd7669331d00..b30831ef4014 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -116,17 +116,20 @@ int xhci_halt(struct xhci_hcd *xhci) STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC); if (!ret) { xhci->xhc_state |= XHCI_STATE_HALTED; - xhci->cmd_ring_state = CMD_RING_STATE_STOPPED; - - if (timer_pending(&xhci->cmd_timer)) { - xhci_dbg_trace(xhci, trace_xhci_dbg_init, - "Cleanup command queue"); - del_timer(&xhci->cmd_timer); - xhci_cleanup_command_queue(xhci); - } - } else + } else { xhci_warn(xhci, "Host not halted after %u microseconds.\n", XHCI_MAX_HALT_USEC); + } + + xhci->cmd_ring_state = CMD_RING_STATE_STOPPED; + + if (timer_pending(&xhci->cmd_timer)) { + xhci_dbg_trace(xhci, trace_xhci_dbg_init, + "Cleanup command queue"); + del_timer(&xhci->cmd_timer); + xhci_cleanup_command_queue(xhci); + } + return ret; }