0

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.

shayst
  • 267
  • 4
  • 14
  • Is your device on an ISA or PCI bus? – CL. Oct 17 '13 at 12:24
  • PCI. Does it affect the function call? – shayst Oct 17 '13 at 13:21
  • For PCI devices, you must set the first parameter of `dma_alloc_coherent`. Anyway, large allocations probably need the [Contiguous Memory Allocator](http://mina86.com/2012/06/10/deep-dive-into-contiguous-memory-allocator-part-i/). – CL. Oct 17 '13 at 13:55
  • The allocation actually works for 2M allocation. Regarding CMA, I understand this is introduced in kernel 3.5, but as I said, I need to work with kernel 3.2 (we are running debian wheezy) – shayst Oct 17 '13 at 14:45

1 Answers1

1

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.

shayst
  • 267
  • 4
  • 14