All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] usb: xhci-mtk: relax TT periodic bandwidth allocation
@ 2022-08-05  6:03 ` Chunfeng Yun
  0 siblings, 0 replies; 8+ messages in thread
From: Chunfeng Yun @ 2022-08-05  6:03 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Chunfeng Yun, Mathias Nyman, Matthias Brugger, Ikjoon Jang,
	linux-usb, linux-arm-kernel, linux-mediatek, linux-kernel,
	Eddie Hung

Currently uses the worst case byte budgets on FS/LS bus bandwidth,
for example, for an isochronos IN endpoint with 192 bytes budget, it
will consume the whole 5 uframes(188 * 5) while the actual FS bus
budget should be just 192 bytes. It cause that many usb audio headsets
with 3 interfaces (audio input, audio output, and HID) cannot be
configured.
To improve it, changes to use "approximate" best case budget for FS/LS
bandwidth management. For the same endpoint from the above example,
the approximate best case budget is now reduced to (188 * 2) bytes.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v2: change commit message
---
 drivers/usb/host/xhci-mtk-sch.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk-sch.c
 b/drivers/usb/host/xhci-mtk-sch.c
index 06a6b19acaae..a17bc584ee99 100644
--- a/drivers/usb/host/xhci-mtk-sch.c
+++ b/drivers/usb/host/xhci-mtk-sch.c
@@ -425,7 +425,6 @@ 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)
 {
-	u32 extra_cs_count;
 	u32 start_ss, last_ss;
 	u32 start_cs, last_cs;
 
@@ -461,18 +460,12 @@ static int check_sch_tt(struct mu3h_sch_ep_info
 *sch_ep, u32 offset)
 		if (last_cs > 7)
 			return -ESCH_CS_OVERFLOW;
 
-		if (sch_ep->ep_type == ISOC_IN_EP)
-			extra_cs_count = (last_cs == 7) ? 1 : 2;
-		else /*  ep_type : INTR IN / INTR OUT */
-			extra_cs_count = 1;
-
-		cs_count += extra_cs_count;
 		if (cs_count > 7)
 			cs_count = 7; /* HW limit */
 
 		sch_ep->cs_count = cs_count;
-		/* one for ss, the other for idle */
-		sch_ep->num_budget_microframes = cs_count + 2;
+		/* ss, idle are ignored */
+		sch_ep->num_budget_microframes = cs_count;
 
 		/*
 		 * if interval=1, maxp >752, num_budge_micoframe is larger
-- 
2.18.0


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

* [PATCH v2 1/2] usb: xhci-mtk: relax TT periodic bandwidth allocation
@ 2022-08-05  6:03 ` Chunfeng Yun
  0 siblings, 0 replies; 8+ messages in thread
From: Chunfeng Yun @ 2022-08-05  6:03 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Chunfeng Yun, Mathias Nyman, Matthias Brugger, Ikjoon Jang,
	linux-usb, linux-arm-kernel, linux-mediatek, linux-kernel,
	Eddie Hung

Currently uses the worst case byte budgets on FS/LS bus bandwidth,
for example, for an isochronos IN endpoint with 192 bytes budget, it
will consume the whole 5 uframes(188 * 5) while the actual FS bus
budget should be just 192 bytes. It cause that many usb audio headsets
with 3 interfaces (audio input, audio output, and HID) cannot be
configured.
To improve it, changes to use "approximate" best case budget for FS/LS
bandwidth management. For the same endpoint from the above example,
the approximate best case budget is now reduced to (188 * 2) bytes.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v2: change commit message
---
 drivers/usb/host/xhci-mtk-sch.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c
