tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bus_dma(9) BUS_DMA_COHERENT is a hint (or not)

On Wed, 24 Aug 2011, Frank Zerangue wrote:

> bus_dma(9) specifies that for bus_dmamem_map() the flag BUS_DMA_COHERENT is a 
> hint; and that a device driver must not rely on this flag for correct 
> operation.  All calls to bus_dmamap_sync() must still be made.
> But for frame buffers this seems impractical to me and it appears in 
> practice, that frame buffers that use DMA do indeed depend on this flag and 
> do not call bus_dmamap_sync() functions.  An example of this is 
> arch/arm/xcale/pxa2xo_lcd.c .
> Does anyone have advice on how one should proceed when writing a driver for a 
> new graphics device?

If you want to be portable you should always insert bus_dmamap_sync() 
calls in appropriate places in the code.  On some machines you don't need 
them.  On some machines you don't even need the BUS_DMA_COHERENT flag, but 
that's not portable.   What if your processor has a relaxed memory model 
and stores to memory and writes can be re-ordered before they ever hit the 
cache?  Or there's a cache on the I/O device that needs to be flushed?

OTOH, if you don't care about portability you can do whatever you want.


Home | Main Index | Thread Index | Old Index