Re: [PATCH 2/5] dma-mapping: move the dma_coherent flag to struct device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 10, 2018 at 04:19:30PM +0100, Robin Murphy wrote:
> If we're likely to refer to it more than once, is it worth wrapping that 
> condition up in something like ARCH_HAS_NONCOHERENT_DMA?

Below is what we'd need.  Which to me doesn't look wortwhile for just
those two conditionals:

diff --git a/include/linux/device.h b/include/linux/device.h
index 983506789402..d260536f6f46 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -1018,9 +1018,7 @@ struct device {
 	bool			offline_disabled:1;
 	bool			offline:1;
 	bool			of_node_reused:1;
-#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)
+#ifdef CONFIG_ARCH_HAS_NONCOHERENT_DMA
 	bool			dma_coherent:1;
 #endif
 };
diff --git a/include/linux/dma-noncoherent.h b/include/linux/dma-noncoherent.h
index 9051b055beec..9e3adf924d1e 100644
--- a/include/linux/dma-noncoherent.h
+++ b/include/linux/dma-noncoherent.h
@@ -6,9 +6,7 @@
 
 #ifdef CONFIG_ARCH_HAS_DMA_COHERENCE_H
 #include <asm/dma-coherence.h>
-#elif 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)
+#elif defined(CONFIG_ARCH_HAS_NONCOHERENT_DMA)
 static inline bool dev_is_dma_coherent(struct device *dev)
 {
 	return dev->dma_coherent;
diff --git a/kernel/dma/Kconfig b/kernel/dma/Kconfig
index 645c7a2ecde8..06283d6e305b 100644
--- a/kernel/dma/Kconfig
+++ b/kernel/dma/Kconfig
@@ -29,6 +29,11 @@ config ARCH_HAS_SYNC_DMA_FOR_CPU
 config ARCH_HAS_SYNC_DMA_FOR_CPU_ALL
 	bool
 
+config ARCH_HAS_NONCOHERENT_DMA
+	def_bool ARCH_HAS_SYNC_DMA_FOR_DEVICE || \
+		ARCH_HAS_SYNC_DMA_FOR_CPU || \
+		ARCH_HAS_SYNC_DMA_FOR_CPU_ALL
+
 config ARCH_HAS_DMA_COHERENT_TO_PFN
 	bool
 


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux