From d9ec32d40f9aeb49613af35f6e7f645ee6b2239f Mon Sep 17 00:00:00 2001 From: sladro Date: Tue, 6 Jan 2026 14:57:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AEbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/dma_alloc.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) 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 };