Subject: Re: [PATCH] powerpc: rework dma-noncoherent to use generic vmap/vunmap functions

From: Benjamin Herrenschmidt <[email-masked]>
Date: Wed, 04 Feb 2009 15:43:45 +1100

On Fri, 2009-01-09 at 15:58 +0300, Ilya Yanok wrote:
> This patch rewrites consistent dma allocations support to use vmalloc
> layer to allocate virtual memory space from vmalloc pool and get rid
> of CONFIG_CONSISTENT_{START,SIZE}.

So as commented before, please drop the defconfig updates.

I'm happy with the idea but I have a few nits with the implementation:

> -/*
>   * Allocate DMA-coherent memory space and return both the kernel remapped
>   * virtual and bus address for that space.
>   */
> @@ -151,19 +41,17 @@ void *
>  __dma_alloc_coherent(size_t size, dma_addr_t *handle, gfp_t gfp)
>  {
>  	struct page *page;
> -	struct vm_region *c;
>  	unsigned long order;
> +	void *v;
> +	int i;
> +	struct page *pages[PAGE_ALIGN(size)>>PAGE_SHIFT];

I'm not -too- fan of that page list one the stack up there.

I understand why you don't wantto kmalloc something here etc... but
that's what __vmalloc_area() does and it's somewhat useful to keep track
of the page array that way, it might prove handy in the future.

Might even be worth adding a generic patch to add a VM_COHERENT_DMA flag
so they can be listed as such and make sure you set the "caller" field
yourself with your own caller.

(Hint: look at the output of /proc/vmallocinfo)

Also, the mucking around with PG_Reserved shouldn't be of any use
anymore.

Cheers,
Ben.