@@ -462,6 +462,8 @@ int dwc_otg_hcd_urb_enqueue(dwc_otg_hcd_t * hcd,
462
462
{
463
463
dwc_irqflags_t flags ;
464
464
int retval = 0 ;
465
+ uint8_t needs_scheduling = 0 ;
466
+ dwc_otg_transaction_type_e tr_type ;
465
467
dwc_otg_qtd_t * qtd ;
466
468
gintmsk_data_t intr_mask = {.d32 = 0 };
467
469
@@ -493,30 +495,29 @@ int dwc_otg_hcd_urb_enqueue(dwc_otg_hcd_t * hcd,
493
495
return - DWC_E_NO_MEMORY ;
494
496
}
495
497
#endif
496
- retval =
497
- dwc_otg_hcd_qtd_add (qtd , hcd , (dwc_otg_qh_t * * ) ep_handle , atomic_alloc );
498
+ intr_mask .d32 = DWC_READ_REG32 (& hcd -> core_if -> core_global_regs -> gintmsk );
499
+ if (!intr_mask .b .sofintr ) needs_scheduling = 1 ;
500
+ if ((((dwc_otg_qh_t * )ep_handle )-> ep_type == UE_BULK ) && !(qtd -> urb -> flags & URB_GIVEBACK_ASAP ))
501
+ /* Do not schedule SG transactions until qtd has URB_GIVEBACK_ASAP set */
502
+ needs_scheduling = 0 ;
503
+
504
+ retval = dwc_otg_hcd_qtd_add (qtd , hcd , (dwc_otg_qh_t * * ) ep_handle , atomic_alloc );
498
505
// creates a new queue in ep_handle if it doesn't exist already
499
506
if (retval < 0 ) {
500
507
DWC_ERROR ("DWC OTG HCD URB Enqueue failed adding QTD. "
501
508
"Error status %d\n" , retval );
502
509
dwc_otg_hcd_qtd_free (qtd );
510
+ return retval ;
503
511
}
504
- intr_mask .d32 = DWC_READ_REG32 (& hcd -> core_if -> core_global_regs -> gintmsk );
505
- if (!intr_mask .b .sofintr && retval == 0 ) {
506
- dwc_otg_transaction_type_e tr_type ;
507
- if ((qtd -> qh -> ep_type == UE_BULK )
508
- && !(qtd -> urb -> flags & URB_GIVEBACK_ASAP )) {
509
- /* Do not schedule SG transactions until qtd has URB_GIVEBACK_ASAP set */
510
- return 0 ;
511
- }
512
+
513
+ if (needs_scheduling ) {
512
514
DWC_SPINLOCK_IRQSAVE (hcd -> lock , & flags );
513
515
tr_type = dwc_otg_hcd_select_transactions (hcd );
514
516
if (tr_type != DWC_OTG_TRANSACTION_NONE ) {
515
517
dwc_otg_hcd_queue_transactions (hcd , tr_type );
516
518
}
517
519
DWC_SPINUNLOCK_IRQRESTORE (hcd -> lock , flags );
518
520
}
519
-
520
521
return retval ;
521
522
}
522
523
@@ -3135,17 +3136,13 @@ dwc_otg_hcd_urb_t *dwc_otg_hcd_urb_alloc(dwc_otg_hcd_t * hcd,
3135
3136
else
3136
3137
dwc_otg_urb = DWC_ALLOC (size );
3137
3138
3138
- if (NULL != dwc_otg_urb )
3139
- dwc_otg_urb -> packet_count = iso_desc_count ;
3139
+ if (dwc_otg_urb )
3140
+ dwc_otg_urb -> packet_count = iso_desc_count ;
3140
3141
else {
3141
- dwc_otg_urb -> packet_count = 0 ;
3142
- if (size != 0 ) {
3143
- DWC_ERROR ("**** DWC OTG HCD URB alloc - "
3144
- "%salloc of %db failed\n" ,
3145
- atomic_alloc ?"atomic " :"" , size );
3146
- }
3147
- }
3148
-
3142
+ DWC_ERROR ("**** DWC OTG HCD URB alloc - "
3143
+ "%salloc of %db failed\n" ,
3144
+ atomic_alloc ?"atomic " :"" , size );
3145
+ }
3149
3146
return dwc_otg_urb ;
3150
3147
}
3151
3148
0 commit comments