Skip to contentSkip to conversation

usb: dwc3: Bug while setting the USB transfer bandwidth on UVC gadget driver

BUG REPORT Chow, Watson 3 participants 10 messages May 14, 2021 – Jun 7, 2021 USB

lore
Share & tools
lore
#0 lore raw

Hi,

I'm using the SoC (Xilinx MPSoC) with DWC3 USB controller. I need to emulate my hardware to work like a USB camera and so make use of the USB UVC gadget driver - g_webcam.

[My problem]

Refer to this link and the driver source code, I find 3 parameters to configure the ISOC transfer bandwidth.
https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/transfer-data-to-isochronous-endpoints#isochronous-transfer-example

They are:

streaming_maxpacket : range [1 - 3072]
streaming_maxburst : range [0 - 15]
streaming_interval : [1 - 16]

So, I load the driver in this way

# modprobe g_webcam streaming_maxpacket=3072 streaming_maxburst=9 streaming_interval=2

Create my own app base on
https://github.com/wlhe/uvc-gadget

Test result
In my evaluation, I can set the combination of parameters up to this. The streaming is ok.

# modprobe g_webcam streaming_maxpacket=3072 streaming_maxburst=9 streaming_interval=2

This should be around 900Mbit/sec. Far less than 5Gbps bandwidth of USB3.0

When I increase the parameter combination to:

# modprobe g_webcam streaming_maxpacket=3072 streaming_maxburst=10 streaming_interval=2

I get the below error message and everything stop.

[ 1089.751559] g_webcam gadget: uvc: VS request completed with status -18.

1. This error is somehow related to the underflow of the transfer queue. Is my understanding correct?
If so, how to solve?
2. My goal is to utilize the full bandwidth of USB3.0. How can I achive?

[Some background information and my test setup]

I started from the Xilinx TRD here.
https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/541786361/Zynq+UltraScale+MPSoC+VCU+TRD+2020.1+-+Xilinx+Low+Latency+PS+DDR+NV12+HDMI+Audio+Video+Capture+and+Display

With kernel version v5.4:
https://github.com/Xilinx/linux-xlnx/tree/xlnx_rebase_v5.4_2020.2

Enabled the UVC gadget and made my own test code to evaluate the transfer throughput on the USB3.0 port.

Test platform:
. Xilinx ZCU106 evaluation board connected to PC through USB3.0 cable
. Xilinx ZCU106 evaluation board would emulate a webcam through USB UVC gadget

My test app:
. Capture 3840x2160@60 video and scale to 1920x1080@60
. Queue the frames to UVC gadget driver
Host PC side:
. X86 PC with Ubuntu 18.04LTS OS
. Use ffplay to capture and display frame from ZCU106

# ffplay /dev/video2 -video_size 1920x1080 -framerate 30

Best regards,

Watson Chow
Design Manager
Avnet Technology Hong Kong Limited

#1 lore raw

Hi Watson,

(please teach your mailer to break lines at 80 columns)

Quoted 5 lines · Watson

Hi,

I'm using the SoC (Xilinx MPSoC) with DWC3 USB controller. I need to emulate my hardware to work like a USB camera and so make use of the USB UVC gadget driver - g_webcam.

which Kernel version are you running?

Quoted 18 lines

Refer to this link and the driver source code, I find 3 parameters to configure the ISOC transfer bandwidth.

https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/transfer-data-to-isochronous-endpoints#isochronous-transfer-example

They are:

streaming_maxpacket : range [1 - 3072]
streaming_maxburst : range [0 - 15]
streaming_interval : [1 - 16]

So, I load the driver in this way

# modprobe g_webcam streaming_maxpacket=3072 streaming_maxburst=9 streaming_interval=2

Create my own app base on
https://github.com/wlhe/uvc-gadget

Quoted 6 lines

Test result

In my evaluation, I can set the combination of parameters up to this. The streaming is ok.

# modprobe g_webcam streaming_maxpacket=3072 streaming_maxburst=9 streaming_interval=2

streaming_maxburst=15 should work here too.

Quoted 2 lines

This should be around 900Mbit/sec. Far less than 5Gbps bandwidth of USB3.0

IIRC Isoc endpoints can't take the full bus bandwidth, I don't remember the exact limit but I think it's 80% of full bandwidth. Still, that should be around 4Gbit/sec

Quoted 9 lines

When I increase the parameter combination to:

# modprobe g_webcam streaming_maxpacket=3072 streaming_maxburst=10 streaming_interval=2

I get the below error message and everything stop.

[ 1089.751559] g_webcam gadget: uvc: VS request completed with status -18.

1. This error is somehow related to the underflow of the transfer queue. Is my understanding correct?

that means the controller lost an isoc interval. There is still discussion going on regarding isoc intervals in dwc3. It turns out the HW doesn't make scheduling super easy for SW :-)

Quoted 11 lines

If so, how to solve?
2. My goal is to utilize the full bandwidth of USB3.0. How can I achive?

