cancel
Showing results for 
Search instead for 
Did you mean: 

USB Superspeed Peripherals

juhu_4653696
New Contributor

Hi,

Last time I change cypress bulk to isochronous mode.  Detail refer to  https://community.cypress.com/t5/USB-Superspeed-Peripherals/how-to-change-bulk-to-isochronous-mode-i...

I find ubuntu16.04 + cypress(Isochronous ) can only open single camera. if open multiple cameras simultaneously, the first camera works well, but next camera will report "VIDIOC_STREAMON failed 28, No space left on device."

kernlog shows:

Apr 20 12:31:52 ecu kernel: [66731.190810] usb 10-3: Not enough bandwidth for new device state.
Apr 20 12:31:52 ecu kernel: [66731.190831] usb 10-3: Not enough bandwidth for altsetting 1

Is the cypress code needs some changes for bandwitdth setting?

Could you help to check the attach file and help to fix it ?

Appreciate for your help!

Jun

0 Likes
1 Solution
Rashi_Vatsa
Moderator
Moderator

Hello Jun,

Please note that the periodic endpoints (like interrupt/isochronous) can be allocated up to 80% of the total available bandwidth on SuperSpeed. 

Please refer to this link with the explanation. As mentioned by you the bandwidth requirement from the USB descriptors is ~ 0.9Gbps and the video bandwidth is ~ 0.7Gbps (which not big difference). To use only  ~0.7Gbps (video bandwidth) bandwidth you can try using UVC_QUIRK_FIX_BANDWIDTH - which will try to estimate the bandwidth required for uncompressed streams instead on relying on the value reported by the camera.

If the host controller allocated bandwidth is not enough for the 3 cameras to stream simultaneously with the video resolution you mentioned then workarounds  mentioned here can be followed

Regards,
Rashi

View solution in original post

0 Likes
24 Replies
juhu_4653696
New Contributor

Apr 21 19:01:27 ecu kernel: [176505.200808] uvcvideo: Device requested 46080 B/frame bandwidth.
Apr 21 19:01:27 ecu kernel: [176505.200811] uvcvideo: Selecting alternate setting 1 (46080 B/frame bandwidth).
Apr 21 19:01:27 ecu kernel: [176505.200812] uvcvideo: Device requested 46080 B/frame bandwidth.
Apr 21 19:01:27 ecu kernel: [176505.200814] uvcvideo: Selecting alternate setting 1 (46080 B/frame bandwidth).
Apr 21 19:01:27 ecu kernel: [176505.200860] xhci_hcd 0000:49:00.0: add ep 0x83, slot id 3, new drop flags = 0x0, new add flags = 0x81
Apr 21 19:01:27 ecu kernel: [176505.200864] xhci_hcd 0000:49:00.0: xhci_check_bandwidth called for udev 00000000dfb1a7cc
Apr 21 19:01:27 ecu kernel: [176505.200876] xhci_hcd 0000:49:00.0: // Ding dong!
Apr 21 19:01:27 ecu kernel: [176505.201309] xhci_hcd 0000:49:00.0: Successful Endpoint Configure command
Apr 21 19:01:27 ecu kernel: [176505.201469] xhci_hcd 0000:49:00.0: add ep 0x83, slot id 2, new drop flags = 0x0, new add flags = 0x81
Apr 21 19:01:27 ecu kernel: [176505.201473] xhci_hcd 0000:49:00.0: xhci_check_bandwidth called for udev 000000004bbf2dcd
Apr 21 19:01:27 ecu kernel: [176505.201483] xhci_hcd 0000:49:00.0: // Ding dong!
Apr 21 19:01:27 ecu kernel: [176505.201542] usb 10-2: Not enough bandwidth for new device state.
Apr 21 19:01:27 ecu kernel: [176505.201547] xhci_hcd 0000:49:00.0: xhci_reset_bandwidth called for udev 000000004bbf2dcd
Apr 21 19:01:27 ecu kernel: [176505.201620] usb 10-2: Not enough bandwidth for altsetting 1
Apr 21 19:01:27 ecu kernel: [176505.201625] xhci_hcd 0000:49:00.0: xhci_check_bandwidth called for udev 000000004bbf2dcd
Apr 21 19:01:27 ecu kernel: [176505.330084] xhci_hcd 0000:49:00.0: xhci_hub_status_data: stopping port polling.
Apr 21 19:01:27 ecu kernel: [176505.687380] uvcvideo: Allocated 64 URB buffers of 8x46080 bytes each.
Apr 21 19:01:27 ecu kernel: [176505.687615] xhci_hcd 0000:49:00.0: ERROR no room on ep ring, try ring expansion
Apr 21 19:01:27 ecu kernel: [176505.687629] xhci_hcd 0000:49:00.0: ring expansion succeed, now has 4 segments
Apr 21 19:01:27 ecu kernel: [176505.693968] uvcvideo: uvc_v4l2_poll
Apr 21 19:01:27 ecu kernel: [176505.702398] xhci_hcd 0000:49:00.0: ERROR no room on ep ring, try ring expansion
Apr 21 19:01:27 ecu kernel: [176505.702418] xhci_hcd 0000:49:00.0: ring expansion succeed, now has 8 segments

