usb: xhci-mtk: add a function to (un)load bandwidth info
[ Upstream commit 338af695fffb12a9407c376ce0cebce896c15050 ] Extract a function to load/unload bandwidth info, and remove a dummy check of TT offset. Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> Link: https://lore.kernel.org/r/6fbc000756a4a4a7efbce651b785fee7561becb6.1615170625.git.chunfeng.yun@mediatek.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Stable-dep-of: 548011957d1d ("usb: xhci-mtk: relax TT periodic bandwidth allocation") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
c2e7000b13
commit
402fa9214e
@ -375,7 +375,6 @@ static void update_bus_bw(struct mu3h_sch_bw_info *sch_bw,
|
||||
sch_ep->bw_budget_table[j];
|
||||
}
|
||||
}
|
||||
sch_ep->allocated = used;
|
||||
}
|
||||
|
||||
static int check_fs_bus_bw(struct mu3h_sch_ep_info *sch_ep, int offset)
|
||||
@ -509,6 +508,19 @@ static void update_sch_tt(struct usb_device *udev,
|
||||
list_del(&sch_ep->tt_endpoint);
|
||||
}
|
||||
|
||||
static int load_ep_bw(struct usb_device *udev, struct mu3h_sch_bw_info *sch_bw,
|
||||
struct mu3h_sch_ep_info *sch_ep, bool loaded)
|
||||
{
|
||||
if (sch_ep->sch_tt)
|
||||
update_sch_tt(udev, sch_ep, loaded);
|
||||
|
||||
/* update bus bandwidth info */
|
||||
update_bus_bw(sch_bw, sch_ep, loaded);
|
||||
sch_ep->allocated = loaded;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static u32 get_esit_boundary(struct mu3h_sch_ep_info *sch_ep)
|
||||
{
|
||||
u32 boundary = sch_ep->esit;
|
||||
@ -535,7 +547,6 @@ static int check_sch_bw(struct usb_device *udev,
|
||||
u32 esit_boundary;
|
||||
u32 min_num_budget;
|
||||
u32 min_cs_count;
|
||||
bool tt_offset_ok = false;
|
||||
int ret;
|
||||
|
||||
/*
|
||||
@ -552,8 +563,6 @@ static int check_sch_bw(struct usb_device *udev,
|
||||
ret = check_sch_tt(udev, sch_ep, offset);
|
||||
if (ret)
|
||||
continue;
|
||||
else
|
||||
tt_offset_ok = true;
|
||||
}
|
||||
|
||||
if ((offset + sch_ep->num_budget_microframes) > esit_boundary)
|
||||
@ -585,29 +594,15 @@ static int check_sch_bw(struct usb_device *udev,
|
||||
sch_ep->cs_count = min_cs_count;
|
||||
sch_ep->num_budget_microframes = min_num_budget;
|
||||
|
||||
if (sch_ep->sch_tt) {
|
||||
/* all offset for tt is not ok*/
|
||||
if (!tt_offset_ok)
|
||||
return -ERANGE;
|
||||
|
||||
update_sch_tt(udev, sch_ep, 1);
|
||||
}
|
||||
|
||||
/* update bus bandwidth info */
|
||||
update_bus_bw(sch_bw, sch_ep, 1);
|
||||
|
||||
return 0;
|
||||
return load_ep_bw(udev, sch_bw, sch_ep, true);
|
||||
}
|
||||
|
||||
static void destroy_sch_ep(struct usb_device *udev,
|
||||
struct mu3h_sch_bw_info *sch_bw, struct mu3h_sch_ep_info *sch_ep)
|
||||
{
|
||||
/* only release ep bw check passed by check_sch_bw() */
|
||||
if (sch_ep->allocated) {
|
||||
update_bus_bw(sch_bw, sch_ep, 0);
|
||||
if (sch_ep->sch_tt)
|
||||
update_sch_tt(udev, sch_ep, 0);
|
||||
}
|
||||
if (sch_ep->allocated)
|
||||
load_ep_bw(udev, sch_bw, sch_ep, false);
|
||||
|
||||
if (sch_ep->sch_tt)
|
||||
drop_tt(udev);
|
||||
|
Loading…
x
Reference in New Issue
Block a user