aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Davis <afd@ti.com>2023-01-06 12:02:50 -0600
committerTom Rini <trini@konsulko.com>2023-01-26 14:17:59 -0500
commit62d4b2b2277b94502e2dcac37a975e20e3d2cbec (patch)
tree742f543d2a1d8b36b7a9ae99c2d4e3c3a73b09e2
parent1ea40869e8a056d0e779164cbf2139be6568d835 (diff)
downloadu-boot-62d4b2b2277b94502e2dcac37a975e20e3d2cbec.zip
u-boot-62d4b2b2277b94502e2dcac37a975e20e3d2cbec.tar.gz
u-boot-62d4b2b2277b94502e2dcac37a975e20e3d2cbec.tar.bz2
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>
-rw-r--r--common/bouncebuf.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/common/bouncebuf.c b/common/bouncebuf.c
index 6d98920..93a3566 100644
--- a/common/bouncebuf.c
+++ b/common/bouncebuf.c
@@ -12,6 +12,7 @@
#include <errno.h>
#include <bouncebuf.h>
#include <asm/cache.h>
+#include <linux/dma-mapping.h>
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,
* and any CPU writebacks don't race with DMA writes
*/
- flush_dcache_range((unsigned long)state->bounce_buffer,
- (unsigned long)(state->bounce_buffer) +
- state->len_aligned);
+ dma_map_single(state->bounce_buffer,
+ state->len_aligned,
+ DMA_BIDIRECTIONAL);
return 0;
}
@@ -78,9 +79,9 @@ int bounce_buffer_stop(struct bounce_buffer *state)
{
if (state->flags & GEN_BB_WRITE) {
/* Invalidate cache so that CPU can see any newly DMA'd data */
- invalidate_dcache_range((unsigned long)state->bounce_buffer,
- (unsigned long)(state->bounce_buffer) +
- state->len_aligned);
+ dma_unmap_single((dma_addr_t)state->bounce_buffer,
+ state->len_aligned,
+ DMA_BIDIRECTIONAL);
}
if (state->bounce_buffer == state->user_buffer)