0 Likes
Rashi_Vatsa
Moderator
Moderator

Hello,

Please let me know the meaning of "multiple camera". Does this mean that host application is opened twice or are 2 FX3 connected to the USB host and both are programmed with same firmware?

Can you please explain your application and let me know what is expected from the device? Also, let me know if there are other USB devices connected to the host when FX3 is streaming

Regards,
Rashi
0 Likes
juhu_4653696
New Contributor

Hi Rashi,

2 FX3 connected to the USB host and both are programmed with same firmware.

use guvcview to open two cameras(1200*1200 resolution). one works well, other camera fail. There are 3 cameras connect to usb hub(bus id 06)(only open two cameras):

/: Bus 06.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
|__ Port 1: Dev 63, If 0, Class=Video, Driver=uvcvideo, 5000M
|__ Port 1: Dev 63, If 1, Class=Video, Driver=uvcvideo, 5000M
|__ Port 2: Dev 64, If 0, Class=Video, Driver=uvcvideo, 5000M
|__ Port 2: Dev 64, If 1, Class=Video, Driver=uvcvideo, 5000M
|__ Port 3: Dev 65, If 1, Class=Video, Driver=uvcvideo, 5000M
|__ Port 3: Dev 65, If 0, Class=Video, Driver=uvcvideo, 5000M

I attached lsusb info log, please review. Thanks!

0 Likes
Rashi_Vatsa
Moderator
Moderator

Hello,

The firmware shared in the thread configures the maximum endpoint payload size supported by USB 3.0 ISOC endpoint per service interval i.e.

(FX3_EP_ISO_VIDEO_SS_BURST + 1) * (FX3_EP_ISO_VIDEO_SS_MULT + 1) * 1024) = (16 (15+1) * 3 (2+1)* 1024) = 48KB/service interval

USB Host may not be able to support the transfer bandwidth required by this setting for both the FX3 devices simultaneously, and they fail to select the configuration. In this case, please consider reducing either the FX3_EP_ISO_VIDEO_SS_BURST or FX3_EP_ISO_VIDEO_SS_MULT settings for any one device or both the devices to reduce the bandwidth requirement of the ISOC transfer.

Regards,
Rashi
0 Likes
juhu_4653696
New Contributor

Hi Rashi,

Thanks for your reply!  We have four usb pub(3.0) setup on pcie bus. and each 3 cameras(1920*1200 UYVY 20fps)  connects to one pub.  Do you think the bandwidth requirement is too high for us? and we change to bulk mode ,we find it works.

