xhci: Handle zero-length isochronous packets.
commit48df4a6fd8c40c0bbcbca2044f5f2bc75dcf6db1
authorSarah Sharp <sarah.a.sharp@linux.intel.com>
Fri, 12 Aug 2011 17:23:01 +0000 (12 10:23 -0700)
committerSarah Sharp <sarah.a.sharp@linux.intel.com>
Tue, 16 Aug 2011 23:46:57 +0000 (16 16:46 -0700)
tree3c1ab23559595b3a2b7cc5955a623f9f3222ae59
parent8a9af4fdf6d5eeb3200a088354d266a87e8260b0
xhci: Handle zero-length isochronous packets.

For a long time, the xHCI driver has had this note:
/* FIXME: Ignoring zero-length packets, can those happen? */

It turns out that, yes, there are drivers that need to queue zero-length
transfers for isochronous OUT transfers.  Without this patch, users will
see kernel hang messages when a driver attempts to enqueue an isochronous
URB with a zero length transfer (because count_isoc_trbs_needed will return
zero for that TD, xhci_td->last_trb will never be set, and updating the
dequeue pointer will cause an infinite loop).

Matěj ran into this issue when using an NI Audio4DJ USB soundcard
with the snd-usb-caiaq driver.  See
https://bugzilla.kernel.org/show_bug.cgi?id=40702

Fix count_isoc_trbs_needed() to return 1 for zero-length transfers (thanks
Alan on the math help).  Update the various TRB field calculations to deal
with zero-length transfers.  We're still transferring one packet with a
zero-length data payload, so the total_packet_count should be 1. The
Transfer Burst Count (TBC) and Transfer Last Burst Packet Count (TLBPC)
fields should be set to zero.

This patch should be backported to kernels as old as 2.6.36.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Tested-by: Matěj Laitl <matej@laitl.cz>
Cc: Daniel Mack <zonque@gmail.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: stable@kernel.org
drivers/usb/host/xhci-ring.c