Commit d3a43e66 authored by Hans de Goede's avatar Hans de Goede Committed by Greg Kroah-Hartman

xhci: Fold queue_set_tr_deq into xhci_queue_new_dequeue_state

xhci_queue_new_dequeue_state is the only caller of queue_set_tr_deq
and queue_set_tr_deq checks for SET_DEQ_PENDING, where as
xhci_queue_new_dequeue_state sets it which is inconsistent.

Simply fold the 2 into one is a nice cleanup and fixes the inconsistency.
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b7f9696b
...@@ -572,38 +572,6 @@ static void td_to_noop(struct xhci_hcd *xhci, struct xhci_ring *ep_ring, ...@@ -572,38 +572,6 @@ static void td_to_noop(struct xhci_hcd *xhci, struct xhci_ring *ep_ring,
} }
} }
static int queue_set_tr_deq(struct xhci_hcd *xhci, int slot_id,
unsigned int ep_index, unsigned int stream_id,
struct xhci_segment *deq_seg,
union xhci_trb *deq_ptr, u32 cycle_state);
void xhci_queue_new_dequeue_state(struct xhci_hcd *xhci,
unsigned int slot_id, unsigned int ep_index,
unsigned int stream_id,
struct xhci_dequeue_state *deq_state)
{
struct xhci_virt_ep *ep = &xhci->devs[slot_id]->eps[ep_index];
xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
"Set TR Deq Ptr cmd, new deq seg = %p (0x%llx dma), "
"new deq ptr = %p (0x%llx dma), new cycle = %u",
deq_state->new_deq_seg,
(unsigned long long)deq_state->new_deq_seg->dma,
deq_state->new_deq_ptr,
(unsigned long long)xhci_trb_virt_to_dma(deq_state->new_deq_seg, deq_state->new_deq_ptr),
deq_state->new_cycle_state);
queue_set_tr_deq(xhci, slot_id, ep_index, stream_id,
deq_state->new_deq_seg,
deq_state->new_deq_ptr,
(u32) deq_state->new_cycle_state);
/* Stop the TD queueing code from ringing the doorbell until
* this command completes. The HC won't set the dequeue pointer
* if the ring is running, and ringing the doorbell starts the
* ring running.
*/
ep->ep_state |= SET_DEQ_PENDING;
}
static void xhci_stop_watchdog_timer_in_irq(struct xhci_hcd *xhci, static void xhci_stop_watchdog_timer_in_irq(struct xhci_hcd *xhci,
struct xhci_virt_ep *ep) struct xhci_virt_ep *ep)
{ {
...@@ -3920,13 +3888,11 @@ int xhci_queue_stop_endpoint(struct xhci_hcd *xhci, struct xhci_command *cmd, ...@@ -3920,13 +3888,11 @@ int xhci_queue_stop_endpoint(struct xhci_hcd *xhci, struct xhci_command *cmd,
trb_slot_id | trb_ep_index | type | trb_suspend, false); trb_slot_id | trb_ep_index | type | trb_suspend, false);
} }
/* Set Transfer Ring Dequeue Pointer command. /* Set Transfer Ring Dequeue Pointer command */
* This should not be used for endpoints that have streams enabled. void xhci_queue_new_dequeue_state(struct xhci_hcd *xhci,
*/ unsigned int slot_id, unsigned int ep_index,
static int queue_set_tr_deq(struct xhci_hcd *xhci, int slot_id, unsigned int stream_id,
unsigned int ep_index, unsigned int stream_id, struct xhci_dequeue_state *deq_state)
struct xhci_segment *deq_seg,
union xhci_trb *deq_ptr, u32 cycle_state)
{ {
dma_addr_t addr; dma_addr_t addr;
u32 trb_slot_id = SLOT_ID_FOR_TRB(slot_id); u32 trb_slot_id = SLOT_ID_FOR_TRB(slot_id);
...@@ -3938,41 +3904,56 @@ static int queue_set_tr_deq(struct xhci_hcd *xhci, int slot_id, ...@@ -3938,41 +3904,56 @@ static int queue_set_tr_deq(struct xhci_hcd *xhci, int slot_id,
struct xhci_command *cmd; struct xhci_command *cmd;
int ret; int ret;
addr = xhci_trb_virt_to_dma(deq_seg, deq_ptr); xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
"Set TR Deq Ptr cmd, new deq seg = %p (0x%llx dma), new deq ptr = %p (0x%llx dma), new cycle = %u",
deq_state->new_deq_seg,
(unsigned long long)deq_state->new_deq_seg->dma,
deq_state->new_deq_ptr,
(unsigned long long)xhci_trb_virt_to_dma(
deq_state->new_deq_seg, deq_state->new_deq_ptr),
deq_state->new_cycle_state);
addr = xhci_trb_virt_to_dma(deq_state->new_deq_seg,
deq_state->new_deq_ptr);
if (addr == 0) { if (addr == 0) {
xhci_warn(xhci, "WARN Cannot submit Set TR Deq Ptr\n"); xhci_warn(xhci, "WARN Cannot submit Set TR Deq Ptr\n");
xhci_warn(xhci, "WARN deq seg = %p, deq pt = %p\n", xhci_warn(xhci, "WARN deq seg = %p, deq pt = %p\n",
deq_seg, deq_ptr); deq_state->new_deq_seg, deq_state->new_deq_ptr);
return 0; return;
} }
ep = &xhci->devs[slot_id]->eps[ep_index]; ep = &xhci->devs[slot_id]->eps[ep_index];
if ((ep->ep_state & SET_DEQ_PENDING)) { if ((ep->ep_state & SET_DEQ_PENDING)) {
xhci_warn(xhci, "WARN Cannot submit Set TR Deq Ptr\n"); xhci_warn(xhci, "WARN Cannot submit Set TR Deq Ptr\n");
xhci_warn(xhci, "A Set TR Deq Ptr command is pending.\n"); xhci_warn(xhci, "A Set TR Deq Ptr command is pending.\n");
return 0; return;
} }
/* This function gets called from contexts where it cannot sleep */ /* This function gets called from contexts where it cannot sleep */
cmd = xhci_alloc_command(xhci, false, false, GFP_ATOMIC); cmd = xhci_alloc_command(xhci, false, false, GFP_ATOMIC);
if (!cmd) { if (!cmd) {
xhci_warn(xhci, "WARN Cannot submit Set TR Deq Ptr: ENOMEM\n"); xhci_warn(xhci, "WARN Cannot submit Set TR Deq Ptr: ENOMEM\n");
return 0; return;
} }
ep->queued_deq_seg = deq_seg; ep->queued_deq_seg = deq_state->new_deq_seg;
ep->queued_deq_ptr = deq_ptr; ep->queued_deq_ptr = deq_state->new_deq_ptr;
if (stream_id) if (stream_id)
trb_sct = SCT_FOR_TRB(SCT_PRI_TR); trb_sct = SCT_FOR_TRB(SCT_PRI_TR);
ret = queue_command(xhci, cmd, ret = queue_command(xhci, cmd,
lower_32_bits(addr) | trb_sct | cycle_state, lower_32_bits(addr) | trb_sct | deq_state->new_cycle_state,
upper_32_bits(addr), trb_stream_id, upper_32_bits(addr), trb_stream_id,
trb_slot_id | trb_ep_index | type, false); trb_slot_id | trb_ep_index | type, false);
if (ret < 0) { if (ret < 0) {
xhci_free_command(xhci, cmd); xhci_free_command(xhci, cmd);
return ret; return;
} }
return 0; /* Stop the TD queueing code from ringing the doorbell until
* this command completes. The HC won't set the dequeue pointer
* if the ring is running, and ringing the doorbell starts the
* ring running.
*/
ep->ep_state |= SET_DEQ_PENDING;
} }
int xhci_queue_reset_ep(struct xhci_hcd *xhci, struct xhci_command *cmd, int xhci_queue_reset_ep(struct xhci_hcd *xhci, struct xhci_command *cmd,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment