[PATCH 4/7] dma-mapping: Always provide dma_default_coherent

Jiaxun Yang posted 7 patches 2 years, 6 months ago
There is a newer version of this series
[PATCH 4/7] dma-mapping: Always provide dma_default_coherent
Posted by Jiaxun Yang 2 years, 6 months ago
dma_default_coherent can be useful for determine default coherency
even on arches without noncoherent support.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 include/linux/dma-map-ops.h | 1 +
 kernel/dma/mapping.c        | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/include/linux/dma-map-ops.h b/include/linux/dma-map-ops.h
index d678afeb8a13..3c6cd17f87c3 100644
--- a/include/linux/dma-map-ops.h
+++ b/include/linux/dma-map-ops.h
@@ -269,6 +269,7 @@ static inline bool dev_is_dma_coherent(struct device *dev)
 	return dev->dma_coherent;
 }
 #else
+#define dma_default_coherent true
 static inline bool dev_is_dma_coherent(struct device *dev)
 {
 	return true;
diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c
index c026a5a5e046..e0b005c8ffce 100644
--- a/kernel/dma/mapping.c
+++ b/kernel/dma/mapping.c
@@ -17,7 +17,11 @@
 #include "debug.h"
 #include "direct.h"
 
+#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
+	defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
+	defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
 bool dma_default_coherent;
+#endif
 
 /*
  * Managed DMA API
-- 
2.37.1 (Apple Git-137.1)
Re: [PATCH 4/7] dma-mapping: Always provide dma_default_coherent
Posted by Christoph Hellwig 2 years, 6 months ago
On Tue, Feb 21, 2023 at 12:46:10PM +0000, Jiaxun Yang wrote:
> dma_default_coherent can be useful for determine default coherency
> even on arches without noncoherent support.

How?
Re: [PATCH 4/7] dma-mapping: Always provide dma_default_coherent
Posted by Jiaxun Yang 2 years, 6 months ago

> 2023年2月21日 17:58,Christoph Hellwig <hch@lst.de> 写道:
> 
> On Tue, Feb 21, 2023 at 12:46:10PM +0000, Jiaxun Yang wrote:
>> dma_default_coherent can be useful for determine default coherency
>> even on arches without noncoherent support.
> 
> How?

I just want to make this symbol always available so OF code can reference it on all arches.
Re: [PATCH 4/7] dma-mapping: Always provide dma_default_coherent
Posted by Robin Murphy 2 years, 6 months ago
On 2023-02-21 17:58, Christoph Hellwig wrote:
> On Tue, Feb 21, 2023 at 12:46:10PM +0000, Jiaxun Yang wrote:
>> dma_default_coherent can be useful for determine default coherency
>> even on arches without noncoherent support.
> 
> How?

Indeed, "default" is conceptually meaningless when there is no possible 
alternative :/

Robin.