1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2015 MediaTek Inc.
5 * Zhigang.Wei <zhigang.wei@mediatek.com>
6 * Chunfeng.Yun <chunfeng.yun@mediatek.com>
9 #include <linux/kernel.h>
10 #include <linux/module.h>
11 #include <linux/slab.h>
16 #define SSP_BW_BOUNDARY 130000
17 #define SS_BW_BOUNDARY 51000
18 /* table 5-5. High-speed Isoc Transaction Limits in usb_20 spec */
19 #define HS_BW_BOUNDARY 6144
20 /* usb2 spec section11.18.1: at most 188 FS bytes per microframe */
21 #define FS_PAYLOAD_MAX 188
23 * max number of microframes for split transfer,
24 * for fs isoc in : 1 ss + 1 idle + 7 cs
26 #define TT_MICROFRAMES_MAX 9
30 /* schedule error type */
31 #define ESCH_SS_Y6 1001
32 #define ESCH_SS_OVERLAP 1002
33 #define ESCH_CS_OVERFLOW 1003
34 #define ESCH_BW_OVERFLOW 1004
35 #define ESCH_FIXME 1005
37 /* mtk scheduler bitmasks */
38 #define EP_BPKTS(p) ((p) & 0x7f)
39 #define EP_BCSCOUNT(p) (((p) & 0x7) << 8)
40 #define EP_BBM(p) ((p) << 11)
41 #define EP_BOFFSET(p) ((p) & 0x3fff)
42 #define EP_BREPEAT(p) (((p) & 0x7fff) << 16)
44 static char *sch_error_string(int err_num)
48 return "Can't schedule Start-Split in Y6";
50 return "Can't find a suitable Start-Split location";
51 case ESCH_CS_OVERFLOW:
52 return "The last Complete-Split is greater than 7";
53 case ESCH_BW_OVERFLOW:
54 return "Bandwidth exceeds the maximum limit";
56 return "FIXME, to be resolved";
62 static int is_fs_or_ls(enum usb_device_speed speed)
64 return speed == USB_SPEED_FULL || speed == USB_SPEED_LOW;
68 decode_ep(struct usb_host_endpoint *ep, enum usb_device_speed speed)
70 static char buf[DBG_BUF_EN];
71 struct usb_endpoint_descriptor *epd = &ep->desc;
72 unsigned int interval;
75 interval = usb_decode_interval(epd, speed);
76 if (interval % 1000) {
83 snprintf(buf, DBG_BUF_EN, "%s ep%d%s %s, mpkt:%d, interval:%d/%d%s",
84 usb_speed_string(speed), usb_endpoint_num(epd),
85 usb_endpoint_dir_in(epd) ? "in" : "out",
86 usb_ep_type_string(usb_endpoint_type(epd)),
87 usb_endpoint_maxp(epd), epd->bInterval, interval, unit);
92 static u32 get_bw_boundary(enum usb_device_speed speed)
97 case USB_SPEED_SUPER_PLUS:
98 boundary = SSP_BW_BOUNDARY;
100 case USB_SPEED_SUPER:
101 boundary = SS_BW_BOUNDARY;
104 boundary = HS_BW_BOUNDARY;
112 * get the bandwidth domain which @ep belongs to.
114 * the bandwidth domain array is saved to @sch_array of struct xhci_hcd_mtk,
115 * each HS root port is treated as a single bandwidth domain,
116 * but each SS root port is treated as two bandwidth domains, one for IN eps,
118 * @real_port value is defined as follow according to xHCI spec:
119 * 1 for SSport0, ..., N+1 for SSportN, N+2 for HSport0, N+3 for HSport1, etc
120 * so the bandwidth domain array is organized as follow for simplification:
121 * SSport0-OUT, SSport0-IN, ..., SSportX-OUT, SSportX-IN, HSport0, ..., HSportY
123 static struct mu3h_sch_bw_info *
124 get_bw_info(struct xhci_hcd_mtk *mtk, struct usb_device *udev,
125 struct usb_host_endpoint *ep)
127 struct xhci_hcd *xhci = hcd_to_xhci(mtk->hcd);
128 struct xhci_virt_device *virt_dev;
131 virt_dev = xhci->devs[udev->slot_id];
132 if (!virt_dev->real_port) {
133 WARN_ONCE(1, "%s invalid real_port\n", dev_name(&udev->dev));
137 if (udev->speed >= USB_SPEED_SUPER) {
138 if (usb_endpoint_dir_out(&ep->desc))
139 bw_index = (virt_dev->real_port - 1) * 2;
141 bw_index = (virt_dev->real_port - 1) * 2 + 1;
143 /* add one more for each SS port */
144 bw_index = virt_dev->real_port + xhci->usb3_rhub.num_ports - 1;
147 return &mtk->sch_array[bw_index];
150 static u32 get_esit(struct xhci_ep_ctx *ep_ctx)
154 esit = 1 << CTX_TO_EP_INTERVAL(le32_to_cpu(ep_ctx->ep_info));
155 if (esit > XHCI_MTK_MAX_ESIT)
156 esit = XHCI_MTK_MAX_ESIT;
161 static struct mu3h_sch_tt *find_tt(struct usb_device *udev)
163 struct usb_tt *utt = udev->tt;
164 struct mu3h_sch_tt *tt, **tt_index, **ptt;
165 bool allocated_index = false;
168 return NULL; /* Not below a TT */
171 * Find/create our data structure.
172 * For hubs with a single TT, we get it directly.
173 * For hubs with multiple TTs, there's an extra level of pointers.
177 tt_index = utt->hcpriv;
178 if (!tt_index) { /* Create the index array */
179 tt_index = kcalloc(utt->hub->maxchild,
180 sizeof(*tt_index), GFP_KERNEL);
182 return ERR_PTR(-ENOMEM);
183 utt->hcpriv = tt_index;
184 allocated_index = true;
186 ptt = &tt_index[udev->ttport - 1];
188 ptt = (struct mu3h_sch_tt **) &utt->hcpriv;
192 if (!tt) { /* Create the mu3h_sch_tt */
193 tt = kzalloc(sizeof(*tt), GFP_KERNEL);
195 if (allocated_index) {
199 return ERR_PTR(-ENOMEM);
201 INIT_LIST_HEAD(&tt->ep_list);
208 /* Release the TT above udev, if it's not in use */
209 static void drop_tt(struct usb_device *udev)
211 struct usb_tt *utt = udev->tt;
212 struct mu3h_sch_tt *tt, **tt_index, **ptt;
215 if (!utt || !utt->hcpriv)
216 return; /* Not below a TT, or never allocated */
220 tt_index = utt->hcpriv;
221 ptt = &tt_index[udev->ttport - 1];
222 /* How many entries are left in tt_index? */
223 for (i = 0; i < utt->hub->maxchild; ++i)
224 cnt += !!tt_index[i];
227 ptt = (struct mu3h_sch_tt **)&utt->hcpriv;
231 if (!tt || !list_empty(&tt->ep_list))
232 return; /* never allocated , or still in use*/
243 static struct mu3h_sch_ep_info *
244 create_sch_ep(struct xhci_hcd_mtk *mtk, struct usb_device *udev,
245 struct usb_host_endpoint *ep, struct xhci_ep_ctx *ep_ctx)
247 struct mu3h_sch_ep_info *sch_ep;
248 struct mu3h_sch_bw_info *bw_info;
249 struct mu3h_sch_tt *tt = NULL;
250 u32 len_bw_budget_table;
253 bw_info = get_bw_info(mtk, udev, ep);
255 return ERR_PTR(-ENODEV);
257 if (is_fs_or_ls(udev->speed))
258 len_bw_budget_table = TT_MICROFRAMES_MAX;
259 else if ((udev->speed >= USB_SPEED_SUPER)
260 && usb_endpoint_xfer_isoc(&ep->desc))
261 len_bw_budget_table = get_esit(ep_ctx);
263 len_bw_budget_table = 1;
265 mem_size = sizeof(struct mu3h_sch_ep_info) +
266 len_bw_budget_table * sizeof(u32);
267 sch_ep = kzalloc(mem_size, GFP_KERNEL);
269 return ERR_PTR(-ENOMEM);
271 if (is_fs_or_ls(udev->speed)) {
275 return ERR_PTR(-ENOMEM);
279 sch_ep->bw_info = bw_info;
282 sch_ep->speed = udev->speed;
283 INIT_LIST_HEAD(&sch_ep->endpoint);
284 INIT_LIST_HEAD(&sch_ep->tt_endpoint);
285 INIT_HLIST_NODE(&sch_ep->hentry);
290 static void setup_sch_info(struct xhci_ep_ctx *ep_ctx,
291 struct mu3h_sch_ep_info *sch_ep)
298 u32 max_esit_payload;
299 u32 *bwb_table = sch_ep->bw_budget_table;
302 ep_type = CTX_TO_EP_TYPE(le32_to_cpu(ep_ctx->ep_info2));
303 maxpkt = MAX_PACKET_DECODED(le32_to_cpu(ep_ctx->ep_info2));
304 max_burst = CTX_TO_MAX_BURST(le32_to_cpu(ep_ctx->ep_info2));
305 mult = CTX_TO_EP_MULT(le32_to_cpu(ep_ctx->ep_info));
307 (CTX_TO_MAX_ESIT_PAYLOAD_HI(
308 le32_to_cpu(ep_ctx->ep_info)) << 16) |
309 CTX_TO_MAX_ESIT_PAYLOAD(le32_to_cpu(ep_ctx->tx_info));
311 sch_ep->esit = get_esit(ep_ctx);
312 sch_ep->num_esit = XHCI_MTK_MAX_ESIT / sch_ep->esit;
313 sch_ep->ep_type = ep_type;
314 sch_ep->maxpkt = maxpkt;
316 sch_ep->burst_mode = 0;
319 if (sch_ep->speed == USB_SPEED_HIGH) {
320 sch_ep->cs_count = 0;
323 * usb_20 spec section5.9
324 * a single microframe is enough for HS synchromous endpoints
327 sch_ep->num_budget_microframes = 1;
330 * xHCI spec section6.2.3.4
331 * @max_burst is the number of additional transactions
332 * opportunities per microframe
334 sch_ep->pkts = max_burst + 1;
335 sch_ep->bw_cost_per_microframe = maxpkt * sch_ep->pkts;
336 bwb_table[0] = sch_ep->bw_cost_per_microframe;
337 } else if (sch_ep->speed >= USB_SPEED_SUPER) {
338 /* usb3_r1 spec section4.4.7 & 4.4.8 */
339 sch_ep->cs_count = 0;
340 sch_ep->burst_mode = 1;
342 * some device's (d)wBytesPerInterval is set as 0,
343 * then max_esit_payload is 0, so evaluate esit_pkts from
346 esit_pkts = DIV_ROUND_UP(max_esit_payload, maxpkt);
348 esit_pkts = (mult + 1) * (max_burst + 1);
350 if (ep_type == INT_IN_EP || ep_type == INT_OUT_EP) {
351 sch_ep->pkts = esit_pkts;
352 sch_ep->num_budget_microframes = 1;
353 bwb_table[0] = maxpkt * sch_ep->pkts;
356 if (ep_type == ISOC_IN_EP || ep_type == ISOC_OUT_EP) {
358 if (sch_ep->esit == 1)
359 sch_ep->pkts = esit_pkts;
360 else if (esit_pkts <= sch_ep->esit)
363 sch_ep->pkts = roundup_pow_of_two(esit_pkts)
366 sch_ep->num_budget_microframes =
367 DIV_ROUND_UP(esit_pkts, sch_ep->pkts);
369 sch_ep->repeat = !!(sch_ep->num_budget_microframes > 1);
370 sch_ep->bw_cost_per_microframe = maxpkt * sch_ep->pkts;
372 for (i = 0; i < sch_ep->num_budget_microframes - 1; i++)
373 bwb_table[i] = sch_ep->bw_cost_per_microframe;
375 /* last one <= bw_cost_per_microframe */
376 bwb_table[i] = maxpkt * esit_pkts
377 - i * sch_ep->bw_cost_per_microframe;
379 } else if (is_fs_or_ls(sch_ep->speed)) {
380 sch_ep->pkts = 1; /* at most one packet for each microframe */
383 * num_budget_microframes and cs_count will be updated when
384 * check TT for INT_OUT_EP, ISOC/INT_IN_EP type
386 sch_ep->cs_count = DIV_ROUND_UP(maxpkt, FS_PAYLOAD_MAX);
387 sch_ep->num_budget_microframes = sch_ep->cs_count;
388 sch_ep->bw_cost_per_microframe =
389 (maxpkt < FS_PAYLOAD_MAX) ? maxpkt : FS_PAYLOAD_MAX;
391 /* init budget table */
392 if (ep_type == ISOC_OUT_EP) {
393 for (i = 0; i < sch_ep->num_budget_microframes; i++)
394 bwb_table[i] = sch_ep->bw_cost_per_microframe;
395 } else if (ep_type == INT_OUT_EP) {
396 /* only first one consumes bandwidth, others as zero */
397 bwb_table[0] = sch_ep->bw_cost_per_microframe;
398 } else { /* INT_IN_EP or ISOC_IN_EP */
399 bwb_table[0] = 0; /* start split */
400 bwb_table[1] = 0; /* idle */
402 * due to cs_count will be updated according to cs
403 * position, assign all remainder budget array
404 * elements as @bw_cost_per_microframe, but only first
405 * @num_budget_microframes elements will be used later
407 for (i = 2; i < TT_MICROFRAMES_MAX; i++)
408 bwb_table[i] = sch_ep->bw_cost_per_microframe;
413 /* Get maximum bandwidth when we schedule at offset slot. */
414 static u32 get_max_bw(struct mu3h_sch_bw_info *sch_bw,
415 struct mu3h_sch_ep_info *sch_ep, u32 offset)
421 for (i = 0; i < sch_ep->num_esit; i++) {
422 u32 base = offset + i * sch_ep->esit;
424 for (j = 0; j < sch_ep->num_budget_microframes; j++) {
425 k = XHCI_MTK_BW_INDEX(base + j);
426 bw = sch_bw->bus_bw[k] + sch_ep->bw_budget_table[j];
434 static void update_bus_bw(struct mu3h_sch_bw_info *sch_bw,
435 struct mu3h_sch_ep_info *sch_ep, bool used)
440 for (i = 0; i < sch_ep->num_esit; i++) {
441 base = sch_ep->offset + i * sch_ep->esit;
442 for (j = 0; j < sch_ep->num_budget_microframes; j++) {
443 k = XHCI_MTK_BW_INDEX(base + j);
445 sch_bw->bus_bw[k] += sch_ep->bw_budget_table[j];
447 sch_bw->bus_bw[k] -= sch_ep->bw_budget_table[j];
452 static int check_fs_bus_bw(struct mu3h_sch_ep_info *sch_ep, int offset)
454 struct mu3h_sch_tt *tt = sch_ep->sch_tt;
459 for (i = 0; i < sch_ep->num_esit; i++) {
460 base = offset + i * sch_ep->esit;
463 * Compared with hs bus, no matter what ep type,
464 * the hub will always delay one uframe to send data
466 for (j = 0; j < sch_ep->num_budget_microframes; j++) {
467 k = XHCI_MTK_BW_INDEX(base + j);
468 tmp = tt->fs_bus_bw[k] + sch_ep->bw_cost_per_microframe;
469 if (tmp > FS_PAYLOAD_MAX)
470 return -ESCH_BW_OVERFLOW;
477 static int check_sch_tt(struct mu3h_sch_ep_info *sch_ep, u32 offset)
479 u32 start_ss, last_ss;
480 u32 start_cs, last_cs;
485 start_ss = offset % 8;
487 if (sch_ep->ep_type == ISOC_OUT_EP) {
488 last_ss = start_ss + sch_ep->cs_count - 1;
491 * usb_20 spec section11.18:
492 * must never schedule Start-Split in Y6
494 if (!(start_ss == 7 || last_ss < 6))
498 u32 cs_count = DIV_ROUND_UP(sch_ep->maxpkt, FS_PAYLOAD_MAX);
501 * usb_20 spec section11.18:
502 * must never schedule Start-Split in Y6
507 /* one uframe for ss + one uframe for idle */
508 start_cs = (start_ss + 2) % 8;
509 last_cs = start_cs + cs_count - 1;
512 return -ESCH_CS_OVERFLOW;
515 cs_count = 7; /* HW limit */
517 sch_ep->cs_count = cs_count;
518 /* ss, idle are ignored */
519 sch_ep->num_budget_microframes = cs_count;
522 * if interval=1, maxp >752, num_budge_micoframe is larger
523 * than sch_ep->esit, will overstep boundary
525 if (sch_ep->num_budget_microframes > sch_ep->esit)
526 sch_ep->num_budget_microframes = sch_ep->esit;
529 return check_fs_bus_bw(sch_ep, offset);
532 static void update_sch_tt(struct mu3h_sch_ep_info *sch_ep, bool used)
534 struct mu3h_sch_tt *tt = sch_ep->sch_tt;
539 bw_updated = sch_ep->bw_cost_per_microframe * (used ? 1 : -1);
541 for (i = 0; i < sch_ep->num_esit; i++) {
542 base = sch_ep->offset + i * sch_ep->esit;
544 for (j = 0; j < sch_ep->num_budget_microframes; j++)
545 tt->fs_bus_bw[XHCI_MTK_BW_INDEX(base + j)] += bw_updated;
549 list_add_tail(&sch_ep->tt_endpoint, &tt->ep_list);
551 list_del(&sch_ep->tt_endpoint);
554 static int load_ep_bw(struct mu3h_sch_bw_info *sch_bw,
555 struct mu3h_sch_ep_info *sch_ep, bool loaded)
558 update_sch_tt(sch_ep, loaded);
560 /* update bus bandwidth info */
561 update_bus_bw(sch_bw, sch_ep, loaded);
562 sch_ep->allocated = loaded;
567 static int check_sch_bw(struct mu3h_sch_ep_info *sch_ep)
569 struct mu3h_sch_bw_info *sch_bw = sch_ep->bw_info;
570 const u32 bw_boundary = get_bw_boundary(sch_ep->speed);
578 * Search through all possible schedule microframes.
579 * and find a microframe where its worst bandwidth is minimum.
581 for (offset = 0; offset < sch_ep->esit; offset++) {
582 ret = check_sch_tt(sch_ep, offset);
586 worst_bw = get_max_bw(sch_bw, sch_ep, offset);
587 if (worst_bw > bw_boundary)
590 if (min_bw > worst_bw) {
595 /* use first-fit for LS/FS */
596 if (sch_ep->sch_tt && min_index >= 0)
604 return ret ? ret : -ESCH_BW_OVERFLOW;
606 sch_ep->offset = min_index;
608 return load_ep_bw(sch_bw, sch_ep, true);
611 static void destroy_sch_ep(struct xhci_hcd_mtk *mtk, struct usb_device *udev,
612 struct mu3h_sch_ep_info *sch_ep)
614 /* only release ep bw check passed by check_sch_bw() */
615 if (sch_ep->allocated)
616 load_ep_bw(sch_ep->bw_info, sch_ep, false);
621 list_del(&sch_ep->endpoint);
622 hlist_del(&sch_ep->hentry);
626 static bool need_bw_sch(struct usb_device *udev,
627 struct usb_host_endpoint *ep)
629 bool has_tt = udev->tt && udev->tt->hub->parent;
631 /* only for periodic endpoints */
632 if (usb_endpoint_xfer_control(&ep->desc)
633 || usb_endpoint_xfer_bulk(&ep->desc))
637 * for LS & FS periodic endpoints which its device is not behind
638 * a TT are also ignored, root-hub will schedule them directly,
639 * but need set @bpkts field of endpoint context to 1.
641 if (is_fs_or_ls(udev->speed) && !has_tt)
644 /* skip endpoint with zero maxpkt */
645 if (usb_endpoint_maxp(&ep->desc) == 0)
651 int xhci_mtk_sch_init(struct xhci_hcd_mtk *mtk)
653 struct xhci_hcd *xhci = hcd_to_xhci(mtk->hcd);
654 struct mu3h_sch_bw_info *sch_array;
657 /* ss IN and OUT are separated */
658 num_usb_bus = xhci->usb3_rhub.num_ports * 2 + xhci->usb2_rhub.num_ports;
660 sch_array = kcalloc(num_usb_bus, sizeof(*sch_array), GFP_KERNEL);
661 if (sch_array == NULL)
664 mtk->sch_array = sch_array;
666 INIT_LIST_HEAD(&mtk->bw_ep_chk_list);
667 hash_init(mtk->sch_ep_hash);
672 void xhci_mtk_sch_exit(struct xhci_hcd_mtk *mtk)
674 kfree(mtk->sch_array);
677 static int add_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
678 struct usb_host_endpoint *ep)
680 struct xhci_hcd_mtk *mtk = hcd_to_mtk(hcd);
681 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
682 struct xhci_ep_ctx *ep_ctx;
683 struct xhci_virt_device *virt_dev;
684 struct mu3h_sch_ep_info *sch_ep;
685 unsigned int ep_index;
687 virt_dev = xhci->devs[udev->slot_id];
688 ep_index = xhci_get_endpoint_index(&ep->desc);
689 ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index);
691 if (!need_bw_sch(udev, ep)) {
693 * set @bpkts to 1 if it is LS or FS periodic endpoint, and its
694 * device does not connected through an external HS hub
696 if (usb_endpoint_xfer_int(&ep->desc)
697 || usb_endpoint_xfer_isoc(&ep->desc))
698 ep_ctx->reserved[0] = cpu_to_le32(EP_BPKTS(1));
703 xhci_dbg(xhci, "%s %s\n", __func__, decode_ep(ep, udev->speed));
705 sch_ep = create_sch_ep(mtk, udev, ep, ep_ctx);
706 if (IS_ERR_OR_NULL(sch_ep))
709 setup_sch_info(ep_ctx, sch_ep);
711 list_add_tail(&sch_ep->endpoint, &mtk->bw_ep_chk_list);
712 hash_add(mtk->sch_ep_hash, &sch_ep->hentry, (unsigned long)ep);
717 static void drop_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
718 struct usb_host_endpoint *ep)
720 struct xhci_hcd_mtk *mtk = hcd_to_mtk(hcd);
721 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
722 struct mu3h_sch_ep_info *sch_ep;
723 struct hlist_node *hn;
725 if (!need_bw_sch(udev, ep))
728 xhci_err(xhci, "%s %s\n", __func__, decode_ep(ep, udev->speed));
730 hash_for_each_possible_safe(mtk->sch_ep_hash, sch_ep,
731 hn, hentry, (unsigned long)ep) {
732 if (sch_ep->ep == ep) {
733 destroy_sch_ep(mtk, udev, sch_ep);
739 int xhci_mtk_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
741 struct xhci_hcd_mtk *mtk = hcd_to_mtk(hcd);
742 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
743 struct xhci_virt_device *virt_dev = xhci->devs[udev->slot_id];
744 struct mu3h_sch_ep_info *sch_ep;
747 xhci_dbg(xhci, "%s() udev %s\n", __func__, dev_name(&udev->dev));
749 list_for_each_entry(sch_ep, &mtk->bw_ep_chk_list, endpoint) {
750 struct xhci_ep_ctx *ep_ctx;
751 struct usb_host_endpoint *ep = sch_ep->ep;
752 unsigned int ep_index = xhci_get_endpoint_index(&ep->desc);
754 ret = check_sch_bw(sch_ep);
756 xhci_err(xhci, "Not enough bandwidth! (%s)\n",
757 sch_error_string(-ret));
761 ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index);
762 ep_ctx->reserved[0] = cpu_to_le32(EP_BPKTS(sch_ep->pkts)
763 | EP_BCSCOUNT(sch_ep->cs_count)
764 | EP_BBM(sch_ep->burst_mode));
765 ep_ctx->reserved[1] = cpu_to_le32(EP_BOFFSET(sch_ep->offset)
766 | EP_BREPEAT(sch_ep->repeat));
768 xhci_dbg(xhci, " PKTS:%x, CSCOUNT:%x, BM:%x, OFFSET:%x, REPEAT:%x\n",
769 sch_ep->pkts, sch_ep->cs_count, sch_ep->burst_mode,
770 sch_ep->offset, sch_ep->repeat);
773 ret = xhci_check_bandwidth(hcd, udev);
775 list_del_init(&mtk->bw_ep_chk_list);
780 void xhci_mtk_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
782 struct xhci_hcd_mtk *mtk = hcd_to_mtk(hcd);
783 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
784 struct mu3h_sch_ep_info *sch_ep, *tmp;
786 xhci_dbg(xhci, "%s() udev %s\n", __func__, dev_name(&udev->dev));
788 list_for_each_entry_safe(sch_ep, tmp, &mtk->bw_ep_chk_list, endpoint)
789 destroy_sch_ep(mtk, udev, sch_ep);
791 xhci_reset_bandwidth(hcd, udev);
794 int xhci_mtk_add_ep(struct usb_hcd *hcd, struct usb_device *udev,
795 struct usb_host_endpoint *ep)
799 ret = xhci_add_endpoint(hcd, udev, ep);
804 ret = add_ep_quirk(hcd, udev, ep);
809 int xhci_mtk_drop_ep(struct usb_hcd *hcd, struct usb_device *udev,
810 struct usb_host_endpoint *ep)
814 ret = xhci_drop_endpoint(hcd, udev, ep);
818 /* needn't check @ep->hcpriv, xhci_endpoint_disable set it NULL */
819 drop_ep_quirk(hcd, udev, ep);