_bus_dmamap_sync() and L2 cache sync

Svatopluk Kraus onwahe at gmail.com
Mon Dec 9 12:14:40 UTC 2013


Hi,

when I and Michal Meloun were debugging problems on our ethernet driver on
arm11 mpcore platform at work, we found out that rx/tx descriptors rings
are not correctly synced for DMA. These descriptors are mapped as
uncachable, i.e. their bus_dmamap_t maps have DMAMAP_COHERENT flag set.

We realized that L2 cache must be synced the same way as L1 cache. I.e., L2
cache write buffer and others must be flushed before DMA is started.

Now, in our implementation, we always call cache_dma_sync() in the
beginning of _bus_dmamap_sync() even for DMAMAP_COHERENT maps. The
cache_dma_sync() is implemented as:

static __inline void
cache_dma_sync(void)
{

    dsb();
    l2cache.sync(l2cache.arg);
    dsb();
}

Regards,
Svatopluk Kraus


More information about the freebsd-arm mailing list