mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] ARM: mmu64: Don't flush freshly invalidated region
@ 2018-08-24  2:54 Andrey Smirnov
  2018-08-24  8:12 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:54 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Current code for dma_sync_single_for_device(), when called with dir
set to DMA_FROM_DEVICE, will first invalidate given region of memory
as a first step and then clean+invalidate it as a second. While the
second step should be harmless it seems to be an unnecessary no-op
that could probably be avoided.

Analogous code in Linux kernel (4.18) in arch/arm64/mm/cache.S:

ENTRY(__dma_map_area)
	cmp	w2, #DMA_FROM_DEVICE
	b.eq	__dma_inv_area
	b	__dma_clean_area
ENDPIPROC(__dma_map_area)

is written to only perform either invalidate or clean, depending on
the direction, so change dma_sync_single_for_device() to behave in the
same vein and perfom _either_ invlidate or flush of the given region.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/cpu/mmu_64.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/cpu/mmu_64.c b/arch/arm/cpu/mmu_64.c
index b6287aec8..69d1b2071 100644
--- a/arch/arm/cpu/mmu_64.c
+++ b/arch/arm/cpu/mmu_64.c
@@ -297,7 +297,8 @@ void dma_sync_single_for_device(dma_addr_t address, size_t size,
 {
 	if (dir == DMA_FROM_DEVICE)
 		v8_inv_dcache_range(address, address + size - 1);
-	v8_flush_dcache_range(address, address + size - 1);
+	else
+		v8_flush_dcache_range(address, address + size - 1);
 }
 
 dma_addr_t dma_map_single(struct device_d *dev, void *ptr, size_t size,
-- 
2.17.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ARM: mmu64: Don't flush freshly invalidated region
  2018-08-24  2:54 [PATCH] ARM: mmu64: Don't flush freshly invalidated region Andrey Smirnov
@ 2018-08-24  8:12 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2018-08-24  8:12 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: barebox

On Thu, Aug 23, 2018 at 07:54:21PM -0700, Andrey Smirnov wrote:
> Current code for dma_sync_single_for_device(), when called with dir
> set to DMA_FROM_DEVICE, will first invalidate given region of memory
> as a first step and then clean+invalidate it as a second. While the
> second step should be harmless it seems to be an unnecessary no-op
> that could probably be avoided.
> 
> Analogous code in Linux kernel (4.18) in arch/arm64/mm/cache.S:
> 
> ENTRY(__dma_map_area)
> 	cmp	w2, #DMA_FROM_DEVICE
> 	b.eq	__dma_inv_area
> 	b	__dma_clean_area
> ENDPIPROC(__dma_map_area)
> 
> is written to only perform either invalidate or clean, depending on
> the direction, so change dma_sync_single_for_device() to behave in the
> same vein and perfom _either_ invlidate or flush of the given region.
> 
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-08-24  8:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-24  2:54 [PATCH] ARM: mmu64: Don't flush freshly invalidated region Andrey Smirnov
2018-08-24  8:12 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox