xhci: Fix handling halted endpoint even if endpoint ring appears empty
authorMathias Nyman <mathias.nyman@linux.intel.com>
Tue, 21 Apr 2020 14:08:20 +0000 (17:08 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 21 Apr 2020 14:27:38 +0000 (16:27 +0200)
commit93ceaa808e8defc67ebca1396e2f42f812a2efc0
tree930d2d9e25ddd084b1b41912f0fd875386d09da3
parent4dfb9ce89fa4e2637cd110f9017b64702d18f463
xhci: Fix handling halted endpoint even if endpoint ring appears empty

If a class driver cancels its only URB then the endpoint ring buffer will
appear empty to the xhci driver. xHC hardware may still process cached
TRBs, and complete with a STALL, halting the endpoint.

This halted endpoint was not handled correctly by xhci driver as events on
empty rings were all assumed to be spurious events.
xhci driver refused to restart the ring with EP_HALTED flag set, so class
driver was never informed the endpoint halted even if it queued new URBs.

The host side of the endpoint needs to be reset, and dequeue pointer should
be moved in order to clear the cached TRBs and resetart the endpoint.

Small adjustments in finding the new dequeue pointer are needed to support
the case of stall on an empty ring and unknown current TD.

Cc: <stable@vger.kernel.org>
cc: Jeremy Compostella <jeremy.compostella@intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20200421140822.28233-2-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-ring.c
drivers/usb/host/xhci.c
drivers/usb/host/xhci.h