lagurus
Posts: 48
Joined: Wed Aug 07, 2013 8:02 am

VCSM limitation

Tue Nov 28, 2017 10:17 am

Hi all,

I am trying to re-implement vcsm_square example from RaspiStill to my project.

Everthing seems to work, I am able to work with GPU memory "directly" and don't use "slow" glReadPixels.

But I have found quite limiting condition : VCSM buffer dimensions must be a power of two. See:
https://github.com/raspberrypi/userland ... ent.c#L316

If is used camera in resolution 1280x960 then must be created VCSM buffer of size 2048x1024. Which must be later also
processed e.g.in OpenCV - but this buffer is almost twice as big.

Any ideas or suggestions for me?

Thank you very much!

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 8504
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: VCSM limitation

Tue Nov 28, 2017 11:10 am

It's not a limitation of VCSM (which will allocate any multiple of the standard 4kB page size), but potentially of the EGL import.
The person who wrote that code isn't particularly active these days, but if you can produce a simple test case then I can try running it and tracing through what happens in the firmware. I don't know how strict that power of 2 limitation is, or why it is required.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

lagurus
Posts: 48
Joined: Wed Aug 07, 2013 8:02 am

Re: VCSM limitation

Tue Nov 28, 2017 10:14 pm

I think that simplest for test will be modify fb_width or fb_height (default set to 1024x1024) in vcsm_square.c

https://github.com/raspberrypi/userlan ... are.c#L123

than run

Code: Select all

raspistill -t 9999999 --preview '0,0,1280,720' --gl --glwin '0,0,1280,720' --glscene vcsm_square

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 8504
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: VCSM limitation

Wed Nov 29, 2017 10:32 am

lagurus wrote:
Tue Nov 28, 2017 10:14 pm
I think that simplest for test will be modify fb_width or fb_height (default set to 1024x1024) in vcsm_square.c

https://github.com/raspberrypi/userlan ... are.c#L123 section

than run

Code: Select all

raspistill -t 9999999 --preview '0,0,1280,720' --gl --glwin '0,0,1280,720' --glscene vcsm_square
OK, that's simple enough so I'll give that a go when I get a chance.

I think it may be related back to a hardware restriction as documented in https://docs.broadcom.com/docs-and-down ... G100-R.pdf section 4 (last paragraph of the intro)
The TMUs require mipmaps to be stored before the level 0 texture in memory, with addresses automatically
determined assuming power of 2 sized images.The TMU unit supports mipmapped non-power-of-two textures,
but the mipmap levels greater than 0 must be padded to fit within a power of 2 container image.
Note that the buffer must be PADDED to a power of 2, not that the number of active pixels is a power of 2. Yes it's extra memory, but shouldn't require extra processing.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

vintozver
Posts: 39
Joined: Thu Jun 01, 2017 2:16 am
Location: Bellevue, WA, USA

Re: VCSM limitation

Mon May 11, 2020 8:25 pm

failed playing of the video in the kodi, running under raspbian, RPI 4B

[ 243.327592] vcsm-cma vcsm-cma: swiotlb buffer is full (sz: 16629760 bytes)
[ 243.327622] vcsm-cma vcsm-cma: swiotlb: coherent allocation failed, size=16629760
[ 243.327656] CPU: 2 PID: 1177 Comm: VideoPlayer Tainted: G C 4.19.97-v8+ #1294
[ 243.327666] Hardware name: Raspberry Pi 4 Model B Rev 1.2 (DT)
[ 243.327675] Call trace:
[ 243.327711] dump_backtrace+0x0/0x178
[ 243.327720] show_stack+0x24/0x30
[ 243.327736] dump_stack+0xa4/0xdc
[ 243.327751] swiotlb_alloc+0x148/0x188
[ 243.327762] __dma_alloc+0xe0/0x230
[ 243.327794] vc_sm_cma_ioctl_alloc+0x128/0x518 [vc_sm_cma]
[ 243.327808] vc_sm_cma_ioctl+0x164/0x320 [vc_sm_cma]
[ 243.327820] vc_sm_cma_compat_ioctl+0x44/0x60 [vc_sm_cma]
[ 243.327838] __arm64_compat_sys_ioctl+0x26c/0xbd8
[ 243.327850] el0_svc_common+0xf4/0x1c0
[ 243.327859] el0_svc_compat_handler+0x30/0x40
[ 243.327868] el0_svc_compat+0x8/0x18
[ 243.327879] [vc_sm_cma_ioctl_alloc]: dma_alloc_coherent alloc of 16629760 bytes failed
[ 243.327889] [vc_sm_cma_ioctl_alloc]: something failed - cleanup. ret -12

[ 243.362044] [vc_sm_cma_ioctl_alloc]: something failed - cleanup. ret -12
[ 243.365712] [vc_sm_cma_ioctl_alloc]: dma_alloc_coherent alloc of 16629760 bytes failed
[ 243.365730] [vc_sm_cma_ioctl_alloc]: something failed - cleanup. ret -12
[ 243.369600] [vc_sm_cma_ioctl_alloc]: dma_alloc_coherent alloc of 16629760 bytes failed

Return to “Camera board”