USB: xhci: Set transfer descriptor size field correctly.
authorSarah Sharp <sarah.a.sharp@linux.intel.com>
Wed, 11 Nov 2009 18:28:30 +0000 (10:28 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 11 Dec 2009 19:55:23 +0000 (11:55 -0800)
commit04dd950d92f41155ed0cdf39b6bfbeea22eadb34
tree6d88c1b0ae7f2b5bbdebd3d29da77c8e1b3eb39b
parentf176a5d81214864904d285912da02c4bc0e9041a
USB: xhci: Set transfer descriptor size field correctly.

The transfer descriptor (TD) is a series of transfer request buffers
(TRBs) that describe the buffer pointer, length, and other
characteristics.  The xHCI controllers want to know an estimate of how
long the TD is, for caching reasons.  In each TRB, there is a "TD size"
field that provides a rough estimate of the remaining buffers to be
transmitted, including the buffer pointed to by that TRB.

The TD size is 5 bits long, and contains the remaining size in bytes,
right shifted by 10 bits.  So a remaining TD size less than 1024 would get
a zero in the TD size field, and a remaining size greater than 32767 would
get 31 in the field.

This patches fixes a bug in the TD_REMAINDER macro that is triggered when
the URB has a scatter gather list with a size bigger than 32767 bytes.
Not all host controllers pay attention to the TD size field, so the bug
will not appear on all USB 3.0 hosts.

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