* [PATCH next 1/2] usb: xhci-mtk: fix wrong remainder of bandwidth budget
@ 2021-03-31 8:25 Chunfeng Yun
2021-03-31 8:25 ` [PATCH next 2/2] usb: xhci-mtk: fix oops when unbind driver Chunfeng Yun
0 siblings, 1 reply; 2+ messages in thread
From: Chunfeng Yun @ 2021-03-31 8:25 UTC (permalink / raw)
To: Mathias Nyman, Greg Kroah-Hartman
Cc: Chunfeng Yun, Matthias Brugger, linux-usb, linux-arm-kernel,
linux-mediatek, linux-kernel
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>
---
drivers/usb/host/xhci-mtk-sch.c | 7 ++-----
1 file 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 */
--
2.18.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH next 2/2] usb: xhci-mtk: fix oops when unbind driver
2021-03-31 8:25 [PATCH next 1/2] usb: xhci-mtk: fix wrong remainder of bandwidth budget Chunfeng Yun
@ 2021-03-31 8:25 ` Chunfeng Yun
0 siblings, 0 replies; 2+ messages in thread
From: Chunfeng Yun @ 2021-03-31 8:25 UTC (permalink / raw)
To: Mathias Nyman, Greg Kroah-Hartman
Cc: Chunfeng Yun, Matthias Brugger, linux-usb, linux-arm-kernel,
linux-mediatek, linux-kernel
The oops happens when unbind driver through sysfs as following,
because xhci_mtk_drop_ep() try to drop the endpoint of root hub
which is not added by xhci_add_endpoint() and the virtual device
is not allocated, in fact also needn't drop it, so should skip it.
Call trace:
xhci_mtk_drop_ep+0x1b8/0x298
usb_hcd_alloc_bandwidth+0x1d8/0x380
usb_disable_device_endpoints+0x8c/0xe0
usb_disable_device+0x128/0x168
usb_disconnect+0xbc/0x2c8
usb_remove_hcd+0xd8/0x210
xhci_mtk_remove+0x98/0x108
platform_remove+0x28/0x60
device_release_driver_internal+0x110/0x1e8
device_driver_detach+0x18/0x28
unbind_store+0xd4/0x108
drv_attr_store+0x24/0x38
Fixes: 14295a150050 ("usb: xhci-mtk: support to build xhci-mtk-hcd.ko")
Reported-by: Eddie Hung <eddie.hung@mediatek.com>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
drivers/usb/host/xhci-mtk-sch.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c
index 7ac76ae28998..8b90da5a6ed1 100644
--- a/drivers/usb/host/xhci-mtk-sch.c
+++ b/drivers/usb/host/xhci-mtk-sch.c
@@ -872,6 +872,8 @@ int xhci_mtk_drop_ep(struct usb_hcd *hcd, struct usb_device *udev,
if (ret)
return ret;
- drop_ep_quirk(hcd, udev, ep);
+ if (ep->hcpriv)
+ drop_ep_quirk(hcd, udev, ep);
+
return 0;
}
--
2.18.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-03-31 8:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-31 8:25 [PATCH next 1/2] usb: xhci-mtk: fix wrong remainder of bandwidth budget Chunfeng Yun
2021-03-31 8:25 ` [PATCH next 2/2] usb: xhci-mtk: fix oops when unbind driver Chunfeng Yun
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).