summaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/xhci-mtk-sch.c
diff options
context:
space:
mode:
authorChunfeng Yun <chunfeng.yun@mediatek.com>2021-03-31 10:25:41 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-04-02 15:56:33 +0200
commitd8fca036ef6d5c7e93157edeab614c8cd2758e90 (patch)
treefa4f096e18395988a71e1e8e58f04f06fb17f5f9 /drivers/usb/host/xhci-mtk-sch.c
parentUSB: gadget: udc: fix wrong pointer passed to IS_ERR() and PTR_ERR() (diff)
downloadlinux-d8fca036ef6d5c7e93157edeab614c8cd2758e90.tar.xz
linux-d8fca036ef6d5c7e93157edeab614c8cd2758e90.zip
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>
Diffstat (limited to 'drivers/usb/host/xhci-mtk-sch.c')
-rw-r--r--drivers/usb/host/xhci-mtk-sch.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c
index a59d1f6d4744..7ac76ae28998 100644
--- a/drivers/usb/host/xhci-mtk-sch.c
+++ b/drivers/usb/host/xhci-mtk-sch.c
@@ -341,7 +341,6 @@ static void setup_sch_info(struct xhci_ep_ctx *ep_ctx,
}
if (ep_type == ISOC_IN_EP || ep_type == ISOC_OUT_EP) {
- u32 remainder;
if (sch_ep->esit == 1)
sch_ep->pkts = esit_pkts;
@@ -357,14 +356,12 @@ static void setup_sch_info(struct xhci_ep_ctx *ep_ctx,
sch_ep->repeat = !!(sch_ep->num_budget_microframes > 1);
sch_ep->bw_cost_per_microframe = maxpkt * sch_ep->pkts;
- remainder = sch_ep->bw_cost_per_microframe;
- remainder *= sch_ep->num_budget_microframes;
- remainder -= (maxpkt * esit_pkts);
for (i = 0; i < sch_ep->num_budget_microframes - 1; i++)
bwb_table[i] = sch_ep->bw_cost_per_microframe;
/* last one <= bw_cost_per_microframe */
- bwb_table[i] = remainder;
+ bwb_table[i] = maxpkt * esit_pkts
+ - i * sch_ep->bw_cost_per_microframe;
}
} else if (is_fs_or_ls(sch_ep->speed)) {
sch_ep->pkts = 1; /* at most one packet for each microframe */