@@ -185,7 +185,7 @@ static void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring, bool consumer
185185 * prepare_transfer()?
186186 */
187187static void inc_enq (struct xhci_hcd * xhci , struct xhci_ring * ring ,
188- bool consumer , bool more_trbs_coming )
188+ bool consumer , bool more_trbs_coming , bool isoc )
189189{
190190 u32 chain ;
191191 union xhci_trb * next ;
@@ -212,11 +212,13 @@ static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring,
212212 if (!chain && !more_trbs_coming )
213213 break ;
214214
215- /* If we're not dealing with 0.95 hardware,
215+ /* If we're not dealing with 0.95 hardware or
216+ * isoc rings on AMD 0.96 host,
216217 * carry over the chain bit of the previous TRB
217218 * (which may mean the chain bit is cleared).
218219 */
219- if (!xhci_link_trb_quirk (xhci )) {
220+ if (!(isoc && (xhci -> quirks & XHCI_AMD_0x96_HOST ))
221+ && !xhci_link_trb_quirk (xhci )) {
220222 next -> link .control &=
221223 cpu_to_le32 (~TRB_CHAIN );
222224 next -> link .control |=
@@ -2409,7 +2411,7 @@ irqreturn_t xhci_msi_irq(int irq, struct usb_hcd *hcd)
24092411 * prepare_transfer()?
24102412 */
24112413static void queue_trb (struct xhci_hcd * xhci , struct xhci_ring * ring ,
2412- bool consumer , bool more_trbs_coming ,
2414+ bool consumer , bool more_trbs_coming , bool isoc ,
24132415 u32 field1 , u32 field2 , u32 field3 , u32 field4 )
24142416{
24152417 struct xhci_generic_trb * trb ;
@@ -2419,15 +2421,15 @@ static void queue_trb(struct xhci_hcd *xhci, struct xhci_ring *ring,
24192421 trb -> field [1 ] = cpu_to_le32 (field2 );
24202422 trb -> field [2 ] = cpu_to_le32 (field3 );
24212423 trb -> field [3 ] = cpu_to_le32 (field4 );
2422- inc_enq (xhci , ring , consumer , more_trbs_coming );
2424+ inc_enq (xhci , ring , consumer , more_trbs_coming , isoc );
24232425}
24242426
24252427/*
24262428 * Does various checks on the endpoint ring, and makes it ready to queue num_trbs.
24272429 * FIXME allocate segments if the ring is full.
24282430 */
24292431static int prepare_ring (struct xhci_hcd * xhci , struct xhci_ring * ep_ring ,
2430- u32 ep_state , unsigned int num_trbs , gfp_t mem_flags )
2432+ u32 ep_state , unsigned int num_trbs , bool isoc , gfp_t mem_flags )
24312433{
24322434 /* Make sure the endpoint has been added to xHC schedule */
24332435 switch (ep_state ) {
@@ -2469,10 +2471,11 @@ static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring,
24692471 next = ring -> enqueue ;
24702472
24712473 while (last_trb (xhci , ring , ring -> enq_seg , next )) {
2472- /* If we're not dealing with 0.95 hardware,
2473- * clear the chain bit.
2474+ /* If we're not dealing with 0.95 hardware or isoc rings
2475+ * on AMD 0.96 host, clear the chain bit.
24742476 */
2475- if (!xhci_link_trb_quirk (xhci ))
2477+ if (!xhci_link_trb_quirk (xhci ) && !(isoc &&
2478+ (xhci -> quirks & XHCI_AMD_0x96_HOST )))
24762479 next -> link .control &= cpu_to_le32 (~TRB_CHAIN );
24772480 else
24782481 next -> link .control |= cpu_to_le32 (TRB_CHAIN );
@@ -2505,6 +2508,7 @@ static int prepare_transfer(struct xhci_hcd *xhci,
25052508 unsigned int num_trbs ,
25062509 struct urb * urb ,
25072510 unsigned int td_index ,
2511+ bool isoc ,
25082512 gfp_t mem_flags )
25092513{
25102514 int ret ;
@@ -2522,7 +2526,7 @@ static int prepare_transfer(struct xhci_hcd *xhci,
25222526
25232527 ret = prepare_ring (xhci , ep_ring ,
25242528 le32_to_cpu (ep_ctx -> ep_info ) & EP_STATE_MASK ,
2525- num_trbs , mem_flags );
2529+ num_trbs , isoc , mem_flags );
25262530 if (ret )
25272531 return ret ;
25282532
@@ -2745,7 +2749,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
27452749
27462750 trb_buff_len = prepare_transfer (xhci , xhci -> devs [slot_id ],
27472751 ep_index , urb -> stream_id ,
2748- num_trbs , urb , 0 , mem_flags );
2752+ num_trbs , urb , 0 , false, mem_flags );
27492753 if (trb_buff_len < 0 )
27502754 return trb_buff_len ;
27512755
@@ -2840,7 +2844,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
28402844 more_trbs_coming = true;
28412845 else
28422846 more_trbs_coming = false;
2843- queue_trb (xhci , ep_ring , false, more_trbs_coming ,
2847+ queue_trb (xhci , ep_ring , false, more_trbs_coming , false,
28442848 lower_32_bits (addr ),
28452849 upper_32_bits (addr ),
28462850 length_field ,
@@ -2931,7 +2935,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
29312935
29322936 ret = prepare_transfer (xhci , xhci -> devs [slot_id ],
29332937 ep_index , urb -> stream_id ,
2934- num_trbs , urb , 0 , mem_flags );
2938+ num_trbs , urb , 0 , false, mem_flags );
29352939 if (ret < 0 )
29362940 return ret ;
29372941
@@ -3003,7 +3007,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
30033007 more_trbs_coming = true;
30043008 else
30053009 more_trbs_coming = false;
3006- queue_trb (xhci , ep_ring , false, more_trbs_coming ,
3010+ queue_trb (xhci , ep_ring , false, more_trbs_coming , false,
30073011 lower_32_bits (addr ),
30083012 upper_32_bits (addr ),
30093013 length_field ,
@@ -3063,7 +3067,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
30633067 num_trbs ++ ;
30643068 ret = prepare_transfer (xhci , xhci -> devs [slot_id ],
30653069 ep_index , urb -> stream_id ,
3066- num_trbs , urb , 0 , mem_flags );
3070+ num_trbs , urb , 0 , false, mem_flags );
30673071 if (ret < 0 )
30683072 return ret ;
30693073
@@ -3096,7 +3100,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
30963100 }
30973101 }
30983102
3099- queue_trb (xhci , ep_ring , false, true,
3103+ queue_trb (xhci , ep_ring , false, true, false,
31003104 setup -> bRequestType | setup -> bRequest << 8 | le16_to_cpu (setup -> wValue ) << 16 ,
31013105 le16_to_cpu (setup -> wIndex ) | le16_to_cpu (setup -> wLength ) << 16 ,
31023106 TRB_LEN (8 ) | TRB_INTR_TARGET (0 ),
@@ -3116,7 +3120,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
31163120 if (urb -> transfer_buffer_length > 0 ) {
31173121 if (setup -> bRequestType & USB_DIR_IN )
31183122 field |= TRB_DIR_IN ;
3119- queue_trb (xhci , ep_ring , false, true,
3123+ queue_trb (xhci , ep_ring , false, true, false,
31203124 lower_32_bits (urb -> transfer_dma ),
31213125 upper_32_bits (urb -> transfer_dma ),
31223126 length_field ,
@@ -3132,7 +3136,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
31323136 field = 0 ;
31333137 else
31343138 field = TRB_DIR_IN ;
3135- queue_trb (xhci , ep_ring , false, false,
3139+ queue_trb (xhci , ep_ring , false, false, false,
31363140 0 ,
31373141 0 ,
31383142 TRB_INTR_TARGET (0 ),
@@ -3281,7 +3285,8 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
32813285 trbs_per_td = count_isoc_trbs_needed (xhci , urb , i );
32823286
32833287 ret = prepare_transfer (xhci , xhci -> devs [slot_id ], ep_index ,
3284- urb -> stream_id , trbs_per_td , urb , i , mem_flags );
3288+ urb -> stream_id , trbs_per_td , urb , i , true,
3289+ mem_flags );
32853290 if (ret < 0 ) {
32863291 if (i == 0 )
32873292 return ret ;
@@ -3351,7 +3356,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
33513356 remainder |
33523357 TRB_INTR_TARGET (0 );
33533358
3354- queue_trb (xhci , ep_ring , false, more_trbs_coming ,
3359+ queue_trb (xhci , ep_ring , false, more_trbs_coming , true,
33553360 lower_32_bits (addr ),
33563361 upper_32_bits (addr ),
33573362 length_field ,
@@ -3433,7 +3438,7 @@ int xhci_queue_isoc_tx_prepare(struct xhci_hcd *xhci, gfp_t mem_flags,
34333438 * Do not insert any td of the urb to the ring if the check failed.
34343439 */
34353440 ret = prepare_ring (xhci , ep_ring , le32_to_cpu (ep_ctx -> ep_info ) & EP_STATE_MASK ,
3436- num_trbs , mem_flags );
3441+ num_trbs , true, mem_flags );
34373442 if (ret )
34383443 return ret ;
34393444
@@ -3492,16 +3497,16 @@ static int queue_command(struct xhci_hcd *xhci, u32 field1, u32 field2,
34923497 reserved_trbs ++ ;
34933498
34943499 ret = prepare_ring (xhci , xhci -> cmd_ring , EP_STATE_RUNNING ,
3495- reserved_trbs , GFP_ATOMIC );
3500+ reserved_trbs , false, GFP_ATOMIC );
34963501 if (ret < 0 ) {
34973502 xhci_err (xhci , "ERR: No room for command on command ring\n" );
34983503 if (command_must_succeed )
34993504 xhci_err (xhci , "ERR: Reserved TRB counting for "
35003505 "unfailable commands failed.\n" );
35013506 return ret ;
35023507 }
3503- queue_trb (xhci , xhci -> cmd_ring , false, false, field1 , field2 , field3 ,
3504- field4 | xhci -> cmd_ring -> cycle_state );
3508+ queue_trb (xhci , xhci -> cmd_ring , false, false, false, field1 , field2 ,
3509+ field3 , field4 | xhci -> cmd_ring -> cycle_state );
35053510 return 0 ;
35063511}
35073512
0 commit comments