mirror of https://github.com/thesofproject/sof.git
drivers: generic: dummydma: Make the Dummy DMA compatible with caching
The semantics of a DMA driver is to transfer data to/from RAM rather than to/from the DSP cache. As such I need to flush the cache before and after the copy (see comments inline). Signed-off-by: Paul Olaru <paul.olaru@nxp.com>
This commit is contained in:
parent
a564aa293a
commit
44c1d9217f
|
@ -29,6 +29,7 @@
|
|||
#include <sof/audio/component.h>
|
||||
#include <sof/drivers/timer.h>
|
||||
#include <sof/lib/alloc.h>
|
||||
#include <sof/lib/cache.h>
|
||||
#include <sof/lib/dma.h>
|
||||
#include <sof/platform.h>
|
||||
#include <sof/spinlock.h>
|
||||
|
@ -93,10 +94,23 @@ static size_t dummy_dma_copy_crt_elem(struct dma_chan_pdata *pdata,
|
|||
remaining_size = orig_size - pdata->elem_progress;
|
||||
copy_size = MIN(remaining_size, bytes);
|
||||
|
||||
/* On playback, invalidate host buffer (it may lie in a cached area).
|
||||
* Otherwise we could be playing stale data.
|
||||
* On capture this should be safe as host.c does a writeback before
|
||||
* triggering the DMA.
|
||||
*/
|
||||
dcache_invalidate_region((void *)rptr, copy_size);
|
||||
|
||||
/* Perform the copy, being careful if we overflow the elem */
|
||||
ret = memcpy_s((void *)wptr, remaining_size, (void *)rptr, copy_size);
|
||||
assert(!ret);
|
||||
|
||||
/* On capture, writeback the host buffer (it may lie in a cached area).
|
||||
* On playback, also writeback because host.c does an invalidate to
|
||||
* be able to use the data transferred by the DMA.
|
||||
*/
|
||||
dcache_writeback_region((void *)wptr, copy_size);
|
||||
|
||||
pdata->elem_progress += copy_size;
|
||||
|
||||
if (remaining_size == copy_size) {
|
||||
|
|
Loading…
Reference in New Issue