summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2012-01-13 15:11:26 -0800
committerVincent Palatin <vpalatin@chromium.org>2012-01-13 18:32:51 -0800
commit51135b4045b8e8743432201f37d8beeb0bfe4fc9 (patch)
tree44c7944e13f180a273eecd4f6ec05d8dfb4503a1 /drivers
parentbfe30f3544585848cda1983f9fe3f9809bf409ed (diff)
ehci: add timeout on interrupt endpoint operations
ensure we cannot get stuck in the keyboard scanning if something wrong happens (USB device unplugged or fatal I/O error) Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BUG=chrome-os-partner:7188 chrome-os-partner:7430 chrome-os-partner:7432 chrome-os-partner:7559 TEST=On lumpy with usb keyboard configured, stress the USB stack and check the keyboard traces. Change-Id: I019ddefa073852ae1abfd4f223ba4c2d6a7bc054 Reviewed-on: https://gerrit.chromium.org/gerrit/14187 Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Patrick Georgi <patrick@georgi-clan.de> Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/host/ehci-hcd.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index d9ae89e3cf..e5c21d7bf6 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1194,6 +1194,7 @@ destroy_int_queue(struct usb_device *dev, struct int_queue *queue)
{
struct ehci_ctrl *ctrl = dev->controller;
int result = -1;
+ unsigned long timeout;
if (disable_periodic(ctrl) < 0) {
debug("FATAL: periodic should never fail, but did");
@@ -1202,6 +1203,7 @@ destroy_int_queue(struct usb_device *dev, struct int_queue *queue)
periodic_schedules--;
struct QH *cur = &ctrl->periodic_queue;
+ timeout = get_timer(0) + 500; /* abort after 500ms */
while (!(cur->qh_link & QH_LINK_TERMINATE)) {
debug("considering %p, with qh_link %x\n", cur, cur->qh_link);
if (NEXT_QH(cur) == queue->first) {
@@ -1211,6 +1213,11 @@ destroy_int_queue(struct usb_device *dev, struct int_queue *queue)
goto out;
}
cur = NEXT_QH(cur);
+ if (get_timer(0) > timeout) {
+ printf("Timeout destroying interrupt endpoint queue\n");
+ result = -1;
+ break;
+ }
}
if (periodic_schedules > 0)
@@ -1232,15 +1239,21 @@ submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
{
void *backbuffer;
struct int_queue *queue;
+ unsigned long timeout;
+ int result = 0;
debug("dev=%p, pipe=%lu, buffer=%p, length=%d, interval=%d",
dev, pipe, buffer, length, interval);
queue = create_int_queue(dev, pipe, 1, length, buffer);
- /* TODO: pick some useful timeout rule */
+ timeout = get_timer(0) + USB_TIMEOUT_MS(pipe);
while ((backbuffer = poll_int_queue(dev, queue)) == NULL)
- ;
+ if (get_timer(0) > timeout) {
+ printf("Timeout poll on interrupt endpoint\n");
+ result = -1;
+ break;
+ }
if (backbuffer != buffer) {
debug("got wrong buffer back (%x instead of %x)\n",
@@ -1252,7 +1265,7 @@ submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
return -1;
/* everything worked out fine */
- return 0;
+ return result;
}
#ifdef CONFIG_SYS_USB_EVENT_POLL