Re: Does kmalloc always return address below 4GB?

Gerd Knorr
2002-03-06T07:00:23Z

> >Look at other drivers using the DMA interfaces like the two aic7xxx
> >and all of the sym53c8xx drivers, they get it right.
>
> Grepping for vmalloc and kmap in them turns up no hits.

Why do you want to vmalloc() memory in the scsi driver?

> computer with >4GB of RAM (CONFIG_HIGHEM) talking to a PCI card
> that only does 32-bit addressing:
>
> pci_set_dma_mask(pcidev, 0xffffffff);
> addr = vmalloc(nbytes);
> /* On an x86 with >4GB of RAM, addr will be <4GB, but
> __pa(addr) might be >4GB, and the system lacks
> PCI address mapping harware. */

use vmalloc_32(), this one returns lowmem.

> dma_addr = pci_map_single(pcidev, addr, nbytes, direction);

This is illegal because addr is a kernel _virtual_ address. You have to
get the page using vmalloc_to_page() and feed this to pci_map_page()
then. With nbytes > PAGE_SIZE you probably want to build a scatterlist
and use pci_map_sg().

Gerd

--
#include </dev/tty>