Re: MAX_DMA_ADDRESS in include/asm/asm-i386/dma.h (2.6.x and 2.4.x)

From: Deepak Saxena
Date: Fri Jul 16 2004 - 17:32:06 EST


On Jul 16 2004, at 15:11, Amit D. Chaudhary was caught saying:
> Deepak,
>
> I am missing what you are directing me to.
>
> If it is,
> pci_alloc_consistent(), linux-2.4.25/arch/i386/kernel/pci-dma.c
> dma_alloc_coherent(), linux-2.6.8-rc1/arch/i386/kernel/pci-dma.c
>
> They internally seem to __get_free_pages()

Correct, but take a second look at the code (2.6):

void *ret;
/* ignore region specifiers */
gfp &= ~(__GFP_DMA | __GFP_HIGHMEM);

if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff))
gfp |= GFP_DMA;

ret = (void *)__get_free_pages(gfp, get_order(size));

It uses GFP_DMA iff your coherent_dma_mask is != 0xffffffff. Assuming
your device can address a the full 32-bit PCI address space, you
need to set the coherent_dma_mask appropriately and you will get
buffers from all addressable lowmem. I don't do much x86, so not
sure how you go about allocating highmem DMA buffers.

> The memory need not be page size, as a matter of fact, using a large
> consecutive block, for example using alloc_bootmem_low() during kernel
> bootup, will simplify the data transfer and result in no internal
> fragmentation, it does introduce inflexibility in changing the size and
> other issues.

If you are using alloc_bootmem_low(), all you should have to do after
allocating the memory is call pci_dma_map_single()/map_sg() to get PCI-DMA
addresses. You still should have no reason to touch MAX_DMA_ADDRESS.

~Deepak

--
Deepak Saxena - dsaxena at plexity dot net - http://www.plexity.net/

"Unlike me, many of you have accepted the situation of your imprisonment and
will die here like rotten cabbages." - Number 6
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/