Lines Matching refs:sch_ep

242 	struct mu3h_sch_ep_info *sch_ep;  in create_sch_ep()  local
250 sch_ep = kzalloc(sizeof(*sch_ep), GFP_KERNEL); in create_sch_ep()
251 if (!sch_ep) in create_sch_ep()
257 kfree(sch_ep); in create_sch_ep()
262 sch_ep->bw_info = bw_info; in create_sch_ep()
263 sch_ep->sch_tt = tt; in create_sch_ep()
264 sch_ep->ep = ep; in create_sch_ep()
265 sch_ep->speed = udev->speed; in create_sch_ep()
266 INIT_LIST_HEAD(&sch_ep->endpoint); in create_sch_ep()
267 INIT_LIST_HEAD(&sch_ep->tt_endpoint); in create_sch_ep()
268 INIT_HLIST_NODE(&sch_ep->hentry); in create_sch_ep()
270 return sch_ep; in create_sch_ep()
274 struct mu3h_sch_ep_info *sch_ep) in setup_sch_info() argument
292 sch_ep->esit = get_esit(ep_ctx); in setup_sch_info()
293 sch_ep->num_esit = XHCI_MTK_MAX_ESIT / sch_ep->esit; in setup_sch_info()
294 sch_ep->ep_type = ep_type; in setup_sch_info()
295 sch_ep->maxpkt = maxpkt; in setup_sch_info()
296 sch_ep->offset = 0; in setup_sch_info()
297 sch_ep->burst_mode = 0; in setup_sch_info()
298 sch_ep->repeat = 0; in setup_sch_info()
300 if (sch_ep->speed == USB_SPEED_HIGH) { in setup_sch_info()
301 sch_ep->cs_count = 0; in setup_sch_info()
308 sch_ep->num_budget_microframes = 1; in setup_sch_info()
315 sch_ep->pkts = max_burst + 1; in setup_sch_info()
316 sch_ep->bw_cost_per_microframe = maxpkt * sch_ep->pkts; in setup_sch_info()
317 } else if (sch_ep->speed >= USB_SPEED_SUPER) { in setup_sch_info()
319 sch_ep->cs_count = 0; in setup_sch_info()
320 sch_ep->burst_mode = 1; in setup_sch_info()
331 sch_ep->pkts = esit_pkts; in setup_sch_info()
332 sch_ep->num_budget_microframes = 1; in setup_sch_info()
337 if (sch_ep->esit == 1) in setup_sch_info()
338 sch_ep->pkts = esit_pkts; in setup_sch_info()
339 else if (esit_pkts <= sch_ep->esit) in setup_sch_info()
340 sch_ep->pkts = 1; in setup_sch_info()
342 sch_ep->pkts = roundup_pow_of_two(esit_pkts) in setup_sch_info()
343 / sch_ep->esit; in setup_sch_info()
345 sch_ep->num_budget_microframes = in setup_sch_info()
346 DIV_ROUND_UP(esit_pkts, sch_ep->pkts); in setup_sch_info()
348 sch_ep->repeat = !!(sch_ep->num_budget_microframes > 1); in setup_sch_info()
350 sch_ep->bw_cost_per_microframe = maxpkt * sch_ep->pkts; in setup_sch_info()
351 } else if (is_fs_or_ls(sch_ep->speed)) { in setup_sch_info()
352 sch_ep->pkts = 1; /* at most one packet for each microframe */ in setup_sch_info()
358 sch_ep->cs_count = DIV_ROUND_UP(maxpkt, FS_PAYLOAD_MAX); in setup_sch_info()
359 sch_ep->num_budget_microframes = sch_ep->cs_count; in setup_sch_info()
360 sch_ep->bw_cost_per_microframe = min_t(u32, maxpkt, FS_PAYLOAD_MAX); in setup_sch_info()
366 struct mu3h_sch_ep_info *sch_ep, u32 offset) in get_max_bw() argument
372 for (i = 0; i < sch_ep->num_esit; i++) { in get_max_bw()
373 u32 base = offset + i * sch_ep->esit; in get_max_bw()
375 for (j = 0; j < sch_ep->num_budget_microframes; j++) { in get_max_bw()
377 bw = sch_bw->bus_bw[k] + sch_ep->bw_cost_per_microframe; in get_max_bw()
386 struct mu3h_sch_ep_info *sch_ep, bool used) in update_bus_bw() argument
392 bw_updated = sch_ep->bw_cost_per_microframe * (used ? 1 : -1); in update_bus_bw()
394 for (i = 0; i < sch_ep->num_esit; i++) { in update_bus_bw()
395 base = sch_ep->offset + i * sch_ep->esit; in update_bus_bw()
396 for (j = 0; j < sch_ep->num_budget_microframes; j++) in update_bus_bw()
401 static int check_fs_bus_bw(struct mu3h_sch_ep_info *sch_ep, int offset) in check_fs_bus_bw() argument
403 struct mu3h_sch_tt *tt = sch_ep->sch_tt; in check_fs_bus_bw()
408 for (i = 0; i < sch_ep->num_esit; i++) { in check_fs_bus_bw()
409 base = offset + i * sch_ep->esit; in check_fs_bus_bw()
415 for (j = 0; j < sch_ep->num_budget_microframes; j++) { in check_fs_bus_bw()
417 tmp = tt->fs_bus_bw[k] + sch_ep->bw_cost_per_microframe; in check_fs_bus_bw()
426 static int check_sch_tt(struct mu3h_sch_ep_info *sch_ep, u32 offset) in check_sch_tt() argument
431 if (!sch_ep->sch_tt) in check_sch_tt()
436 if (sch_ep->ep_type == ISOC_OUT_EP) { in check_sch_tt()
437 last_ss = start_ss + sch_ep->cs_count - 1; in check_sch_tt()
447 u32 cs_count = DIV_ROUND_UP(sch_ep->maxpkt, FS_PAYLOAD_MAX); in check_sch_tt()
466 sch_ep->cs_count = cs_count; in check_sch_tt()
468 sch_ep->num_budget_microframes = cs_count; in check_sch_tt()
474 if (sch_ep->num_budget_microframes > sch_ep->esit) in check_sch_tt()
475 sch_ep->num_budget_microframes = sch_ep->esit; in check_sch_tt()
478 return check_fs_bus_bw(sch_ep, offset); in check_sch_tt()
481 static void update_sch_tt(struct mu3h_sch_ep_info *sch_ep, bool used) in update_sch_tt() argument
483 struct mu3h_sch_tt *tt = sch_ep->sch_tt; in update_sch_tt()
488 bw_updated = sch_ep->bw_cost_per_microframe * (used ? 1 : -1); in update_sch_tt()
490 for (i = 0; i < sch_ep->num_esit; i++) { in update_sch_tt()
491 base = sch_ep->offset + i * sch_ep->esit; in update_sch_tt()
493 for (j = 0; j < sch_ep->num_budget_microframes; j++) in update_sch_tt()
498 list_add_tail(&sch_ep->tt_endpoint, &tt->ep_list); in update_sch_tt()
500 list_del(&sch_ep->tt_endpoint); in update_sch_tt()
504 struct mu3h_sch_ep_info *sch_ep, bool loaded) in load_ep_bw() argument
506 if (sch_ep->sch_tt) in load_ep_bw()
507 update_sch_tt(sch_ep, loaded); in load_ep_bw()
510 update_bus_bw(sch_bw, sch_ep, loaded); in load_ep_bw()
511 sch_ep->allocated = loaded; in load_ep_bw()
516 static int check_sch_bw(struct mu3h_sch_ep_info *sch_ep) in check_sch_bw() argument
518 struct mu3h_sch_bw_info *sch_bw = sch_ep->bw_info; in check_sch_bw()
519 const u32 bw_boundary = get_bw_boundary(sch_ep->speed); in check_sch_bw()
530 for (offset = 0; offset < sch_ep->esit; offset++) { in check_sch_bw()
531 ret = check_sch_tt(sch_ep, offset); in check_sch_bw()
535 worst_bw = get_max_bw(sch_bw, sch_ep, offset); in check_sch_bw()
545 if (sch_ep->sch_tt && min_index >= 0) in check_sch_bw()
555 sch_ep->offset = min_index; in check_sch_bw()
557 return load_ep_bw(sch_bw, sch_ep, true); in check_sch_bw()
561 struct mu3h_sch_ep_info *sch_ep) in destroy_sch_ep() argument
564 if (sch_ep->allocated) in destroy_sch_ep()
565 load_ep_bw(sch_ep->bw_info, sch_ep, false); in destroy_sch_ep()
567 if (sch_ep->sch_tt) in destroy_sch_ep()
570 list_del(&sch_ep->endpoint); in destroy_sch_ep()
571 hlist_del(&sch_ep->hentry); in destroy_sch_ep()
572 kfree(sch_ep); in destroy_sch_ep()
633 struct mu3h_sch_ep_info *sch_ep; in add_ep_quirk() local
654 sch_ep = create_sch_ep(mtk, udev, ep); in add_ep_quirk()
655 if (IS_ERR_OR_NULL(sch_ep)) in add_ep_quirk()
658 setup_sch_info(ep_ctx, sch_ep); in add_ep_quirk()
660 list_add_tail(&sch_ep->endpoint, &mtk->bw_ep_chk_list); in add_ep_quirk()
661 hash_add(mtk->sch_ep_hash, &sch_ep->hentry, (unsigned long)ep); in add_ep_quirk()
671 struct mu3h_sch_ep_info *sch_ep; in drop_ep_quirk() local
679 hash_for_each_possible_safe(mtk->sch_ep_hash, sch_ep, in drop_ep_quirk()
681 if (sch_ep->ep == ep) { in drop_ep_quirk()
682 destroy_sch_ep(mtk, udev, sch_ep); in drop_ep_quirk()
693 struct mu3h_sch_ep_info *sch_ep; in xhci_mtk_check_bandwidth() local
698 list_for_each_entry(sch_ep, &mtk->bw_ep_chk_list, endpoint) { in xhci_mtk_check_bandwidth()
700 struct usb_host_endpoint *ep = sch_ep->ep; in xhci_mtk_check_bandwidth()
703 ret = check_sch_bw(sch_ep); in xhci_mtk_check_bandwidth()
711 ep_ctx->reserved[0] = cpu_to_le32(EP_BPKTS(sch_ep->pkts) in xhci_mtk_check_bandwidth()
712 | EP_BCSCOUNT(sch_ep->cs_count) in xhci_mtk_check_bandwidth()
713 | EP_BBM(sch_ep->burst_mode)); in xhci_mtk_check_bandwidth()
714 ep_ctx->reserved[1] = cpu_to_le32(EP_BOFFSET(sch_ep->offset) in xhci_mtk_check_bandwidth()
715 | EP_BREPEAT(sch_ep->repeat)); in xhci_mtk_check_bandwidth()
718 sch_ep->pkts, sch_ep->cs_count, sch_ep->burst_mode, in xhci_mtk_check_bandwidth()
719 sch_ep->offset, sch_ep->repeat); in xhci_mtk_check_bandwidth()
733 struct mu3h_sch_ep_info *sch_ep, *tmp; in xhci_mtk_reset_bandwidth() local
737 list_for_each_entry_safe(sch_ep, tmp, &mtk->bw_ep_chk_list, endpoint) in xhci_mtk_reset_bandwidth()
738 destroy_sch_ep(mtk, udev, sch_ep); in xhci_mtk_reset_bandwidth()