[Some background information and my test setup]

I started from the Xilinx TRD here.

https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/541786361/Zynq+UltraScale+MPSoC+VCU+TRD+2020.1+-+Xilinx+Low+Latency+PS+DDR+NV12+HDMI+Audio+Video+Capture+and+Display

With kernel version v5.4:
https://github.com/Xilinx/linux-xlnx/tree/xlnx_rebase_v5.4_2020.2

v5.4 is super old, please test with v5.12 or the latest v5.13-rc. Also, when reporting dwc3 bugs, make sure to include regdump and trace events as described in dwc3 documentation

Signature · 1 line
balbi
#2 lore raw

Balbi,

Thanks for your quick reply.

Some questions

1. You mentioned that the max bandwidth in isoc mode (USB3.0) should be around 4Gbps.

I have the below calcuation on bandwidth:
In USB3.0, 1 micro frame would take 125us and can transfer max 45000 bytes So, in 1 sec, we will have 8000 micro frames

Max bandwidth = 8000 x 4500 x 8 = 2.88Gbps

Is my understanding correct?

2. To achieve the max throughput, I need to configure the uvc gadget driver with below parameters. Am I right?

# modprobe g_webcam streaming_maxpacket=3072 streaming_maxburst=15 
streaming_interval=1

3. You suggest me to try on kernel v5.12 or the latest v5.13-rc. It looks not easy in my side to upgrade the kernel version. It would affect those other device drivers I'm currently using. So, do you think there's any short cut to fix this problem under my current kernel version - v5.4?

4. I read through the procedures to capture debug info by debugfs. However, in my test with "streaming_maxburst" set to 10 or above, my system would crash and I can't pick the log from that point. Any suggestion?

best regards,

Watson

-----Original Message-----
From: Felipe Balbi <[email protected]>
Sent: Friday, May 14, 2021 3:16 PM
To: Chow, Watson <[email protected]>; [email protected]
Subject: Re: [BUG REPORT] usb: dwc3: Bug while setting the USB transfer bandwidth on UVC gadget driver

Hi Watson,

(please teach your mailer to break lines at 80 columns)

Quoted 5 lines · Watson

Hi,

I'm using the SoC (Xilinx MPSoC) with DWC3 USB controller. I need to emulate my hardware to work like a USB camera and so make use of the USB UVC gadget driver - g_webcam.

which Kernel version are you running?

Quoted 19 lines

Refer to this link and the driver source code, I find 3 parameters to configure the ISOC transfer bandwidth.

https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/trans
fer-data-to-isochronous-endpoints#isochronous-transfer-example

They are:

streaming_maxpacket : range [1 - 3072] streaming_maxburst : range [0 - 15] streaming_interval : [1 - 16]

So, I load the driver in this way

# modprobe g_webcam streaming_maxpacket=3072 streaming_maxburst=9 
streaming_interval=2

Create my own app base on
https://github.com/wlhe/uvc-gadget

Quoted 7 lines

Test result

In my evaluation, I can set the combination of parameters up to this. The streaming is ok.

# modprobe g_webcam streaming_maxpacket=3072 streaming_maxburst=9 
streaming_interval=2

streaming_maxburst=15 should work here too.

Quoted 2 lines

This should be around 900Mbit/sec. Far less than 5Gbps bandwidth of USB3.0

IIRC Isoc endpoints can't take the full bus bandwidth, I don't remember the exact limit but I think it's 80% of full bandwidth. Still, that should be around 4Gbit/sec

Quoted 10 lines

When I increase the parameter combination to:

# modprobe g_webcam streaming_maxpacket=3072 streaming_maxburst=10 
streaming_interval=2

I get the below error message and everything stop.

[ 1089.751559] g_webcam gadget: uvc: VS request completed with status -18.

1. This error is somehow related to the underflow of the transfer queue. Is my understanding correct?

that means the controller lost an isoc interval. There is still discussion going on regarding isoc intervals in dwc3. It turns out the HW doesn't make scheduling super easy for SW :-)

Quoted 5 lines

If so, how to solve?
2. My goal is to utilize the full bandwidth of USB3.0. How can I achive?

[Some background information and my test setup]

Quoted 8 lines

I started from the Xilinx TRD here.

https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/541786361/Zynq+U
ltraScale+MPSoC+VCU+TRD+2020.1+-+Xilinx+Low+Latency+PS+DDR+NV12+HDMI+A udio+Video+Capture+and+Display

With kernel version v5.4:
https://github.com/Xilinx/linux-xlnx/tree/xlnx_rebase_v5.4_2020.2

v5.4 is super old, please test with v5.12 or the latest v5.13-rc. Also, when reporting dwc3 bugs, make sure to include regdump and trace events as described in dwc3 documentation

--
balbi

#3 lore raw

Hi,

