]> git.itanic.dy.fi Git - linux-stable/commit
USB: xHCI: prevent infinite loop when processing MSE event
authorAndiry Xu <andiry.xu@amd.com>
Mon, 19 Sep 2011 23:05:12 +0000 (16:05 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 20 Sep 2011 00:15:47 +0000 (17:15 -0700)
commitc2d7b49f42f50d7fc5cbfd195b785a128723fdf4
tree24bedd5bfe4a08fe49757c938b6c59aab9acfa7c
parent44f4c3ed60fb21e1d2dd98304390ac121e6c7c6d
USB: xHCI: prevent infinite loop when processing MSE event

When a xHC host is unable to handle isochronous transfer in the
interval, it reports a Missed Service Error event and skips some tds.

Currently xhci driver handles MSE event in the following ways:

1. When encounter a MSE event, set ep->skip flag, update event ring
   dequeue pointer and return.

2. When encounter the next event on this ep, the driver will run the
   do-while loop, fetch td from ep's td_list to find the td
   corresponding to this event.  All tds missed are marked as short
   transfer(-EXDEV).

The do-while loop will end in two ways:

1. If the td pointed by the event trb is found;

2. If the ep ring's td_list is empty.

However, if a buggy HW reports some unpredicted event (for example, an
overrun event following a MSE event while the ep ring is actually not
empty), the driver will never find the td, and it will loop until the
td_list is empty.

Unfortunately, the spinlock is dropped when give back a urb in the
do-while loop.  During the spinlock released period, the class driver
may still submit urbs and add tds to the td_list.  This may cause
disaster, since the td_list will never be empty and the loop never ends,
and the system hangs.

To fix this, count the number of TDs on the ep ring before skipping TDs,
and quit the loop when skipped that number of tds.  This guarantees the
do-while loop will end after certain number of cycles, and driver will
not be trapped in an infinite loop.

Signed-off-by: Andiry Xu <andiry.xu@amd.com>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/usb/host/xhci-ring.c