public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Vignesh Raghavendra <vigneshr@ti.com>
To: u-boot@lists.denx.de
Subject: [PATCH v4 03/10] soc: ti: k3-navss-ringacc: Flush/invalidate caches on ring push/pop
Date: Mon, 9 Dec 2019 10:25:33 +0530	[thread overview]
Message-ID: <20191209045540.10702-4-vigneshr@ti.com> (raw)
In-Reply-To: <20191209045540.10702-1-vigneshr@ti.com>

Flush caches when pushing an element to ring and invalidate caches when
popping an element from ring in Exposed Ring mode. Otherwise DMA
transfers don't work properly in R5 SPL (with caches enabled) where the
core is not in coherency domain.

Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
 drivers/soc/ti/k3-navss-ringacc.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/soc/ti/k3-navss-ringacc.c b/drivers/soc/ti/k3-navss-ringacc.c
index 64ebc0ba0030..f06ea29c986c 100644
--- a/drivers/soc/ti/k3-navss-ringacc.c
+++ b/drivers/soc/ti/k3-navss-ringacc.c
@@ -6,6 +6,7 @@
  */
 
 #include <common.h>
+#include <cpu_func.h>
 #include <asm/io.h>
 #include <malloc.h>
 #include <asm/dma-mapping.h>
@@ -807,6 +808,11 @@ static int k3_nav_ringacc_ring_push_mem(struct k3_nav_ring *ring, void *elem)
 
 	memcpy(elem_ptr, elem, (4 << ring->elm_size));
 
+	flush_dcache_range((unsigned long)ring->ring_mem_virt,
+			   ALIGN((unsigned long)ring->ring_mem_virt +
+				 ring->size * (4 << ring->elm_size),
+				 ARCH_DMA_MINALIGN));
+
 	ring->windex = (ring->windex + 1) % ring->size;
 	ring->free--;
 	ringacc_writel(1, &ring->rt->db);
@@ -823,6 +829,11 @@ static int k3_nav_ringacc_ring_pop_mem(struct k3_nav_ring *ring, void *elem)
 
 	elem_ptr = k3_nav_ringacc_get_elm_addr(ring, ring->rindex);
 
+	invalidate_dcache_range((unsigned long)ring->ring_mem_virt,
+				ALIGN((unsigned long)ring->ring_mem_virt +
+				      ring->size * (4 << ring->elm_size),
+				      ARCH_DMA_MINALIGN));
+
 	memcpy(elem, elem_ptr, (4 << ring->elm_size));
 
 	ring->rindex = (ring->rindex + 1) % ring->size;
-- 
2.24.0

  parent reply	other threads:[~2019-12-09  4:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-09  4:55 [PATCH v4 00/10] dma: ti: k3-udma: Add support for J721e Vignesh Raghavendra
2019-12-09  4:55 ` [PATCH v4 01/10] lib: Import few bitmap functions from Linux Vignesh Raghavendra
2019-12-09  4:55 ` [PATCH v4 02/10] dma: ti: k3-udma: Query DMA channels allocated from Resource Manager Vignesh Raghavendra
2019-12-09  4:55 ` Vignesh Raghavendra [this message]
2019-12-09  4:55 ` [PATCH v4 04/10] soc: ti: k3-navss-ringacc: Get SYSFW reference from DT phandle Vignesh Raghavendra
2019-12-09  4:55 ` [PATCH v4 05/10] dma: ti: k3-udma: Remove coherency check for cache ops Vignesh Raghavendra
2019-12-09  4:55 ` [PATCH v4 06/10] dma: ti: k3-udma: Fix debug prints during enabling MEM_TO_DEV transfers Vignesh Raghavendra
2019-12-09  4:55 ` [PATCH v4 07/10] dma: ti: k3-udma: Switch to exposed ring mode Vignesh Raghavendra
2019-12-09  4:55 ` [PATCH v4 08/10] dma: ti: k3-udma: Fix ring push operation for 32 bit cores Vignesh Raghavendra
2019-12-09  4:55 ` [PATCH v4 09/10] dma: ti: k3-udma: Fix build warnings when building for 32 bit platforms Vignesh Raghavendra
2019-12-09  4:55 ` [PATCH v4 10/10] dma: ti: k3-udma: Add new compatible to J721e Vignesh Raghavendra
2020-01-20  5:58 ` [PATCH v4 00/10] dma: ti: k3-udma: Add support for J721e Lokesh Vutla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191209045540.10702-4-vigneshr@ti.com \
    --to=vigneshr@ti.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox