linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 2/2] usb: host: xhci: Handle the right timeout command
       [not found] <b0157454dce55d1288c7e097ddffc3d6c81351b2.1482212656.git.baolin.wang@linaro.org>
@ 2016-12-20  5:59 ` Baolin Wang
  0 siblings, 0 replies; only message in thread
From: Baolin Wang @ 2016-12-20  5:59 UTC (permalink / raw)
  To: mathias.nyman, gregkh
  Cc: baolu.lu, linux-usb, linux-kernel, broonie, baolin.wang, linaro-kernel

If a command event is found on the event ring during an interrupt,
we need to stop the command timer with del_timer(). Since del_timer()
can fail if the timer is running and waiting on the xHCI lock, then
it maybe get the wrong timeout command in xhci_handle_command_timeout()
if host fetched a new command and updated the xhci->current_cmd in
handle_cmd_completion(). For this situation, we need a way to signal
to the command timer that everything is fine and it should exit.

We should check if the command timer is pending in xhci_handle_command_timeout()
function, if the command timer is pending, which means current timeout
command has been handled by host and host has fetched new command and
re-added the command timer, then just return and wait for new current
command. If not, it means current command is timeout and need to be
handled.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
Changes since v1:
 - Remove the counter and just check if the command timer is pending.
---
 drivers/usb/host/xhci-ring.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 9965a4c..3947344 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1269,7 +1269,7 @@ void xhci_handle_command_timeout(unsigned long data)
 	xhci = (struct xhci_hcd *) data;
 
 	spin_lock_irqsave(&xhci->lock, flags);
-	if (!xhci->current_cmd) {
+	if (!xhci->current_cmd || timer_pending(&xhci->cmd_timer)) {
 		spin_unlock_irqrestore(&xhci->lock, flags);
 		return;
 	}
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-12-20  6:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <b0157454dce55d1288c7e097ddffc3d6c81351b2.1482212656.git.baolin.wang@linaro.org>
2016-12-20  5:59 ` [PATCH v2 2/2] usb: host: xhci: Handle the right timeout command Baolin Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).