(please don't top-post :-)

Quoted 9 lines · Watson

Balbi,

Thanks for your quick reply.

Some questions

1. You mentioned that the max bandwidth in isoc mode (USB3.0) should be around 4Gbps.

Quoted 7 lines

I have the below calcuation on bandwidth:
In USB3.0, 1 micro frame would take 125us and can transfer max 45000 bytes So, in 1 sec, we will have 8000 micro frames

Max bandwidth = 8000 x 4500 x 8 = 2.88Gbps

Is my understanding correct?

probably, It's been a while since I've dug through the spec, to be frank

Quoted 5 lines

2. To achieve the max throughput, I need to configure the uvc gadget driver with below parameters. Am I right?

# modprobe g_webcam streaming_maxpacket=3072 streaming_maxburst=15 
streaming_interval=1

right, but there's an assumption here that the gadget will be able to feed data in a timely manner.

Quoted 4 lines

3. You suggest me to try on kernel v5.12 or the latest v5.13-rc. It looks not easy in my side to upgrade the kernel version. It would affect those other device drivers I'm currently using. So, do you think there's any short cut to fix this problem under my current kernel version - v5.4?

In that case, you need to ask for support from whoever forces you to stay with such an old kernel. I believe that would be Xilinx.

Quoted 3 lines

4. I read through the procedures to capture debug info by debugfs. However, in my test with "streaming_maxburst" set to 10 or above, my system would crash and I can't pick the log from that point. Any suggestion?

have a look at ftrace_dump_on_oops.

Signature · 1 line
balbi
#4 lore raw

Hi,

Quoted 3 lines

Hi,

(please don't top-post :-)

I have tried my best to meet the format requirement

Quoted 21 lines
Quoted 9 lines · Watson

Balbi,

Thanks for your quick reply.

Some questions

1. You mentioned that the max bandwidth in isoc mode (USB3.0) should be around 4Gbps.

Quoted 7 lines

I have the below calcuation on bandwidth:
In USB3.0, 1 micro frame would take 125us and can transfer max 45000 bytes So, in 1 sec, we will have 8000 micro frames

Max bandwidth = 8000 x 4500 x 8 = 2.88Gbps

Is my understanding correct?

probably, It's been a while since I've dug through the spec, to be frank

Quoted 8 lines
Quoted 5 lines

2. To achieve the max throughput, I need to configure the uvc gadget driver with below parameters. Am I right?

# modprobe g_webcam streaming_maxpacket=3072 streaming_maxburst=15 
streaming_interval=1

right, but there's an assumption here that the gadget will be able to feed data in a timely manner.

How does the DWC3 driver or the gadget driver handle the case with intermittent drop of the input video streaming?

Any recover mechanism?

Quoted 8 lines
Quoted 5 lines

3. You suggest me to try on kernel v5.12 or the latest v5.13-rc. It looks not easy in my side to upgrade the kernel version. It would affect those other device drivers I'm currently using. So, do you think there's any short cut to fix this problem under my current kernel version - v5.4?

In that case, you need to ask for support from whoever forces you to stay with such an old kernel. I believe that would be Xilinx.

I have a thought to back port those changes around the dwc3 and gadget driver from the latest kernel version to my kernel (v5.4). Do you think this is feasible?

Quoted 6 lines
Quoted 4 lines

4. I read through the procedures to capture debug info by debugfs. However, in my test with "streaming_maxburst" set to 10 or above, my system would crash and I can't pick the log from that point. Any suggestion?

have a look at ftrace_dump_on_oops.

I will explore how to enable this

Quoted 1 line

Btw, do you know which SoC platform can run the UVC gadget in max throughput. Raspberry Pi/TI Beaglebone/i.MX ???

best regards,

Watson
-----Original Message-----
From: Felipe Balbi <[email protected]>
Sent: Friday, May 14, 2021 6:32 PM
To: Chow, Watson <[email protected]>; [email protected]
Subject: RE: [BUG REPORT] usb: dwc3: Bug while setting the USB transfer bandwidth on UVC gadget driver

Hi,

(please don't top-post :-)

Quoted 9 lines · Watson

Balbi,

Thanks for your quick reply.

Some questions

1. You mentioned that the max bandwidth in isoc mode (USB3.0) should be around 4Gbps.

Quoted 7 lines

I have the below calcuation on bandwidth:
In USB3.0, 1 micro frame would take 125us and can transfer max 45000 bytes So, in 1 sec, we will have 8000 micro frames

Max bandwidth = 8000 x 4500 x 8 = 2.88Gbps

Is my understanding correct?

probably, It's been a while since I've dug through the spec, to be frank

Quoted 5 lines

2. To achieve the max throughput, I need to configure the uvc gadget driver with below parameters. Am I right?

# modprobe g_webcam streaming_maxpacket=3072 streaming_maxburst=15 
streaming_interval=1

right, but there's an assumption here that the gadget will be able to feed data in a timely manner.

Quoted 4 lines

3. You suggest me to try on kernel v5.12 or the latest v5.13-rc. It looks not easy in my side to upgrade the kernel version. It would affect those other device drivers I'm currently using. So, do you think there's any short cut to fix this problem under my current kernel version - v5.4?

In that case, you need to ask for support from whoever forces you to stay with such an old kernel. I believe that would be Xilinx.

Quoted 3 lines

4. I read through the procedures to capture debug info by debugfs. However, in my test with "streaming_maxburst" set to 10 or above, my system would crash and I can't pick the log from that point. Any suggestion?

have a look at ftrace_dump_on_oops.

Signature · 1 line
balbi
#5 lore raw

Hi,

Quoted 6 lines · Watson

Hi,

Quoted 3 lines

Hi,

(please don't top-post :-)

I have tried my best to meet the format requirement

Thanks

Quoted 26 lines
Quoted 26 lines
Quoted 9 lines · Watson

Balbi,

Thanks for your quick reply.

Some questions

1. You mentioned that the max bandwidth in isoc mode (USB3.0) should be around 4Gbps.

Quoted 7 lines

I have the below calcuation on bandwidth:
In USB3.0, 1 micro frame would take 125us and can transfer max 45000 bytes So, in 1 sec, we will have 8000 micro frames

Max bandwidth = 8000 x 4500 x 8 = 2.88Gbps

Is my understanding correct?

probably, It's been a while since I've dug through the spec, to be frank

Quoted 5 lines

2. To achieve the max throughput, I need to configure the uvc gadget driver with below parameters. Am I right?

# modprobe g_webcam streaming_maxpacket=3072 streaming_maxburst=15 
streaming_interval=1
Quoted 7 lines
Quoted 2 lines

right, but there's an assumption here that the gadget will be able to feed data in a timely manner.

How does the DWC3 driver or the gadget driver handle the case with intermittent drop of the input video streaming?

Any recover mechanism?

yeah, the missed ISOC is reported to the gadget driver and that has to queue new requests.

Quoted 11 lines
Quoted 7 lines
Quoted 4 lines

3. You suggest me to try on kernel v5.12 or the latest v5.13-rc. It looks not easy in my side to upgrade the kernel version. It would affect those other device drivers I'm currently using. So, do you think there's any short cut to fix this problem under my current kernel version - v5.4?

In that case, you need to ask for support from whoever forces you to stay with such an old kernel. I believe that would be Xilinx.

I have a thought to back port those changes around the dwc3 and gadget driver from the latest kernel version to my kernel (v5.4). Do you think this is feasible?

should be, but it's likely quite a bit of work:

$ git rev-list --count v5.4..linus/master -- drivers/usb/dwc3/
257
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

4. I read through the procedures to capture debug info by debugfs. However, in my test with "streaming_maxburst" set to 10 or above, my system would crash and I can't pick the log from that point. Any suggestion?

Quoted 8 lines
Quoted 1 line

have a look at ftrace_dump_on_oops.

I will explore how to enable this

Quoted 1 line

Btw, do you know which SoC platform can run the UVC gadget in max throughput. Raspberry Pi/TI Beaglebone/i.MX ???

Raspberry Pi uses dwc2
Beaglebone uses musb
i.MX, I think some of them use dwc3 at least.

Signature · 1 line
balbi
#6 lore raw

Balbi,

Quoted 57 lines

Hi,

Quoted 6 lines · Watson

Hi,

Quoted 3 lines

Hi,

(please don't top-post :-)

I have tried my best to meet the format requirement

Thanks

Quoted 26 lines
Quoted 26 lines
Quoted 9 lines · Watson

Balbi,

Thanks for your quick reply.

Some questions

1. You mentioned that the max bandwidth in isoc mode (USB3.0) should be around 4Gbps.

Quoted 7 lines

I have the below calcuation on bandwidth:
In USB3.0, 1 micro frame would take 125us and can transfer max 45000 bytes So, in 1 sec, we will have 8000 micro frames

Max bandwidth = 8000 x 4500 x 8 = 2.88Gbps

Is my understanding correct?

probably, It's been a while since I've dug through the spec, to be frank

Quoted 5 lines

2. To achieve the max throughput, I need to configure the uvc gadget driver with below parameters. Am I right?

# modprobe g_webcam streaming_maxpacket=3072 streaming_maxburst=15 
streaming_interval=1
Quoted 7 lines
Quoted 2 lines

right, but there's an assumption here that the gadget will be able to feed data in a timely manner.

How does the DWC3 driver or the gadget driver handle the case with intermittent drop of the input video streaming?

Any recover mechanism?

yeah, the missed ISOC is reported to the gadget driver and that has to queue new requests.

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

3. You suggest me to try on kernel v5.12 or the latest v5.13-rc. It looks not easy in my side to upgrade the kernel version. It would affect those other device drivers I'm currently using. So, do you think there's any short cut to fix this problem under my current kernel version - v5.4?

In that case, you need to ask for support from whoever forces you to stay with such an old kernel. I believe that would be Xilinx.

Quoted 9 lines
Quoted 3 lines

I have a thought to back port those changes around the dwc3 and gadget driver from the latest kernel version to my kernel (v5.4). Do you think this is feasible?

should be, but it's likely quite a bit of work:

$ git rev-list --count v5.4..linus/master -- drivers/usb/dwc3/
257

Upgraded the kernel version to 5.9, I can set the g_webcam module pararmeters as follow (for max bandwidth):

streaming_maxpacket=3072
streaming_maxburst=15
streaming_interval=1

Data transfer with above setting is working now - tested with dummy data generator in the uvc-gadget app.

This concludes that kernel 5.4 is too old for DWC3 and UVC gadget driver in high bandwidth usage

Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 3 lines

4. I read through the procedures to capture debug info by debugfs. However, in my test with "streaming_maxburst" set to 10 or above, my system would crash and I can't pick the log from that point. Any suggestion?

have a look at ftrace_dump_on_oops.

I will explore how to enable this

Quoted 1 line
Quoted 7 lines
Quoted 2 lines

Btw, do you know which SoC platform can run the UVC gadget in max throughput. Raspberry Pi/TI Beaglebone/i.MX ???

Raspberry Pi uses dwc2
Beaglebone uses musb
i.MX, I think some of them use dwc3 at least.

Watson

-----Original Message-----
From: Felipe Balbi <[email protected]>
Sent: Monday, May 17, 2021 1:32 PM
To: Chow, Watson <[email protected]>; [email protected]
Subject: RE: [BUG REPORT] usb: dwc3: Bug while setting the USB transfer bandwidth on UVC gadget driver

Hi,

Quoted 6 lines · Watson

Hi,

Quoted 3 lines

Hi,

(please don't top-post :-)

I have tried my best to meet the format requirement

Thanks

Quoted 26 lines
Quoted 26 lines
Quoted 9 lines · Watson

Balbi,

Thanks for your quick reply.

Some questions

1. You mentioned that the max bandwidth in isoc mode (USB3.0) should be around 4Gbps.

Quoted 7 lines

I have the below calcuation on bandwidth:
In USB3.0, 1 micro frame would take 125us and can transfer max 45000 bytes So, in 1 sec, we will have 8000 micro frames

Max bandwidth = 8000 x 4500 x 8 = 2.88Gbps

Is my understanding correct?

probably, It's been a while since I've dug through the spec, to be frank

Quoted 5 lines

2. To achieve the max throughput, I need to configure the uvc gadget driver with below parameters. Am I right?

# modprobe g_webcam streaming_maxpacket=3072 streaming_maxburst=15 
streaming_interval=1
Quoted 7 lines
Quoted 2 lines

right, but there's an assumption here that the gadget will be able to feed data in a timely manner.

How does the DWC3 driver or the gadget driver handle the case with intermittent drop of the input video streaming?

Any recover mechanism?

yeah, the missed ISOC is reported to the gadget driver and that has to queue new requests.

Quoted 11 lines
Quoted 7 lines
Quoted 4 lines

3. You suggest me to try on kernel v5.12 or the latest v5.13-rc. It looks not easy in my side to upgrade the kernel version. It would affect those other device drivers I'm currently using. So, do you think there's any short cut to fix this problem under my current kernel version - v5.4?

In that case, you need to ask for support from whoever forces you to stay with such an old kernel. I believe that would be Xilinx.

I have a thought to back port those changes around the dwc3 and gadget driver from the latest kernel version to my kernel (v5.4). Do you think this is feasible?

should be, but it's likely quite a bit of work:

$ git rev-list --count v5.4..linus/master -- drivers/usb/dwc3/
257
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

4. I read through the procedures to capture debug info by debugfs. However, in my test with "streaming_maxburst" set to 10 or above, my system would crash and I can't pick the log from that point. Any suggestion?

Quoted 8 lines
Quoted 1 line

have a look at ftrace_dump_on_oops.

I will explore how to enable this

Quoted 1 line

Btw, do you know which SoC platform can run the UVC gadget in max throughput. Raspberry Pi/TI Beaglebone/i.MX ???

Raspberry Pi uses dwc2
Beaglebone uses musb
i.MX, I think some of them use dwc3 at least.

Signature · 1 line
balbi
#7 lore raw

Hi,

Quoted 25 lines · Watson
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

3. You suggest me to try on kernel v5.12 or the latest v5.13-rc. It looks not easy in my side to upgrade the kernel version. It would affect those other device drivers I'm currently using. So, do you think there's any short cut to fix this problem under my current kernel version - v5.4?

In that case, you need to ask for support from whoever forces you to stay with such an old kernel. I believe that would be Xilinx.

Quoted 9 lines
Quoted 3 lines

I have a thought to back port those changes around the dwc3 and gadget driver from the latest kernel version to my kernel (v5.4). Do you think this is feasible?

should be, but it's likely quite a bit of work:

$ git rev-list --count v5.4..linus/master -- drivers/usb/dwc3/
257

Upgraded the kernel version to 5.9, I can set the g_webcam module pararmeters as follow (for max bandwidth):

streaming_maxpacket=3072
streaming_maxburst=15
streaming_interval=1

Quoted 5 lines

Data transfer with above setting is working now - tested with dummy data generator in the uvc-gadget app.

This concludes that kernel 5.4 is too old for DWC3 and UVC gadget driver in high bandwidth usage

Cool, thanks for letting me know :-)

Signature · 1 line
balbi
#8 lore raw
In reply to Chow, Watson
Quoted 7 lines · Watson

Upgraded the kernel version to 5.9, I can set the g_webcam module pararmeters as follow (for max bandwidth):

streaming_maxpacket=3072
streaming_maxburst=15
streaming_interval=1

According the spec:
Maximum number of packet within one SoF:
(bMaxBurst + 1) * (Mult + 1) = (15  + 1) * (2 + 1)= 48
Maximum bandwidth = 48 * 1024 * 8 (B/bit) * 8 (125us/1ms) = 3.072Gbps USB 3.0 is 8/10b coding, the theory maximum bandwidth is 5 * 0.8 = 4.096Gbps So, your setting tells host that your have the capabilities to get the maximum bandwidth,but you may can't get it due to the FIFO depth for endpoint and system bus latency.

Peter

Quoted 120 lines

Data transfer with above setting is working now - tested with dummy data generator in the uvc-gadget app.

This concludes that kernel 5.4 is too old for DWC3 and UVC gadget driver in high bandwidth usage

Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 3 lines

4. I read through the procedures to capture debug info by debugfs. However, in my test with "streaming_maxburst" set to 10 or above, my system would crash and I can't pick the log from that point. Any suggestion?

have a look at ftrace_dump_on_oops.

I will explore how to enable this

Quoted 1 line
Quoted 7 lines
Quoted 2 lines

Btw, do you know which SoC platform can run the UVC gadget in max throughput. Raspberry Pi/TI Beaglebone/i.MX ???

Raspberry Pi uses dwc2
Beaglebone uses musb
i.MX, I think some of them use dwc3 at least.

Watson

-----Original Message-----
From: Felipe Balbi <[email protected]>
Sent: Monday, May 17, 2021 1:32 PM
To: Chow, Watson <[email protected]>; [email protected]
Subject: RE: [BUG REPORT] usb: dwc3: Bug while setting the USB transfer bandwidth on UVC gadget driver

Hi,

Quoted 6 lines · Watson

Hi,

Quoted 3 lines

Hi,

(please don't top-post :-)

I have tried my best to meet the format requirement

Thanks

Quoted 26 lines
Quoted 26 lines
Quoted 9 lines · Watson

Balbi,

Thanks for your quick reply.

Some questions

1. You mentioned that the max bandwidth in isoc mode (USB3.0) should be around 4Gbps.

Quoted 7 lines

I have the below calcuation on bandwidth:
In USB3.0, 1 micro frame would take 125us and can transfer max 45000 bytes So, in 1 sec, we will have 8000 micro frames

Max bandwidth = 8000 x 4500 x 8 = 2.88Gbps

Is my understanding correct?

probably, It's been a while since I've dug through the spec, to be frank

Quoted 5 lines

2. To achieve the max throughput, I need to configure the uvc gadget driver with below parameters. Am I right?

# modprobe g_webcam streaming_maxpacket=3072 streaming_maxburst=15 
streaming_interval=1
Quoted 7 lines
Quoted 2 lines

right, but there's an assumption here that the gadget will be able to feed data in a timely manner.

How does the DWC3 driver or the gadget driver handle the case with intermittent drop of the input video streaming?

Any recover mechanism?

yeah, the missed ISOC is reported to the gadget driver and that has to queue new requests.

Quoted 11 lines
Quoted 7 lines
Quoted 4 lines

3. You suggest me to try on kernel v5.12 or the latest v5.13-rc. It looks not easy in my side to upgrade the kernel version. It would affect those other device drivers I'm currently using. So, do you think there's any short cut to fix this problem under my current kernel version - v5.4?

In that case, you need to ask for support from whoever forces you to stay with such an old kernel. I believe that would be Xilinx.

I have a thought to back port those changes around the dwc3 and gadget driver from the latest kernel version to my kernel (v5.4). Do you think this is feasible?

should be, but it's likely quite a bit of work:

$ git rev-list --count v5.4..linus/master -- drivers/usb/dwc3/
257
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

4. I read through the procedures to capture debug info by debugfs. However, in my test with "streaming_maxburst" set to 10 or above, my system would crash and I can't pick the log from that point. Any suggestion?

Quoted 8 lines
Quoted 1 line

have a look at ftrace_dump_on_oops.

I will explore how to enable this

Quoted 1 line

Btw, do you know which SoC platform can run the UVC gadget in max throughput. Raspberry Pi/TI Beaglebone/i.MX ???

Raspberry Pi uses dwc2
Beaglebone uses musb
i.MX, I think some of them use dwc3 at least.

Signature · 1 line
balbi
Signature · 2 lines
Thanks,
Peter Chen
#9 lore raw

Peter,

Quoted 9 lines · Watson
Quoted 7 lines

Upgraded the kernel version to 5.9, I can set the g_webcam module pararmeters as follow (for max bandwidth):

streaming_maxpacket=3072
streaming_maxburst=15
streaming_interval=1

Quoted 8 lines

According the spec:
Maximum number of packet within one SoF:
(bMaxBurst + 1) * (Mult + 1) = (15 + 1) * (2 + 1)= 48
Maximum bandwidth = 48 * 1024 * 8 (B/bit) * 8 (125us/1ms) = 3.072Gbps USB 3.0 is 8/10b coding, the theory maximum bandwidth is 5 * 0.8 = 4.096Gbps So, your setting tells host that your have the capabilities to get the maximum bandwidth,but you may can't get it due to the FIFO depth for endpoint and system bus latency.

This aligns with my thought. Thx!

Quoted 117 lines

Peter

Quoted 114 lines

Data transfer with above setting is working now - tested with dummy data generator in the uvc-gadget app.

This concludes that kernel 5.4 is too old for DWC3 and UVC gadget driver in high bandwidth usage

Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 3 lines

4. I read through the procedures to capture debug info by debugfs. However, in my test with "streaming_maxburst" set to 10 or above, my system would crash and I can't pick the log from that point. Any suggestion?

have a look at ftrace_dump_on_oops.

I will explore how to enable this

Quoted 1 line
Quoted 7 lines
Quoted 2 lines

Btw, do you know which SoC platform can run the UVC gadget in max throughput. Raspberry Pi/TI Beaglebone/i.MX ???

Raspberry Pi uses dwc2
Beaglebone uses musb
i.MX, I think some of them use dwc3 at least.

Watson

-----Original Message-----
From: Felipe Balbi <[email protected]>
Sent: Monday, May 17, 2021 1:32 PM
To: Chow, Watson <[email protected]>; [email protected]
Subject: RE: [BUG REPORT] usb: dwc3: Bug while setting the USB transfer bandwidth on UVC gadget driver

Hi,

Quoted 6 lines · Watson

Hi,

Quoted 3 lines

Hi,

(please don't top-post :-)

I have tried my best to meet the format requirement

Thanks

Quoted 26 lines
Quoted 26 lines
Quoted 9 lines · Watson

Balbi,

Thanks for your quick reply.

Some questions

1. You mentioned that the max bandwidth in isoc mode (USB3.0) should be around 4Gbps.

Quoted 7 lines

I have the below calcuation on bandwidth:
In USB3.0, 1 micro frame would take 125us and can transfer max 45000 bytes So, in 1 sec, we will have 8000 micro frames

Max bandwidth = 8000 x 4500 x 8 = 2.88Gbps

Is my understanding correct?

probably, It's been a while since I've dug through the spec, to be frank

Quoted 5 lines

2. To achieve the max throughput, I need to configure the uvc gadget driver with below parameters. Am I right?

# modprobe g_webcam streaming_maxpacket=3072 streaming_maxburst=15 
streaming_interval=1
Quoted 7 lines
Quoted 2 lines

right, but there's an assumption here that the gadget will be able to feed data in a timely manner.

How does the DWC3 driver or the gadget driver handle the case with intermittent drop of the input video streaming?

Any recover mechanism?

yeah, the missed ISOC is reported to the gadget driver and that has to queue new requests.

Quoted 11 lines
Quoted 7 lines
Quoted 4 lines

3. You suggest me to try on kernel v5.12 or the latest v5.13-rc. It looks not easy in my side to upgrade the kernel version. It would affect those other device drivers I'm currently using. So, do you think there's any short cut to fix this problem under my current kernel version - v5.4?

In that case, you need to ask for support from whoever forces you to stay with such an old kernel. I believe that would be Xilinx.

I have a thought to back port those changes around the dwc3 and gadget driver from the latest kernel version to my kernel (v5.4). Do you think this is feasible?

should be, but it's likely quite a bit of work:

$ git rev-list --count v5.4..linus/master -- drivers/usb/dwc3/
257
Quoted 12 lines
Quoted 5 lines
Quoted 3 lines

4. I read through the procedures to capture debug info by debugfs. However, in my test with "streaming_maxburst" set to 10 or above, my system would crash and I can't pick the log from that point. Any suggestion?

have a look at ftrace_dump_on_oops.

I will explore how to enable this

Quoted 1 line

Btw, do you know which SoC platform can run the UVC gadget in max throughput. Raspberry Pi/TI Beaglebone/i.MX ???

Quoted 12 lines
Quoted 6 lines

Raspberry Pi uses dwc2
Beaglebone uses musb
i.MX, I think some of them use dwc3 at least.

Signature · 1 line
balbi
Signature · 2 lines
Thanks,
Peter Chen

Watson Chow

-----Original Message-----
From: Peter Chen <[email protected]>
Sent: Monday, June 7, 2021 2:11 PM
To: Chow, Watson <[email protected]>
Cc: Felipe Balbi <[email protected]>; [email protected]
Subject: Re: [BUG REPORT] usb: dwc3: Bug while setting the USB transfer bandwidth on UVC gadget driver

Quoted 7 lines · Watson

Upgraded the kernel version to 5.9, I can set the g_webcam module pararmeters as follow (for max bandwidth):

streaming_maxpacket=3072
streaming_maxburst=15
streaming_interval=1

According the spec:
Maximum number of packet within one SoF:
(bMaxBurst + 1) * (Mult + 1) = (15  + 1) * (2 + 1)= 48
Maximum bandwidth = 48 * 1024 * 8 (B/bit) * 8 (125us/1ms) = 3.072Gbps USB 3.0 is 8/10b coding, the theory maximum bandwidth is 5 * 0.8 = 4.096Gbps So, your setting tells host that your have the capabilities to get the maximum bandwidth,but you may can't get it due to the FIFO depth for endpoint and system bus latency.

Peter

Quoted 120 lines

Data transfer with above setting is working now - tested with dummy data generator in the uvc-gadget app.

This concludes that kernel 5.4 is too old for DWC3 and UVC gadget driver in high bandwidth usage

Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 3 lines

4. I read through the procedures to capture debug info by debugfs. However, in my test with "streaming_maxburst" set to 10 or above, my system would crash and I can't pick the log from that point. Any suggestion?

have a look at ftrace_dump_on_oops.

I will explore how to enable this

Quoted 1 line
Quoted 7 lines
Quoted 2 lines

Btw, do you know which SoC platform can run the UVC gadget in max throughput. Raspberry Pi/TI Beaglebone/i.MX ???

Raspberry Pi uses dwc2
Beaglebone uses musb
i.MX, I think some of them use dwc3 at least.

Watson

-----Original Message-----
From: Felipe Balbi <[email protected]>
Sent: Monday, May 17, 2021 1:32 PM
To: Chow, Watson <[email protected]>; [email protected]
Subject: RE: [BUG REPORT] usb: dwc3: Bug while setting the USB transfer bandwidth on UVC gadget driver

Hi,

Quoted 6 lines · Watson

Hi,

Quoted 3 lines

Hi,

(please don't top-post :-)

I have tried my best to meet the format requirement

Thanks

Quoted 26 lines
Quoted 26 lines
Quoted 9 lines · Watson

Balbi,

Thanks for your quick reply.

Some questions

1. You mentioned that the max bandwidth in isoc mode (USB3.0) should be around 4Gbps.

Quoted 7 lines

I have the below calcuation on bandwidth:
In USB3.0, 1 micro frame would take 125us and can transfer max 45000 bytes So, in 1 sec, we will have 8000 micro frames

Max bandwidth = 8000 x 4500 x 8 = 2.88Gbps

Is my understanding correct?

probably, It's been a while since I've dug through the spec, to be frank

Quoted 5 lines

2. To achieve the max throughput, I need to configure the uvc gadget driver with below parameters. Am I right?

# modprobe g_webcam streaming_maxpacket=3072 streaming_maxburst=15 
streaming_interval=1
Quoted 7 lines
Quoted 2 lines

right, but there's an assumption here that the gadget will be able to feed data in a timely manner.

How does the DWC3 driver or the gadget driver handle the case with intermittent drop of the input video streaming?

Any recover mechanism?

yeah, the missed ISOC is reported to the gadget driver and that has to queue new requests.

Quoted 11 lines
Quoted 7 lines
Quoted 4 lines

3. You suggest me to try on kernel v5.12 or the latest v5.13-rc. It looks not easy in my side to upgrade the kernel version. It would affect those other device drivers I'm currently using. So, do you think there's any short cut to fix this problem under my current kernel version - v5.4?

In that case, you need to ask for support from whoever forces you to stay with such an old kernel. I believe that would be Xilinx.

I have a thought to back port those changes around the dwc3 and gadget driver from the latest kernel version to my kernel (v5.4). Do you think this is feasible?

should be, but it's likely quite a bit of work:

$ git rev-list --count v5.4..linus/master -- drivers/usb/dwc3/
257
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

4. I read through the procedures to capture debug info by debugfs. However, in my test with "streaming_maxburst" set to 10 or above, my system would crash and I can't pick the log from that point. Any suggestion?

Quoted 8 lines
Quoted 1 line

have a look at ftrace_dump_on_oops.

I will explore how to enable this

Quoted 1 line

Btw, do you know which SoC platform can run the UVC gadget in max throughput. Raspberry Pi/TI Beaglebone/i.MX ???

Raspberry Pi uses dwc2
Beaglebone uses musb
i.MX, I think some of them use dwc3 at least.

Signature · 1 line
balbi
Signature · 2 lines
Thanks,
Peter Chen