xhci: Fix giving back cancelled URBs even if halted endpoint can't reset
authorMathias Nyman <mathias.nyman@linux.intel.com>
Wed, 12 May 2021 08:08:13 +0000 (11:08 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 May 2021 12:47:36 +0000 (14:47 +0200)
commit9b6a126ae58d9edfdde2d5f2e87f7615ea5e0155
tree370549689331d25df2b770a531c3f24b3a0259d7
parentb813511135e8b84fa741afdfbab4937919100bef
xhci: Fix giving back cancelled URBs even if halted endpoint can't reset

Commit 9ebf30007858 ("xhci: Fix halted endpoint at stop endpoint command
completion") in 5.12 changes how cancelled URBs are given back.

To cancel a URB xhci driver needs to stop the endpoint first.
To clear a halted endpoint xhci driver needs to reset the endpoint.

In rare cases when an endpoint halt (error) races with a endpoint stop we
need to clear the reset before removing, and giving back the cancelled URB.

The above change in 5.12 takes care of this, but it also relies on the
reset endpoint completion handler to give back the cancelled URBs.

There are cases when driver refuses to queue reset endpoint commands,
for example when a link suddenly goes to an inactive error state.
In this case the cancelled URB is never given back.

Fix this by giving back the URB in the stop endpoint if queuing a reset
endpoint command fails.

Fixes: 9ebf30007858 ("xhci: Fix halted endpoint at stop endpoint command completion")
CC: <stable@vger.kernel.org> # 5.12
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20210512080816.866037-3-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-ring.c