@@ -416,15 +416,14 @@ static u32 get_max_bw(struct mu3h_sch_bw_info *sch_bw,
416
416
{
417
417
u32 max_bw = 0 ;
418
418
u32 bw ;
419
- int i ;
420
- int j ;
419
+ int i , j , k ;
421
420
422
421
for (i = 0 ; i < sch_ep -> num_esit ; i ++ ) {
423
422
u32 base = offset + i * sch_ep -> esit ;
424
423
425
424
for (j = 0 ; j < sch_ep -> num_budget_microframes ; j ++ ) {
426
- bw = sch_bw -> bus_bw [ base + j ] +
427
- sch_ep -> bw_budget_table [j ];
425
+ k = XHCI_MTK_BW_INDEX ( base + j );
426
+ bw = sch_bw -> bus_bw [ k ] + sch_ep -> bw_budget_table [j ];
428
427
if (bw > max_bw )
429
428
max_bw = bw ;
430
429
}
@@ -436,18 +435,16 @@ static void update_bus_bw(struct mu3h_sch_bw_info *sch_bw,
436
435
struct mu3h_sch_ep_info * sch_ep , bool used )
437
436
{
438
437
u32 base ;
439
- int i ;
440
- int j ;
438
+ int i , j , k ;
441
439
442
440
for (i = 0 ; i < sch_ep -> num_esit ; i ++ ) {
443
441
base = sch_ep -> offset + i * sch_ep -> esit ;
444
442
for (j = 0 ; j < sch_ep -> num_budget_microframes ; j ++ ) {
443
+ k = XHCI_MTK_BW_INDEX (base + j );
445
444
if (used )
446
- sch_bw -> bus_bw [base + j ] +=
447
- sch_ep -> bw_budget_table [j ];
445
+ sch_bw -> bus_bw [k ] += sch_ep -> bw_budget_table [j ];
448
446
else
449
- sch_bw -> bus_bw [base + j ] -=
450
- sch_ep -> bw_budget_table [j ];
447
+ sch_bw -> bus_bw [k ] -= sch_ep -> bw_budget_table [j ];
451
448
}
452
449
}
453
450
}
@@ -457,7 +454,7 @@ static int check_fs_bus_bw(struct mu3h_sch_ep_info *sch_ep, int offset)
457
454
struct mu3h_sch_tt * tt = sch_ep -> sch_tt ;
458
455
u32 tmp ;
459
456
int base ;
460
- int i , j ;
457
+ int i , j , k ;
461
458
462
459
for (i = 0 ; i < sch_ep -> num_esit ; i ++ ) {
463
460
base = offset + i * sch_ep -> esit ;
@@ -467,7 +464,8 @@ static int check_fs_bus_bw(struct mu3h_sch_ep_info *sch_ep, int offset)
467
464
* the hub will always delay one uframe to send data
468
465
*/
469
466
for (j = 0 ; j < sch_ep -> num_budget_microframes ; j ++ ) {
470
- tmp = tt -> fs_bus_bw [base + j ] + sch_ep -> bw_budget_table [j ];
467
+ k = XHCI_MTK_BW_INDEX (base + j );
468
+ tmp = tt -> fs_bus_bw [k ] + sch_ep -> bw_budget_table [j ];
471
469
if (tmp > FS_PAYLOAD_MAX )
472
470
return - ESCH_BW_OVERFLOW ;
473
471
}
@@ -542,16 +540,18 @@ static void update_sch_tt(struct mu3h_sch_ep_info *sch_ep, bool used)
542
540
{
543
541
struct mu3h_sch_tt * tt = sch_ep -> sch_tt ;
544
542
u32 base ;
545
- int i , j ;
543
+ int i , j , k ;
546
544
547
545
for (i = 0 ; i < sch_ep -> num_esit ; i ++ ) {
548
546
base = sch_ep -> offset + i * sch_ep -> esit ;
549
547
550
- for (j = 0 ; j < sch_ep -> num_budget_microframes ; j ++ )
548
+ for (j = 0 ; j < sch_ep -> num_budget_microframes ; j ++ ) {
549
+ k = XHCI_MTK_BW_INDEX (base + j );
551
550
if (used )
552
- tt -> fs_bus_bw [base + j ] += sch_ep -> bw_budget_table [j ];
551
+ tt -> fs_bus_bw [k ] += sch_ep -> bw_budget_table [j ];
553
552
else
554
- tt -> fs_bus_bw [base + j ] -= sch_ep -> bw_budget_table [j ];
553
+ tt -> fs_bus_bw [k ] -= sch_ep -> bw_budget_table [j ];
554
+ }
555
555
}
556
556
557
557
if (used )
@@ -573,27 +573,9 @@ static int load_ep_bw(struct mu3h_sch_bw_info *sch_bw,
573
573
return 0 ;
574
574
}
575
575
576
- static u32 get_esit_boundary (struct mu3h_sch_ep_info * sch_ep )
577
- {
578
- u32 boundary = sch_ep -> esit ;
579
-
580
- if (sch_ep -> sch_tt ) { /* LS/FS with TT */
581
- /*
582
- * tune for CS, normally esit >= 8 for FS/LS,
583
- * not add one for other types to avoid access array
584
- * out of boundary
585
- */
586
- if (sch_ep -> ep_type == ISOC_OUT_EP && boundary > 1 )
587
- boundary -- ;
588
- }
589
-
590
- return boundary ;
591
- }
592
-
593
576
static int check_sch_bw (struct mu3h_sch_ep_info * sch_ep )
594
577
{
595
578
struct mu3h_sch_bw_info * sch_bw = sch_ep -> bw_info ;
596
- const u32 esit_boundary = get_esit_boundary (sch_ep );
597
579
const u32 bw_boundary = get_bw_boundary (sch_ep -> speed );
598
580
u32 offset ;
599
581
u32 worst_bw ;
@@ -606,10 +588,6 @@ static int check_sch_bw(struct mu3h_sch_ep_info *sch_ep)
606
588
* and find a microframe where its worst bandwidth is minimum.
607
589
*/
608
590
for (offset = 0 ; offset < sch_ep -> esit ; offset ++ ) {
609
-
610
- if ((offset + sch_ep -> num_budget_microframes ) > esit_boundary )
611
- break ;
612
-
613
591
ret = check_sch_tt (sch_ep , offset );
614
592
if (ret )
615
593
continue ;
0 commit comments