I haven't no idea which value suitable for FX3_EP_ISO_VIDEO_SS_BURST  and FX3_EP_ISO_VIDEO_SS_MULT.

FX3_EP_ISO_VIDEO_SS_BURST = 0x0f  and FX3_EP_ISO_VIDEO_SS_MULT=1 ?

It will affect other performance?

jun

0 Likes
juhu_4653696
New Contributor

sorry, correct it:

FX3_EP_ISO_VIDEO_SS_BURST = 0x08 and FX3_EP_ISO_VIDEO_SS_MULT=1 ?

jun

0 Likes
juhu_4653696
New Contributor

Hi Rashi,

It looks like  your suggest can be effective! I change the setting as bleow, two cameras works well simultaneously:+#define FX3_EP_ISO_VIDEO_SS_BURST (0x0a)
+#define FX3_EP_ISO_VIDEO_SS_MULT (0x01)
+#define FX3_UVC_ISO_PAYLOAD_SIZE ((FX3_EP_ISO_VIDEO_SS_BURST - 4) * 1024)

but how to computer the bandwith?  next setp i need test 3 cameras(2 tf cameras + 1 obj camera):

tf camera ------ 1920*1200 UYVY 10 fps

obj camera ------ 1200*1200 UYVY 20fps

so how i change the setting? I find if reduce FX3_UVC_ISO_PAYLOAD_SIZE and FX3_EP_ISO_VIDEO_SS_MULT too small , no image send. so how i calculate the setting if i want to open 3 cameras?

Many thanks for your help!

jun

 

 

0 Likes
juhu_4653696
New Contributor

Hi Rashi,

After change many times . I find:

for tf camera(1920*1200*10fps),  the minimum is FX3_EP_ISO_VIDEO_SS_BURST=7 FX3_EP_ISO_VIDEO_SS_MULT=1 

#define FX3_UVC_ISO_PAYLOAD_SIZE ((FX3_EP_ISO_VIDEO_SS_BURST - 1) * 1024)

if lower it , no image will send.

for obj camera(1200*1200*20fps), the minimum is FX3_EP_ISO_VIDEO_SS_BURST=0x0e FX3_EP_ISO_VIDEO_SS_MULT=2 

#define FX3_UVC_ISO_PAYLOAD_SIZE ((FX3_EP_ISO_VIDEO_SS_BURST + 1) * (FX3_EP_ISO_VIDEO_SS_MULT + 1) * 1024)

if lower it , no image will send.

 if (2 tf + 1 obj) in a hub, the issue  still exist.

so how i adjust them?   Is it necessary to adjust other parameters?  please refer to diff  in attachment

Thanks.

jun

0 Likes
Rashi_Vatsa
Moderator
Moderator

Hello,

Glad to hear that simultaneous streaming form 2 FX3 was successful after reducing FX3_EP_ISO_VIDEO_SS_MULT/FX3_EP_ISO_VIDEO_SS_BURST

Please connect only the object camera to the host and let me know if it works with following setting

for obj camera(1200*1200*20fps),  FX3_EP_ISO_VIDEO_SS_BURST=0x0E FX3_EP_ISO_VIDEO_SS_MULT=0

#define FX3_UVC_ISO_PAYLOAD_SIZE ((FX3_EP_ISO_VIDEO_SS_BURST + 1) * (FX3_EP_ISO_VIDEO_SS_MULT + 1) * 1024)

Please let me know if all the three cameras will be connected to host directly (on separate USB 3.0 ports) or through a hub via single USB port.

Also, let me know which  USB host controller is used while testing this

Regards,
Rashi
0 Likes
juhu_4653696
New Contributor

Hi Rashi,

Connect only one object camera to the host with "FX3_EP_ISO_VIDEO_SS_MULT=0". the camera no image send. It seems like I can't reduce FX3_EP_ISO_VIDEO_SS_MULT or FX3_EP_ISO_VIDEO_SS_BURST for obj camera(1200*1200*20fps).

