Now that queue_trb() generates the correct TRB_CYCLE value for all commands, there is no need for the callers to worry about it. Remove all the code from xhci_queue_bulk_tx() that remembered the location of the first TRB and its cycle bit. Also remove related variables that used to be passed to giveback_first_trb. There are no references left to ring->cycle_state or TRB_CYCLE (or 0x1 meaing TRB_CYCLE) in the code that generates TRB. Signed-off-by: David Laight <david.laight@xxxxxxxxxx> --- drivers/usb/host/xhci-ring.c | 78 +++----------------------------------------- 1 file changed, 5 insertions(+), 73 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index c1ba8ca..0d0bd7f 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2906,12 +2906,8 @@ static void queue_trb(struct xhci_hcd *xhci, struct xhci_ring *ring, trb = &ring->enqueue->generic; - /* - * Ignore the caller's CYCLE bit. - * The caller doesn't know whether the real first TRB is - * actually a LINK (or NOP) TRB. - */ - field4 = (field4 & ~TRB_CYCLE) | ring->cycle_state; + /* Give the controller ownership of all but the first TRB */ + field4 |= ring->cycle_state; if (trb == &ring->enqueue_first->generic) field4 ^= TRB_CYCLE; @@ -3284,13 +3280,9 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, int num_sgs; int trb_buff_len, this_sg_len, running_total; unsigned int total_packet_count; - bool first_trb; u64 addr; bool more_trbs_coming; - struct xhci_generic_trb *start_trb; - int start_cycle; - ep_ring = xhci_urb_to_transfer_ring(xhci, urb); if (!ep_ring) return -EINVAL; @@ -3309,14 +3301,6 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, urb_priv = urb->hcpriv; td = urb_priv->td[0]; - /* - * Don't give the first TRB to the hardware (by toggling the cycle bit) - * until we've finished creating all the other TRBs. The ring's cycle - * state may change as we enqueue the other TRBs, so save it too. - */ - start_trb = &ep_ring->enqueue->generic; - start_cycle = ep_ring->cycle_state; - running_total = 0; /* * How much data is in the first TRB? @@ -3335,21 +3319,12 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, if (trb_buff_len > urb->transfer_buffer_length) trb_buff_len = urb->transfer_buffer_length; - first_trb = true; /* Queue the first TRB, even if it's zero-length */ do { u32 field = 0; u32 length_field = 0; u32 remainder = 0; - /* Don't change the cycle bit of the first TRB until later */ - if (first_trb) { - first_trb = false; - if (start_cycle == 0) - field |= 0x1; - } else - field |= ep_ring->cycle_state; - /* Chain all the TRBs together; clear the chain bit in the last * TRB to indicate it's the last TRB in the chain. */ @@ -3435,10 +3410,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb_priv *urb_priv; struct xhci_td *td; int num_trbs; - struct xhci_generic_trb *start_trb; - bool first_trb; bool more_trbs_coming; - int start_cycle; u32 field, length_field; int running_total, trb_buff_len, ret; @@ -3479,14 +3451,6 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, urb_priv = urb->hcpriv; td = urb_priv->td[0]; - /* - * Don't give the first TRB to the hardware (by toggling the cycle bit) - * until we've finished creating all the other TRBs. The ring's cycle - * state may change as we enqueue the other TRBs, so save it too. - */ - start_trb = &ep_ring->enqueue->generic; - start_cycle = ep_ring->cycle_state; - running_total = 0; total_packet_count = DIV_ROUND_UP(urb->transfer_buffer_length, usb_endpoint_maxp(&urb->ep->desc)); @@ -3497,21 +3461,11 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, if (trb_buff_len > urb->transfer_buffer_length) trb_buff_len = urb->transfer_buffer_length; - first_trb = true; - /* Queue the first TRB, even if it's zero-length */ do { u32 remainder = 0; field = 0; - /* Don't change the cycle bit of the first TRB until later */ - if (first_trb) { - first_trb = false; - if (start_cycle == 0) - field |= 0x1; - } else - field |= ep_ring->cycle_state; - /* Chain all the TRBs together; clear the chain bit in the last * TRB to indicate it's the last TRB in the chain. */ @@ -3573,8 +3527,6 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, int num_trbs; int ret; struct usb_ctrlrequest *setup; - struct xhci_generic_trb *start_trb; - int start_cycle; u32 field, length_field; struct urb_priv *urb_priv; struct xhci_td *td; @@ -3608,21 +3560,11 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, urb_priv = urb->hcpriv; td = urb_priv->td[0]; - /* - * Don't give the first TRB to the hardware (by toggling the cycle bit) - * until we've finished creating all the other TRBs. The ring's cycle - * state may change as we enqueue the other TRBs, so save it too. - */ - start_trb = &ep_ring->enqueue->generic; - start_cycle = ep_ring->cycle_state; - /* Queue setup TRB - see section 6.4.1.2.1 */ /* FIXME better way to translate setup_packet into two u32 fields? */ setup = (struct usb_ctrlrequest *) urb->setup_packet; field = 0; field |= TRB_IDT | TRB_TYPE(TRB_SETUP); - if (start_cycle == 0) - field |= 0x1; /* xHCI 1.0 6.4.1.2.1: Transfer Type field */ if (xhci->hci_version == 0x100) { @@ -3658,7 +3600,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, lower_32_bits(urb->transfer_dma), upper_32_bits(urb->transfer_dma), length_field, - field | ep_ring->cycle_state); + field); } /* Save the DMA address of the last TRB in the TD */ @@ -3675,7 +3617,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, 0, TRB_INTR_TARGET(0), /* Event on completion */ - field | TRB_IOC | TRB_TYPE(TRB_STATUS) | ep_ring->cycle_state); + field | TRB_IOC | TRB_TYPE(TRB_STATUS)); giveback_first_trb(xhci, slot_id, ep_index, ep_ring); return 0; @@ -3763,9 +3705,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb_priv *urb_priv; struct xhci_td *td; int num_tds, trbs_per_td; - struct xhci_generic_trb *start_trb; bool first_trb; - int start_cycle; u32 field, length_field; int running_total, trb_buff_len, td_len, td_remain_len, ret; u64 start_addr, addr; @@ -3781,8 +3721,6 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, } start_addr = (u64) urb->transfer_dma; - start_trb = &ep_ring->enqueue->generic; - start_cycle = ep_ring->cycle_state; urb_priv = urb->hcpriv; /* Queue the first TRB, even if it's zero-length */ @@ -3827,16 +3765,10 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, field |= TRB_TYPE(TRB_ISOC); /* Assume URB_ISO_ASAP is set */ field |= TRB_SIA; - if (i == 0) { - if (start_cycle == 0) - field |= 0x1; - } else - field |= ep_ring->cycle_state; first_trb = false; } else { /* Queue other normal TRBs */ field |= TRB_TYPE(TRB_NORMAL); - field |= ep_ring->cycle_state; } /* Only set interrupt on short packet for IN EPs */ @@ -4007,7 +3939,7 @@ static int queue_command(struct xhci_hcd *xhci, u32 field1, u32 field2, return ret; } queue_trb(xhci, xhci->cmd_ring, false, field1, field2, field3, - field4 | xhci->cmd_ring->cycle_state); + field4); /* The 'first' TRB might be a LINK TRB... */ giveback_first_trb(xhci, 0, 0, xhci->cmd_ring); return 0; -- 1.8.1.2 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html