xhci: correct the usage of USB_CTRL_SET_TIMEOUT
Subsystems (2)
PATCH 1/1 xhci: correct the usage of USB_CTRL_SET_TIMEOUT
From: xiao jin <[email protected]>
Date: Wed, 9 Oct 2013 09:09:46 +0800
Subject: [PATCH] xhci: correct the usage of USB_CTRL_SET_TIMEOUT
The usage of USB_CTRL_SET_TIMEOUT is incorrect. The definition of USB_CTRL_SET_TIMEOUT is 5000ms. The input timeout to wait_for_completion_interruptible_timeout is jiffies. That makes the timeout be longer than what we want, such as 50s in some platform.
The patch is to convert USB_CTRL_SET_TIMEOUT to jiffies as command completion event timeout.
--- drivers/usb/host/xhci-hub.c | 2 +- drivers/usb/host/xhci.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/usb/host/xhci-hub.c +1 -1
@@ -295,7 +295,7 @@ static int xhci_stop_device(struct xhci_hcd *xhci, int slot_id, int suspend)/* Wait for last stop endpoint command to finish */ timeleft =wait_for_completion_interruptible_timeout ( cmd->completion, -USB_CTRL_SET_TIMEOUT ); +msecs_to_jiffies (USB_CTRL_SET_TIMEOUT ));if (timeleft <=0 ) {xhci_warn (xhci,"%s while waiting for stop endpoint command\n" , timeleft ==0 ?"Timeout" :"Signal" );
drivers/usb/host/xhci.c +1 -1
@@ -3486,7 +3486,7 @@ int xhci_discover_or_reset_device(struct usb_hcd *hcd, struct usb_device *udev)/* Wait for the Reset Device command to finish */ timeleft =wait_for_completion_interruptible_timeout ( reset_device_cmd->completion, -USB_CTRL_SET_TIMEOUT ); +msecs_to_jiffies (USB_CTRL_SET_TIMEOUT ));if (timeleft <=0 ) {xhci_warn (xhci,"%s while waiting for reset device command\n" , timeleft ==0 ?"Timeout" :"Signal" );
Signature · 1 line
1.7.1
Hi Xiao,
Quoted 3 lines · Xiao Jin
From: xiao jin <[email protected]>
Date: Wed, 9 Oct 2013 09:09:46 +0800
Subject: [PATCH] xhci: correct the usage ofUSB_CTRL_SET_TIMEOUT
As I mentioned in another email, you need to use git send-email to avoid putting these extra lines in your patches. They won't apply otherwise.
Quoted 8 lines
The usage of
USB_CTRL_SET_TIMEOUTis incorrect. The definition ofUSB_CTRL_SET_TIMEOUTis 5000ms. The input timeout towait_for_completion_interruptible_timeoutis jiffies. That makes the timeout be longer than what we want, such as 50s in some platform.The patch is to convert
USB_CTRL_SET_TIMEOUTto jiffies as command completion event timeout.
Good catch! I agree this should be fixed. However, can you fix this by changing the code to use XHCI_CMD_DEFAULT_TIMEOUT instead of USB_CTRL_SET_TIMEOUT? That's properly defined as five seconds:
xhci.h:#define XHCI_CMD_DEFAULT_TIMEOUT (5 * HZ)
Can you fix this and use git send-email to send a v2 patch?
Also, are there any really bad effects of this bug, other than possibly taking a really long time to suspend a system? I'm also concerned about *why* your host controller is taking so long to respond to the Stop Endpoint command. Was it because of the bug fixed by the other patch you sent?
Thanks,
Sarah Sharp
Quoted 37 lines
Signed-off-by xiao jin <[email protected]>--- drivers/usb/host/xhci-hub.c | 2 +- drivers/usb/host/xhci.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/usb/host/xhci-hub.c +1
-1@@ -295,7 +295,7 @@ static int xhci_stop_device(struct xhci_hcd *xhci, int slot_id, int suspend)/* Wait for last stop endpoint command to finish */ timeleft =wait_for_completion_interruptible_timeout ( cmd->completion, -USB_CTRL_SET_TIMEOUT ); +msecs_to_jiffies (USB_CTRL_SET_TIMEOUT ));if (timeleft <=0 ) {xhci_warn (xhci,"%s while waiting for stop endpoint command\n" , timeleft ==0 ?"Timeout" :"Signal" );drivers/usb/host/xhci.c +1
-1@@ -3486,7 +3486,7 @@ int xhci_discover_or_reset_device(struct usb_hcd *hcd, struct usb_device *udev)/* Wait for the Reset Device command to finish */ timeleft =wait_for_completion_interruptible_timeout ( reset_device_cmd->completion, -USB_CTRL_SET_TIMEOUT ); +msecs_to_jiffies (USB_CTRL_SET_TIMEOUT ));if (timeleft <=0 ) {xhci_warn (xhci,"%s while waiting for reset device command\n" , timeleft ==0 ?"Timeout" :"Signal" );Signature · 1 line
1.7.1