Lines Matching defs:sch_ep

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