libcamera: prefer udmabuf over dma-heaps - #464
Conversation
On Hamoa, CMA memory is currently insufficient for libcamera operation at some resolutions. Reorder the buffer allocator provider list so that /dev/udmabuf is tried before the CMA and system dma-heaps. Components that allow the udmabuf provider (software ISP, virtual pipeline) now use it whenever /dev/udmabuf is available, instead of falling back to it only when the dma-heaps can not be opened. The change is carried as a qcom-specific patch applied through a libcamera bbappend. Signed-off-by: Wenmeng Liu <wenmeng.liu@oss.qualcomm.com>
|
kernel config PR: qualcomm-linux/kernel-topics#1805 |
Test Results1 files - 18 1 suites - 77 2m 14s ⏱️ - 1h 33m 33s Results for commit fe7e479. ± Comparison against base commit 2c0f42b. This pull request removes 72 tests. |
|
I think this is a more generic problem, to be solved with libcamera itself. If the allocator can't provide enough memory, the libcamera should be able to fallback to the other allocators. This is especially true for the CMA allocators where we know that memory space is limited. |
|
The upstream linux-media (e.g. gstreamer) direction seems to be to use udmabuf more and more where ever possible now that it is generally available in most distro configurations. I think trying relatively unlimited udmabuf memory before CMA heaps makes sense from a not wasting scarce resources like CMA. OTOH IIRC the try CMA first approach is there for platforms where e.g. the video hw encoder which may sit after libcamera can only operate on CMA memory. So I think that rather then carrying a downstream patch the following should be done:
Dmitry Baryshkov (@lumag)'s idea of falling back to another allocator is interesting but I think that will complicate things quite a bit. E.g. in case of platforms where we actually want CMA to be tried first, returning a udmabuf backed dmabuf may cause errors elsewhere (e.g. the video-encoder), so I'm not sure how helpful this will be. I think that a configurable setting in which order to try the allocators should solve this nicely. |
|
Wenmeng Liu (@wenmliu) I think, Hans de Goede (@jwrdegoede) 's reply means: please open a merge request against libcamera, once agreed there, please backport it to QLI. |
|
Ack, I was about to write: to be clear my suggestion to fix this should be done upstream first. |
|
p.s. :
|
|
Sounds good. I'll work on the changes and submit them upstream. |
Just an FYI but you probably already know: UDMABUF is not enabled in defconfig |
Interesting, I'm not really a defconfig user, but that is a good point and one which is probably worth fixing... Let me discuss this with Robert Mader who has been pushing this from the gstreamer side. |
Yes, that's why I submitted a PR to enable UDMABUF for Qualcomm platforms: |
On Hamoa, CMA memory is currently insufficient for libcamera operation at some resolutions. Reorder the buffer allocator provider list so that /dev/udmabuf is tried before the CMA and system dma-heaps. Components that allow the udmabuf provider (software ISP, virtual pipeline) now use it whenever /dev/udmabuf is available, instead of falling back to it only when the dma-heaps can not be opened.
The change is carried as a qcom-specific patch applied through a libcamera bbappend.