* [PATCH] common: bouncebuf: Use dma-mapping for cache ops
@ 2023-01-06 18:02 Andrew Davis
2023-01-07 0:13 ` Simon Glass
2023-01-27 19:07 ` Tom Rini
0 siblings, 2 replies; 3+ messages in thread
From: Andrew Davis @ 2023-01-06 18:02 UTC (permalink / raw)
To: Simon Glass, Tom Rini, u-boot; +Cc: Andrew Davis
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>
---
common/bouncebuf.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/common/bouncebuf.c b/common/bouncebuf.c
index 6d98920de66..93a35668cc2 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)
--
2.38.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] common: bouncebuf: Use dma-mapping for cache ops
2023-01-06 18:02 [PATCH] common: bouncebuf: Use dma-mapping for cache ops Andrew Davis
@ 2023-01-07 0:13 ` Simon Glass
2023-01-27 19:07 ` Tom Rini
1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2023-01-07 0:13 UTC (permalink / raw)
To: Andrew Davis; +Cc: Tom Rini, u-boot
On Fri, 6 Jan 2023 at 11:02, Andrew Davis <afd@ti.com> wrote:
>
> 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>
> ---
> common/bouncebuf.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
Reviewed-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] common: bouncebuf: Use dma-mapping for cache ops
2023-01-06 18:02 [PATCH] common: bouncebuf: Use dma-mapping for cache ops Andrew Davis
2023-01-07 0:13 ` Simon Glass
@ 2023-01-27 19:07 ` Tom Rini
1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2023-01-27 19:07 UTC (permalink / raw)
To: Andrew Davis; +Cc: Simon Glass, u-boot
[-- Attachment #1: Type: text/plain, Size: 339 bytes --]
On Fri, Jan 06, 2023 at 12:02:50PM -0600, Andrew Davis wrote:
> 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>
Applied to u-boot/master, thanks!
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-27 19:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-06 18:02 [PATCH] common: bouncebuf: Use dma-mapping for cache ops Andrew Davis
2023-01-07 0:13 ` Simon Glass
2023-01-27 19:07 ` Tom Rini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox