common: bouncebuf: Use dma-mapping for cache ops
This matches how this would be done in Linux and these functions do the alignment for us which makes the code look cleaner. Signed-off-by: Andrew Davis <afd@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
9787ecfd0d
commit
b75ca26b22
1 changed files with 7 additions and 6 deletions
|
@ -12,6 +12,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <bouncebuf.h>
|
#include <bouncebuf.h>
|
||||||
#include <asm/cache.h>
|
#include <asm/cache.h>
|
||||||
|
#include <linux/dma-mapping.h>
|
||||||
|
|
||||||
static int addr_aligned(struct bounce_buffer *state)
|
static int addr_aligned(struct bounce_buffer *state)
|
||||||
{
|
{
|
||||||
|
@ -59,9 +60,9 @@ int bounce_buffer_start_extalign(struct bounce_buffer *state, void *data,
|
||||||
* Flush data to RAM so DMA reads can pick it up,
|
* Flush data to RAM so DMA reads can pick it up,
|
||||||
* and any CPU writebacks don't race with DMA writes
|
* and any CPU writebacks don't race with DMA writes
|
||||||
*/
|
*/
|
||||||
flush_dcache_range((unsigned long)state->bounce_buffer,
|
dma_map_single(state->bounce_buffer,
|
||||||
(unsigned long)(state->bounce_buffer) +
|
state->len_aligned,
|
||||||
state->len_aligned);
|
DMA_BIDIRECTIONAL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -78,9 +79,9 @@ int bounce_buffer_stop(struct bounce_buffer *state)
|
||||||
{
|
{
|
||||||
if (state->flags & GEN_BB_WRITE) {
|
if (state->flags & GEN_BB_WRITE) {
|
||||||
/* Invalidate cache so that CPU can see any newly DMA'd data */
|
/* Invalidate cache so that CPU can see any newly DMA'd data */
|
||||||
invalidate_dcache_range((unsigned long)state->bounce_buffer,
|
dma_unmap_single((dma_addr_t)state->bounce_buffer,
|
||||||
(unsigned long)(state->bounce_buffer) +
|
state->len_aligned,
|
||||||
state->len_aligned);
|
DMA_BIDIRECTIONAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->bounce_buffer == state->user_buffer)
|
if (state->bounce_buffer == state->user_buffer)
|
||||||
|
|
Loading…
Reference in a new issue