The obj camera connect to host through a hub via single USB port.

 hub device is (47:00.0 USB controller: Texas Instruments TUSB73x0 SuperSpeed USB 3.0 xHCI Host Controller (rev 02))

3 obj cameras connect to hub port(1/2/3). please review below:

/: Bus 06.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
|__ Port 1: Dev 77, If 0, Class=Video, Driver=uvcvideo, 5000M
|__ Port 1: Dev 77, If 1, Class=Video, Driver=uvcvideo, 5000M
|__ Port 2: Dev 78, If 0, Class=Video, Driver=uvcvideo, 5000M
|__ Port 2: Dev 78, If 1, Class=Video, Driver=uvcvideo, 5000M
|__ Port 3: Dev 76, If 1, Class=Video, Driver=uvcvideo, 5000M
|__ Port 3: Dev 76, If 0, Class=Video, Driver=uvcvideo, 5000M

0 Likes
juhu_4653696
New Contributor

The attachment is "lsusb -s 06:76 -vvv" for obj camera.

The hub is 3.0 hub, bandwith is 5000M. for 3x obj camera, total  bandwith is 3*1200*1200*2*20fps*8=3*460800000B=3*440MB/s=1.3GB/s. I think bandwith is small than the usb bandwith(5G). why the host throw a issue :

"cam_init_mmap: mmap buf 1(1) OK: len 4608000
cam_fetch_image: ioctl VIDIOC_STREAMON failed, errno=28(No space left on device)"

jun

0 Likes
Rashi_Vatsa
Moderator
Moderator

Hello,

It seems like I can't reduce FX3_EP_ISO_VIDEO_SS_MULT or FX3_EP_ISO_VIDEO_SS_BURST for obj camera(1200*1200*20fps).

>> To check the reason of  camera not working when the settings are reduced, please let me know the DMA buffer size used for this camera.  Also, share the UART debug prints for us to check.

cam_fetch_image: ioctl VIDIOC_STREAMON failed, errno=28(No space left on device)"

>> This error usually occurs when the host controller is out of bandwidth. As you might be aware that the maximum data payload size  of an ISOC endpoint  effects the bandwidth requirements of the bus. For object camera, the payload size is 48 (16*3*1024) KB/125 us (minimum service interval) , so that works out to be 3Gbps (theoretical max throughput for ISOC endpoint) . 5Gbps is only the signaling  rate for USB 3.0

Regards,
Rashi
0 Likes
juhu_4653696
New Contributor

Hi Rashi,

The DMA buffer size setting:

#define CY_FX_EP_BULK_VIDEO_PKT_SIZE (0x400) /* 1024 Bytes */

#define CY_FX_EP_BULK_VIDEO_PKTS_COUNT (0x10) /* 16 packets (burst of 16) per DMA buffer. */

/* Number of DMA buffers per GPIF DMA thread. */
#define CY_FX_UVC_STREAM_BUF_COUNT (4)

Reduced payload size to 16(8*2*1024)KB/125us and retested it, it works well. If open 3x camera , it will show:

cam_fetch_image: ioctl VIDIOC_STREAMON failed, errno=28(No space left on device)"

But if reduce it further to 12(6*2*1024)KB/125us, the camera will no work! and the UART debug print as bleow:

CyU3PDmaMultiChannelCommitBuffer Fail! status = 71 !
DMA Reset Event: Commit buffer failure

Best Regards,

jun

0 Likes
juhu_4653696
New Contributor

Hi Rashi,

Now  i can reduce to 16(8*2*1024)KB/125us,the single camera open works, but for 3x camera open simultaneously, the bandwith is 16*3=48k, why the issue of "No space left" still exist?

jun

0 Likes
Rashi_Vatsa
Moderator
Moderator

Hello,

If open 3x camera , it will show:

