diff --git a/src/utils/dma_alloc.cpp b/src/utils/dma_alloc.cpp index 042b7dd..ba1e908 100644 --- a/src/utils/dma_alloc.cpp +++ b/src/utils/dma_alloc.cpp @@ -164,14 +164,26 @@ DmaBufferPtr DmaAlloc(size_t alloc_size) { return DmaBufferPtr(reused, [](DmaBuffer* b) { Pool().Put(b); }); } - // Try different dma_heap devices - prefer CMA for RGA compatibility (<4GB) + // Try different dma_heap devices. + // Notes: + // - Some RGA drivers cannot map buffers whose physical address is >4GB; prefer DMA32 heaps. + // - CMA heaps are also <4GB friendly but can be small/fragmented under multi-stream load. const char* heap_paths[] = { + // Prefer CMA first when available. "/dev/dma_heap/cma", - "/dev/dma_heap/cma-uncached", + "/dev/dma_heap/cma-uncached", "/dev/dma_heap/linux,cma", - "/dev/dma_heap/reserved", + + // Then prefer DMA32 heaps to keep allocations under 4GB. + "/dev/dma_heap/system-dma32", + "/dev/dma_heap/system-uncached-dma32", + + // Generic system heaps (may allocate >4GB on high-mem systems). "/dev/dma_heap/system-uncached", "/dev/dma_heap/system", + + // Last resort. + "/dev/dma_heap/reserved", nullptr };