[U-Boot] [PATCH] mmc:dcache: Cache line size aligned internal MMC buffers

Mike Frysinger
2011-08-24T18:06:26Z

On Wednesday, August 24, 2011 13:27:05 Anton Staaf wrote:
> On Wed, Aug 24, 2011 at 6:25 AM, Wolfgang Denk wrote:
> > Lukasz Majewski wrote:
> >> 4. get_dcache_line_size() can be simply defined as
> >> #define get_dcache_line_size() CONFIG_SYS_CACHE_LINE_SIZE if we
> >> _really_ want to save a few bytes.
> >
> > Actually I fail to understand why we would ever need
> > get_dcache_line_size() in a boot loader.
>
> It is required so that we can correctly allocate buffers that will be
> used by DMA engines to read or write data. The reason that these
> buffers need to be cache line size aligned is because unaligned cache
> invalidates are not possible to do in a safe way. The problem is that
> invalidating a partial cache line requires invalidating the entire
> line. And the other part of the line can contain nearby variables
> (especially if the buffer is stack allocated), so we have to first
> flush the cache line to be safe. However, that flush will clobber the
> values that the DMA engine wrote to main memory that are not reflected
> in the cache.

right, and that's why i want to "hide" it be hind a "dma buffer allocate" API
so that people can just say "i want a dma safe buffer" rather than having to
delve into these details. they'll inevitable get confused and screw it up. ;)
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110824/e9c342c4/attachment.pgp