Skip to contentSkip to conversation

Does kmalloc always return address below 4GB?

DISCUSSION Adam J. Richter 2 participants 2 messages Mar 5, 2002

lore
Share & tools
lore
#0 lore raw
Quoted 3 lines

Just use pci_alloc_consistent, it never gives you anything larger than 32-bit addresses, please read the documentation :-)

I see the smiley, but let me point out that I have
read Documentation/DMA-mapping.txt and I was misled by this sentence:

| If you acquired your memory via the page allocator
| (i.e. __get_free_page*()) or the generic memory allocators
| (i.e. kmalloc() or kmem_cache_alloc()) then you may DMA to/from
| that memory using the addresses returned from those routines.

It might be a good idea to rephrase it. If I knew what that
sentence I would propose a patch to the DMA-mapping.txt file, but I honestly don't know what proposition that sentence is supposed to convey. If there really is no guarantee that this sentence is conveying, then I guess the sentence should be deleted.

Anyhow, thanks for your quick clarification. The driver
breaking on 64-bit architectures was exactly what I was worried about.

Adam J. Richter     __     ______________   4880 Stevens Creek Blvd, Suite 104
[email protected]     \ /                  San Jose, California 95129-1034
+1 408 261-6630         | g g d r a s i l   United States of America

fax +1 408 261-6631 "Free Software For The Rest Of Us."

#1 lore raw

From: "Adam J. Richter" <[email protected]>
Date: Tue, 5 Mar 2002 03:52:14 -0800

   | If you acquired your memory via the page allocator
   | (i.e. __get_free_page*()) or the generic memory allocators
   | (i.e. kmalloc() or kmem_cache_alloc()) then you may DMA to/from
   | that memory using the addresses returned from those routines.

It might be a good idea to rephrase it. If I knew what that
sentence I would propose a patch to the DMA-mapping.txt file, but I honestly don't know what proposition that sentence is supposed to convey. If there really is no guarantee that this sentence is conveying, then I guess the sentence should be deleted.

Probably it should qualify what it means with "and you used GFP_KERNEL". Because that was the intention.

I'll fix that.

However, you can use GFP_HIGH memory with pci_map_page _iff_ you set your DMA mask to allow 64-bits.

The original impetus for that quoted bit of DMA-mapping.txt was to make sure nobody used vmalloc() or kmap() pointers.