This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM5728: USB uvc-gadget application failed to allocate buffers

Part Number: AM5728

Tool/software: Linux

Hello,

We are trying to run uvc-gadget application on processor SDK v05.03.00.07 but it failed to allocate buffers.

http://processors.wiki.ti.com/index.php/Usbgeneralpage#USB_Video

Target log is here.



root@am57xx-evm:~# ls -l /dev/video* crw-rw---- 1 root video 81, 2 Apr 6 01:37 /dev/video0 crw-rw---- 1 root video 81, 1 Apr 6 01:37 /dev/video10 crw-rw---- 1 root video 81, 0 Apr 6 01:37 /dev/video11 root@am57xx-evm:~# modprobe g_webcam [ 296.379760] g_webcam gadget: uvc_function_bind [ 296.384410] g_webcam gadget: Webcam Video Gadget [ 296.389234] g_webcam gadget: g_webcam ready root@am57xx-evm:~# ls -l /dev/video* crw-rw---- 1 root video 81, 2 Apr 6 01:37 /dev/video0 crw-rw---- 1 root video 81, 3 Apr 6 01:42 /dev/video1 crw-rw---- 1 root video 81, 1 Apr 6 01:37 /dev/video10 crw-rw---- 1 root video 81, 0 Apr 6 01:37 /dev/video11 root@am57xx-evm:~# uvc-gadget -d /dev/video1 Device /dev/video1 opened: dwc3-gadget (gadget). [ 331.780165] g_webcam gadget: high-speed config #1: Video [ 331.785514] g_webcam gadget: uvc_function_set_alt(0, 0) [ 331.790762] g_webcam gadget: reset UVC Control [ 331.795234] g_webcam gadget: uvc_function_set_alt(1, 0) [ 331.801281] g_webcam gadget: uvc_function_set_alt(1, 0) bRequestType a1 bRequest 87 wValue 0100 wIndex 0001 wLength 001a streaming request (req 87 cs 01) bRequestType 21 bRequest 01 wValue 0100 wIndex 0001 wLength 001a streaming request (req 01 cs 01) setting probe control, length = 26 bRequestType a1 bRequest 81 wValue 0100 wIndex 0001 wLength 001a streaming request (req 81 cs 01) bRequestType a1 bRequest 87 wValue 0200 wIndex 0200 wLength 0002 control request (req 87 cs 02) bRequestType a1 bRequest 87 wValue 0200 wIndex 0200 wLength 0002 control request (req 87 cs 02) bRequestType a1 bRequest 87 wValue 0200 wIndex 0200 wLength 0002 control request (req 87 cs 02) bRequestType a1 bRequest 87 wValue 0200 wIndex 0200 wLength 0002 control request (req 87 cs 02) bRequestType a1 bRequest 87 wValue 0200 wIndex 0200 wLength 0002 control request (req 87 cs 02) bRequestType a1 bRequest 87 wValue 0200 wIndex 0200 wLength 0002 control request (req 87 cs 02) bRequestType a1 bRequest 87 wValue 0200 wIndex 0200 wLength 0002 control request (req 87 cs 02) bRequestType a1 bRequest 87 wValue 0200 wIndex 0200 wLength 0002 control request (req 87 cs 02) bRequestType a1 bRequest 87 wValue 0200 wIndex 0200 wLength 0002 control request (req 87 cs 02) bRequestType a1 bRequest 87 wValue 0200 wIndex 0200 wLength 0002 control request (req 87 cs 02) bRequestType a1 bRequest 87 wValue 0200 wIndex 0200 wLength 0002 control request (req 87 cs 02) bRequestType a1 bRequest 87 wValue 0200 wIndex 0200 wLength 0002 control request (req 87 cs 02) bRequestType a1 bRequest 87 wValue 0200 wIndex 0200 wLength 0002 control request (req 87 cs 02) bRequestType a1 bRequest 87 wValue 0200 wIndex 0200 wLength 0002 control request (req 87 cs 02) bRequestType a1 bRequest 87 wValue 0200 wIndex 0200 wLength 0002 control request (req 87 cs 02) bRequestType a1 bRequest 87 wValue 0200 wIndex 0200 wLength 0002 control request (req 87 cs 02) bRequestType a1 bRequest 87 wValue 0200 wIndex 0200 wLength 0002 control request (req 87 cs 02) bRequestType a1 bRequest 87 wValue 0200 wIndex 0100 wLength 0001 control request (req 87 cs 02) bRequestType 21 bRequest 01 wValue 0100 wIndex 0001 wLength 001a streaming request (req 01 cs 01) setting probe control, length = 26 WARNING: MJPEG requested and no image loaded. bRequestType a1 bRequest 82 wValue 0100 wIndex 0001 wLength 001a streaming request (req 82 cs 01) bRequestType a1 bRequest 83 wValue 0100 wIndex 0001 wLength 001a streaming request (req 83 cs 01) bRequestType 21 bRequest 01 wValue 0100 wIndex 0001 wLength 001a streaming request (req 01 cs 01) setting probe control, length = 26 WARNING: MJPEG requested and no image loaded. bRequestType a1 bRequest 81 wValue 0100 wIndex 0001 wLength 001a streaming request (req 81 cs 01) bRequestType 21 bRequest 01 wValue 0100 wIndex 0001 wLength 001a streaming request (req 01 cs 01) setting probe control, length = 26 WARNING: MJPEG requested and no image loaded. bRequestType a1 bRequest 82 wValue 0100 wIndex 0001 wLength 001a streaming request (req 82 cs 01) bRequestType a1 bRequest 83 wValue 0100 wIndex 0001 wLength 001a streaming request (req 83 cs 01) bRequestType 21 bRequest 01 wValue 0100 wIndex 0001 wLength 001a streaming request (req 01 cs 01) setting probe control, length = 26 WARNING: MJPEG requested and no image loaded. bRequestType a1 bRequest 81 wValue 0100 wIndex 0001 wLength 001a streaming request (req 81 cs 01) bRequestType 21 bRequest 01 wValue 0100 wIndex 0001 wLength 001a streaming request (req 01 cs 01) setting probe control, length = 26 WARNING: MJPEG requested and no image loaded. bRequestType a1 bRequest 82 wValue 0100 wIndex 0001 wLength 001a streaming request (req 82 cs 01) bRequestType a1 bRequest 83 wValue 0100 wIndex 0001 wLength 001a streaming request (req 83 cs 01) bRequestType 21 bRequest 01 wValue 0100 wIndex 0001 wLength 001a streaming request (req 01 cs 01) setting probe control, length = 26 WARNING: MJPEG requested and no image loaded. bRequestType a1 bRequest 81 wValue 0100 wIndex 0001 wLength 001a streaming request (req 81 cs 01) bRequestType 21 bRequest 01 wValue 0200 wIndex 0001 wLength 001a[ 502.248756] g_webcam gadget: uvc_function_set_alt(1, 1) streaming request (req 01 cs 02) setting commit control, leng[ 502.259131] g_webcam gadget: reset UVC th = 26 WARNING: MJPEG requested and no image loaded. Setting [ 502.270462] uvc-gadget: vmalloc: allocation failure: 0 bytes, mode:0x14080c0(GFP_KERNEL|__GFP_ZERO), nodemask=(null) format to 0x47504a4d 640x360 Starting video stream. [ 502.284723] uvc-gadget cpuset=/ mems_allowed=0 [ 502.295507] CPU: 1 PID: 1114 Comm: uvc-gadget Tainted: G O 4.14.79-ge669d52447 #1 [ 502.304157] Hardware name: Generic DRA74X (Flattened Device Tree) [ 502.310274] Backtrace: [ 502.312743] [<c020b4dc>] (dump_backtrace) from [<c020b7c0>] (show_stack+0x18/0x1c) [ 502.320345] r7:fffff000 r6:60030013 r5:00000000 r4:c1053d10 [ 502.326034] [<c020b7a8>] (show_stack) from [<c0931508>] (dump_stack+0x90/0xa4) [ 502.333292] [<c0931478>] (dump_stack) from [<c02e6548>] (warn_alloc+0xc4/0x16c) [ 502.340633] r7:fffff000 r6:ffffffff r5:0000071f r4:00000000 [ 502.346321] [<c02e6488>] (warn_alloc) from [<c031cfe8>] (__vmalloc_node_range+0x210/0x23c) [ 502.354620] r3:00000000 r2:c0bbb790 [ 502.358208] r5:0000071f r4:00000000 [ 502.361800] [<c031cdd8>] (__vmalloc_node_range) from [<c031d0dc>] (vmalloc_user+0x70/0xac) [ 502.370101] r9:bf4cd6bc r8:ed10b200 r7:fffff000 r6:00000001 r5:0000071f r4:014080c0 [ 502.377888] [<c031d06c>] (vmalloc_user) from [<bf4cd714>] (vb2_vmalloc_alloc+0x58/0xac [videobuf2_vmalloc]) [ 502.387668] r5:00000000 r4:ed44f500 [ 502.391268] [<bf4cd6bc>] (vb2_vmalloc_alloc [videobuf2_vmalloc]) from [<c072cae4>] (__vb2_queue_alloc+0x170/0x424) [ 502.401662] r7:fffff000 r6:ec0b2468 r5:ed10b200 r4:00000000 [ 502.407348] [<c072c974>] (__vb2_queue_alloc) from [<c072dcd4>] (vb2_core_reqbufs+0x104/0x358) [ 502.415910] r10:ed421180 r9:00000000 r8:ee895e28 r7:bf4da064 r6:ec0b26ec r5:ec0b2468 [ 502.423771] r4:00000000 [ 502.426317] [<c072dbd0>] (vb2_core_reqbufs) from [<c0730c94>] (vb2_reqbufs+0x38/0x3c) [ 502.434181] r10:ed421180 r9:00000000 r8:00000008 r7:bf4da064 r6:ee84cb00 r5:ec0b2468 [ 502.442042] r4:ee895e28 [ 502.444600] [<c0730c5c>] (vb2_reqbufs) from [<bf4d5228>] (uvcg_alloc_buffers+0x14/0x20 [usb_f_uvc]) [ 502.453683] r5:ed421180 r4:ee895e28 [ 502.457293] [<bf4d5214>] (uvcg_alloc_buffers [usb_f_uvc]) from [<bf4d57d0>] (uvc_v4l2_reqbufs+0x38/0x44 [usb_f_uvc]) [ 502.467858] r5:ed421180 r4:ee895e28 [ 502.471462] [<bf4d5798>] (uvc_v4l2_reqbufs [usb_f_uvc]) from [<c071b910>] (v4l_reqbufs+0x50/0x54) [ 502.480371] r5:ed421180 r4:ee895e28 [ 502.483965] [<c071b8c0>] (v4l_reqbufs) from [<c071acbc>] (__video_do_ioctl+0x30c/0x314) [ 502.492002] r7:c071b8c0 r6:ec0b2000 r5:c0145608 r4:00000003 [ 502.497689] [<c071a9b0>] (__video_do_ioctl) from [<c071a570>] (video_usercopy+0x78/0x49c) [ 502.505901] r10:00000000 r9:00000000 r8:ee895e28 r7:00000000 r6:00000014 r5:00000003 [ 502.513762] r4:c0145608 [ 502.516309] [<c071a4f8>] (video_usercopy) from [<c071a9ac>] (video_ioctl2+0x18/0x1c) [ 502.524085] r10:ed519070 r9:ee894000 r8:ec0b2418 r7:bef2a7ec r6:c0145608 r5:ed421180 [ 502.531945] r4:ec0b2000 [ 502.534493] [<c071a994>] (video_ioctl2) from [<c0716bf4>] (v4l2_ioctl+0x84/0xe0) [ 502.541927] [<c0716b70>] (v4l2_ioctl) from [<c034ed3c>] (do_vfs_ioctl+0xa8/0x790) [ 502.549443] r9:ee894000 r8:00000003 r7:c0145608 r6:00000003 r5:ed421180 r4:bef2a7ec [ 502.557222] [<c034ec94>] (do_vfs_ioctl) from [<c034f460>] (SyS_ioctl+0x3c/0x60) [ 502.564564] r10:00000036 r9:ee894000 r8:bef2a7ec r7:c0145608 r6:00000003 r5:ed421180 [ 502.572424] r4:ed421180 [ 502.574972] [<c034f424>] (SyS_ioctl) from [<c0207c40>] (ret_fast_syscall+0x0/0x4c) [ 502.582575] r9:ee894000 r8:c0207e44 r7:00000036 r6:00000004 r5:00000001 r4:00025208 [ 502.590494] Mem-Info: [ 502.592831] active_anon:4592 inactive_anon:2254 isolated_anon:0 [ 502.592831] active_file:7930 inactive_file:29267 isolated_file:0 [ 502.592831] unevictable:0 dirty:2 writeback:0 unstable:0 [ 502.592831] slab_reclaimable:3611 slab_unreclaimable:3656 [ 502.592831] mapped:6541 shmem:2635 pagetables:303 bounce:0 [ 502.592831] free:391961 free_pcp:421 free_cma:27701 [ 502.627294] Node 0 active_anon:18368kB inactive_anon:9016kB active_file:31720kB inactive_file:117068kB unevictable:0kB isolated(anon):0kB isolated(file):0kB mapped:26164kB dirty:8kB writeback:0kB shmem:10540kB writeback_tmp:0kB unstable:0kB all_unreclaimable? no [ 502.650946] DMA free:430504kB min:2504kB low:3128kB high:3752kB active_anon:0kB inactive_anon:0kB active_file:12336kB inactive_file:1000kB unevictable:0kB writepending:8kB present:589824kB managed:558488kB mlocked:0kB kernel_stack:1088kB pagetables:0kB bounce:0kB free_pcp:440kB local_pcp:208kB free_cma:87968kB [ 502.678629] lowmem_reserve[]: 0 0 1253 1253 [ 502.682948] HighMem free:1137340kB min:512kB low:2556kB high:4600kB active_anon:18368kB inactive_anon:9016kB active_file:19384kB inactive_file:116068kB unevictable:0kB writepending:0kB present:1307648kB managed:1307648kB mlocked:0kB kernel_stack:0kB pagetables:1212kB bounce:0kB free_pcp:1212kB local_pcp:680kB free_cma:22836kB [ 502.712033] lowmem_reserve[]: 0 0 0 0 [ 502.715929] DMA: 10*4kB (MEC) 10*8kB (UME) 1*16kB (U) 7*32kB (UC) 5*64kB (EC) 6*128kB (UMC) 2*256kB (ME) 5*512kB (EC) 4*1024kB (EC) 2*2048kB (UM) 102*4096kB (MC) = 430504kB [ 502.731483] HighMem: 17*4kB (UMC) 3*8kB (MC) 6*16kB (MC) 6*32kB (UMC) 7*64kB (UMC) 9*128kB (UM) 7*256kB (UM) 10*512kB (UM) 4*1024kB (UM) 5*2048kB (UC) 272*4096kB (UMC) = 1137340kB [ 502.747700] 39832 total pagecache pages [ 502.751597] 0 pages in swap cache [ 502.754922] Swap cache stats: add 0, delete 0, find 0/0 [ 502.760188] Free swap = 0kB [ 502.763143] Total swap = 0kB [ 502.766032] 474368 pages RAM [ 502.768940] 326912 pages HighMem/MovableOnly [ 502.773278] 7834 pages reserved [ 502.776430] 47104 pages cma reserved /dev/video1: unable to request buffers (12). Failed to allocate buffers.

