linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: dma: Drop cache invalidation from arch_dma_prep_coherent()
@ 2022-08-23 12:21 Will Deacon
  2022-08-24  9:58 ` Ard Biesheuvel
                   ` (3 more replies)
  0 siblings, 4 replies; 21+ messages in thread
From: Will Deacon @ 2022-08-23 12:21 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Will Deacon, Catalin Marinas, Mark Rutland, Robin Murphy,
	Christoph Hellwig, Ard Biesheuvel

arch_dma_prep_coherent() is called when preparing a non-cacheable region
for a consistent DMA buffer allocation. Since the buffer pages may
previously have been written via a cacheable mapping and consequently
allocated as dirty cachelines, the purpose of this function is to remove
these dirty lines from the cache, writing them back so that the
non-coherent device is able to see them.

On arm64, this operation can be achieved with a clean to the point of
coherency; a subsequent invalidation is not required and serves little
purpose in the presence of a cacheable alias (e.g. the linear map),
since clean lines can be speculatively fetched back into the cache after
the invalidation operation has completed.

Relax the cache maintenance in arch_dma_prep_coherent() so that only a
clean, and not a clean-and-invalidate operation is performed.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Will Deacon <will@kernel.org>
---

I'm slightly wary about this change as other architectures seem to do
clean+invalidate here, but I'd like to hear what others think in any
case.

 arch/arm64/mm/dma-mapping.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
index 599cf81f5685..83a512a6ff0d 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -36,7 +36,7 @@ void arch_dma_prep_coherent(struct page *page, size_t size)
 {
 	unsigned long start = (unsigned long)page_address(page);
 
-	dcache_clean_inval_poc(start, start + size);
+	dcache_clean_poc(start, start + size);
 }
 
 #ifdef CONFIG_IOMMU_DMA
-- 
2.37.1.595.g718a3a8f04-goog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-09-22 20:03 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-23 12:21 [PATCH] arm64: dma: Drop cache invalidation from arch_dma_prep_coherent() Will Deacon
2022-08-24  9:58 ` Ard Biesheuvel
2022-08-24 11:23   ` Will Deacon
2022-08-24 11:49     ` Ard Biesheuvel
2022-08-24 22:00 ` Catalin Marinas
2022-09-07  9:04   ` Christoph Hellwig
2022-09-07 14:10     ` Russell King (Oracle)
2022-09-07 14:14       ` Christoph Hellwig
2022-09-07 14:15         ` Russell King (Oracle)
2022-09-07  9:03 ` Christoph Hellwig
2022-09-07  9:27   ` Robin Murphy
2022-09-07 16:25     ` Will Deacon
2022-09-07 17:50       ` Robin Murphy
2022-09-08 10:32       ` Catalin Marinas
2022-09-08 11:32         ` Robin Murphy
2022-09-08 13:02           ` Catalin Marinas
2022-09-08 13:27             ` Catalin Marinas
2022-09-08 13:32               ` Will Deacon
2022-09-08 15:49         ` Catalin Marinas
2022-09-07 16:28   ` Will Deacon
2022-09-22 20:02 ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).