index 06a6b19acaae..a17bc584ee99 100644
--- a/drivers/usb/host/xhci-mtk-sch.c
+++ b/drivers/usb/host/xhci-mtk-sch.c
@@ -425,7 +425,6 @@ 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)
 {
-	u32 extra_cs_count;
 	u32 start_ss, last_ss;
 	u32 start_cs, last_cs;
 
@@ -461,18 +460,12 @@ static int check_sch_tt(struct mu3h_sch_ep_info *sch_ep, u32 offset)
 		if (last_cs > 7)
 			return -ESCH_CS_OVERFLOW;
 
-		if (sch_ep->ep_type == ISOC_IN_EP)
-			extra_cs_count = (last_cs == 7) ? 1 : 2;
-		else /*  ep_type : INTR IN / INTR OUT */
-			extra_cs_count = 1;
-
-		cs_count += extra_cs_count;
 		if (cs_count > 7)
 			cs_count = 7; /* HW limit */
 
 		sch_ep->cs_count = cs_count;
-		/* one for ss, the other for idle */
-		sch_ep->num_budget_microframes = cs_count + 2;
+		/* ss, idle are ignored */
+		sch_ep->num_budget_microframes = cs_count;
 
 		/*
 		 * if interval=1, maxp >752, num_budge_micoframe is larger
-- 
2.18.0



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

* [PATCH v2 1/2] usb: xhci-mtk: relax TT periodic bandwidth allocation
@ 2022-08-05  6:03 ` Chunfeng Yun
  0 siblings, 0 replies; 8+ messages in thread
From: Chunfeng Yun @ 2022-08-05  6:03 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Chunfeng Yun, Mathias Nyman, Matthias Brugger, Ikjoon Jang,
	linux-usb, linux-arm-kernel, linux-mediatek, linux-kernel,
	Eddie Hung

Currently uses the worst case byte budgets on FS/LS bus bandwidth,
for example, for an isochronos IN endpoint with 192 bytes budget, it
will consume the whole 5 uframes(188 * 5) while the actual FS bus
budget should be just 192 bytes. It cause that many usb audio headsets
with 3 interfaces (audio input, audio output, and HID) cannot be
configured.
To improve it, changes to use "approximate" best case budget for FS/LS
bandwidth management. For the same endpoint from the above example,
the approximate best case budget is now reduced to (188 * 2) bytes.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v2: change commit message
---
 drivers/usb/host/xhci-mtk-sch.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c
index 06a6b19acaae..a17bc584ee99 100644
--- a/drivers/usb/host/xhci-mtk-sch.c
+++ b/drivers/usb/host/xhci-mtk-sch.c
@@ -425,7 +425,6 @@ 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)
 {
-	u32 extra_cs_count;
 	u32 start_ss, last_ss;
 	u32 start_cs, last_cs;
 
@@ -461,18 +460,12 @@ static int check_sch_tt(struct mu3h_sch_ep_info *sch_ep, u32 offset)
 		if (last_cs > 7)
 			return -ESCH_CS_OVERFLOW;
 
-		if (sch_ep->ep_type == ISOC_IN_EP)
-			extra_cs_count = (last_cs == 7) ? 1 : 2;
-		else /*  ep_type : INTR IN / INTR OUT */
-			extra_cs_count = 1;
-
-		cs_count += extra_cs_count;
 		if (cs_count > 7)
 			cs_count = 7; /* HW limit */
 
 		sch_ep->cs_count = cs_count;
-		/* one for ss, the other for idle */
-		sch_ep->num_budget_microframes = cs_count + 2;
+		/* ss, idle are ignored */
+		sch_ep->num_budget_microframes = cs_count;
 
 		/*
 		 * if interval=1, maxp >752, num_budge_micoframe is larger
-- 
2.18.0


_______________________________________________
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] 8+ messages in thread

* [PATCH v2 2/2] usb: xhci-mtk: fix bandwidth release issue
  2022-08-05  6:03 ` Chunfeng Yun
  (?)
@ 2022-08-05  6:03   ` Chunfeng Yun
  -1 siblings, 0 replies; 8+ messages in thread
From: Chunfeng Yun @ 2022-08-05  6:03 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Chunfeng Yun, Mathias Nyman, Matthias Brugger, Ikjoon Jang,
	linux-usb, linux-arm-kernel, linux-mediatek, linux-kernel,
	Eddie Hung

This happens when @udev->reset_resume is set to true, when usb resume,
the flow as below:
  - hub_resume
    - usb_disable_interface
      - usb_disable_endpoint
        - usb_hcd_disable_endpoint
          - xhci_endpoint_disable  // it set @ep->hcpriv to NULL

Then when reset usb device, it will drop allocated endpoints,
the flow as below:
  - usb_reset_and_verify_device
    - usb_hcd_alloc_bandwidth
      - xhci_mtk_drop_ep

but @ep->hcpriv is already set to NULL, the bandwidth will be not
released anymore.

Due to the added endponts are stored in hash table, we can drop the check
of @ep->hcpriv.

Fixes: 4ce186665e7c ("usb: xhci-mtk: Do not use xhci's virt_dev in
 drop_endpoint")
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v2: add comment
---
 drivers/usb/host/xhci-mtk-sch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk-sch.c
 b/drivers/usb/host/xhci-mtk-sch.c
index a17bc584ee99..579899eb24c1 100644
--- a/drivers/usb/host/xhci-mtk-sch.c
+++ b/drivers/usb/host/xhci-mtk-sch.c
@@ -764,8 +764,8 @@ int xhci_mtk_drop_ep(struct usb_hcd *hcd, struct
 usb_device *udev,
 	if (ret)
 		return ret;
 
-	if (ep->hcpriv)
-		drop_ep_quirk(hcd, udev, ep);
+	/* needn't check @ep->hcpriv, xhci_endpoint_disable set it NULL */
+	drop_ep_quirk(hcd, udev, ep);
 
 	return 0;
 }
