Alignment problems: arm_memblock_steal() + dma_declare_coherent_memory()

2 messages, 2 authors, 2012-09-14 · open the first message on its own page

Alignment problems: arm_memblock_steal() + dma_declare_coherent_memory()

From: javier Martin <hidden>
Date: 2012-09-14 08:49:28

Hello,
we use arm_memblock_steal() + dma_declare_coherent_memory() in order
to reserve son contiguous video memory in our platform:
http://git.linuxtv.org/media_tree.git/blob/refs/heads/staging/for_v3.7:/arch/arm/mach-imx/mach-imx27_visstrim_m10.c

We've noticed that some restrictive alignment constraints are being
applied. For example, for coda driver, the following allocations are
made:

coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 557056
bytes, out of 8388608 (vaddr = 0xc6000000) PAGE_SHIFT = 0xc
coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 65536
bytes, out of 8388608 (vaddr = 0xc6100000) PAGE_SHIFT = 0xc
coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 10240
bytes, out of 8388608 (vaddr = 0xc6110000) PAGE_SHIFT = 0xc
coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 622080
bytes, out of 8388608 (vaddr = 0xc6200000) PAGE_SHIFT = 0xc
coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 622080
bytes, out of 8388608 (vaddr = 0xc6300000) PAGE_SHIFT = 0xc
coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 622080
bytes, out of 8388608 (vaddr = 0xc6400000) PAGE_SHIFT = 0xc
coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 589824
bytes, out of 8388608 (vaddr = 0xc6500000) PAGE_SHIFT = 0xc
coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 589824
bytes, out of 8388608 (vaddr = 0xc6600000) PAGE_SHIFT = 0xc
coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 622080
bytes, out of 8388608 (vaddr = 0xc6700000) PAGE_SHIFT = 0xc

If we take a look at the size of each allocation and the different
vaddr values we find that the alignment is 0x100000 = 1MB for values
like 622080 byte size. Why is that?
A lot of memory is being wasted this way and our HW does not have such
1MB alignment requirements.

Regards.
-- 
Javier Martin
Vista Silicon S.L.
CDTUC - FASE C - Oficina S-345
Avda de los Castros s/n
39005- Santander. Cantabria. Spain
+34 942 25 32 60
www.vista-silicon.com

Re: Alignment problems: arm_memblock_steal() + dma_declare_coherent_memory()

From: Russell King - ARM Linux <hidden>
Date: 2012-09-14 09:23:55

On Fri, Sep 14, 2012 at 10:49:27AM +0200, javier Martin wrote:
Hello,
we use arm_memblock_steal() + dma_declare_coherent_memory() in order
to reserve son contiguous video memory in our platform:
http://git.linuxtv.org/media_tree.git/blob/refs/heads/staging/for_v3.7:/arch/arm/mach-imx/mach-imx27_visstrim_m10.c

We've noticed that some restrictive alignment constraints are being
applied. For example, for coda driver, the following allocations are
made:

coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 557056
bytes, out of 8388608 (vaddr = 0xc6000000) PAGE_SHIFT = 0xc
coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 65536
bytes, out of 8388608 (vaddr = 0xc6100000) PAGE_SHIFT = 0xc
coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 10240
bytes, out of 8388608 (vaddr = 0xc6110000) PAGE_SHIFT = 0xc
coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 622080
bytes, out of 8388608 (vaddr = 0xc6200000) PAGE_SHIFT = 0xc
coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 622080
bytes, out of 8388608 (vaddr = 0xc6300000) PAGE_SHIFT = 0xc
coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 622080
bytes, out of 8388608 (vaddr = 0xc6400000) PAGE_SHIFT = 0xc
coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 589824
bytes, out of 8388608 (vaddr = 0xc6500000) PAGE_SHIFT = 0xc
coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 589824
bytes, out of 8388608 (vaddr = 0xc6600000) PAGE_SHIFT = 0xc
coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 622080
bytes, out of 8388608 (vaddr = 0xc6700000) PAGE_SHIFT = 0xc

If we take a look at the size of each allocation and the different
vaddr values we find that the alignment is 0x100000 = 1MB for values
like 622080 byte size. Why is that?
Have you thought about get_order() on the allocation size, and what the
resulting order will be?  I'm sure if you could come up with a better
allocation algorithm for this which doesn't lead to too much fragmentation
(or convert it to use the pool infrastructure)...

BTW, your question has nothing to do with arm_memblock_steal().
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help