Flushing DMA Buffer Allocated with AllocateCommonBuffer

If I allocate a buffer using AllocateCommonBuffer for use by my DMA and
specify that caching is allowed, how do I flush the data to the actual
memory on a write or clear the cache lines before a read of updated data
when the device writes? Should I just stick with non-cache enable common
buffer?

Data written by the cpu to a device can exists in the cache (unless this is
write-through cache) and needs to get flushed to the actual physical memory
so the device can bus master it.

Data written by a device can exist in the memory but the cache lines may
have old data in them so they need to be invalidated before the cpu can
‘read’ the data.

Direct is not direct when caches are involved…

“Moreira, Alberto” wrote in message
news:xxxxx@ntdev…
>
> Think of it: it’s called “direct” memory access because it doesn’t involve
> the processors. Caches belong in the processors. Ergo…
>
> Alberto.
>