cam_fetch_image: ioctl VIDIOC_STREAMON failed, errno=28(No space left on device)"

>> Please let me know if two camera work fine when connected to host

 

But if reduce it further to 12(6*2*1024)KB/125us, the camera will no work! and the UART debug print as below:

>> The commit buffer failures are seen when the host is slow to consume the data from the DMA buffers of FX3 ( DMA overflow condition). Please try to configure the endpoint payload size as multiple of DMA buffer size i.e. 8KB

Now  i can reduce to 16(8*2*1024)KB/125us,the single camera open works, but for 3x camera open simultaneously, the bandwidth is 16*3=48k, why the issue of "No space left" still exist?

>> The problem seems to be with the host controller settings. Please let me know if the same setup can be tested using different host controller.

Regards,
Rashi
0 Likes
juhu_4653696
New Contributor

Hi Rashi,

Two cameras work fine when connected to host, but 3x cameras will show "No space left on device".  I change iso to bulk mode , 3x cameras work fine,  so the problem seems not to be with the host controller settings.  and i calculate one obj camera max bandwith is 1200*1200*16*30 hz  = 700Mb/s,  the total max bandwith is 3*700=2.1Gbps, it is much less than 5G 3.0 usb.  The main issuse is 16k(8*2*1024)/server interval(about 1Gbps) setting  can't open 3x camera, although  it is much less than 5G.

Thanks!

jun

0 Likes
juhu_4653696
New Contributor

Hi Rashi,

Two cameras work fine when connected to host, but 3x cameras will show "No space left on device".  I change iso to bulk mode , 3x cameras work fine,  so the problem seems not to be with the host controller settings.  and i calculate one obj camera max bandwith is 1200*1200*16*30 hz  = 700Mb/s,  the total max bandwith is 3*700=2.1Gbps, it is much less than 5G 3.0 usb.  The main issuse is 16k(8*2*1024)/server interval(about 1Gbps) setting  can't open 3x camera, although  it is much less than 5G.

Thanks!

jun

0 Likes
juhu_4653696
New Contributor

Hi Rashi,

I have changed FX3_UVC_ISO_PAYLOAD_SIZE to 8k, but no work. It seems like too small? I set to 16k ,it is work well , but open 3x camera will shows "No space left".

Best Regards

jun

0 Likes
Rashi_Vatsa
Moderator
Moderator

Hello Jun,

Please note that the periodic endpoints (like interrupt/isochronous) can be allocated up to 80% of the total available bandwidth on SuperSpeed. 

Please refer to this link with the explanation. As mentioned by you the bandwidth requirement from the USB descriptors is ~ 0.9Gbps and the video bandwidth is ~ 0.7Gbps (which not big difference). To use only  ~0.7Gbps (video bandwidth) bandwidth you can try using UVC_QUIRK_FIX_BANDWIDTH - which will try to estimate the bandwidth required for uncompressed streams instead on relying on the value reported by the camera.

If the host controller allocated bandwidth is not enough for the 3 cameras to stream simultaneously with the video resolution you mentioned then workarounds  mentioned here can be followed

Regards,
Rashi

View solution in original post

0 Likes
juhu_4653696
New Contributor

Hi Rashi,

I try UVC_QUIRK_FIX_BANDWIDTH and quirks=128.  and open debug trace echo 0xffff > /sys/module/uvcvideo/parameters/trace and print log as below:

Apr 28 17:11:42 ecu kernel: [ 3982.301590] uvcvideo: Device requested 46080 B/frame bandwidth.
Apr 28 17:11:42 ecu kernel: [ 3982.301592] uvcvideo: Selecting alternate setting 1 (46080 B/frame bandwidth).
Apr 28 17:11:42 ecu kernel: [ 3982.315297] uvcvideo: Allocated 32 URB buffers of 32x46080 bytes each.

This log is corresponding to 45k(15*3*1024)/service interval in cypress fw.