On the host, we use Ubuntu 18.04 and run guvcview. But just get black image and the stream is disconnected after a few seconds.

guvcview -d /dev/video1 -f yuv

Webcam gadget: UVC Camera (usb-0000:00:14.0-1.2):
	/dev/video1

Integrated Camera: Integrated C (usb-0000:00:14.0-8):
	/dev/video0

Driver Info (not using libv4l2):
	Driver name   : uvcvideo
	Card type     : Webcam gadget: UVC Camera
	Bus info      : usb-0000:00:14.0-1.2
	Driver version: 4.15.18
	Capabilities  : 0x84200001
		Video Capture
		Streaming
		Extended Pix Format
		Device Capabilities
	Device Caps   : 0x04200001
		Video Capture
		Streaming
		Extended Pix Format
Priority: 2
Video input : 0 (Camera 1: ok)
Format Video Capture:
	Width/Height      : 640/360
	Pixel Format      : 'MJPG'
	Field             : None
	Bytes per Line    : 0
	Size Image        : 460800
	Colorspace        : sRGB
	Transfer Function : Default (maps to sRGB)
	YCbCr/HSV Encoding: Default (maps to ITU-R 601)
	Quantization      : Default (maps to Full Range)
	Flags             : 
Crop Capability Video Capture:
	Bounds      : Left 0, Top 0, Width 640, Height 360
	Default     : Left 0, Top 0, Width 640, Height 360
	Pixel Aspect: 1/1
