[PATCH] allow coherent DMA API to work before main page allocator is set up

Dan Malek dan at embeddededge.com
Sat May 21 07:03:59 EST 2005


On May 20, 2005, at 10:12 AM, Marcelo Tosatti wrote:

> The following patch changes dma_alloc_coherent() to, in case the
> main page allocator is not yet up and running, use the bootmem
> allocator instead.

I'm concerned about this ...  Why did the drivers change in 2.6
such that they now call dma_alloc_coherent() prior to the VM set up?

> It also adds a new parameter to m8xx_cpm_hostalloc() to send back
> the physical address to its caller.

Anyone calling m8xx_cpm_hostalloc() is likely to be immediately
calling dma_alloc_coherent().  There is some design problem here
if we can't properly use these interfaces and get the mapping we
need.  The TLB pinning option won't work if we can't do this.


>  ..... Special casing such as
> drivers/serial/cpm_uart/cpm_uart_cpm1.c's cpm_uart_allocbuf() can be
> removed:
>
>         if (is_con) {
>                 mem_addr = (u8 *) m8xx_cpm_hostalloc(memsz);
>                 dma_addr = 0;
>         } else
>                 mem_addr = dma_alloc_coherent(NULL, memsz, &dma_addr,
>                                               GFP_KERNEL);

This is bogus and should not be necessary.  The original serial
driver was able to work without doing this, I spent lots of time so
stuff like this wasn't necessary, and it's sad to see us take such
a step backward.

> What is your opinion on this approach?

As you can tell, I don't like it and we shouldn't need it :-)
The first call to m8xx_cpm_hostalloc() should be able to call
dma_consistent_alloc() to get a consistent page.  If this isn't the
case, we have to fix the drivers so they can do this.  The only
change that should be necessary is to return the physical address
from m8xx_cpm_hostalloc(), if for some reason we see some
need to get rid of the immensely useful iopa() function.

Thanks.


	-- Dan




More information about the Linuxppc-embedded mailing list