diff mbox series

[03/17] usb: xhci-mtk: get the microframe boundary for ESIT

Message ID 1614934975-15188-3-git-send-email-chunfeng.yun@mediatek.com (mailing list archive)
State Superseded
Headers show
Series [01/17] usb: xhci-mtk: remove or operator for setting schedule parameters | expand

Commit Message

Chunfeng Yun March 5, 2021, 9:02 a.m. UTC
Tune the boundary for FS/LS ESIT due to CS:
For ISOC out-ep, the controller starts transfer data after
the first SS; for others, the data is already transfered
before the last CS.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 drivers/usb/host/xhci-mtk-sch.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

Comments

Sergey Shtylyov March 5, 2021, 9:13 a.m. UTC | #1
Hello!

On 05.03.2021 12:02, Chunfeng Yun wrote:

> Tune the boundary for FS/LS ESIT due to CS:
> For ISOC out-ep, the controller starts transfer data after
> the first SS; for others, the data is already transfered

    Transferred.

> before the last CS.
> 
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
>   drivers/usb/host/xhci-mtk-sch.c | 24 +++++++++++++++++++-----
>   1 file changed, 19 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c
> index 8950d1f10a7f..e3b18dfca874 100644
> --- a/drivers/usb/host/xhci-mtk-sch.c
> +++ b/drivers/usb/host/xhci-mtk-sch.c
> @@ -513,22 +513,35 @@ static void update_sch_tt(struct usb_device *udev,
>   		list_del(&sch_ep->tt_endpoint);
>   }
>   
> +static u32 get_esit_boundary(struct mu3h_sch_ep_info *sch_ep)
> +{
> +	u32 boundary = sch_ep->esit;
> +
> +	if (sch_ep->sch_tt) { /* LS/FS with TT */
> +		/* tune for CS */
> +		if (sch_ep->ep_type != ISOC_OUT_EP)
> +			boundary += 1;

    Why not:

			boundary++;

> +		else if (boundary > 1) /* normally esit >= 8 for FS/LS */
> +			boundary -= 1;

			boundary--;

[...]

MBR, Sergei
Greg KH March 5, 2021, 9:16 a.m. UTC | #2
On Fri, Mar 05, 2021 at 12:13:33PM +0300, Sergei Shtylyov wrote:
> Hello!
> 
> On 05.03.2021 12:02, Chunfeng Yun wrote:
> 
> > Tune the boundary for FS/LS ESIT due to CS:
> > For ISOC out-ep, the controller starts transfer data after
> > the first SS; for others, the data is already transfered
> 
>    Transferred.
> 
> > before the last CS.
> > 
> > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> > ---
> >   drivers/usb/host/xhci-mtk-sch.c | 24 +++++++++++++++++++-----
> >   1 file changed, 19 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c
> > index 8950d1f10a7f..e3b18dfca874 100644
> > --- a/drivers/usb/host/xhci-mtk-sch.c
> > +++ b/drivers/usb/host/xhci-mtk-sch.c
> > @@ -513,22 +513,35 @@ static void update_sch_tt(struct usb_device *udev,
> >   		list_del(&sch_ep->tt_endpoint);
> >   }
> > +static u32 get_esit_boundary(struct mu3h_sch_ep_info *sch_ep)
> > +{
> > +	u32 boundary = sch_ep->esit;
> > +
> > +	if (sch_ep->sch_tt) { /* LS/FS with TT */
> > +		/* tune for CS */
> > +		if (sch_ep->ep_type != ISOC_OUT_EP)
> > +			boundary += 1;
> 
>    Why not:
> 
> 			boundary++;
> 
> > +		else if (boundary > 1) /* normally esit >= 8 for FS/LS */
> > +			boundary -= 1;
> 
> 			boundary--;

Doesn't matter either way, it's the author's choice.

greg k-h
Chunfeng Yun March 8, 2021, 1:57 a.m. UTC | #3
On Fri, 2021-03-05 at 12:13 +0300, Sergei Shtylyov wrote:
> Hello!
> 
> On 05.03.2021 12:02, Chunfeng Yun wrote:
> 
> > Tune the boundary for FS/LS ESIT due to CS:
> > For ISOC out-ep, the controller starts transfer data after
> > the first SS; for others, the data is already transfered
> 
>     Transferred.
Ok
> 
> > before the last CS.
> > 
> > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> > ---
> >   drivers/usb/host/xhci-mtk-sch.c | 24 +++++++++++++++++++-----
> >   1 file changed, 19 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c
> > index 8950d1f10a7f..e3b18dfca874 100644
> > --- a/drivers/usb/host/xhci-mtk-sch.c
> > +++ b/drivers/usb/host/xhci-mtk-sch.c
> > @@ -513,22 +513,35 @@ static void update_sch_tt(struct usb_device *udev,
> >   		list_del(&sch_ep->tt_endpoint);
> >   }
> >   
> > +static u32 get_esit_boundary(struct mu3h_sch_ep_info *sch_ep)
> > +{
> > +	u32 boundary = sch_ep->esit;
> > +
> > +	if (sch_ep->sch_tt) { /* LS/FS with TT */
> > +		/* tune for CS */
> > +		if (sch_ep->ep_type != ISOC_OUT_EP)
> > +			boundary += 1;
> 
>     Why not:
> 
> 			boundary++;
Forgot it, it's modified from "boundary = sch_ep->esit + 1;"

Thanks
> 
> > +		else if (boundary > 1) /* normally esit >= 8 for FS/LS */
> > +			boundary -= 1;
> 
> 			boundary--;
> 
> [...]
> 
> MBR, Sergei
diff mbox series

Patch

diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c
index 8950d1f10a7f..e3b18dfca874 100644
--- a/drivers/usb/host/xhci-mtk-sch.c
+++ b/drivers/usb/host/xhci-mtk-sch.c
@@ -513,22 +513,35 @@  static void update_sch_tt(struct usb_device *udev,
 		list_del(&sch_ep->tt_endpoint);
 }
 
+static u32 get_esit_boundary(struct mu3h_sch_ep_info *sch_ep)
+{
+	u32 boundary = sch_ep->esit;
+
+	if (sch_ep->sch_tt) { /* LS/FS with TT */
+		/* tune for CS */
+		if (sch_ep->ep_type != ISOC_OUT_EP)
+			boundary += 1;
+		else if (boundary > 1) /* normally esit >= 8 for FS/LS */
+			boundary -= 1;
+	}
+
+	return boundary;
+}
+
 static int check_sch_bw(struct usb_device *udev,
 	struct mu3h_sch_bw_info *sch_bw, struct mu3h_sch_ep_info *sch_ep)
 {
 	u32 offset;
-	u32 esit;
 	u32 min_bw;
 	u32 min_index;
 	u32 worst_bw;
 	u32 bw_boundary;
+	u32 esit_boundary;
 	u32 min_num_budget;
 	u32 min_cs_count;
 	bool tt_offset_ok = false;
 	int ret;
 
-	esit = sch_ep->esit;
-
 	/*
 	 * Search through all possible schedule microframes.
 	 * and find a microframe where its worst bandwidth is minimum.
@@ -537,7 +550,8 @@  static int check_sch_bw(struct usb_device *udev,
 	min_index = 0;
 	min_cs_count = sch_ep->cs_count;
 	min_num_budget = sch_ep->num_budget_microframes;
-	for (offset = 0; offset < esit; offset++) {
+	esit_boundary = get_esit_boundary(sch_ep);
+	for (offset = 0; offset < sch_ep->esit; offset++) {
 		if (is_fs_or_ls(udev->speed)) {
 			ret = check_sch_tt(udev, sch_ep, offset);
 			if (ret)
@@ -546,7 +560,7 @@  static int check_sch_bw(struct usb_device *udev,
 				tt_offset_ok = true;
 		}
 
-		if ((offset + sch_ep->num_budget_microframes) > sch_ep->esit)
+		if ((offset + sch_ep->num_budget_microframes) > esit_boundary)
 			break;
 
 		worst_bw = get_max_bw(sch_bw, sch_ep, offset);