Selection: crop_default, Left 0, Top 0, Width 640, Height 360
Selection: crop_bounds, Left 0, Top 0, Width 640, Height 360
Streaming Parameters Video Capture:
	Capabilities     : timeperframe
	Frames per second: 15.000 (15/1)
	Read buffers     : 0

Also we tried to use gstreamer to capture video1 stream on the host. It looks like working but the captured image is still black.

On the host,

gst-launch-1.0 -v v4l2src device=/dev/video2 ! video/x-raw,format=YUY2,width=640,height=360,framerate=10/1 ! videoconvert ! autovideosink

On the target,

root@am57xx-evm:~# modprobe g_webcam
[  270.672681] g_webcam gadget: uvc_function_bind
[  270.678202] g_webcam gadget: Webcam Video Gadget
[  270.682845] g_webcam gadget: g_webcam ready
root@am57xx-evm:~# uvc-gadget -d /dev/video1
Device /dev/video1 opened: dwc3-gadget (gadget).
[  296.267502] g_webcam gadget: high-speed config #1: Video
[  296.272849] g_webcam gadget: uvc_function_set_alt(0, 0)
[  296.278097] g_webcam gadget: reset UVC Control
[  296.282570] g_webcam gadget: uvc_function_set_alt(1, 0)
[  296.288540] g_webcam gadget: uvc_function_set_alt(1, 0)
bRequestType a1 bRequest 87 wValue 0100 wIndex 0001 wLength 001a
streaming request (req 87 cs 01)
bRequestType 21 bRequest 01 wValue 0100 wIndex 0001 wLength 001a
streaming request (req 01 cs 01)
setting probe control, length = 26
bRequestType a1 bRequest 81 wValue 0100 wIndex 0001 wLength 001a
streaming request (req 81 cs 01)
bRequestType a1 bRequest 87 wValue 0200 wIndex 0200 wLength 0002
control request (req 87 cs 02)
bRequestType a1 bRequest 87 wValue 0200 wIndex 0200 wLength 0002
control request (req 87 cs 02)
bRequestType a1 bRequest 87 wValue 0200 wIndex 0200 wLength 0002
control request (req 87 cs 02)
bRequestType a1 bRequest 87 wValue 0200 wIndex 0200 wLength 0002
control request (req 87 cs 02)
bRequestType a1 bRequest 87 wValue 0200 wIndex 0200 wLength 0002
control request (req 87 cs 02)
bRequestType a1 bRequest 87 wValue 0200 wIndex 0200 wLength 0002
control request (req 87 cs 02)
bRequestType 21 bRequest 01 wValue 0100 wIndex 0001 wLength 001a
streaming request (req 01 cs 01)
setting probe control, length = 26
bRequestType a1 bRequest 82 wValue 0100 wIndex 0001 wLength 001a
streaming request (req 82 cs 01)
bRequestType a1 bRequest 83 wValue 0100 wIndex 0001 wLength 001a
streaming request (req 83 cs 01)
bRequestType 21 bRequest 01 wValue 0100 wIndex 0001 wLength 001a
streaming request (req 01 cs 01)
setting probe control, length = 26
bRequestType a1 bRequest 81 wValue 0100 wIndex 0001 wLength 001a
streaming request (req 81 cs 01)
bRequestType 21 bRequest 01 wValue 0200 wIndex 0001 wLength 001a[  424.195285] g_webcam gadget: uvc_function_set_alt(1, 1)
[  424.205538] g_webcam gadget: reset UVC

streaming request (req 01 cs 02)
setting commit control, length = 26
Setting format to 0x56595559 640x360
Starting video stream.
/dev/video1: 4 buffers requested.
/dev/video1: buffer 0 mapped at address 0xb6d70000.
/dev/video1: buffer 1 mapped at address 0xb6cff000.
/dev/video1: buffer 2 mapped at address 0xb6c8e000.
/dev/video1: buffer 3 mapped at address 0xb6c1d000.

Thanks in advance,

Ohira

  • Hi Ohira,

    I will try the same test on the EVM to see if I can reproduce the issue. I will keep you posted.
  • Hi Ohira,

    I am not sure what causes the vmalloc failure in your test, I don't see it in my test. But I can confirm the test sequence you described leads to black screen on the host side.

    If add a parameter shown as below when loading the g_webcam driver, you should be able to see the streaming video on the host.

    # modprobe g_webcam streaming_maxpacket=3072