linux-mips
[Top] [All Lists]

Re: DMA_NONCOHERENT and dma_map_single

To: Dimitri Torfs <dimitri@sonycom.com>
Subject: Re: DMA_NONCOHERENT and dma_map_single
From: Ralf Baechle <ralf@linux-mips.org>
Date: Mon, 19 Jan 2004 00:05:19 +0100
Cc: linux-mips@linux-mips.org
In-reply-to: <20040118195006.GA22616@sonycom.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <20040118195006.GA22616@sonycom.com>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mutt/1.4.1i
On Sun, Jan 18, 2004 at 08:50:06PM +0100, Dimitri Torfs wrote:

>   dma_map_single() is supposed to be called on a buffer that exactly
>   starts and ends on a cacheline boundary, otherwise "bad things"
>   (e.g. overwrite of data that was written by device, ...) (especially
>   on dma non-coherent systems) may happen. 
> 
>   So what should be done when dma_map_single is not called
>   with a sane (ptr, size) argument ?
> 
>     - is the driver (caller) considered buggy and should we return a 0
>       return-value ?
>     - is the driver (caller) considered buggy but we do the mapping
>       anyway, hoping that the driver has not/will not touched/touch
>       the boundary cachelines ?

The driver is considered buggy;  dma_map_single's behaviour is undefined so
it's perfectly ok if it paints neighbour's cat pink ;-)

>     - should we take appropriate actions to make sure the
>       cache-effects do not come into play (e.g. by using some kind of
>       bounce buffer) ?

Technically bounce buffers can be handled inside dma_map_single & co but
it's not a good idea.  Better set the appropriate flags so higher levels
can allocate memory with the appropriate GFP_* flags and thereby hopefully
avoid overly frequent buffer bouncing.

  Ralf

<Prev in Thread] Current Thread [Next in Thread>