Potential performance issue on DMA_FROM_DEVICE

Liu Dave-R63238 DaveLiu at freescale.com
Mon Apr 20 13:23:17 EST 2009


Guys,

The commit 03d70617 is using the dcbf for all of unaligned start
or non-multi cache line of size. It will cause performance lost
due to dcbf all M-state cache line in the whole address range
(start->end). It causes unnecessary bus traffic (when the mid part
of range with M-state).

However, we actually need care for only unaligned head part and
unaligned tail part of range (start->end).

Patch welcomed.

Thanks, Dave

Ps:
/*
 * make an area consistent.
 */
void __dma_sync(void *vaddr, size_t size, int direction)
{
        unsigned long start = (unsigned long)vaddr;
        unsigned long end   = start + size;

        switch (direction) {
        case DMA_NONE:
                BUG();
        case DMA_FROM_DEVICE:
                /*
                 * invalidate only when cache-line aligned otherwise
there is
                 * the potential for discarding uncommitted data from
the cache
                 */
                if ((start & (L1_CACHE_BYTES - 1)) || (size &
(L1_CACHE_BYTES - 1)))
                        flush_dcache_range(start, end);
                else
                        invalidate_dcache_range(start, end);
                break;
        case DMA_TO_DEVICE:             /* writeback only */
                clean_dcache_range(start, end);
                break;
        case DMA_BIDIRECTIONAL: /* writeback and invalidate */
                flush_dcache_range(start, end);
                break;
        }
}
EXPORT_SYMBOL(__dma_sync);



More information about the Linuxppc-dev mailing list