Allocating uncached memory in 2.6.25(powerpc/440)

3 messages, 2 authors, 2008-09-19 · open the first message on its own page

Allocating uncached memory in 2.6.25(powerpc/440)

From: vb <hidden>
Date: 2008-09-19 21:47:19

I wonder if anyone can help with some hints in this situation:

here is a code fragment to illustrate my question:

if ((ai = kmalloc(sizeof(alloc_info_t) + 4 * szw, GFP_ATOMIC |
GFP_DMA)) != NULL) {
        ai->src = FROM_KMALLOC;
printk("\n%s:%d %p\n", __FUNCTION__, __LINE__, ai);
 while(szw) {

Re: Allocating uncached memory in 2.6.25(powerpc/440)

From: vb <hidden>
Date: 2008-09-19 21:56:12

Oh man, sorry, those damn keyboard shortcuts, let me try again :-)


I wonder if anyone can help with some hints in this situation:

here is a code fragment to illustrate the questions:

 if ((ai = kmalloc(sizeof(alloc_info_t) + 4 * szw, GFP_ATOMIC |
GFP_DMA)) != NULL) {
        ai->src = FROM_KMALLOC;
       printk("\n%s:%d %p\n", __FUNCTION__, __LINE__, ai);

basically, a block of contiguous memory is allocated. This block is
needed to set up some DMA descriptors, so it needs to be uncached, and
I thought this is what GFP_DMA flag is for.

I stop execution using a JTAG probe right after the printk above, and
examine the TLB matching the allocated address.

This is what printk reports:
sal_alloc:163 eee76000

And the TLB record for this memory is the default kernel 256M page:

61 : 00 e0000000 256MB V0 -> 0_20000000 U:0000 ---G- ---XWR

Which is obviously cached (missing the I bit set).

How is this supposed to work?

Is this right to expect the address returned by kmalloc() to be mapped
to uncached TLB in case GFP_DMA flag is passed in?

What are the proper ways of setting up shared memory in this kernel?


Any hints will be highly appreciated,

TIA,
Vadim

Re: Allocating uncached memory in 2.6.25(powerpc/440)

From: Roland Dreier <hidden>
Date: 2008-09-19 22:09:45

 > basically, a block of contiguous memory is allocated. This block is
 > needed to set up some DMA descriptors, so it needs to be uncached, and
 > I thought this is what GFP_DMA flag is for.

No, GFP_DMA doesn't have that meaning.  To allocate uncached memory, use
dma_alloc_coherent().

 - R.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help