linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] usb: xhci-mtk: relax peridoc TT bandwidth checking
@ 2021-03-30  8:06 Ikjoon Jang
  2021-03-30  8:06 ` [PATCH 1/2] usb: xhci-mtk: remove unnecessary assignments in periodic TT scheduler Ikjoon Jang
  2021-03-30  8:06 ` [PATCH 2/2] usb: xhci-mtk: relax periodic TT bandwidth checking Ikjoon Jang
  0 siblings, 2 replies; 11+ messages in thread
From: Ikjoon Jang @ 2021-03-30  8:06 UTC (permalink / raw)
  To: linux-usb
  Cc: Ikjoon Jang, Chunfeng Yun, Greg Kroah-Hartman, Mathias Nyman,
	Matthias Brugger, linux-arm-kernel, linux-kernel, linux-mediatek

This series is for supporting typical full speed USB audio headsets
with speaker, microphone, and control knobs together.

With current implementation, such a device cannot be configured
due to xhci-mtk's bandwidth allocation failure even when there's
enough bandwidth available.

Ikjoon Jang (2):
  usb: xhci-mtk: remove unnecessary assignments in periodic TT scheduler
  usb: xhci-mtk: relax periodic TT bandwidth checking

 drivers/usb/host/xhci-mtk-sch.c | 120 +++++++++++---------------------
 drivers/usb/host/xhci-mtk.h     |   2 -
 2 files changed, 41 insertions(+), 81 deletions(-)

-- 
2.31.0.291.g576ba9dcdaf-goog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/2] usb: xhci-mtk: remove unnecessary assignments in periodic TT scheduler
  2021-03-30  8:06 [PATCH 0/2] usb: xhci-mtk: relax peridoc TT bandwidth checking Ikjoon Jang
@ 2021-03-30  8:06 ` Ikjoon Jang
  2021-03-31  8:30   ` Chunfeng Yun
  2021-03-30  8:06 ` [PATCH 2/2] usb: xhci-mtk: relax periodic TT bandwidth checking Ikjoon Jang
  1 sibling, 1 reply; 11+ messages in thread
From: Ikjoon Jang @ 2021-03-30  8:06 UTC (permalink / raw)
  To: linux-usb
  Cc: Ikjoon Jang, Chunfeng Yun, Greg Kroah-Hartman, Mathias Nyman,
	Matthias Brugger, linux-arm-kernel, linux-kernel, linux-mediatek

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);
 }
-- 
2.31.0.291.g576ba9dcdaf-goog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/2] usb: xhci-mtk: relax periodic TT bandwidth checking
  2021-03-30  8:06 [PATCH 0/2] usb: xhci-mtk: relax peridoc TT bandwidth checking Ikjoon Jang
  2021-03-30  8:06 ` [PATCH 1/2] usb: xhci-mtk: remove unnecessary assignments in periodic TT scheduler Ikjoon Jang
@ 2021-03-30  8:06 ` Ikjoon Jang
  2021-03-31  8:31   ` Chunfeng Yun
  1 sibling, 1 reply; 11+ messages in thread
From: Ikjoon Jang @ 2021-03-30  8:06 UTC (permalink / raw)
  To: linux-usb
  Cc: Ikjoon Jang, Chunfeng Yun, Greg Kroah-Hartman, Mathias Nyman,
	Matthias Brugger, linux-arm-kernel, linux-kernel, linux-mediatek

Software bandwidth checking logics used by xhci-mtk puts
a quite heavy constraints to TT periodic endpoint allocations.

This patch provides a relaxed bandwidth calculation by
- Allowing multiple periodic transactions in a same microframe
  for a device with multiple interrupt endpoints.
- Using best case budget instead of maximum number of
  complete-split when calculating byte budgets on lower speed bus

Without this patch, a typical full speed audio headset with
3 periodic endpoints (audio isoc-in/out, input int-in) cannot be
configured with xhci-mtk.

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

 drivers/usb/host/xhci-mtk-sch.c | 68 ++++++++++-----------------------
 drivers/usb/host/xhci-mtk.h     |  2 -
 2 files changed, 20 insertions(+), 50 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c
