I have this x86 device and a kernel module that tries to allocate DMA memory. It has a parameter called dmasize that allows to control the size of allocated memory.

I've noticed that allocation succeeds when dmasize=2M but not if larger. Even at boot time. I heard there was a limitation by CONSISTENT_DMA_SIZE, but looking at lxr, I can't find it for arch x86 kernel 3.2.

Not sure if it is relevant, but this is a 32 bit machine with 8GB of RAM and a pae enabled kernel.

This is the call to dma_alloc_coherent:

dma_addr_t dma_handle;

if (!(_dma_vbase = dma_alloc_coherent(0, alloc_size, &dma_handle, GFP_KERNEL)) || !dma_handle) {
    gprintk("_alloc_mpool: Kernel failed to allocate the memory pool of size 0x%lx\n", (unsigned long)alloc_size);
    return;
    }

Appreciate anyone who can help with this.

有帮助吗?

解决方案

Just in case anyone comes across this, the answer is as follows: The config flag CONFIG_FORCE_MAX_ZONEORDER which defaults at 11 at most architecture is the cause for this limitation.

increasing it to 12 (and recompiling the kernel) fixes the problem.

I suspect using CMA will also be possible but since my kernel doesn't support it, I cannot say for sure.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top