Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: xhci-mtk: fix wrong remainder of bandwidth budget

The remainder of the last bandwidth bugdget is wrong,
it's the value alloacted in last bugdget, not unused.

Reported-by: Yaqii Wu <Yaqii.Wu@mediatek.com>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/1617179142-2681-1-git-send-email-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Chunfeng Yun and committed by
Greg Kroah-Hartman
d8fca036 2e3d055b

+2 -5
+2 -5
drivers/usb/host/xhci-mtk-sch.c
··· 341 341 } 342 342 343 343 if (ep_type == ISOC_IN_EP || ep_type == ISOC_OUT_EP) { 344 - u32 remainder; 345 344 346 345 if (sch_ep->esit == 1) 347 346 sch_ep->pkts = esit_pkts; ··· 356 357 sch_ep->repeat = !!(sch_ep->num_budget_microframes > 1); 357 358 sch_ep->bw_cost_per_microframe = maxpkt * sch_ep->pkts; 358 359 359 - remainder = sch_ep->bw_cost_per_microframe; 360 - remainder *= sch_ep->num_budget_microframes; 361 - remainder -= (maxpkt * esit_pkts); 362 360 for (i = 0; i < sch_ep->num_budget_microframes - 1; i++) 363 361 bwb_table[i] = sch_ep->bw_cost_per_microframe; 364 362 365 363 /* last one <= bw_cost_per_microframe */ 366 - bwb_table[i] = remainder; 364 + bwb_table[i] = maxpkt * esit_pkts 365 + - i * sch_ep->bw_cost_per_microframe; 367 366 } 368 367 } else if (is_fs_or_ls(sch_ep->speed)) { 369 368 sch_ep->pkts = 1; /* at most one packet for each microframe */