index 0cb41007ec65..76827e48049a 100644
--- a/drivers/usb/host/xhci-mtk-sch.c
+++ b/drivers/usb/host/xhci-mtk-sch.c
@@ -388,13 +388,17 @@ static void setup_sch_info(struct xhci_ep_ctx *ep_ctx,
 		} else { /* INT_IN_EP or ISOC_IN_EP */
 			bwb_table[0] = 0; /* start split */
 			bwb_table[1] = 0; /* idle */
+
+			sch_ep->num_budget_microframes += 2;
+			if (sch_ep->num_budget_microframes > sch_ep->esit)
+				sch_ep->num_budget_microframes = sch_ep->esit;
 			/*
 			 * due to cs_count will be updated according to cs
 			 * position, assign all remainder budget array
 			 * elements as @bw_cost_per_microframe, but only first
 			 * @num_budget_microframes elements will be used later
 			 */
-			for (i = 2; i < TT_MICROFRAMES_MAX; i++)
+			for (i = 2; i < sch_ep->num_budget_microframes; i++)
 				bwb_table[i] =	sch_ep->bw_cost_per_microframe;
 		}
 	}
@@ -449,20 +453,17 @@ static void update_bus_bw(struct mu3h_sch_bw_info *sch_bw,
 static int check_fs_bus_bw(struct mu3h_sch_ep_info *sch_ep, int offset)
 {
 	struct mu3h_sch_tt *tt = sch_ep->sch_tt;
-	u32 num_esit, tmp;
-	int base;
 	int i, j;
+	const int nr_lower_uframes =
+		DIV_ROUND_UP(sch_ep->maxpkt, FS_PAYLOAD_MAX);
 
-	num_esit = XHCI_MTK_MAX_ESIT / sch_ep->esit;
-	for (i = 0; i < num_esit; i++) {
-		base = offset + i * sch_ep->esit;
-
+	for (i = offset; i < XHCI_MTK_MAX_ESIT; i += sch_ep->esit) {
 		/*
 		 * Compared with hs bus, no matter what ep type,
 		 * the hub will always delay one uframe to send data
 		 */
-		for (j = 0; j < sch_ep->cs_count; j++) {
-			tmp = tt->fs_bus_bw[base + j] + sch_ep->bw_cost_per_microframe;
+		for (j = 0; j < nr_lower_uframes; j++) {
+			u32 tmp = tt->fs_bus_bw[i + j + 1] + sch_ep->bw_cost_per_microframe;
 			if (tmp > FS_PAYLOAD_MAX)
 				return -ESCH_BW_OVERFLOW;
 		}
@@ -473,11 +474,9 @@ static int check_fs_bus_bw(struct mu3h_sch_ep_info *sch_ep, int offset)
 
 static int check_sch_tt(struct mu3h_sch_ep_info *sch_ep, u32 offset)
 {
-	struct mu3h_sch_tt *tt = sch_ep->sch_tt;
 	u32 extra_cs_count;
 	u32 start_ss, last_ss;
 	u32 start_cs, last_cs;
-	int i;
 
 	if (!sch_ep->sch_tt)
 		return 0;
@@ -494,10 +493,6 @@ static int check_sch_tt(struct mu3h_sch_ep_info *sch_ep, u32 offset)
 		if (!(start_ss == 7 || last_ss < 6))
 			return -ESCH_SS_Y6;
 
-		for (i = 0; i < sch_ep->cs_count; i++)
-			if (test_bit(offset + i, tt->ss_bit_map))
-				return -ESCH_SS_OVERLAP;
-
 	} else {
 		u32 cs_count = DIV_ROUND_UP(sch_ep->maxpkt, FS_PAYLOAD_MAX);
 
@@ -524,19 +519,7 @@ static int check_sch_tt(struct mu3h_sch_ep_info *sch_ep, u32 offset)
 		if (cs_count > 7)
 			cs_count = 7; /* HW limit */
 
-		if (test_bit(offset, tt->ss_bit_map))
-			return -ESCH_SS_OVERLAP;
-
 		sch_ep->cs_count = cs_count;
-		/* one for ss, the other for idle */
-		sch_ep->num_budget_microframes = cs_count + 2;
-
-		/*
-		 * if interval=1, maxp >752, num_budge_micoframe is larger
-		 * than sch_ep->esit, will overstep boundary
-		 */
-		if (sch_ep->num_budget_microframes > sch_ep->esit)
-			sch_ep->num_budget_microframes = sch_ep->esit;
 	}
 
 	return check_fs_bus_bw(sch_ep, offset);
@@ -545,31 +528,18 @@ static int check_sch_tt(struct mu3h_sch_ep_info *sch_ep, u32 offset)
 static void update_sch_tt(struct mu3h_sch_ep_info *sch_ep, bool used)
 {
 	struct mu3h_sch_tt *tt = sch_ep->sch_tt;
-	u32 base, num_esit;
-	int bw_updated;
-	int bits;
-	int i, j;
-
-	num_esit = XHCI_MTK_MAX_ESIT / sch_ep->esit;
-	bits = (sch_ep->ep_type == ISOC_OUT_EP) ? sch_ep->cs_count : 1;
+	int i, j, bw_updated;
+	const int nr_lower_uframes =
+		DIV_ROUND_UP(sch_ep->maxpkt, FS_PAYLOAD_MAX);
 
 	if (used)
 		bw_updated = sch_ep->bw_cost_per_microframe;
 	else
 		bw_updated = -sch_ep->bw_cost_per_microframe;
 
-	for (i = 0; i < num_esit; i++) {
-		base = sch_ep->offset + i * sch_ep->esit;
-
-		for (j = 0; j < bits; j++) {
-			if (used)
-				set_bit(base + j, tt->ss_bit_map);
-			else
-				clear_bit(base + j, tt->ss_bit_map);
-		}
-
-		for (j = 0; j < sch_ep->cs_count; j++)
-			tt->fs_bus_bw[base + j] += bw_updated;
+	for (i = sch_ep->offset; i < XHCI_MTK_MAX_ESIT; i += sch_ep->esit) {
+		for (j = 0; j < nr_lower_uframes; j++)
+			tt->fs_bus_bw[i+ j + 1] += bw_updated;
 	}
 
 	if (used)
@@ -634,9 +604,11 @@ static int check_sch_bw(struct mu3h_sch_bw_info *sch_bw,
 		if (min_bw > worst_bw) {
 			min_bw = worst_bw;
 			found = i;
+			/* fastpath: bandwidth contributions to host is low
+			 * when it's fs/ls */
+			if (sch_ep->sch_tt || min_bw == 0)
+				break;
 		}
-		if (min_bw == 0)
-			break;
 	}
 
 	/* check bandwidth */
diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
index 621ec1a85009..8a879f99ae1c 100644
--- a/drivers/usb/host/xhci-mtk.h
+++ b/drivers/usb/host/xhci-mtk.h
@@ -20,12 +20,10 @@
 #define XHCI_MTK_MAX_ESIT	64
 
 /**
- * @ss_bit_map: used to avoid start split microframes overlay
  * @fs_bus_bw: array to keep track of bandwidth already used for FS
  * @ep_list: Endpoints using this TT
  */
 struct mu3h_sch_tt {
-	DECLARE_BITMAP(ss_bit_map, XHCI_MTK_MAX_ESIT);
 	u32 fs_bus_bw[XHCI_MTK_MAX_ESIT];
 	struct list_head ep_list;
 };
-- 
2.31.0.291.g576ba9dcdaf-goog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] usb: xhci-mtk: remove unnecessary assignments in periodic TT scheduler
  2021-03-30  8:06 ` [PATCH 1/2] usb: xhci-mtk: remove unnecessary assignments in periodic TT scheduler Ikjoon Jang
@ 2021-03-31  8:30   ` Chunfeng Yun
  2021-04-05  7:04     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 11+ messages in thread
From: Chunfeng Yun @ 2021-03-31  8:30 UTC (permalink / raw)
  To: Ikjoon Jang, Yaqii Wu
  Cc: linux-usb, Greg Kroah-Hartman, Mathias Nyman, Matthias Brugger,
	linux-arm-kernel, linux-kernel, linux-mediatek

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);
>  }

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] usb: xhci-mtk: relax periodic TT bandwidth checking
  2021-03-30  8:06 ` [PATCH 2/2] usb: xhci-mtk: relax periodic TT bandwidth checking Ikjoon Jang
@ 2021-03-31  8:31   ` Chunfeng Yun
  0 siblings, 0 replies; 11+ messages in thread
From: Chunfeng Yun @ 2021-03-31  8:31 UTC (permalink / raw)
  To: Ikjoon Jang, Yaqii Wu
  Cc: linux-usb, Greg Kroah-Hartman, Mathias Nyman, Matthias Brugger,
	linux-arm-kernel, linux-kernel, linux-mediatek

On Tue, 2021-03-30 at 16:06 +0800, Ikjoon Jang wrote:
> Software bandwidth checking logics used by xhci-mtk puts
> a quite heavy constraints to TT periodic endpoint allocations.
> 
> This patch provides a relaxed bandwidth calculation by
> - Allowing multiple periodic transactions in a same microframe
>   for a device with multiple interrupt endpoints.
> - Using best case budget instead of maximum number of
>   complete-split when calculating byte budgets on lower speed bus
> 
> Without this patch, a typical full speed audio headset with
> 3 periodic endpoints (audio isoc-in/out, input int-in) cannot be
> configured with xhci-mtk.
> 
> Signed-off-by: Ikjoon Jang <ikjn@chromium.org>
> ---
cc Yaqii Wu <Yaqii.Wu@mediatek.com>

I'll test it, thanks

> 
>  drivers/usb/host/xhci-mtk-sch.c | 68 ++++++++++-----------------------
>  drivers/usb/host/xhci-mtk.h     |  2 -
>  2 files changed, 20 insertions(+), 50 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c
> index 0cb41007ec65..76827e48049a 100644
> --- a/drivers/usb/host/xhci-mtk-sch.c
> +++ b/drivers/usb/host/xhci-mtk-sch.c
> @@ -388,13 +388,17 @@ static void setup_sch_info(struct xhci_ep_ctx *ep_ctx,
>  		} else { /* INT_IN_EP or ISOC_IN_EP */
>  			bwb_table[0] = 0; /* start split */
>  			bwb_table[1] = 0; /* idle */
> +
> +			sch_ep->num_budget_microframes += 2;
> +			if (sch_ep->num_budget_microframes > sch_ep->esit)
> +				sch_ep->num_budget_microframes = sch_ep->esit;
>  			/*
>  			 * due to cs_count will be updated according to cs
>  			 * position, assign all remainder budget array
>  			 * elements as @bw_cost_per_microframe, but only first
>  			 * @num_budget_microframes elements will be used later
>  			 */
> -			for (i = 2; i < TT_MICROFRAMES_MAX; i++)
> +			for (i = 2; i < sch_ep->num_budget_microframes; i++)
>  				bwb_table[i] =	sch_ep->bw_cost_per_microframe;
>  		}
>  	}
> @@ -449,20 +453,17 @@ static void update_bus_bw(struct mu3h_sch_bw_info *sch_bw,
>  static int check_fs_bus_bw(struct mu3h_sch_ep_info *sch_ep, int offset)
>  {
>  	struct mu3h_sch_tt *tt = sch_ep->sch_tt;
> -	u32 num_esit, tmp;
> -	int base;
>  	int i, j;
> +	const int nr_lower_uframes =
> +		DIV_ROUND_UP(sch_ep->maxpkt, FS_PAYLOAD_MAX);
>  
> -	num_esit = XHCI_MTK_MAX_ESIT / sch_ep->esit;
> -	for (i = 0; i < num_esit; i++) {
> -		base = offset + i * sch_ep->esit;
> -
> +	for (i = offset; i < XHCI_MTK_MAX_ESIT; i += sch_ep->esit) {
>  		/*
>  		 * Compared with hs bus, no matter what ep type,
>  		 * the hub will always delay one uframe to send data
>  		 */
> -		for (j = 0; j < sch_ep->cs_count; j++) {
> -			tmp = tt->fs_bus_bw[base + j] + sch_ep->bw_cost_per_microframe;
> +		for (j = 0; j < nr_lower_uframes; j++) {
> +			u32 tmp = tt->fs_bus_bw[i + j + 1] + sch_ep->bw_cost_per_microframe;
>  			if (tmp > FS_PAYLOAD_MAX)
>  				return -ESCH_BW_OVERFLOW;
>  		}
> @@ -473,11 +474,9 @@ static int check_fs_bus_bw(struct mu3h_sch_ep_info *sch_ep, int offset)
>  
>  static int check_sch_tt(struct mu3h_sch_ep_info *sch_ep, u32 offset)
>  {
> -	struct mu3h_sch_tt *tt = sch_ep->sch_tt;
>  	u32 extra_cs_count;
>  	u32 start_ss, last_ss;
>  	u32 start_cs, last_cs;
> -	int i;
>  
>  	if (!sch_ep->sch_tt)
>  		return 0;
> @@ -494,10 +493,6 @@ static int check_sch_tt(struct mu3h_sch_ep_info *sch_ep, u32 offset)
>  		if (!(start_ss == 7 || last_ss < 6))
>  			return -ESCH_SS_Y6;
>  
> -		for (i = 0; i < sch_ep->cs_count; i++)
> -			if (test_bit(offset + i, tt->ss_bit_map))
> -				return -ESCH_SS_OVERLAP;
> -
>  	} else {
>  		u32 cs_count = DIV_ROUND_UP(sch_ep->maxpkt, FS_PAYLOAD_MAX);
>  
> @@ -524,19 +519,7 @@ static int check_sch_tt(struct mu3h_sch_ep_info *sch_ep, u32 offset)
>  		if (cs_count > 7)
>  			cs_count = 7; /* HW limit */
>  
> -		if (test_bit(offset, tt->ss_bit_map))
> -			return -ESCH_SS_OVERLAP;
> -
>  		sch_ep->cs_count = cs_count;
> -		/* one for ss, the other for idle */
> -		sch_ep->num_budget_microframes = cs_count + 2;
> -
> -		/*
> -		 * if interval=1, maxp >752, num_budge_micoframe is larger
> -		 * than sch_ep->esit, will overstep boundary
> -		 */
> -		if (sch_ep->num_budget_microframes > sch_ep->esit)
> -			sch_ep->num_budget_microframes = sch_ep->esit;
>  	}
>  
>  	return check_fs_bus_bw(sch_ep, offset);
> @@ -545,31 +528,18 @@ static int check_sch_tt(struct mu3h_sch_ep_info *sch_ep, u32 offset)
>  static void update_sch_tt(struct mu3h_sch_ep_info *sch_ep, bool used)
>  {
>  	struct mu3h_sch_tt *tt = sch_ep->sch_tt;
> -	u32 base, num_esit;
> -	int bw_updated;
> -	int bits;
> -	int i, j;
> -
> -	num_esit = XHCI_MTK_MAX_ESIT / sch_ep->esit;
> -	bits = (sch_ep->ep_type == ISOC_OUT_EP) ? sch_ep->cs_count : 1;
> +	int i, j, bw_updated;
> +	const int nr_lower_uframes =
> +		DIV_ROUND_UP(sch_ep->maxpkt, FS_PAYLOAD_MAX);
>  
>  	if (used)
>  		bw_updated = sch_ep->bw_cost_per_microframe;
>  	else
>  		bw_updated = -sch_ep->bw_cost_per_microframe;
>  
> -	for (i = 0; i < num_esit; i++) {
> -		base = sch_ep->offset + i * sch_ep->esit;
> -
> -		for (j = 0; j < bits; j++) {
> -			if (used)
> -				set_bit(base + j, tt->ss_bit_map);
> -			else
> -				clear_bit(base + j, tt->ss_bit_map);
> -		}
> -
> -		for (j = 0; j < sch_ep->cs_count; j++)
> -			tt->fs_bus_bw[base + j] += bw_updated;
> +	for (i = sch_ep->offset; i < XHCI_MTK_MAX_ESIT; i += sch_ep->esit) {
> +		for (j = 0; j < nr_lower_uframes; j++)
> +			tt->fs_bus_bw[i+ j + 1] += bw_updated;
>  	}
>  
>  	if (used)
> @@ -634,9 +604,11 @@ static int check_sch_bw(struct mu3h_sch_bw_info *sch_bw,
>  		if (min_bw > worst_bw) {
>  			min_bw = worst_bw;
>  			found = i;
> +			/* fastpath: bandwidth contributions to host is low
> +			 * when it's fs/ls */
> +			if (sch_ep->sch_tt || min_bw == 0)
> +				break;
>  		}
> -		if (min_bw == 0)
> -			break;
>  	}
>  
>  	/* check bandwidth */
> diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
> index 621ec1a85009..8a879f99ae1c 100644
> --- a/drivers/usb/host/xhci-mtk.h
> +++ b/drivers/usb/host/xhci-mtk.h
> @@ -20,12 +20,10 @@
>  #define XHCI_MTK_MAX_ESIT	64
>  
>  /**
> - * @ss_bit_map: used to avoid start split microframes overlay
>   * @fs_bus_bw: array to keep track of bandwidth already used for FS
>   * @ep_list: Endpoints using this TT
>   */
>  struct mu3h_sch_tt {
> -	DECLARE_BITMAP(ss_bit_map, XHCI_MTK_MAX_ESIT);
>  	u32 fs_bus_bw[XHCI_MTK_MAX_ESIT];
>  	struct list_head ep_list;
>  };

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] usb: xhci-mtk: remove unnecessary assignments in periodic TT scheduler
  2021-03-31  8:30   ` Chunfeng Yun
@ 2021-04-05  7:04     ` Greg Kroah-Hartman
  2021-04-06  2:18       ` Chunfeng Yun
  0 siblings, 1 reply; 11+ messages in thread
From: Greg Kroah-Hartman @ 2021-04-05  7:04 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: Ikjoon Jang, Yaqii Wu, linux-usb, Mathias Nyman,
	Matthias Brugger, linux-arm-kernel, linux-kernel, linux-mediatek

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] usb: xhci-mtk: remove unnecessary assignments in periodic TT scheduler
  2021-04-05  7:04     ` Greg Kroah-Hartman
@ 2021-04-06  2:18       ` Chunfeng Yun
  2021-04-22  8:46         ` Greg Kroah-Hartman
  0 siblings, 1 reply; 11+ messages in thread
From: Chunfeng Yun @ 2021-04-06  2:18 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Ikjoon Jang, Yaqii Wu, linux-usb, Mathias Nyman,
	Matthias Brugger, linux-arm-kernel, linux-kernel, linux-mediatek

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] usb: xhci-mtk: remove unnecessary assignments in periodic TT scheduler
  2021-04-06  2:18       ` Chunfeng Yun
@ 2021-04-22  8:46         ` Greg Kroah-Hartman
  2021-04-23  3:26           ` Chunfeng Yun
  0 siblings, 1 reply; 11+ messages in thread
From: Greg Kroah-Hartman @ 2021-04-22  8:46 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: Ikjoon Jang, Yaqii Wu, linux-usb, Mathias Nyman,
	Matthias Brugger, linux-arm-kernel, linux-kernel, linux-mediatek

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] usb: xhci-mtk: remove unnecessary assignments in periodic TT scheduler
  2021-04-22  8:46         ` Greg Kroah-Hartman
@ 2021-04-23  3:26           ` Chunfeng Yun
  2021-04-23  5:23             ` Greg Kroah-Hartman
  0 siblings, 1 reply; 11+ messages in thread
From: Chunfeng Yun @ 2021-04-23  3:26 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Ikjoon Jang, Yaqii Wu, linux-usb, Mathias Nyman,
	Matthias Brugger, linux-arm-kernel, linux-kernel, linux-mediatek

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] usb: xhci-mtk: remove unnecessary assignments in periodic TT scheduler
  2021-04-23  3:26           ` Chunfeng Yun
@ 2021-04-23  5:23             ` Greg Kroah-Hartman
  2021-04-23  6:06               ` Chunfeng Yun
  0 siblings, 1 reply; 11+ messages in thread
From: Greg Kroah-Hartman @ 2021-04-23  5:23 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: Ikjoon Jang, Yaqii Wu, linux-usb, Mathias Nyman,
	Matthias Brugger, linux-arm-kernel, linux-kernel, linux-mediatek

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] usb: xhci-mtk: remove unnecessary assignments in periodic TT scheduler
  2021-04-23  5:23             ` Greg Kroah-Hartman
@ 2021-04-23  6:06               ` Chunfeng Yun
  0 siblings, 0 replies; 11+ messages in thread
From: Chunfeng Yun @ 2021-04-23  6:06 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Ikjoon Jang, Yaqii Wu, linux-usb, Mathias Nyman,
	Matthias Brugger, linux-arm-kernel, linux-kernel, linux-mediatek

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-04-23  6:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-30  8:06 [PATCH 0/2] usb: xhci-mtk: relax peridoc TT bandwidth checking Ikjoon Jang
2021-03-30  8:06 ` [PATCH 1/2] usb: xhci-mtk: remove unnecessary assignments in periodic TT scheduler Ikjoon Jang
2021-03-31  8:30   ` Chunfeng Yun
2021-04-05  7:04     ` Greg Kroah-Hartman
2021-04-06  2:18       ` Chunfeng Yun
2021-04-22  8:46         ` Greg Kroah-Hartman
2021-04-23  3:26           ` Chunfeng Yun
2021-04-23  5:23             ` Greg Kroah-Hartman
2021-04-23  6:06               ` Chunfeng Yun
2021-03-30  8:06 ` [PATCH 2/2] usb: xhci-mtk: relax periodic TT bandwidth checking Ikjoon Jang
2021-03-31  8:31   ` 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).