[PATCH] libcamera: dma_heaps: Add support for using udmabuf to alloc DMA heaps

Hans de Goede hdegoede at redhat.com
Thu May 30 19:08:52 CEST 2024


Hi Brian,

On 5/29/24 2:29 AM, Bryan O'Donoghue wrote:
> On 27/05/2024 15:16, Hans de Goede wrote:
>> +static constexpr std::array<DmaHeapInfo, 4> heapInfos = { {
>> +    { DmaHeap::DmaHeapFlag::Cma, "/dev/dma_heap/linux,cma", false },
>> +    { DmaHeap::DmaHeapFlag::Cma, "/dev/dma_heap/reserved", false },
>> +    { DmaHeap::DmaHeapFlag::System, "/dev/dma_heap/system", false },
>> +    { DmaHeap::DmaHeapFlag::System, "/dev/udmabuf", true },
>>   } };
> 
> I have
> 
> deckard at x13s-linux:~/Development/linux$ ls /dev/udmabuf
> /dev/udmabuf
> deckard at x13s-linux:~/Development/linux$ ls /dev/d
> disk/     dma_heap/ dri/
> deckard at x13s-linux:~/Development/linux$ ls /dev/dma_heap/
> linux,cma  system
> 
> LIBCAMERA_LOG_LEVELS=*:DEBUG ./build.master.dbg/src/apps/qcam/qcam
> 
> Gives
> 
> [0:15:09.128108059] [6874] DEBUG DmaHeap dma_heaps.cpp:112 Using /dev/dma_heap/linux,cma
> 
> I thought we said udmabuf should be default over cma_heap ?
> 
> At a risk of displaying a lack of knowledge, I tried forcing the flag to useUDmaBuf = true;
> 
> I get
> 
> Zero-copy enabled
> [0:18:13.834305484] [7388] ERROR DmaHeap dma_heaps.cpp:201 UdmaHeap failed to allocate 15073280 bytes: Invalid argument
> [0:18:13.834365480] [7388] ERROR SoftwareIsp software_isp.cpp:246 failed to allocate a dma_buf
> 
> Do I need to do something more than CONFIG_UDAMBUF=y ?

If you just set "useUDmaBuf = true;" then the DmaHeap code will still
open /dev/dma_heap/linux,cma  but you are now using that fd with
code-paths which expect an fd for /dev/udmabuf so it is unsurprising
that that does not work.

To test the udmabuf code you can either modify:

static constexpr std::array<DmaHeapInfo, 4> heapInfos = { {
	{ DmaHeap::DmaHeapFlag::Cma, "/dev/dma_heap/linux,cma", false },
	{ DmaHeap::DmaHeapFlag::Cma, "/dev/dma_heap/reserved", false },
	{ DmaHeap::DmaHeapFlag::System, "/dev/dma_heap/system", false },
	{ DmaHeap::DmaHeapFlag::System, "/dev/udmabuf", true },
} };

To only list the /dev/udmabuf line; or just do:

sudo rm /dev/dma_heap/*

Note I'm posting a v2 of the udmabuf series in a couple of minutes,
if you are going to re-test please test that.

Regards,

Hans


 

> 
> ---
> bod
> 



More information about the libcamera-devel mailing list