Lines Matching refs:sch_ep

242 	struct mu3h_sch_ep_info *sch_ep;  in create_sch_ep()  local
257 sch_ep = kzalloc(mem_size, GFP_KERNEL); in create_sch_ep()
258 if (!sch_ep) in create_sch_ep()
264 kfree(sch_ep); in create_sch_ep()
269 sch_ep->sch_tt = tt; in create_sch_ep()
270 sch_ep->ep = ep; in create_sch_ep()
271 sch_ep->speed = udev->speed; in create_sch_ep()
272 INIT_LIST_HEAD(&sch_ep->endpoint); in create_sch_ep()
273 INIT_LIST_HEAD(&sch_ep->tt_endpoint); in create_sch_ep()
275 return sch_ep; in create_sch_ep()
279 struct mu3h_sch_ep_info *sch_ep) in setup_sch_info() argument
287 u32 *bwb_table = sch_ep->bw_budget_table; in setup_sch_info()
299 sch_ep->esit = get_esit(ep_ctx); in setup_sch_info()
300 sch_ep->ep_type = ep_type; in setup_sch_info()
301 sch_ep->maxpkt = maxpkt; in setup_sch_info()
302 sch_ep->offset = 0; in setup_sch_info()
303 sch_ep->burst_mode = 0; in setup_sch_info()
304 sch_ep->repeat = 0; in setup_sch_info()
306 if (sch_ep->speed == USB_SPEED_HIGH) { in setup_sch_info()
307 sch_ep->cs_count = 0; in setup_sch_info()
314 sch_ep->num_budget_microframes = 1; in setup_sch_info()
321 sch_ep->pkts = max_burst + 1; in setup_sch_info()
322 sch_ep->bw_cost_per_microframe = maxpkt * sch_ep->pkts; in setup_sch_info()
323 bwb_table[0] = sch_ep->bw_cost_per_microframe; in setup_sch_info()
324 } else if (sch_ep->speed >= USB_SPEED_SUPER) { in setup_sch_info()
326 sch_ep->cs_count = 0; in setup_sch_info()
327 sch_ep->burst_mode = 1; in setup_sch_info()
338 sch_ep->pkts = esit_pkts; in setup_sch_info()
339 sch_ep->num_budget_microframes = 1; in setup_sch_info()
340 bwb_table[0] = maxpkt * sch_ep->pkts; in setup_sch_info()
345 if (sch_ep->esit == 1) in setup_sch_info()
346 sch_ep->pkts = esit_pkts; in setup_sch_info()
347 else if (esit_pkts <= sch_ep->esit) in setup_sch_info()
348 sch_ep->pkts = 1; in setup_sch_info()
350 sch_ep->pkts = roundup_pow_of_two(esit_pkts) in setup_sch_info()
351 / sch_ep->esit; in setup_sch_info()
353 sch_ep->num_budget_microframes = in setup_sch_info()
354 DIV_ROUND_UP(esit_pkts, sch_ep->pkts); in setup_sch_info()
356 sch_ep->repeat = !!(sch_ep->num_budget_microframes > 1); in setup_sch_info()
357 sch_ep->bw_cost_per_microframe = maxpkt * sch_ep->pkts; in setup_sch_info()
359 for (i = 0; i < sch_ep->num_budget_microframes - 1; i++) in setup_sch_info()
360 bwb_table[i] = sch_ep->bw_cost_per_microframe; in setup_sch_info()
364 - i * sch_ep->bw_cost_per_microframe; in setup_sch_info()
366 } else if (is_fs_or_ls(sch_ep->speed)) { in setup_sch_info()
367 sch_ep->pkts = 1; /* at most one packet for each microframe */ in setup_sch_info()
373 sch_ep->cs_count = DIV_ROUND_UP(maxpkt, FS_PAYLOAD_MAX); in setup_sch_info()
374 sch_ep->num_budget_microframes = sch_ep->cs_count; in setup_sch_info()
375 sch_ep->bw_cost_per_microframe = in setup_sch_info()
380 for (i = 0; i < sch_ep->num_budget_microframes; i++) in setup_sch_info()
381 bwb_table[i] = sch_ep->bw_cost_per_microframe; in setup_sch_info()
384 bwb_table[0] = sch_ep->bw_cost_per_microframe; in setup_sch_info()
395 bwb_table[i] = sch_ep->bw_cost_per_microframe; in setup_sch_info()
402 struct mu3h_sch_ep_info *sch_ep, u32 offset) in get_max_bw() argument
410 num_esit = XHCI_MTK_MAX_ESIT / sch_ep->esit; in get_max_bw()
412 u32 base = offset + i * sch_ep->esit; in get_max_bw()
414 for (j = 0; j < sch_ep->num_budget_microframes; j++) { in get_max_bw()
416 sch_ep->bw_budget_table[j]; in get_max_bw()
425 struct mu3h_sch_ep_info *sch_ep, bool used) in update_bus_bw() argument
432 num_esit = XHCI_MTK_MAX_ESIT / sch_ep->esit; in update_bus_bw()
434 base = sch_ep->offset + i * sch_ep->esit; in update_bus_bw()
435 for (j = 0; j < sch_ep->num_budget_microframes; j++) { in update_bus_bw()
438 sch_ep->bw_budget_table[j]; in update_bus_bw()
441 sch_ep->bw_budget_table[j]; in update_bus_bw()
446 static int check_fs_bus_bw(struct mu3h_sch_ep_info *sch_ep, int offset) in check_fs_bus_bw() argument
448 struct mu3h_sch_tt *tt = sch_ep->sch_tt; in check_fs_bus_bw()
452 u8 uframes = DIV_ROUND_UP(sch_ep->maxpkt, FS_PAYLOAD_MAX); in check_fs_bus_bw()
454 num_esit = XHCI_MTK_MAX_ESIT / sch_ep->esit; in check_fs_bus_bw()
456 if (sch_ep->ep_type == INT_IN_EP || sch_ep->ep_type == ISOC_IN_EP) in check_fs_bus_bw()
460 base = offset + i * sch_ep->esit; in check_fs_bus_bw()
463 tmp = tt->fs_bus_bw[base + j] + sch_ep->bw_cost_per_microframe; in check_fs_bus_bw()
472 static int check_sch_tt(struct mu3h_sch_ep_info *sch_ep, u32 offset) in check_sch_tt() argument
480 if (sch_ep->ep_type == ISOC_OUT_EP) { in check_sch_tt()
481 last_ss = start_ss + sch_ep->cs_count - 1; in check_sch_tt()
491 u32 cs_count = DIV_ROUND_UP(sch_ep->maxpkt, FS_PAYLOAD_MAX); in check_sch_tt()
507 if (sch_ep->ep_type == ISOC_IN_EP) in check_sch_tt()
516 sch_ep->cs_count = cs_count; in check_sch_tt()
518 sch_ep->num_budget_microframes = cs_count + 2; in check_sch_tt()
524 if (sch_ep->num_budget_microframes > sch_ep->esit) in check_sch_tt()
525 sch_ep->num_budget_microframes = sch_ep->esit; in check_sch_tt()
528 return check_fs_bus_bw(sch_ep, offset); in check_sch_tt()
531 static void update_sch_tt(struct mu3h_sch_ep_info *sch_ep, bool used) in update_sch_tt() argument
533 struct mu3h_sch_tt *tt = sch_ep->sch_tt; in update_sch_tt()
537 int offset = sch_ep->offset; in update_sch_tt()
538 u8 uframes = DIV_ROUND_UP(sch_ep->maxpkt, FS_PAYLOAD_MAX); in update_sch_tt()
540 num_esit = XHCI_MTK_MAX_ESIT / sch_ep->esit; in update_sch_tt()
543 bw_updated = sch_ep->bw_cost_per_microframe; in update_sch_tt()
545 bw_updated = -sch_ep->bw_cost_per_microframe; in update_sch_tt()
547 if (sch_ep->ep_type == INT_IN_EP || sch_ep->ep_type == ISOC_IN_EP) in update_sch_tt()
551 base = offset + i * sch_ep->esit; in update_sch_tt()
558 list_add_tail(&sch_ep->tt_endpoint, &tt->ep_list); in update_sch_tt()
560 list_del(&sch_ep->tt_endpoint); in update_sch_tt()
564 struct mu3h_sch_ep_info *sch_ep, bool loaded) in load_ep_bw() argument
566 if (sch_ep->sch_tt) in load_ep_bw()
567 update_sch_tt(sch_ep, loaded); in load_ep_bw()
570 update_bus_bw(sch_bw, sch_ep, loaded); in load_ep_bw()
571 sch_ep->allocated = loaded; in load_ep_bw()
576 static u32 get_esit_boundary(struct mu3h_sch_ep_info *sch_ep) in get_esit_boundary() argument
578 u32 boundary = sch_ep->esit; in get_esit_boundary()
580 if (sch_ep->sch_tt) { /* LS/FS with TT */ in get_esit_boundary()
586 if (sch_ep->ep_type == ISOC_OUT_EP && boundary > 1) in get_esit_boundary()
594 struct mu3h_sch_ep_info *sch_ep) in check_sch_bw() argument
612 min_cs_count = sch_ep->cs_count; in check_sch_bw()
613 min_num_budget = sch_ep->num_budget_microframes; in check_sch_bw()
614 esit_boundary = get_esit_boundary(sch_ep); in check_sch_bw()
615 for (offset = 0; offset < sch_ep->esit; offset++) { in check_sch_bw()
616 if (sch_ep->sch_tt) { in check_sch_bw()
617 ret = check_sch_tt(sch_ep, offset); in check_sch_bw()
622 if ((offset + sch_ep->num_budget_microframes) > esit_boundary) in check_sch_bw()
625 worst_bw = get_max_bw(sch_bw, sch_ep, offset); in check_sch_bw()
629 min_cs_count = sch_ep->cs_count; in check_sch_bw()
630 min_num_budget = sch_ep->num_budget_microframes; in check_sch_bw()
636 bw_boundary = get_bw_boundary(sch_ep->speed); in check_sch_bw()
641 sch_ep->offset = min_index; in check_sch_bw()
642 sch_ep->cs_count = min_cs_count; in check_sch_bw()
643 sch_ep->num_budget_microframes = min_num_budget; in check_sch_bw()
645 return load_ep_bw(sch_bw, sch_ep, true); in check_sch_bw()
649 struct mu3h_sch_bw_info *sch_bw, struct mu3h_sch_ep_info *sch_ep) in destroy_sch_ep() argument
652 if (sch_ep->allocated) in destroy_sch_ep()
653 load_ep_bw(sch_bw, sch_ep, false); in destroy_sch_ep()
655 if (sch_ep->sch_tt) in destroy_sch_ep()
658 list_del(&sch_ep->endpoint); in destroy_sch_ep()
659 kfree(sch_ep); in destroy_sch_ep()
721 struct mu3h_sch_ep_info *sch_ep; in add_ep_quirk() local
742 sch_ep = create_sch_ep(udev, ep, ep_ctx); in add_ep_quirk()
743 if (IS_ERR_OR_NULL(sch_ep)) in add_ep_quirk()
746 setup_sch_info(ep_ctx, sch_ep); in add_ep_quirk()
748 list_add_tail(&sch_ep->endpoint, &mtk->bw_ep_chk_list); in add_ep_quirk()
760 struct mu3h_sch_ep_info *sch_ep, *tmp; in drop_ep_quirk() local
771 list_for_each_entry_safe(sch_ep, tmp, &sch_bw->bw_ep_list, endpoint) { in drop_ep_quirk()
772 if (sch_ep->ep == ep) { in drop_ep_quirk()
773 destroy_sch_ep(udev, sch_bw, sch_ep); in drop_ep_quirk()
785 struct mu3h_sch_ep_info *sch_ep, *tmp; in xhci_mtk_check_bandwidth() local
790 list_for_each_entry(sch_ep, &mtk->bw_ep_chk_list, endpoint) { in xhci_mtk_check_bandwidth()
791 sch_bw = get_bw_info(mtk, udev, sch_ep->ep); in xhci_mtk_check_bandwidth()
793 ret = check_sch_bw(sch_bw, sch_ep); in xhci_mtk_check_bandwidth()
801 list_for_each_entry_safe(sch_ep, tmp, &mtk->bw_ep_chk_list, endpoint) { in xhci_mtk_check_bandwidth()
803 struct usb_host_endpoint *ep = sch_ep->ep; in xhci_mtk_check_bandwidth()
807 list_move_tail(&sch_ep->endpoint, &sch_bw->bw_ep_list); in xhci_mtk_check_bandwidth()
810 ep_ctx->reserved[0] = cpu_to_le32(EP_BPKTS(sch_ep->pkts) in xhci_mtk_check_bandwidth()
811 | EP_BCSCOUNT(sch_ep->cs_count) in xhci_mtk_check_bandwidth()
812 | EP_BBM(sch_ep->burst_mode)); in xhci_mtk_check_bandwidth()
813 ep_ctx->reserved[1] = cpu_to_le32(EP_BOFFSET(sch_ep->offset) in xhci_mtk_check_bandwidth()
814 | EP_BREPEAT(sch_ep->repeat)); in xhci_mtk_check_bandwidth()
817 sch_ep->pkts, sch_ep->cs_count, sch_ep->burst_mode, in xhci_mtk_check_bandwidth()
818 sch_ep->offset, sch_ep->repeat); in xhci_mtk_check_bandwidth()
829 struct mu3h_sch_ep_info *sch_ep, *tmp; in xhci_mtk_reset_bandwidth() local
833 list_for_each_entry_safe(sch_ep, tmp, &mtk->bw_ep_chk_list, endpoint) { in xhci_mtk_reset_bandwidth()
834 sch_bw = get_bw_info(mtk, udev, sch_ep->ep); in xhci_mtk_reset_bandwidth()
835 destroy_sch_ep(udev, sch_bw, sch_ep); in xhci_mtk_reset_bandwidth()