History

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.

Christoph Hellwig committed 5 years ago

Commit 6d4e9a81 parent 14ac09a13 files · +14 −39Browse files

Unified · Split

13 files
  1. arch/mips/Kconfig +0 −1
  2. arch/mips/alchemy/common/setup.c +1 −1
  3. arch/mips/include/asm/dma-coherence.h +0 −22
  4. arch/mips/kernel/setup.c +0 −4
  5. arch/mips/mm/c-r4k.c +1 −1
  6. arch/mips/mm/dma-noncoherent.c +0 −1
  7. arch/mips/mti-malta/malta-setup.c +1 −1
  8. arch/mips/pci/pci-alchemy.c +1 −1
  9. arch/mips/pistachio/init.c +0 −1
  10. drivers/base/core.c +6 −0
  11. include/linux/dma-map-ops.h +2 −3
  12. kernel/dma/Kconfig +0 −3
  13. kernel/dma/mapping.c +2 −0
arch/mips/Kconfig+0−1
@@ -1163,7 +1163,6 @@ config ARCH_SUPPORTS_UPROBES · 1162 unmodified lines
11631163 bool
11641164
11651165 config DMA_MAYBE_COHERENT
1166− select ARCH_HAS_DMA_COHERENCE_H
11671166 select DMA_NONCOHERENT
11681167 bool
11691168
arch/mips/alchemy/common/setup.c+1−1
@@ -28,8 +28,8 @@ · 27 unmodified lines
2828 #include <linux/init.h>
2929 #include <linux/ioport.h>
3030 #include <linux/mm.h>
31+#include <linux/dma-map-ops.h> /* for dma_default_coherent */
3132
32−#include <asm/dma-coherence.h>
3333 #include <asm/mipsregs.h>
3434
3535 #include <au1000.h>
arch/mips/include/asm/dma-coherence.h+0−22
@@ -1,22 +0,0 @@
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
arch/mips/kernel/setup.c+0−4
@@ -36,7 +36,6 @@ · 35 unmodified lines
3636 #include <asm/cdmm.h>
3737 #include <asm/cpu.h>
3838 #include <asm/debug.h>
39−#include <asm/dma-coherence.h>
4039 #include <asm/sections.h>
4140 #include <asm/setup.h>
4241 #include <asm/smp-ops.h>
@@ -803,9 +802,6 @@ arch_initcall(debugfs_mips); · 760 unmodified lines
803802 #endif
804803
805804 #ifdef CONFIG_DMA_MAYBE_COHERENT
806−bool dma_default_coherent;
807−EXPORT_SYMBOL_GPL(dma_default_coherent);
808−
809805 static int __init setcoherentio(char *str)
810806 {
811807 dma_default_coherent = true;
arch/mips/mm/c-r4k.c+1−1
@@ -19,6 +19,7 @@ · 18 unmodified lines
1919 #include <linux/mm.h>
2020 #include <linux/export.h>
2121 #include <linux/bitops.h>
22+#include <linux/dma-map-ops.h> /* for dma_default_coherent */
2223
2324 #include <asm/bcache.h>
2425 #include <asm/bootinfo.h>
@@ -35,7 +36,6 @@ · 10 unmodified lines
3536 #include <asm/war.h>
3637 #include <asm/cacheflush.h> /* for run_uncached() */
3738 #include <asm/traps.h>
38−#include <asm/dma-coherence.h>
3939 #include <asm/mips-cps.h>
4040
4141 /*
arch/mips/mm/dma-noncoherent.c+0−1
@@ -10,7 +10,6 @@ · 9 unmodified lines
1010
1111 #include <asm/cache.h>
1212 #include <asm/cpu-type.h>
13−#include <asm/dma-coherence.h>
1413 #include <asm/io.h>
1514
1615 /*
arch/mips/mti-malta/malta-setup.c+1−1
@@ -13,8 +13,8 @@ · 12 unmodified lines
1313 #include <linux/pci.h>
1414 #include <linux/screen_info.h>
1515 #include <linux/time.h>
16+#include <linux/dma-map-ops.h> /* for dma_default_coherent */
1617
17−#include <asm/dma-coherence.h>
1818 #include <asm/fw/fw.h>
1919 #include <asm/mips-cps.h>
2020 #include <asm/mips-boards/generic.h>
arch/mips/pci/pci-alchemy.c+1−1
@@ -17,8 +17,8 @@ · 16 unmodified lines
1717 #include <linux/init.h>
1818 #include <linux/syscore_ops.h>
1919 #include <linux/vmalloc.h>
20+#include <linux/dma-map-ops.h> /* for dma_default_coherent */
2021
21−#include <asm/dma-coherence.h>
2222 #include <asm/mach-au1x00/au1000.h>
2323 #include <asm/tlbmisc.h>
2424
arch/mips/pistachio/init.c+0−1
@@ -13,7 +13,6 @@ · 12 unmodified lines
1313 #include <linux/of_fdt.h>
1414
1515 #include <asm/cacheflush.h>
16−#include <asm/dma-coherence.h>
1716 #include <asm/fw/fw.h>
1817 #include <asm/mips-boards/generic.h>
1918 #include <asm/mips-cps.h>
drivers/base/core.c+6−0
@@ -28,6 +28,7 @@ · 27 unmodified lines
2828 #include <linux/sched/signal.h>
2929 #include <linux/sched/mm.h>
3030 #include <linux/sysfs.h>
31+#include <linux/dma-map-ops.h> /* for dma_default_coherent */
3132
3233 #include "base.h"
3334 #include "power/power.h"
@@ -2585,6 +2586,11 @@ void device_initialize(struct device *dev) · 2551 unmodified lines
25852586 INIT_LIST_HEAD(&dev->links.suppliers);
25862587 INIT_LIST_HEAD(&dev->links.defer_sync);
25872588 dev->links.status = DL_DEV_NO_DRIVER;
2589+#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
2590+ defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
2591+ defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
2592+ dev->dma_coherent = dma_default_coherent;
2593+#endif
25882594 }
25892595 EXPORT_SYMBOL_GPL(device_initialize);
25902596
include/linux/dma-map-ops.h+2−3
@@ -229,11 +229,10 @@ bool dma_free_from_pool(struct device *dev, void *start, size_t size); · 228 unmodified lines
229229 int dma_direct_set_offset(struct device *dev, phys_addr_t cpu_start,
230230 dma_addr_t dma_start, u64 size);
231231
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) || \
235233 defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
236234 defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
235+extern bool dma_default_coherent;
237236 static inline bool dev_is_dma_coherent(struct device *dev)
238237 {
239238 return dev->dma_coherent;
kernel/dma/Kconfig+0−3
@@ -33,9 +33,6 @@ config NEED_DMA_MAP_STATE · 32 unmodified lines
3333 config ARCH_DMA_ADDR_T_64BIT
3434 def_bool 64BIT || PHYS_ADDR_T_64BIT
3535
36−config ARCH_HAS_DMA_COHERENCE_H
37− bool
38−
3936 config ARCH_HAS_DMA_SET_MASK
4037 bool
4138
kernel/dma/mapping.c+2−0
@@ -16,6 +16,8 @@ · 15 unmodified lines
1616 #include "debug.h"
1717 #include "direct.h"
1818
19+bool dma_default_coherent;
20+
1921 /*
2022 * Managed DMA API
2123 */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t