Skip to contentSkip to conversation

generic device DMA implementation

RFC Adam J. Richter 1 participant 1 message Dec 5, 2002

lore
Share & tools
lore
#0 lore raw
Quoted 8 lines · Benjamin Herrenschmidt
Quoted 2 lines · James Bottomley

If you have a machine that has both consistent and inconsistent blocks, you need to encode that in dma_addr_t (which is a platform definable type).

I don't agree here. Encoding things in dma_addr_t, then special casing in consistent_{map,unmap,sync,....) looks really ugly to me ! You want dma_addr_t to contain a bus address for the given bus you are working with and pass that to your device, period.

I don't think that James meant actually defining flag bits
inside of dma_addr_t, although I suppose you could do it for some unused high bits on some architectures. I think the implication was that you could have something like:

static inline int is_consistent(dma_addr_t addr)

{
	return (addr >= CONSISTENT_AREA_START && addr < CONSISTENT_AREA_END);
}

I also don't recall anyone proposing special casing
dma_{map,unmap,sync} based on the results of such a check. I think the only function that might use it would be maybe_wmb(addr,len), which, on some might machines might be:

static inline void maybe_wmb(dma_addr_t addr, size_t len)

{
	if (!is_consistent(addr))
		wmb();
}

In practice, I think dma_malloc() would either always return
consistent memory or never return consistent memory on a given machine, so maybe_wmb would probably never do such range checking. Instead it would compile to nothing on machines where dma_alloc always returned consistent memory, would compile to wmb() on systems where dma_alloc would only succeed if it could return non-consistent memory, and would compile to a procedure pointer on parisc that would either set to point to a no-op or wmb, depending on which kind of machine the kernel was booted on.

Adam J. Richter     __     ______________   575 Oroville Road
[email protected]     \ /                  Milpitas, California 95035
+1 408 309-6081         | g g d r a s i l   United States of America

"Free Software For The Rest Of Us."