-- 
2.18.0


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

* [PATCH v2 2/2] usb: xhci-mtk: fix bandwidth release issue
@ 2022-08-05  6:03   ` Chunfeng Yun
  0 siblings, 0 replies; 8+ messages in thread
From: Chunfeng Yun @ 2022-08-05  6:03 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Chunfeng Yun, Mathias Nyman, Matthias Brugger, Ikjoon Jang,
	linux-usb, linux-arm-kernel, linux-mediatek, linux-kernel,
	Eddie Hung

This happens when @udev->reset_resume is set to true, when usb resume,
the flow as below:
  - hub_resume
    - usb_disable_interface
      - usb_disable_endpoint
        - usb_hcd_disable_endpoint
          - xhci_endpoint_disable  // it set @ep->hcpriv to NULL

Then when reset usb device, it will drop allocated endpoints,
the flow as below:
  - usb_reset_and_verify_device
    - usb_hcd_alloc_bandwidth
      - xhci_mtk_drop_ep

but @ep->hcpriv is already set to NULL, the bandwidth will be not
released anymore.

Due to the added endponts are stored in hash table, we can drop the check
of @ep->hcpriv.

Fixes: 4ce186665e7c ("usb: xhci-mtk: Do not use xhci's virt_dev in drop_endpoint")
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v2: add comment
---
 drivers/usb/host/xhci-mtk-sch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c
index a17bc584ee99..579899eb24c1 100644
--- a/drivers/usb/host/xhci-mtk-sch.c
+++ b/drivers/usb/host/xhci-mtk-sch.c
@@ -764,8 +764,8 @@ int xhci_mtk_drop_ep(struct usb_hcd *hcd, struct usb_device *udev,
 	if (ret)
 		return ret;
 
-	if (ep->hcpriv)
-		drop_ep_quirk(hcd, udev, ep);
+	/* needn't check @ep->hcpriv, xhci_endpoint_disable set it NULL */
+	drop_ep_quirk(hcd, udev, ep);
 
 	return 0;
 }
-- 
2.18.0



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

* [PATCH v2 2/2] usb: xhci-mtk: fix bandwidth release issue
@ 2022-08-05  6:03   ` Chunfeng Yun
  0 siblings, 0 replies; 8+ messages in thread
From: Chunfeng Yun @ 2022-08-05  6:03 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Chunfeng Yun, Mathias Nyman, Matthias Brugger, Ikjoon Jang,
	linux-usb, linux-arm-kernel, linux-mediatek, linux-kernel,
	Eddie Hung

