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
1163 bool1163 bool
1164 1164
1165config DMA_MAYBE_COHERENT1165config DMA_MAYBE_COHERENT
1166 select ARCH_HAS_DMA_COHERENCE_H
1167 select DMA_NONCOHERENT1166 select DMA_NONCOHERENT
1168 bool1167 bool
1169 1168
arch/mips/alchemy/common/setup.c+1−1
@@ -28,8 +28,8 @@ · 27 unmodified lines
28#include <linux/init.h>28#include <linux/init.h>
29#include <linux/ioport.h>29#include <linux/ioport.h>
30#include <linux/mm.h>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#include <asm/mipsregs.h>33#include <asm/mipsregs.h>
34 34
35#include <au1000.h>35#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
13extern bool dma_default_coherent;
14static 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
36#include <asm/cdmm.h>36#include <asm/cdmm.h>
37#include <asm/cpu.h>37#include <asm/cpu.h>
38#include <asm/debug.h>38#include <asm/debug.h>
39#include <asm/dma-coherence.h>
40#include <asm/sections.h>39#include <asm/sections.h>
41#include <asm/setup.h>40#include <asm/setup.h>
42#include <asm/smp-ops.h>41#include <asm/smp-ops.h>
@@ -803,9 +802,6 @@ arch_initcall(debugfs_mips); · 760 unmodified lines
803#endif802#endif
804 803
805#ifdef CONFIG_DMA_MAYBE_COHERENT804#ifdef CONFIG_DMA_MAYBE_COHERENT
806bool dma_default_coherent;
807EXPORT_SYMBOL_GPL(dma_default_coherent);
808
809static int __init setcoherentio(char *str)805static int __init setcoherentio(char *str)
810{806{
811 dma_default_coherent = true;807 dma_default_coherent = true;
arch/mips/mm/c-r4k.c+1−1
@@ -19,6 +19,7 @@ · 18 unmodified lines
19#include <linux/mm.h>19#include <linux/mm.h>
20#include <linux/export.h>20#include <linux/export.h>
21#include <linux/bitops.h>21#include <linux/bitops.h>
22#include <linux/dma-map-ops.h> /* for dma_default_coherent */
22 23
23#include <asm/bcache.h>24#include <asm/bcache.h>
24#include <asm/bootinfo.h>25#include <asm/bootinfo.h>
@@ -35,7 +36,6 @@ · 10 unmodified lines
35#include <asm/war.h>36#include <asm/war.h>
36#include <asm/cacheflush.h> /* for run_uncached() */37#include <asm/cacheflush.h> /* for run_uncached() */
37#include <asm/traps.h>38#include <asm/traps.h>
38#include <asm/dma-coherence.h>
39#include <asm/mips-cps.h>39#include <asm/mips-cps.h>
40 40
41/*41/*
arch/mips/mm/dma-noncoherent.c+0−1
@@ -10,7 +10,6 @@ · 9 unmodified lines
10 10
11#include <asm/cache.h>11#include <asm/cache.h>
12#include <asm/cpu-type.h>12#include <asm/cpu-type.h>
13#include <asm/dma-coherence.h>
14#include <asm/io.h>13#include <asm/io.h>
15 14
16/*15/*
arch/mips/mti-malta/malta-setup.c+1−1
@@ -13,8 +13,8 @@ · 12 unmodified lines
13#include <linux/pci.h>13#include <linux/pci.h>
14#include <linux/screen_info.h>14#include <linux/screen_info.h>
15#include <linux/time.h>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#include <asm/fw/fw.h>18#include <asm/fw/fw.h>
19#include <asm/mips-cps.h>19#include <asm/mips-cps.h>
20#include <asm/mips-boards/generic.h>20#include <asm/mips-boards/generic.h>
arch/mips/pci/pci-alchemy.c+1−1
@@ -17,8 +17,8 @@ · 16 unmodified lines
17#include <linux/init.h>17#include <linux/init.h>
18#include <linux/syscore_ops.h>18#include <linux/syscore_ops.h>
19#include <linux/vmalloc.h>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#include <asm/mach-au1x00/au1000.h>22#include <asm/mach-au1x00/au1000.h>
23#include <asm/tlbmisc.h>23#include <asm/tlbmisc.h>
24 24
arch/mips/pistachio/init.c+0−1
@@ -13,7 +13,6 @@ · 12 unmodified lines
13#include <linux/of_fdt.h>13#include <linux/of_fdt.h>
14 14
15#include <asm/cacheflush.h>15#include <asm/cacheflush.h>
16#include <asm/dma-coherence.h>
17#include <asm/fw/fw.h>16#include <asm/fw/fw.h>
18#include <asm/mips-boards/generic.h>17#include <asm/mips-boards/generic.h>
19#include <asm/mips-cps.h>18#include <asm/mips-cps.h>
drivers/base/core.c+6−0
@@ -28,6 +28,7 @@ · 27 unmodified lines
28#include <linux/sched/signal.h>28#include <linux/sched/signal.h>
29#include <linux/sched/mm.h>29#include <linux/sched/mm.h>
30#include <linux/sysfs.h>30#include <linux/sysfs.h>
31#include <linux/dma-map-ops.h> /* for dma_default_coherent */
31 32
32#include "base.h"33#include "base.h"
33#include "power/power.h"34#include "power/power.h"
@@ -2585,6 +2586,11 @@ void device_initialize(struct device *dev) · 2551 unmodified lines
2585 INIT_LIST_HEAD(&dev->links.suppliers);2586 INIT_LIST_HEAD(&dev->links.suppliers);
2586 INIT_LIST_HEAD(&dev->links.defer_sync);2587 INIT_LIST_HEAD(&dev->links.defer_sync);
2587 dev->links.status = DL_DEV_NO_DRIVER;2588 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
2588}2594}
2589EXPORT_SYMBOL_GPL(device_initialize);2595EXPORT_SYMBOL_GPL(device_initialize);
2590 2596
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
229int dma_direct_set_offset(struct device *dev, phys_addr_t cpu_start,229int dma_direct_set_offset(struct device *dev, phys_addr_t cpu_start,
230 dma_addr_t dma_start, u64 size);230 dma_addr_t dma_start, u64 size);
231 231
232#ifdef CONFIG_ARCH_HAS_DMA_COHERENCE_H232#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
233#include <asm/dma-coherence.h>
234#elif defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
235 defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \233 defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
236 defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)234 defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
235extern bool dma_default_coherent;
237static inline bool dev_is_dma_coherent(struct device *dev)236static inline bool dev_is_dma_coherent(struct device *dev)
238{237{
239 return dev->dma_coherent;238 return dev->dma_coherent;
kernel/dma/Kconfig+0−3
@@ -33,9 +33,6 @@ config NEED_DMA_MAP_STATE · 32 unmodified lines
33config ARCH_DMA_ADDR_T_64BIT33config ARCH_DMA_ADDR_T_64BIT
34 def_bool 64BIT || PHYS_ADDR_T_64BIT34 def_bool 64BIT || PHYS_ADDR_T_64BIT
35 35
36config ARCH_HAS_DMA_COHERENCE_H
37 bool
38
39config ARCH_HAS_DMA_SET_MASK36config ARCH_HAS_DMA_SET_MASK
40 bool37 bool
41 38
kernel/dma/mapping.c+2−0
@@ -16,6 +16,8 @@ · 15 unmodified lines
16#include "debug.h"16#include "debug.h"
17#include "direct.h"17#include "direct.h"
18 18
19bool dma_default_coherent;
20
19/*21/*
20 * Managed DMA API22 * Managed DMA API
21 */23 */

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