Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

driver core: lift dma_default_coherent into common code

Lift the dma_default_coherent variable from the mips architecture code
to the driver core. This allows an architecture to sdefault all device
to be DMA coherent at run time, even if the kernel is build with support
for DMA noncoherent device. By allowing device_initialize to set the
->dma_coherent field to this default the amount of arch hooks required
for this behavior can be greatly reduced.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Christoph Hellwig and committed by
Thomas Bogendoerfer
6d4e9a8e 14ac09a6

+14 -39
-1
arch/mips/Kconfig
··· 1163 1163 bool 1164 1164 1165 1165 config DMA_MAYBE_COHERENT 1166 - select ARCH_HAS_DMA_COHERENCE_H 1167 1166 select DMA_NONCOHERENT 1168 1167 bool 1169 1168
+1 -1
arch/mips/alchemy/common/setup.c
··· 28 28 #include <linux/init.h> 29 29 #include <linux/ioport.h> 30 30 #include <linux/mm.h> 31 + #include <linux/dma-map-ops.h> /* for dma_default_coherent */ 31 32 32 - #include <asm/dma-coherence.h> 33 33 #include <asm/mipsregs.h> 34 34 35 35 #include <au1000.h>
-22
arch/mips/include/asm/dma-coherence.h
··· 1 - /* 2 - * This file is subject to the terms and conditions of the GNU General Public 3 - * License. See the file "COPYING" in the main directory of this archive 4 - * for more details. 5 - * 6 - * Copyright (C) 2006 Ralf Baechle <ralf@linux-mips.org> 7 - * 8 - */ 9 - #ifndef __ASM_DMA_COHERENCE_H 10 - #define __ASM_DMA_COHERENCE_H 11 - 12 - #ifdef CONFIG_DMA_MAYBE_COHERENT 13 - extern bool dma_default_coherent; 14 - static inline bool dev_is_dma_coherent(struct device *dev) 15 - { 16 - return dma_default_coherent; 17 - } 18 - #else 19 - #define dma_default_coherent (!IS_ENABLED(CONFIG_DMA_NONCOHERENT)) 20 - #endif 21 - 22 - #endif
-4
arch/mips/kernel/setup.c
··· 36 36 #include <asm/cdmm.h> 37 37 #include <asm/cpu.h> 38 38 #include <asm/debug.h> 39 - #include <asm/dma-coherence.h> 40 39 #include <asm/sections.h> 41 40 #include <asm/setup.h> 42 41 #include <asm/smp-ops.h> ··· 802 803 #endif 803 804 804 805 #ifdef CONFIG_DMA_MAYBE_COHERENT 805 - bool dma_default_coherent; 806 - EXPORT_SYMBOL_GPL(dma_default_coherent); 807 - 808 806 static int __init setcoherentio(char *str) 809 807 { 810 808 dma_default_coherent = true;
+1 -1
arch/mips/mm/c-r4k.c
··· 19 19 #include <linux/mm.h> 20 20 #include <linux/export.h> 21 21 #include <linux/bitops.h> 22 + #include <linux/dma-map-ops.h> /* for dma_default_coherent */ 22 23 23 24 #include <asm/bcache.h> 24 25 #include <asm/bootinfo.h> ··· 36 35 #include <asm/war.h> 37 36 #include <asm/cacheflush.h> /* for run_uncached() */ 38 37 #include <asm/traps.h> 39 - #include <asm/dma-coherence.h> 40 38 #include <asm/mips-cps.h> 41 39 42 40 /*
-1
arch/mips/mm/dma-noncoherent.c
··· 10 10 11 11 #include <asm/cache.h> 12 12 #include <asm/cpu-type.h> 13 - #include <asm/dma-coherence.h> 14 13 #include <asm/io.h> 15 14 16 15 /*
+1 -1
arch/mips/mti-malta/malta-setup.c
··· 13 13 #include <linux/pci.h> 14 14 #include <linux/screen_info.h> 15 15 #include <linux/time.h> 16 + #include <linux/dma-map-ops.h> /* for dma_default_coherent */ 16 17 17 - #include <asm/dma-coherence.h> 18 18 #include <asm/fw/fw.h> 19 19 #include <asm/mips-cps.h> 20 20 #include <asm/mips-boards/generic.h>
+1 -1
arch/mips/pci/pci-alchemy.c
··· 17 17 #include <linux/init.h> 18 18 #include <linux/syscore_ops.h> 19 19 #include <linux/vmalloc.h> 20 + #include <linux/dma-map-ops.h> /* for dma_default_coherent */ 20 21 21 - #include <asm/dma-coherence.h> 22 22 #include <asm/mach-au1x00/au1000.h> 23 23 #include <asm/tlbmisc.h> 24 24
-1
arch/mips/pistachio/init.c
··· 13 13 #include <linux/of_fdt.h> 14 14 15 15 #include <asm/cacheflush.h> 16 - #include <asm/dma-coherence.h> 17 16 #include <asm/fw/fw.h> 18 17 #include <asm/mips-boards/generic.h> 19 18 #include <asm/mips-cps.h>
+6
drivers/base/core.c
··· 28 28 #include <linux/sched/signal.h> 29 29 #include <linux/sched/mm.h> 30 30 #include <linux/sysfs.h> 31 + #include <linux/dma-map-ops.h> /* for dma_default_coherent */ 31 32 32 33 #include "base.h" 33 34 #include "power/power.h" ··· 2586 2585 INIT_LIST_HEAD(&dev->links.suppliers); 2587 2586 INIT_LIST_HEAD(&dev->links.defer_sync); 2588 2587 dev->links.status = DL_DEV_NO_DRIVER; 2588 + #if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \ 2589 + defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \ 2590 + defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL) 2591 + dev->dma_coherent = dma_default_coherent; 2592 + #endif 2589 2593 } 2590 2594 EXPORT_SYMBOL_GPL(device_initialize); 2591 2595
+2 -3
include/linux/dma-map-ops.h
··· 229 229 int dma_direct_set_offset(struct device *dev, phys_addr_t cpu_start, 230 230 dma_addr_t dma_start, u64 size); 231 231 232 - #ifdef CONFIG_ARCH_HAS_DMA_COHERENCE_H 233 - #include <asm/dma-coherence.h> 234 - #elif defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \ 232 + #if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \ 235 233 defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \ 236 234 defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL) 235 + extern bool dma_default_coherent; 237 236 static inline bool dev_is_dma_coherent(struct device *dev) 238 237 { 239 238 return dev->dma_coherent;
-3
kernel/dma/Kconfig
··· 33 33 config ARCH_DMA_ADDR_T_64BIT 34 34 def_bool 64BIT || PHYS_ADDR_T_64BIT 35 35 36 - config ARCH_HAS_DMA_COHERENCE_H 37 - bool 38 - 39 36 config ARCH_HAS_DMA_SET_MASK 40 37 bool 41 38
+2
kernel/dma/mapping.c
··· 16 16 #include "debug.h" 17 17 #include "direct.h" 18 18 19 + bool dma_default_coherent; 20 + 19 21 /* 20 22 * Managed DMA API 21 23 */