Skip to contentSkip to conversation

generic device DMA implementation

RFC Adam J. Richter 2 participants 2 messages Dec 5, 2002

lore
Share & tools
lore
#0 lore raw
Quoted 8 lines · James Bottomley
Quoted 7 lines
Quoted 5 lines · [email protected] said:

Do you have an example of where the second option is useful? Off hand the only places I can think of where you'd use a consistent_alloc() rather than map_single() and friends is in cases where the hardware's behaviour means you absolutely positively have to have consistent memory.

Quoted 5 lines
Quoted 3 lines

Well, it comes from parisc drivers. Here you'd really rather have consistent memory because it's more efficient, but on certain platforms it's just not possible.

Hmm... that doesn't seem sufficient to explain it.

The question is not what is possible, but what is optimal.

Yes, it is possible to write drivers for machines without
consistent memory that work with any DMA device, by using dma_{map,sync}_single as you suggest, even if caching could be disabled. That is how drivers/scsi/53c700.c and drivers/net/lasi_82596.c work today.

The advantages of James's approach is that it will result in
these drivers having simpler source code and even smaller object code on machines that do not have this problem.

If were to try the approach of using pci_{map,sync}_single
always (i.e., just writing the code not to use alloc_consistent), that would have a performance cost on machines where using consistent memory for writing small amounts of data is cheaper than the cost of the cache flushes that would otherwise be required.

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."

#1 lore raw
Quoted 22 lines · Adam J. Richter
Quoted 8 lines · James Bottomley
Quoted 7 lines
Quoted 5 lines · [email protected] said:

Do you have an example of where the second option is useful? Off hand the only places I can think of where you'd use a consistent_alloc() rather than map_single() and friends is in cases where the hardware's behaviour means you absolutely positively have to have consistent memory.

Quoted 5 lines
Quoted 3 lines

Well, it comes from parisc drivers. Here you'd really rather have consistent memory because it's more efficient, but on certain platforms it's just not possible.

Hmm... that doesn't seem sufficient to explain it.

The question is not what is possible, but what is optimal.

Yes, it is possible to write drivers for machines without
consistent memory that work with any DMA device, by using dma_{map,sync}_single as you suggest, even if caching could be disabled. That is how drivers/scsi/53c700.c and drivers/net/lasi_82596.c work today.

Quoted 3 lines

The advantages of James's approach is that it will result in
these drivers having simpler source code and even smaller object code on machines that do not have this problem.

Since, with James's approach you'd need a dma sync function (which might compile to NOP) in pretty much the same places you'd need map/sync calls, I don't see that it does make the source noticeably simpler.

The only difference is that the map functions might also involve iommu or similar setup - which also could compile to a nop in some cases.

Quoted 5 lines

If were to try the approach of using pci_{map,sync}_single
always (i.e., just writing the code not to use alloc_consistent), that would have a performance cost on machines where using consistent memory for writing small amounts of data is cheaper than the cost of the cache flushes that would otherwise be required.

Well, I'm only talking about the cases where we actually care about reducing the use of consistent memory.

Signature · 4 lines
David Gibson			| For every complex problem there is a
[email protected]	| solution which is simple, neat and
				| wrong.
http://www.ozlabs.org/people/dgibson