This happens when @udev->reset_resume is set to true, when usb resume,
the flow as below:
  - hub_resume
    - usb_disable_interface
      - usb_disable_endpoint
        - usb_hcd_disable_endpoint
          - xhci_endpoint_disable  // it set @ep->hcpriv to NULL

Then when reset usb device, it will drop allocated endpoints,
the flow as below:
  - usb_reset_and_verify_device
    - usb_hcd_alloc_bandwidth
      - xhci_mtk_drop_ep

but @ep->hcpriv is already set to NULL, the bandwidth will be not
released anymore.

Due to the added endponts are stored in hash table, we can drop the check
of @ep->hcpriv.

Fixes: 4ce186665e7c ("usb: xhci-mtk: Do not use xhci's virt_dev in drop_endpoint")
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v2: add comment
---
 drivers/usb/host/xhci-mtk-sch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c
index a17bc584ee99..579899eb24c1 100644
--- a/drivers/usb/host/xhci-mtk-sch.c
+++ b/drivers/usb/host/xhci-mtk-sch.c
@@ -764,8 +764,8 @@ int xhci_mtk_drop_ep(struct usb_hcd *hcd, struct usb_device *udev,
 	if (ret)
 		return ret;
 
-	if (ep->hcpriv)
-		drop_ep_quirk(hcd, udev, ep);
+	/* needn't check @ep->hcpriv, xhci_endpoint_disable set it NULL */
+	drop_ep_quirk(hcd, udev, ep);
 
 	return 0;
 }
-- 
2.18.0


_______________________________________________
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] 8+ messages in thread

* Re: [PATCH v2 1/2] usb: xhci-mtk: relax TT periodic bandwidth allocation
  2022-08-05  6:03 ` Chunfeng Yun
@ 2022-08-18 17:48   ` Greg Kroah-Hartman
  -1 siblings, 0 replies; 8+ messages in thread
From: Greg Kroah-Hartman @ 2022-08-18 17:48 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: Mathias Nyman, Matthias Brugger, Ikjoon Jang, linux-usb,
	linux-arm-kernel, linux-mediatek, linux-kernel, Eddie Hung

