Rename dcache_dma_preread() to dcache_inv_poc_dma() to make it clear that it

is a dcache invalidate to point of coherency just like dcache_inv_poc(), but
a slightly different version specific to dma operations.  Elaborate the
comment about how and why it's different.
This commit is contained in:
Ian Lepore 2015-10-24 19:39:41 +00:00
parent 18c74b2242
commit d818f2b6b9
2 changed files with 10 additions and 8 deletions

View File

@ -1284,7 +1284,7 @@ dma_preread_safe(vm_offset_t va, vm_paddr_t pa, vm_size_t size)
if ((va + size) & cpuinfo.dcache_line_mask)
dcache_wb_poc(va + size, pa + size, 1);
dcache_dma_preread(va, pa, size);
dcache_inv_poc_dma(va, pa, size);
}
static void
@ -1406,7 +1406,7 @@ _bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op)
if ((op & BUS_DMASYNC_PREREAD) && !(op & BUS_DMASYNC_PREWRITE)) {
bpage = STAILQ_FIRST(&map->bpages);
while (bpage != NULL) {
dcache_dma_preread(bpage->vaddr, bpage->busaddr,
dcache_inv_poc_dma(bpage->vaddr, bpage->busaddr,
bpage->datacount);
bpage = STAILQ_NEXT(bpage, links);
}

View File

@ -471,15 +471,17 @@ dcache_inv_poc(vm_offset_t va, vm_paddr_t pa, vm_size_t size)
}
/*
* Discard D-cache lines to PoC, prior to overwrite by DMA engine
* Discard D-cache lines to PoC, prior to overwrite by DMA engine.
*
* Invalidate caches, discarding data in dirty lines. This is useful
* if the memory is about to be overwritten, e.g. by a DMA engine.
* Invalidate caches from innermost to outermost to follow the flow
* of dirty cachelines.
* Normal invalidation does L2 then L1 to ensure that stale data from L2 doesn't
* flow into L1 while invalidating. This routine is intended to be used only
* when invalidating a buffer before a DMA operation loads new data into memory.
* The concern in this case is that dirty lines are not evicted to main memory,
* overwriting the DMA data. For that reason, the L1 is done first to ensure
* that an evicted L1 line doesn't flow to L2 after the L2 has been cleaned.
*/
static __inline void
dcache_dma_preread(vm_offset_t va, vm_paddr_t pa, vm_size_t size)
dcache_inv_poc_dma(vm_offset_t va, vm_paddr_t pa, vm_size_t size)
{
vm_offset_t eva = va + size;