提交 ae3bf16e 编写于 作者: M Mathias Nyman 提交者: sanglipeng

xhci: move and rename xhci_cleanup_halted_endpoint()

stable inclusion
from stable-v5.10.164
commit 2f90fcedc5d6efcd5b608d28e0321521a6d9193e
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7T7G4

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=2f90fcedc5d6efcd5b608d28e0321521a6d9193e

--------------------------------

[ Upstream commit 7c6c334e ]

Halted endpoints can be discoverd both when handling transfer events and
command completion events. Move code that handles halted endpoints before
both of those event handlers.

Rename the function to xhci_handle_halted_ep() to better describe
what it does. Try to reserve "cleanup" word in function names for last
stage cleanup activities.

No functional changes
Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20210129130044.206855-21-mathias.nyman@linux.intel.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Stable-dep-of: a1575120 ("xhci: Prevent infinite loop in transaction errors recovery for streams")
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: Nsanglipeng <sanglipeng1@jd.com>
上级 19e3c2e3
......@@ -839,6 +839,35 @@ static int xhci_reset_halted_ep(struct xhci_hcd *xhci, unsigned int slot_id,
return ret;
}
static void xhci_handle_halted_endpoint(struct xhci_hcd *xhci,
struct xhci_virt_ep *ep, unsigned int stream_id,
struct xhci_td *td,
enum xhci_ep_reset_type reset_type)
{
unsigned int slot_id = ep->vdev->slot_id;
int err;
/*
* Avoid resetting endpoint if link is inactive. Can cause host hang.
* Device will be reset soon to recover the link so don't do anything
*/
if (ep->vdev->flags & VDEV_PORT_ERROR)
return;
ep->ep_state |= EP_HALTED;
err = xhci_reset_halted_ep(xhci, slot_id, ep->ep_index, reset_type);
if (err)
return;
if (reset_type == EP_HARD_RESET) {
ep->ep_state |= EP_HARD_CLEAR_TOGGLE;
xhci_cleanup_stalled_ring(xhci, slot_id, ep->ep_index, stream_id,
td);
}
xhci_ring_cmd_db(xhci);
}
/*
* When we get a command completion for a Stop Endpoint Command, we need to
* unlink any cancelled TDs from the ring. There are two ways to do that:
......@@ -1994,35 +2023,6 @@ static void xhci_clear_hub_tt_buffer(struct xhci_hcd *xhci, struct xhci_td *td,
}
}
static void xhci_cleanup_halted_endpoint(struct xhci_hcd *xhci,
struct xhci_virt_ep *ep, unsigned int stream_id,
struct xhci_td *td,
enum xhci_ep_reset_type reset_type)
{
unsigned int slot_id = ep->vdev->slot_id;
int err;
/*
* Avoid resetting endpoint if link is inactive. Can cause host hang.
* Device will be reset soon to recover the link so don't do anything
*/
if (ep->vdev->flags & VDEV_PORT_ERROR)
return;
ep->ep_state |= EP_HALTED;
err = xhci_reset_halted_ep(xhci, slot_id, ep->ep_index, reset_type);
if (err)
return;
if (reset_type == EP_HARD_RESET) {
ep->ep_state |= EP_HARD_CLEAR_TOGGLE;
xhci_cleanup_stalled_ring(xhci, slot_id, ep->ep_index, stream_id,
td);
}
xhci_ring_cmd_db(xhci);
}
/* Check if an error has halted the endpoint ring. The class driver will
* cleanup the halt for a non-default control endpoint if we indicate a stall.
* However, a babble and other errors also halt the endpoint ring, and the class
......@@ -2098,7 +2098,8 @@ static int finish_td(struct xhci_hcd *xhci, struct xhci_td *td,
*/
if ((ep->ep_index != 0) || (trb_comp_code != COMP_STALL_ERROR))
xhci_clear_hub_tt_buffer(xhci, td, ep);
xhci_cleanup_halted_endpoint(xhci, ep, ep_ring->stream_id, td,
xhci_handle_halted_endpoint(xhci, ep, ep_ring->stream_id, td,
EP_HARD_RESET);
} else {
/* Update ring dequeue pointer */
......@@ -2383,8 +2384,9 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td,
break;
td->status = 0;
xhci_cleanup_halted_endpoint(xhci, ep, ep_ring->stream_id, td,
EP_SOFT_RESET);
xhci_handle_halted_endpoint(xhci, ep, ep_ring->stream_id, td,
EP_SOFT_RESET);
return 0;
default:
/* do nothing */
......@@ -2459,8 +2461,8 @@ static int handle_tx_event(struct xhci_hcd *xhci,
case COMP_USB_TRANSACTION_ERROR:
case COMP_INVALID_STREAM_TYPE_ERROR:
case COMP_INVALID_STREAM_ID_ERROR:
xhci_cleanup_halted_endpoint(xhci, ep, 0, NULL,
EP_SOFT_RESET);
xhci_handle_halted_endpoint(xhci, ep, 0, NULL,
EP_SOFT_RESET);
goto cleanup;
case COMP_RING_UNDERRUN:
case COMP_RING_OVERRUN:
......@@ -2643,10 +2645,10 @@ static int handle_tx_event(struct xhci_hcd *xhci,
if (trb_comp_code == COMP_STALL_ERROR ||
xhci_requires_manual_halt_cleanup(xhci, ep_ctx,
trb_comp_code)) {
xhci_cleanup_halted_endpoint(xhci, ep,
ep_ring->stream_id,
NULL,
EP_HARD_RESET);
xhci_handle_halted_endpoint(xhci, ep,
ep_ring->stream_id,
NULL,
EP_HARD_RESET);
}
goto cleanup;
}
......@@ -2738,9 +2740,9 @@ static int handle_tx_event(struct xhci_hcd *xhci,
if (trb_comp_code == COMP_STALL_ERROR ||
xhci_requires_manual_halt_cleanup(xhci, ep_ctx,
trb_comp_code))
xhci_cleanup_halted_endpoint(xhci, ep,
ep_ring->stream_id,
td, EP_HARD_RESET);
xhci_handle_halted_endpoint(xhci, ep,
ep_ring->stream_id,
td, EP_HARD_RESET);
goto cleanup;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册