diff mbox series

[1/2] usb: xhci-mtk: remove unnecessary assignments in periodic TT scheduler

Message ID 20210330160508.1.I797d214790033d0402d19ff6b47a34aff60d3062@changeid (mailing list archive)
State New, archived
Headers show
Series usb: xhci-mtk: relax peridoc TT bandwidth checking | expand

Commit Message

Ikjoon Jang March 30, 2021, 8:06 a.m. UTC
Remove unnecessary variables in check_sch_bw().
No functional changes, just for better readability.

Signed-off-by: Ikjoon Jang <ikjn@chromium.org>
---

 drivers/usb/host/xhci-mtk-sch.c | 52 +++++++++++++--------------------
 1 file changed, 21 insertions(+), 31 deletions(-)

Comments

Chunfeng Yun (云春峰) March 31, 2021, 8:30 a.m. UTC | #1
cc Yaqii Wu <Yaqii.Wu@mediatek.com>

I'll test it , thanks

On Tue, 2021-03-30 at 16:06 +0800, Ikjoon Jang wrote:
> Remove unnecessary variables in check_sch_bw().
> No functional changes, just for better readability.
> 
> Signed-off-by: Ikjoon Jang <ikjn@chromium.org>
> ---
> 
>  drivers/usb/host/xhci-mtk-sch.c | 52 +++++++++++++--------------------
>  1 file changed, 21 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c
> index a59d1f6d4744..0cb41007ec65 100644
> --- a/drivers/usb/host/xhci-mtk-sch.c
> +++ b/drivers/usb/host/xhci-mtk-sch.c
> @@ -479,6 +479,9 @@ static int check_sch_tt(struct mu3h_sch_ep_info *sch_ep, u32 offset)
>  	u32 start_cs, last_cs;
>  	int i;
>  
> +	if (!sch_ep->sch_tt)
> +		return 0;
> +
>  	start_ss = offset % 8;
>  
>  	if (sch_ep->ep_type == ISOC_OUT_EP) {
> @@ -606,54 +609,41 @@ static u32 get_esit_boundary(struct mu3h_sch_ep_info *sch_ep)
>  static int check_sch_bw(struct mu3h_sch_bw_info *sch_bw,
>  			struct mu3h_sch_ep_info *sch_ep)
>  {
> -	u32 offset;
> -	u32 min_bw;
> -	u32 min_index;
> -	u32 worst_bw;
> -	u32 bw_boundary;
> -	u32 esit_boundary;
> -	u32 min_num_budget;
> -	u32 min_cs_count;
> -	int ret = 0;
> +	int i, found = -1;
> +	const u32 esit_boundary = get_esit_boundary(sch_ep);
> +	const u32 bw_boundary = get_bw_boundary(sch_ep->speed);
> +	u32 min_bw = ~0;
>  
>  	/*
>  	 * Search through all possible schedule microframes.
>  	 * and find a microframe where its worst bandwidth is minimum.
>  	 */
> -	min_bw = ~0;
> -	min_index = 0;
> -	min_cs_count = sch_ep->cs_count;
> -	min_num_budget = sch_ep->num_budget_microframes;
> -	esit_boundary = get_esit_boundary(sch_ep);
> -	for (offset = 0; offset < sch_ep->esit; offset++) {
> -		if (sch_ep->sch_tt) {
> -			ret = check_sch_tt(sch_ep, offset);
> -			if (ret)
> -				continue;
> -		}
> +	for (i = 0; i < sch_ep->esit; i++) {
> +		u32 worst_bw;
>  
> -		if ((offset + sch_ep->num_budget_microframes) > esit_boundary)
> +		if ((i + sch_ep->num_budget_microframes) > esit_boundary)
>  			break;
>  
> -		worst_bw = get_max_bw(sch_bw, sch_ep, offset);
> +		if (check_sch_tt(sch_ep, i))
> +			continue;
> +
> +		worst_bw = get_max_bw(sch_bw, sch_ep, i);
> +		if (worst_bw > bw_boundary)
> +			continue;
> +
>  		if (min_bw > worst_bw) {
>  			min_bw = worst_bw;
> -			min_index = offset;
> -			min_cs_count = sch_ep->cs_count;
> -			min_num_budget = sch_ep->num_budget_microframes;
> +			found = i;
>  		}
>  		if (min_bw == 0)
>  			break;
>  	}
>  
> -	bw_boundary = get_bw_boundary(sch_ep->speed);
>  	/* check bandwidth */
> -	if (min_bw > bw_boundary)
> -		return ret ? ret : -ESCH_BW_OVERFLOW;
> +	if (found < 0)
> +		return -ESCH_BW_OVERFLOW;
>  
> -	sch_ep->offset = min_index;
> -	sch_ep->cs_count = min_cs_count;
> -	sch_ep->num_budget_microframes = min_num_budget;
> +	sch_ep->offset = found;
>  
>  	return load_ep_bw(sch_bw, sch_ep, true);
>  }
Greg KH April 5, 2021, 7:04 a.m. UTC | #2
On Wed, Mar 31, 2021 at 04:30:55PM +0800, Chunfeng Yun wrote:
> cc Yaqii Wu <Yaqii.Wu@mediatek.com>
> 
> I'll test it , thanks

Did you test this series and find any problems?  If not, I'll go queue
these up...

thanks,

greg k-h
Chunfeng Yun (云春峰) April 6, 2021, 2:18 a.m. UTC | #3
On Mon, 2021-04-05 at 09:04 +0200, Greg Kroah-Hartman wrote:
> On Wed, Mar 31, 2021 at 04:30:55PM +0800, Chunfeng Yun wrote:
> > cc Yaqii Wu <Yaqii.Wu@mediatek.com>
> > 
> > I'll test it , thanks
> 
> Did you test this series and find any problems?  If not, I'll go queue
> these up...
Yes, found an issue on the start-split transaction, but not found the
root cause yet :(

> 
> thanks,
> 
> greg k-h
Greg KH April 22, 2021, 8:46 a.m. UTC | #4
On Tue, Apr 06, 2021 at 10:18:12AM +0800, Chunfeng Yun wrote:
> On Mon, 2021-04-05 at 09:04 +0200, Greg Kroah-Hartman wrote:
> > On Wed, Mar 31, 2021 at 04:30:55PM +0800, Chunfeng Yun wrote:
> > > cc Yaqii Wu <Yaqii.Wu@mediatek.com>
> > > 
> > > I'll test it , thanks
> > 
> > Did you test this series and find any problems?  If not, I'll go queue
> > these up...
> Yes, found an issue on the start-split transaction, but not found the
> root cause yet :(

So you are objecting to these being merged at this point in time?  Can
you provide feedback to the author about what is wrong?

thanks,

greg k-h
Chunfeng Yun (云春峰) April 23, 2021, 3:26 a.m. UTC | #5
On Thu, 2021-04-22 at 10:46 +0200, Greg Kroah-Hartman wrote:
> On Tue, Apr 06, 2021 at 10:18:12AM +0800, Chunfeng Yun wrote:
> > On Mon, 2021-04-05 at 09:04 +0200, Greg Kroah-Hartman wrote:
> > > On Wed, Mar 31, 2021 at 04:30:55PM +0800, Chunfeng Yun wrote:
> > > > cc Yaqii Wu <Yaqii.Wu@mediatek.com>
> > > > 
> > > > I'll test it , thanks
> > > 
> > > Did you test this series and find any problems?  If not, I'll go queue
> > > these up...
> > Yes, found an issue on the start-split transaction, but not found the
> > root cause yet :(
> 
> So you are objecting to these being merged at this point in time? 
Yes

>  Can
> you provide feedback to the author about what is wrong?
Already provided feedback add discussed on issue tracker in private

Thanks a lot

> 
> thanks,
> 
> greg k-h
Greg KH April 23, 2021, 5:23 a.m. UTC | #6
On Fri, Apr 23, 2021 at 11:26:31AM +0800, Chunfeng Yun wrote:
> On Thu, 2021-04-22 at 10:46 +0200, Greg Kroah-Hartman wrote:
> > On Tue, Apr 06, 2021 at 10:18:12AM +0800, Chunfeng Yun wrote:
> > > On Mon, 2021-04-05 at 09:04 +0200, Greg Kroah-Hartman wrote:
> > > > On Wed, Mar 31, 2021 at 04:30:55PM +0800, Chunfeng Yun wrote:
> > > > > cc Yaqii Wu <Yaqii.Wu@mediatek.com>
> > > > > 
> > > > > I'll test it , thanks
> > > > 
> > > > Did you test this series and find any problems?  If not, I'll go queue
> > > > these up...
> > > Yes, found an issue on the start-split transaction, but not found the
> > > root cause yet :(
> > 
> > So you are objecting to these being merged at this point in time? 
> Yes
> 
> >  Can
> > you provide feedback to the author about what is wrong?
> Already provided feedback add discussed on issue tracker in private

That doesn't help us much as we can't see that :(

Please always keep us informed as to what is going on with publically
posted changes, otherwise you could find them being picked up and merged
into trees without an objection.

thanks,

greg k-h
Chunfeng Yun (云春峰) April 23, 2021, 6:06 a.m. UTC | #7
On Fri, 2021-04-23 at 07:23 +0200, Greg Kroah-Hartman wrote:
> On Fri, Apr 23, 2021 at 11:26:31AM +0800, Chunfeng Yun wrote:
> > On Thu, 2021-04-22 at 10:46 +0200, Greg Kroah-Hartman wrote:
> > > On Tue, Apr 06, 2021 at 10:18:12AM +0800, Chunfeng Yun wrote:
> > > > On Mon, 2021-04-05 at 09:04 +0200, Greg Kroah-Hartman wrote:
> > > > > On Wed, Mar 31, 2021 at 04:30:55PM +0800, Chunfeng Yun wrote:
> > > > > > cc Yaqii Wu <Yaqii.Wu@mediatek.com>
> > > > > > 
> > > > > > I'll test it , thanks
> > > > > 
> > > > > Did you test this series and find any problems?  If not, I'll go queue
> > > > > these up...
> > > > Yes, found an issue on the start-split transaction, but not found the
> > > > root cause yet :(
> > > 
> > > So you are objecting to these being merged at this point in time? 
> > Yes
> > 
> > >  Can
> > > you provide feedback to the author about what is wrong?
> > Already provided feedback add discussed on issue tracker in private
> 
> That doesn't help us much as we can't see that :(
> 
> Please always keep us informed as to what is going on with publically
> posted changes, otherwise you could find them being picked up and merged
> into trees without an objection.
Got it.
I'll update status when find the root cause of SS transaction issue,
thanks a lot.

> 
> thanks,
> 
> greg k-h
diff mbox series

Patch

diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c
index a59d1f6d4744..0cb41007ec65 100644
--- a/drivers/usb/host/xhci-mtk-sch.c
+++ b/drivers/usb/host/xhci-mtk-sch.c
@@ -479,6 +479,9 @@  static int check_sch_tt(struct mu3h_sch_ep_info *sch_ep, u32 offset)
 	u32 start_cs, last_cs;
 	int i;
 
+	if (!sch_ep->sch_tt)
+		return 0;
+
 	start_ss = offset % 8;
 
 	if (sch_ep->ep_type == ISOC_OUT_EP) {
@@ -606,54 +609,41 @@  static u32 get_esit_boundary(struct mu3h_sch_ep_info *sch_ep)
 static int check_sch_bw(struct mu3h_sch_bw_info *sch_bw,
 			struct mu3h_sch_ep_info *sch_ep)
 {
-	u32 offset;
-	u32 min_bw;
-	u32 min_index;
-	u32 worst_bw;
-	u32 bw_boundary;
-	u32 esit_boundary;
-	u32 min_num_budget;
-	u32 min_cs_count;
-	int ret = 0;
+	int i, found = -1;
+	const u32 esit_boundary = get_esit_boundary(sch_ep);
+	const u32 bw_boundary = get_bw_boundary(sch_ep->speed);
+	u32 min_bw = ~0;
 
 	/*
 	 * Search through all possible schedule microframes.
 	 * and find a microframe where its worst bandwidth is minimum.
 	 */
-	min_bw = ~0;
-	min_index = 0;
-	min_cs_count = sch_ep->cs_count;
-	min_num_budget = sch_ep->num_budget_microframes;
-	esit_boundary = get_esit_boundary(sch_ep);
-	for (offset = 0; offset < sch_ep->esit; offset++) {
-		if (sch_ep->sch_tt) {
-			ret = check_sch_tt(sch_ep, offset);
-			if (ret)
-				continue;
-		}
+	for (i = 0; i < sch_ep->esit; i++) {
+		u32 worst_bw;
 
-		if ((offset + sch_ep->num_budget_microframes) > esit_boundary)
+		if ((i + sch_ep->num_budget_microframes) > esit_boundary)
 			break;
 
-		worst_bw = get_max_bw(sch_bw, sch_ep, offset);
+		if (check_sch_tt(sch_ep, i))
+			continue;
+
+		worst_bw = get_max_bw(sch_bw, sch_ep, i);
+		if (worst_bw > bw_boundary)
+			continue;
+
 		if (min_bw > worst_bw) {
 			min_bw = worst_bw;
-			min_index = offset;
-			min_cs_count = sch_ep->cs_count;
-			min_num_budget = sch_ep->num_budget_microframes;
+			found = i;
 		}
 		if (min_bw == 0)
 			break;
 	}
 
-	bw_boundary = get_bw_boundary(sch_ep->speed);
 	/* check bandwidth */
-	if (min_bw > bw_boundary)
-		return ret ? ret : -ESCH_BW_OVERFLOW;
+	if (found < 0)
+		return -ESCH_BW_OVERFLOW;
 
-	sch_ep->offset = min_index;
-	sch_ep->cs_count = min_cs_count;
-	sch_ep->num_budget_microframes = min_num_budget;
+	sch_ep->offset = found;
 
 	return load_ep_bw(sch_bw, sch_ep, true);
 }