All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: dwc3: gadget: Give some time to schedule isoc
@ 2022-03-08  2:59 Thinh Nguyen
  2022-03-09 23:40 ` Michael Grzeschik
  0 siblings, 1 reply; 2+ messages in thread
From: Thinh Nguyen @ 2022-03-08  2:59 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, linux-usb
  Cc: John Youn, Thinh Nguyen, Michael Grzeschik

Currently the driver will schedule isoc transfers immediately on the
next interval, which is quite aggressive when the interval is 125us.
There's report that some platforms may need more time to process the
transfer, otherwise the controller may miss the first interval. Let's
keep it simple and give the controller at least 500us to schedule the
isoc transfer.

Link: https://lore.kernel.org/linux-usb/20220302143539.GI11577@pengutronix.de/
Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
---
 drivers/usb/dwc3/gadget.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index a0c883f19a41..eb88ef5dd16f 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1830,7 +1830,13 @@ static int __dwc3_gadget_start_isoc(struct dwc3_ep *dep)
 	}
 
 	for (i = 0; i < DWC3_ISOC_MAX_RETRIES; i++) {
-		dep->frame_number = DWC3_ALIGN_FRAME(dep, i + 1);
+		int future_interval = i + 1;
+
+		/* Give the controller at least 500us to schedule transfers */
+		if (desc->bInterval < 3)
+			future_interval += 3 - desc->bInterval;
+
+		dep->frame_number = DWC3_ALIGN_FRAME(dep, future_interval);
 
 		ret = __dwc3_gadget_kick_transfer(dep);
 		if (ret != -EAGAIN)

base-commit: 98d107b84614a1c6b0b8009feae49c5fb0ef4758
-- 
2.28.0


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

* Re: [PATCH] usb: dwc3: gadget: Give some time to schedule isoc
  2022-03-08  2:59 [PATCH] usb: dwc3: gadget: Give some time to schedule isoc Thinh Nguyen
@ 2022-03-09 23:40 ` Michael Grzeschik
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Grzeschik @ 2022-03-09 23:40 UTC (permalink / raw)
  To: Thinh Nguyen; +Cc: Felipe Balbi, Greg Kroah-Hartman, linux-usb, John Youn

[-- Attachment #1: Type: text/plain, Size: 1833 bytes --]

On Mon, Mar 07, 2022 at 06:59:56PM -0800, Thinh Nguyen wrote:
>Currently the driver will schedule isoc transfers immediately on the
>next interval, which is quite aggressive when the interval is 125us.
>There's report that some platforms may need more time to process the
>transfer, otherwise the controller may miss the first interval. Let's
>keep it simple and give the controller at least 500us to schedule the
>isoc transfer.
>
>Link: https://lore.kernel.org/linux-usb/20220302143539.GI11577@pengutronix.de/
>Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>

Tested-by: Michael Grzeschik <m.grzeschik@pengutronix.de>

>---
> drivers/usb/dwc3/gadget.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
>index a0c883f19a41..eb88ef5dd16f 100644
>--- a/drivers/usb/dwc3/gadget.c
>+++ b/drivers/usb/dwc3/gadget.c
>@@ -1830,7 +1830,13 @@ static int __dwc3_gadget_start_isoc(struct dwc3_ep *dep)
> 	}
>
> 	for (i = 0; i < DWC3_ISOC_MAX_RETRIES; i++) {
>-		dep->frame_number = DWC3_ALIGN_FRAME(dep, i + 1);
>+		int future_interval = i + 1;
>+
>+		/* Give the controller at least 500us to schedule transfers */
>+		if (desc->bInterval < 3)
>+			future_interval += 3 - desc->bInterval;
>+
>+		dep->frame_number = DWC3_ALIGN_FRAME(dep, future_interval);
>
> 		ret = __dwc3_gadget_kick_transfer(dep);
> 		if (ret != -EAGAIN)
>
>base-commit: 98d107b84614a1c6b0b8009feae49c5fb0ef4758
>-- 
>2.28.0
>
>

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2022-03-09 23:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-08  2:59 [PATCH] usb: dwc3: gadget: Give some time to schedule isoc Thinh Nguyen
2022-03-09 23:40 ` Michael Grzeschik

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.