From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gk1KM-00045G-Ny for barebox@lists.infradead.org; Thu, 17 Jan 2019 06:39:03 +0000 Received: by mail-pl1-x643.google.com with SMTP id b5so4270066plr.4 for ; Wed, 16 Jan 2019 22:38:58 -0800 (PST) From: Andrey Smirnov Date: Wed, 16 Jan 2019 22:38:35 -0800 Message-Id: <20190117063840.13674-8-andrew.smirnov@gmail.com> In-Reply-To: <20190117063840.13674-1-andrew.smirnov@gmail.com> References: <20190117063840.13674-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH 07/12] ARM64: mmu: Invalidate memory before remapping as DMA coherent To: barebox@lists.infradead.org Cc: Andrey Smirnov Although there are known problems caused by this, it seems prudent to invalidate the region of memory we are about remap as uncached. Additionaliy this matches how dma_alloc_coherent() is implemented on ARM. Signed-off-by: Andrey Smirnov --- arch/arm/cpu/mmu_64.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm/cpu/mmu_64.c b/arch/arm/cpu/mmu_64.c index a7186eda4..1ee6a3b8c 100644 --- a/arch/arm/cpu/mmu_64.c +++ b/arch/arm/cpu/mmu_64.c @@ -248,6 +248,14 @@ void mmu_disable(void) isb(); } +static void dma_inv_range(void *ptr, size_t size) +{ + unsigned long start = (unsigned long)ptr; + unsigned long end = start + size - 1; + + v8_inv_dcache_range(start, end); +} + void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle) { void *ret; @@ -257,6 +265,8 @@ void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle) if (dma_handle) *dma_handle = (dma_addr_t)ret; + dma_inv_range(ret, size); + arch_remap_range(ret, size, MAP_UNCACHED); return ret; -- 2.20.1 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox