Re: _PAGE_PCD bit in DMAable memory

From: Roland Dreier
Date: Sun May 16 2004 - 21:21:38 EST


fc> Hi, I am trying to get DMAable memory on i386
fc> (kmalloc(GFP_DMA,)) but seems _PAGE_PCD is not set on the
fc> pages that i get back the memory from. Am I getting the
fc> correct results? If yes, then is it not that GFP_DMA should
fc> give me non-cacheable memory (equivalent to setting _PAGE_PCD
fc> along with _PAGE_PWT on i386). Can anyone confirm for me that
fc> GFP_DMA will *always* give me non-cacheable and contiguous
fc> memory.

On i386, the GFP_DMA flag controls _where_ the memory will be
allocated, namely in the low 16 MB. This is really a relic of the
days of 24-bit ISA DMA.

On i386, the memory does not have to be non-cacheable, since in the PC
architecture the bus controller will maintain consistency by snooping
the CPU. However, to be portable, your code should use
pci_alloc_consistent() to get memory for DMAing. This will do the
right thing on all platforms, including making sure that the memory is
non-cacheable on architectures where the bus controller does not snoop.

(By the way, kmalloc() will always return contiguous memory, but you
should still use pci_alloc_consistent for DMA memory)

- Roland
-
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/