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.
Unified · Split
| @@ -1163,7 +1163,6 @@ config ARCH_SUPPORTS_UPROBES · 1162 unmodified lines | ||
| 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 | |
| @@ -28,8 +28,8 @@ · 27 unmodified lines | ||
| 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> |
| @@ -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 | |
| @@ -36,7 +36,6 @@ · 35 unmodified lines | ||
| 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> |
| @@ -803,9 +802,6 @@ arch_initcall(debugfs_mips); · 760 unmodified lines | ||
| 803 | 802 | #endif |
| 804 | 803 | |
| 805 | 804 | #ifdef CONFIG_DMA_MAYBE_COHERENT |
| 806 | −bool dma_default_coherent; | |
| 807 | −EXPORT_SYMBOL_GPL(dma_default_coherent); | |
| 808 | − | |
| 809 | 805 | static int __init setcoherentio(char *str) |
| 810 | 806 | { |
| 811 | 807 | dma_default_coherent = true; |
| @@ -19,6 +19,7 @@ · 18 unmodified lines | ||
| 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> |
| @@ -35,7 +36,6 @@ · 10 unmodified lines | ||
| 35 | 36 | #include <asm/war.h> |
| 36 | 37 | #include <asm/cacheflush.h> /* for run_uncached() */ |
| 37 | 38 | #include <asm/traps.h> |
| 38 | −#include <asm/dma-coherence.h> | |
| 39 | 39 | #include <asm/mips-cps.h> |
| 40 | 40 | |
| 41 | 41 | /* |
| @@ -10,7 +10,6 @@ · 9 unmodified lines | ||
| 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 | /* |
| @@ -13,8 +13,8 @@ · 12 unmodified lines | ||
| 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> |
| @@ -17,8 +17,8 @@ · 16 unmodified lines | ||
| 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 | |
| @@ -13,7 +13,6 @@ · 12 unmodified lines | ||
| 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> |
| @@ -28,6 +28,7 @@ · 27 unmodified lines | ||
| 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" |
| @@ -2585,6 +2586,11 @@ void device_initialize(struct device *dev) · 2551 unmodified lines | ||
| 2585 | 2586 | INIT_LIST_HEAD(&dev->links.suppliers); |
| 2586 | 2587 | INIT_LIST_HEAD(&dev->links.defer_sync); |
| 2587 | 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 | } |
| 2589 | 2595 | EXPORT_SYMBOL_GPL(device_initialize); |
| 2590 | 2596 | |
| @@ -229,11 +229,10 @@ bool dma_free_from_pool(struct device *dev, void *start, size_t size); · 228 unmodified lines | ||
| 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; |
| @@ -33,9 +33,6 @@ config NEED_DMA_MAP_STATE · 32 unmodified lines | ||
| 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 | |
| @@ -16,6 +16,8 @@ · 15 unmodified lines | ||
| 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 | */ |