Subject: Re: 64 bit DMA tags for PCI
To: Frank van der Linden <>
From: Matt Thomas <>
List: tech-kern
Date: 05/12/2003 00:15:38
At 10:02 AM 5/11/2003, Frank van der Linden wrote:
>In order to avoid bounce buffers on machines with more than 4G of ram,
>we need a way to specify that a platform is capable of doing DMA to/from
>addresses that are 64 bits wide. The easiest way is to encode this in
>the DMA tag. It's been suggested before to add a pa_dmat64 to the PCI
>attach args, and I agree that this is a good way to do it, short of
>more invasive changes to the bus_dma interface.
>The above isn't hard to implement, but I'm undecided about some issues.
>A device driver knows if a device is capable of 64bit DMA. Some devices
>need to be explicitly told to do so, and use seperate data structures
>for it. Others, like wm(4) and bge(4), simply always deal with 64bit
>addresses. The driver must make a decision to use 64bit DMA addressing
>or not; for a 32bit platform it may not be worth switching on because
>of extra overhead.
>The following are possible
>         * Always have the 32bit and 64bit tag point to valid DMA tags,
>           but have them possibly be the same. This means that a device
>           driver can always pick the 64bit one, but may have some overhead
>           for using wider data structures, etc.

This is simple but I think too simple.

>         * Define a PCI_DMA_NO_TAG value, assigned to the 64bit tag if
>           64bit PCI DMA is not available on this platform. Have the
>           driver check for it, and only use the 64bit tag if it's
>           != PCI_DMA_NO_TAG. Even then, you may still do a bit too
>           much work, as you may have a system that can do 64bit DMA
>           addressing, but has less than 4G of memory.

I also want a #define that indicates the 64bit DMA is available so that
if it isn't present, the code can be compiled out.  No need for 64bit
DMA support on macppc or hpcmips for instance

>         * Define a function like pci_dma64_available(pa), that makes
>           a platform-specific decision about the use/need for
>           64bit DMA addressing. A default version would be:
>         int pci_dma64_available(struct pci_attach_args *pa)
>         {
>                 if (sizeof(bus_addr_t) >= 8 &&
>                     pa->pa_dmat64 != PCI_DMA_NO_TAG &&
>                     (uint64_t)physmem > 0xffffffffULL)
>                         return 1;
>                 return 0;
>         }

Since bus_dma_tag_t are pointers, why not let this function
return the bus_dma_tag_t for 64bit dma if useful or NULL if not.

>- Frank
>Frank van der Linden                          
>---------------------- -------------------------
>NetBSD development                                     Embedded, Storage, 

Matt Thomas               Internet:
3am Software Foundry      WWW URL:
Cupertino, CA             Disclaimer: I avow all knowledge of this message