summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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