xhci-mtk releases allocated TT bandwidth data only when whole
endpoints of a device are dropped as there're only {add|drop}_endpoint()
hooks are defined. This patchset adds more hooks and releases all
bandwidth data from reset_bandwidth() path, not drop_endpoint().
Changes in v2:
- fix a 0-day warning from unused variable
- split one big patch into three patches
- bugfix in hw flags
Ikjoon Jang (3):
usb: xhci-mtk: code cleanups in getting bandwidth table
usb: xhci-mtk: delay association of tt and ep
usb: xhci-mtk: fix unreleased bandwidth data
drivers/usb/host/xhci-mtk-sch.c | 180 ++++++++++++++++++++------------
drivers/usb/host/xhci-mtk.h | 13 +++
drivers/usb/host/xhci.c | 9 ++
3 files changed, 133 insertions(+), 69 deletions(-)
--
2.29.2.576.ga3fc446d84-goog
Simplifies the codes for getting internal bandwidth data,
No functional changes.
Signed-off-by: Ikjoon Jang <[email protected]>
---
drivers/usb/host/xhci-mtk-sch.c | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c
index 45c54d56ecbd..c334b6d76479 100644
--- a/drivers/usb/host/xhci-mtk-sch.c
+++ b/drivers/usb/host/xhci-mtk-sch.c
@@ -49,9 +49,11 @@ static int is_fs_or_ls(enum usb_device_speed speed)
* so the bandwidth domain array is organized as follow for simplification:
* SSport0-OUT, SSport0-IN, ..., SSportX-OUT, SSportX-IN, HSport0, ..., HSportY
*/
-static int get_bw_index(struct xhci_hcd *xhci, struct usb_device *udev,
- struct usb_host_endpoint *ep)
+static struct mu3h_sch_bw_info *get_bw_info(struct xhci_hcd_mtk *mtk,
+ struct usb_device *udev,
+ struct usb_host_endpoint *ep)
{
+ struct xhci_hcd *xhci = hcd_to_xhci(mtk->hcd);
struct xhci_virt_device *virt_dev;
int bw_index;
@@ -67,7 +69,7 @@ static int get_bw_index(struct xhci_hcd *xhci, struct usb_device *udev,
bw_index = virt_dev->real_port + xhci->usb3_rhub.num_ports - 1;
}
- return bw_index;
+ return &mtk->sch_array[bw_index];
}
static u32 get_esit(struct xhci_ep_ctx *ep_ctx)
@@ -603,9 +605,7 @@ int xhci_mtk_add_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
struct xhci_virt_device *virt_dev;
struct mu3h_sch_bw_info *sch_bw;
struct mu3h_sch_ep_info *sch_ep;
- struct mu3h_sch_bw_info *sch_array;
unsigned int ep_index;
- int bw_index;
int ret = 0;
xhci = hcd_to_xhci(hcd);
@@ -613,7 +613,6 @@ int xhci_mtk_add_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
ep_index = xhci_get_endpoint_index(&ep->desc);
slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx);
ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index);
- sch_array = mtk->sch_array;
xhci_dbg(xhci, "%s() type:%d, speed:%d, mpkt:%d, dir:%d, ep:%p\n",
__func__, usb_endpoint_type(&ep->desc), udev->speed,
@@ -632,8 +631,7 @@ int xhci_mtk_add_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
return 0;
}
- bw_index = get_bw_index(xhci, udev, ep);
- sch_bw = &sch_array[bw_index];
+ sch_bw = get_bw_info(mtk, udev, ep);
sch_ep = create_sch_ep(udev, ep, ep_ctx);
if (IS_ERR_OR_NULL(sch_ep))
@@ -673,15 +671,12 @@ void xhci_mtk_drop_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
struct xhci_hcd *xhci;
struct xhci_slot_ctx *slot_ctx;
struct xhci_virt_device *virt_dev;
- struct mu3h_sch_bw_info *sch_array;
struct mu3h_sch_bw_info *sch_bw;
struct mu3h_sch_ep_info *sch_ep;
- int bw_index;
xhci = hcd_to_xhci(hcd);
virt_dev = xhci->devs[udev->slot_id];
slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx);
- sch_array = mtk->sch_array;
xhci_dbg(xhci, "%s() type:%d, speed:%d, mpks:%d, dir:%d, ep:%p\n",
__func__, usb_endpoint_type(&ep->desc), udev->speed,
@@ -691,8 +686,7 @@ void xhci_mtk_drop_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
if (!need_bw_sch(ep, udev->speed, slot_ctx->tt_info & TT_SLOT))
return;
- bw_index = get_bw_index(xhci, udev, ep);
- sch_bw = &sch_array[bw_index];
+ sch_bw = get_bw_info(mtk, udev, ep);
list_for_each_entry(sch_ep, &sch_bw->bw_ep_list, endpoint) {
if (sch_ep->ep == ep) {
--
2.29.2.576.ga3fc446d84-goog
On Thu, 2020-12-10 at 18:47 +0800, Ikjoon Jang wrote:
> xhci-mtk releases allocated TT bandwidth data only when whole
> endpoints of a device are dropped as there're only {add|drop}_endpoint()
> hooks are defined. This patchset adds more hooks and releases all
> bandwidth data from reset_bandwidth() path, not drop_endpoint().
>
>
> Changes in v2:
> - fix a 0-day warning from unused variable
> - split one big patch into three patches
> - bugfix in hw flags
>
> Ikjoon Jang (3):
> usb: xhci-mtk: code cleanups in getting bandwidth table
> usb: xhci-mtk: delay association of tt and ep
> usb: xhci-mtk: fix unreleased bandwidth data
>
> drivers/usb/host/xhci-mtk-sch.c | 180 ++++++++++++++++++++------------
> drivers/usb/host/xhci-mtk.h | 13 +++
> drivers/usb/host/xhci.c | 9 ++
> 3 files changed, 133 insertions(+), 69 deletions(-)
Thanks for your patch, I'll test it and check it with our DE
>
On Fri, Dec 11, 2020 at 9:53 AM Chunfeng Yun <[email protected]> wrote:
>
> On Thu, 2020-12-10 at 18:47 +0800, Ikjoon Jang wrote:
> > xhci-mtk releases allocated TT bandwidth data only when whole
> > endpoints of a device are dropped as there're only {add|drop}_endpoint()
> > hooks are defined. This patchset adds more hooks and releases all
> > bandwidth data from reset_bandwidth() path, not drop_endpoint().
> >
> >
> > Changes in v2:
> > - fix a 0-day warning from unused variable
> > - split one big patch into three patches
> > - bugfix in hw flags
> >
> > Ikjoon Jang (3):
> > usb: xhci-mtk: code cleanups in getting bandwidth table
> > usb: xhci-mtk: delay association of tt and ep
> > usb: xhci-mtk: fix unreleased bandwidth data
> >
> > drivers/usb/host/xhci-mtk-sch.c | 180 ++++++++++++++++++++------------
> > drivers/usb/host/xhci-mtk.h | 13 +++
> > drivers/usb/host/xhci.c | 9 ++
> > 3 files changed, 133 insertions(+), 69 deletions(-)
> Thanks for your patch, I'll test it and check it with our DE
Thanks, I will upload v3.
But I don't expect any logic changes from v2.
Can you please give me feedback on v2 if you find anything?
>
> >
>
On Fri, 2020-12-11 at 14:36 +0800, Ikjoon Jang wrote:
> On Fri, Dec 11, 2020 at 9:53 AM Chunfeng Yun <[email protected]> wrote:
> >
> > On Thu, 2020-12-10 at 18:47 +0800, Ikjoon Jang wrote:
> > > xhci-mtk releases allocated TT bandwidth data only when whole
> > > endpoints of a device are dropped as there're only {add|drop}_endpoint()
> > > hooks are defined. This patchset adds more hooks and releases all
> > > bandwidth data from reset_bandwidth() path, not drop_endpoint().
> > >
> > >
> > > Changes in v2:
> > > - fix a 0-day warning from unused variable
> > > - split one big patch into three patches
> > > - bugfix in hw flags
> > >
> > > Ikjoon Jang (3):
> > > usb: xhci-mtk: code cleanups in getting bandwidth table
> > > usb: xhci-mtk: delay association of tt and ep
> > > usb: xhci-mtk: fix unreleased bandwidth data
> > >
> > > drivers/usb/host/xhci-mtk-sch.c | 180 ++++++++++++++++++++------------
> > > drivers/usb/host/xhci-mtk.h | 13 +++
> > > drivers/usb/host/xhci.c | 9 ++
> > > 3 files changed, 133 insertions(+), 69 deletions(-)
> > Thanks for your patch, I'll test it and check it with our DE
>
> Thanks, I will upload v3.
> But I don't expect any logic changes from v2.
> Can you please give me feedback on v2 if you find anything?
Ok
>
> >
> > >
> >