On Fri, Aug 05, 2022 at 02:03:27PM +0800, Chunfeng Yun wrote:
> Currently uses the worst case byte budgets on FS/LS bus bandwidth,
> for example, for an isochronos IN endpoint with 192 bytes budget, it
> will consume the whole 5 uframes(188 * 5) while the actual FS bus
> budget should be just 192 bytes. It cause that many usb audio headsets
> with 3 interfaces (audio input, audio output, and HID) cannot be
> configured.
> To improve it, changes to use "approximate" best case budget for FS/LS
> bandwidth management. For the same endpoint from the above example,
> the approximate best case budget is now reduced to (188 * 2) bytes.
> 
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
> v2: change commit message
> ---
>  drivers/usb/host/xhci-mtk-sch.c | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-mtk-sch.c
>  b/drivers/usb/host/xhci-mtk-sch.c
> index 06a6b19acaae..a17bc584ee99 100644
> --- a/drivers/usb/host/xhci-mtk-sch.c
> +++ b/drivers/usb/host/xhci-mtk-sch.c
> @@ -425,7 +425,6 @@ 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)
>  {
> -	u32 extra_cs_count;
>  	u32 start_ss, last_ss;
>  	u32 start_cs, last_cs;
>  
> @@ -461,18 +460,12 @@ static int check_sch_tt(struct mu3h_sch_ep_info
>  *sch_ep, u32 offset)
>  		if (last_cs > 7)
>  			return -ESCH_CS_OVERFLOW;
>  
> -		if (sch_ep->ep_type == ISOC_IN_EP)
> -			extra_cs_count = (last_cs == 7) ? 1 : 2;
> -		else /*  ep_type : INTR IN / INTR OUT */
> -			extra_cs_count = 1;
> -
> -		cs_count += extra_cs_count;
>  		if (cs_count > 7)
>  			cs_count = 7; /* HW limit */
>  
>  		sch_ep->cs_count = cs_count;
> -		/* one for ss, the other for idle */
> -		sch_ep->num_budget_microframes = cs_count + 2;
> +		/* ss, idle are ignored */
> +		sch_ep->num_budget_microframes = cs_count;
>  
>  		/*
>  		 * if interval=1, maxp >752, num_budge_micoframe is larger
> -- 
> 2.18.0
> 

This doesn't apply to my tree without fuzz, and when I force it, I get a
build error.  Can you please rebase against 6.0-rc1 and resend?

thanks,

greg k-h

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

* Re: [PATCH v2 1/2] usb: xhci-mtk: relax TT periodic bandwidth allocation
@ 2022-08-18 17:48   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 8+ messages in thread
From: Greg Kroah-Hartman @ 2022-08-18 17:48 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: Mathias Nyman, Matthias Brugger, Ikjoon Jang, linux-usb,
	linux-arm-kernel, linux-mediatek, linux-kernel, Eddie Hung

On Fri, Aug 05, 2022 at 02:03:27PM +0800, Chunfeng Yun wrote:
> Currently uses the worst case byte budgets on FS/LS bus bandwidth,
> for example, for an isochronos IN endpoint with 192 bytes budget, it
> will consume the whole 5 uframes(188 * 5) while the actual FS bus
> budget should be just 192 bytes. It cause that many usb audio headsets
> with 3 interfaces (audio input, audio output, and HID) cannot be
> configured.
> To improve it, changes to use "approximate" best case budget for FS/LS
> bandwidth management. For the same endpoint from the above example,
> the approximate best case budget is now reduced to (188 * 2) bytes.
> 
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
> v2: change commit message
> ---
>  drivers/usb/host/xhci-mtk-sch.c | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-mtk-sch.c
>  b/drivers/usb/host/xhci-mtk-sch.c
> index 06a6b19acaae..a17bc584ee99 100644
> --- a/drivers/usb/host/xhci-mtk-sch.c
> +++ b/drivers/usb/host/xhci-mtk-sch.c
> @@ -425,7 +425,6 @@ 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)
>  {
> -	u32 extra_cs_count;
>  	u32 start_ss, last_ss;
>  	u32 start_cs, last_cs;
>  
> @@ -461,18 +460,12 @@ static int check_sch_tt(struct mu3h_sch_ep_info
>  *sch_ep, u32 offset)
>  		if (last_cs > 7)
>  			return -ESCH_CS_OVERFLOW;
>  
> -		if (sch_ep->ep_type == ISOC_IN_EP)
> -			extra_cs_count = (last_cs == 7) ? 1 : 2;
> -		else /*  ep_type : INTR IN / INTR OUT */
> -			extra_cs_count = 1;
> -
> -		cs_count += extra_cs_count;
>  		if (cs_count > 7)
>  			cs_count = 7; /* HW limit */
>  
>  		sch_ep->cs_count = cs_count;
> -		/* one for ss, the other for idle */
> -		sch_ep->num_budget_microframes = cs_count + 2;
> +		/* ss, idle are ignored */
> +		sch_ep->num_budget_microframes = cs_count;
>  
>  		/*
>  		 * if interval=1, maxp >752, num_budge_micoframe is larger
> -- 
> 2.18.0
> 

This doesn't apply to my tree without fuzz, and when I force it, I get a
build error.  Can you please rebase against 6.0-rc1 and resend?

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] 8+ messages in thread

end of thread, other threads:[~2022-08-18 17:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-05  6:03 [PATCH v2 1/2] usb: xhci-mtk: relax TT periodic bandwidth allocation Chunfeng Yun
2022-08-05  6:03 ` Chunfeng Yun
2022-08-05  6:03 ` Chunfeng Yun
2022-08-05  6:03 ` [PATCH v2 2/2] usb: xhci-mtk: fix bandwidth release issue Chunfeng Yun
2022-08-05  6:03   ` Chunfeng Yun
2022-08-05  6:03   ` Chunfeng Yun
2022-08-18 17:48 ` [PATCH v2 1/2] usb: xhci-mtk: relax TT periodic bandwidth allocation Greg Kroah-Hartman
2022-08-18 17:48   ` Greg Kroah-Hartman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.