and i change to 16k(8*2*1024)/service interval in cypress fw, the log is :

Apr 28 20:00:09 ecu kernel: [14089.891943] uvcvideo: Device requested 16384 B/frame bandwidth.
Apr 28 20:00:09 ecu kernel: [14089.891944] uvcvideo: uvc_endpoint_max_bpi psize=16384. best_psize=4294967295
Apr 28 20:00:09 ecu kernel: [14089.891945] uvcvideo: Selecting alternate setting 1 (16384 B/frame bandwidth).
Apr 28 20:00:09 ecu kernel: [14089.893346] uvcvideo: [uvc_init_video_isoc] size=2880000 psize=16384 bandwidth

so the Device requested 46080 B/frame bandwidth  <----> 45k/interval(cy)

             Device requested 16384 B/frame bandwidth <----> 16k/interval(cy)

In ubuntu host, request bandwith is related to psize(Compute the maximum number of bytes per interval for an endpoint.) So i think it's getting closer to the truth!

in uvc code :

psize = uvc_endpoint_max_bpi(stream->dev->udev, ep);

static unsigned int uvc_endpoint_max_bpi(struct usb_device *dev,
struct usb_host_endpoint *ep)
{
u16 psize;
u16 mult;

switch (dev->speed) {
case USB_SPEED_SUPER:
case USB_SPEED_SUPER_PLUS:
return le16_to_cpu(ep->ss_ep_comp.wBytesPerInterval);

So wBytesPerInterval decides the psize,and psize decides request bandwith.

Do you know how to set wBytesPerInterval  in cypress, maybe it could be reduce further!

Seems the actual bandwith is less than 1G(16k/125us invertal),there is hope in reduce service interval.

The problem is  that if i reduce FX3_EP_ISO_VIDEO_SS_BURST or FX3_EP_ISO_VIDEO_SS_MULT, the camera will not date......

jun

0 Likes
juhu_4653696
New Contributor

if I set FX3_EP_ISO_VIDEO_SS_BURST=0x05,FX3_EP_ISO_VIDEO_SS_MULT=1,

cypress print :CyU3PDmaMultiChannelCommitBuffer Fail! status = 71 !

host print:

Apr 28 20:30:50 ecu kernel: [15930.596348] uvcvideo: Dropping payload (out of sync).
Apr 28 20:30:50 ecu kernel: [15930.596349] uvcvideo: Dropping payload (out of sync).
Apr 28 20:30:50 ecu kernel: [15930.596349] uvcvideo: Dropping payload (out of sync).

0 Likes
Rashi_Vatsa
Moderator
Moderator

Hello,

wBytesPerInterval is described in super speed endpoint descriptor for USB 3.0 device

0x04 * (FX3_EP_ISO_VIDEO_SS_MULT + 1) * (FX3_EP_ISO_VIDEO_SS_BURST + 1), /* Bytes per interval */

An isochronous transfer can specify the service interval as 2 ^(bInterval-1) x 125 µs, where bInterval ranges from 1 to 16

bInterval value can be set from the USB endpoint descriptors. The default value is set to 1 which results service interval of 125 us (2 ^ ( 1-1) x 125)

0x01, /* Servicing interval for data transfers: 1 uFrame */

Regards,
Rashi
0 Likes
juhu_4653696
New Contributor

Hi Rashi,

As your description, maybe i can change bInterval, or change Bytes per interval, but it seems only reduce to 16(8*2*1024)KB/125us. If reduce further it  or set bInterval=0x02, camere not work. So dou you think cyress setting is not useful for this issue "No space left"?

Many thanks for your help!

jun

0 Likes
Rashi_Vatsa
Moderator
Moderator

Hello Jun,

As mentioned in the document I shared earlier, the problem seems to be  the host controller as it is not able to allocate the bandwidth required for 3 cameras. You can try using BULK endpoint instead of isochronous endpoint.

Regards,
Rashi
0 Likes