kmalloc(..., GFP_ATOMIC) buffers contiguous - hence suitable for

Khachaturov, Vassilii (Vassilii.Khachaturov@comverse.com)
Tue, 8 May 2001 10:24:58 -0400


Hi folks!

(I have looked up in the archive the linux-kernel threads for kwds
"DMA, contiguous, address" before writing this mail, and read the
corresponding threads.)

I am trying to port some driver to Linux2.4/i386. I have just read
the "Linux device drivers" book by A.Rubini, and this is what he
says there in Ch.13 "Mmap & DMA", on the GFP_DMA allocator flag:

"The kernel guarantees that DMA-capable buffers have 2 features.
1st, the phys. addrs must be conseccutive when get_free_page()
returns > 1 page (but this is always true, indep. of GFP_DMA,
because the kernel arranges free memory in clusters of consecutive pages).
And second, when GFP_DMA is set, the kernel guarantees that only addrs lower
than MAX_DMA_ADDRESS are returned. The macro MAX_DMA_ADDRESS is set to 16MB
on the PC, to deal with the
ISA [...].

As far as PCI is concerned, there's no MAX_DMA_ADDRESS limit,
and a PCI dev. driver should avoid setting GFP_DMA when
allocating its buffers."

Is this really still true at kernels 2.2 and on? (The book
refers to 2.1.43 as to the most modern version as of the time
of its writing) I.e., can I just assume a buffer which I know
to have been successfully allocated with just a
kmalloc(..., GFP_ATOMIC)
will be physically contiguous and hence suitable for PCI DMA?

I tried to understand the corresponding code path in mm/slab.c,
but failed to come up with a 100%-assuring opinion out of it.

The driver and the device at present are not oriented for
doing scatter-gather.

TIA for any possible help,
Vassilii
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/