Re: Does kmalloc always return address below 4GB?

David S. Miller (davem@redhat.com)
Tue, 05 Mar 2002 07:15:14 -0800 (PST)


From: "Adam J. Richter" <adam@yggdrasil.com>
Date: Tue, 5 Mar 2002 06:43:35 -0800

Just to be clear, I assume that you mean that you cannot
simply cast these virtual addresses to dma_addr_t and that the
underlying physical memory is not guaranteed to be below 4GB,
but that you can use that memory with pci_map_single if your
PCI device can handle 64 bit addresses.

If I got it right, then here is some proposed replacement
text, to possibly save you a little effort:

You haven't got it right. Physical address > 4GB does not mean
your 32-bit device cannot DMA to it. Stop thinking about
implementation, that's the whole point of the abstraction :-)

On 64-bit platforms that don't set CONFIG_HIGHMEM, they have MMU's on
the PCI bus that can map arbitrary 64-bit physical addresses to 32-bit
PCI bus addresses. So on these platforms you may pass any pointer
from kmalloc()/alloc_page() whatsoever into the pci_map_foo()
routines.

In order to handle highmem pages, you have to set your DMA mask
appropriately (to indicate 64-bit addressing capability) and
use pci_map_page() instead of pci_map_single().

Look at other drivers using the DMA interfaces like the two aic7xxx
and all of the sym53c8xx drivers, they get it right.
-
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/