]> bbs.cooldavid.org Git - net-next-2.6.git/commit
USB: xhci: Fix check for room on the ring.
authorSarah Sharp <sarah.a.sharp@linux.intel.com>
Tue, 18 May 2010 23:05:26 +0000 (16:05 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 20 May 2010 20:21:30 +0000 (13:21 -0700)
commit44ebd037c54f80db3121ac9f5fe6e677b76e11d5
treed0a3784e7a7005086ab9842e6d047172bb37d385
parentbc88d2eba5e19d10dd546e428314909d889b3b6a
USB: xhci: Fix check for room on the ring.

The length of the scatter gather list a driver can enqueue is limited by
the bus' sg_tablesize to 62 entries.  Each entry will be described by at
least one transfer request block (TRB).  If the entry's buffer crosses a
64KB boundary, then that entry will have to be described by two or more
TRBs.  So even if the USB device driver respects sg_tablesize, the whole
scatter list may take more than 62 TRBs to describe, and won't fit on
the ring.

Don't assume that an empty ring means there is enough room on the
transfer ring.  The old code would unconditionally queue this too-large
transfer, and over write the beginning of the transfer.  This would mean
the cycle bit was unchanged in those overwritten transfers, causing the
hardware to think it didn't own the TRBs, and the host would seem to
hang.

Now drivers may see submit_urb() fail with -ENOMEM if the transfers are
too big to fit on the ring.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/host/xhci-ring.c