diff options
| author | Christoph Hellwig <hch@lst.de> | 2018-01-09 10:32:02 -0500 |
|---|---|---|
| committer | Christoph Hellwig <hch@lst.de> | 2018-01-15 03:35:16 -0500 |
| commit | f73337f4cef277f3c70f4bf9bdd6e93a52f57bdd (patch) | |
| tree | f85c2d58516b46d545fdf7e5f72689373a75f301 /arch/cris | |
| parent | 1a9777a8a01fb88659a3dda48080c95c34cab7d3 (diff) | |
cris: use dma-direct
cris currently has an incomplete direct mapping dma_map_ops implementation
if PCI support is enabled. Replace it with the fully feature generic
dma-direct implementation.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
Diffstat (limited to 'arch/cris')
| -rw-r--r-- | arch/cris/Kconfig | 4 | ||||
| -rw-r--r-- | arch/cris/arch-v32/drivers/pci/Makefile | 2 | ||||
| -rw-r--r-- | arch/cris/arch-v32/drivers/pci/dma.c | 77 | ||||
| -rw-r--r-- | arch/cris/include/asm/Kbuild | 1 | ||||
| -rw-r--r-- | arch/cris/include/asm/dma-mapping.h | 20 |
5 files changed, 6 insertions, 98 deletions
diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig index 54d3f426763b..cd5a0865c97f 100644 --- a/arch/cris/Kconfig +++ b/arch/cris/Kconfig | |||
| @@ -33,6 +33,9 @@ config GENERIC_CALIBRATE_DELAY | |||
| 33 | config NO_IOPORT_MAP | 33 | config NO_IOPORT_MAP |
| 34 | def_bool y if !PCI | 34 | def_bool y if !PCI |
| 35 | 35 | ||
| 36 | config NO_DMA | ||
| 37 | def_bool y if !PCI | ||
| 38 | |||
| 36 | config FORCE_MAX_ZONEORDER | 39 | config FORCE_MAX_ZONEORDER |
| 37 | int | 40 | int |
| 38 | default 6 | 41 | default 6 |
| @@ -72,6 +75,7 @@ config CRIS | |||
| 72 | select GENERIC_SCHED_CLOCK if ETRAX_ARCH_V32 | 75 | select GENERIC_SCHED_CLOCK if ETRAX_ARCH_V32 |
| 73 | select HAVE_DEBUG_BUGVERBOSE if ETRAX_ARCH_V32 | 76 | select HAVE_DEBUG_BUGVERBOSE if ETRAX_ARCH_V32 |
| 74 | select HAVE_NMI | 77 | select HAVE_NMI |
| 78 | select DMA_DIRECT_OPS if PCI | ||
| 75 | 79 | ||
| 76 | config HZ | 80 | config HZ |
| 77 | int | 81 | int |
diff --git a/arch/cris/arch-v32/drivers/pci/Makefile b/arch/cris/arch-v32/drivers/pci/Makefile index bff7482f2444..93c8be6170b1 100644 --- a/arch/cris/arch-v32/drivers/pci/Makefile +++ b/arch/cris/arch-v32/drivers/pci/Makefile | |||
| @@ -2,4 +2,4 @@ | |||
| 2 | # Makefile for Etrax cardbus driver | 2 | # Makefile for Etrax cardbus driver |
| 3 | # | 3 | # |
| 4 | 4 | ||
| 5 | obj-$(CONFIG_ETRAX_CARDBUS) += bios.o dma.o | 5 | obj-$(CONFIG_ETRAX_CARDBUS) += bios.o |
diff --git a/arch/cris/arch-v32/drivers/pci/dma.c b/arch/cris/arch-v32/drivers/pci/dma.c deleted file mode 100644 index 8c3802244ef3..000000000000 --- a/arch/cris/arch-v32/drivers/pci/dma.c +++ /dev/null | |||
| @@ -1,77 +0,0 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | /* | ||
| 3 | * Dynamic DMA mapping support. | ||
| 4 | * | ||
| 5 | * On cris there is no hardware dynamic DMA address translation, | ||
| 6 | * so consistent alloc/free are merely page allocation/freeing. | ||
| 7 | * The rest of the dynamic DMA mapping interface is implemented | ||
| 8 | * in asm/pci.h. | ||
| 9 | * | ||
| 10 | * Borrowed from i386. | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include <linux/types.h> | ||
| 14 | #include <linux/mm.h> | ||
| 15 | #include <linux/string.h> | ||
| 16 | #include <linux/pci.h> | ||
| 17 | #include <linux/gfp.h> | ||
| 18 | #include <asm/io.h> | ||
| 19 | |||
| 20 | static void *v32_dma_alloc(struct device *dev, size_t size, | ||
| 21 | dma_addr_t *dma_handle, gfp_t gfp, unsigned long attrs) | ||
| 22 | { | ||
| 23 | void *ret; | ||
| 24 | |||
| 25 | if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff)) | ||
| 26 | gfp |= GFP_DMA; | ||
| 27 | |||
| 28 | ret = (void *)__get_free_pages(gfp, get_order(size)); | ||
| 29 | |||
| 30 | if (ret != NULL) { | ||
| 31 | memset(ret, 0, size); | ||
| 32 | *dma_handle = virt_to_phys(ret); | ||
| 33 | } | ||
| 34 | return ret; | ||
| 35 | } | ||
| 36 | |||
| 37 | static void v32_dma_free(struct device *dev, size_t size, void *vaddr, | ||
| 38 | dma_addr_t dma_handle, unsigned long attrs) | ||
| 39 | { | ||
| 40 | free_pages((unsigned long)vaddr, get_order(size)); | ||
| 41 | } | ||
| 42 | |||
| 43 | static inline dma_addr_t v32_dma_map_page(struct device *dev, | ||
| 44 | struct page *page, unsigned long offset, size_t size, | ||
| 45 | enum dma_data_direction direction, unsigned long attrs) | ||
| 46 | { | ||
| 47 | return page_to_phys(page) + offset; | ||
| 48 | } | ||
| 49 | |||
| 50 | static inline int v32_dma_map_sg(struct device *dev, struct scatterlist *sg, | ||
| 51 | int nents, enum dma_data_direction direction, | ||
| 52 | unsigned long attrs) | ||
| 53 | { | ||
| 54 | printk("Map sg\n"); | ||
| 55 | return nents; | ||
| 56 | } | ||
| 57 | |||
| 58 | static inline int v32_dma_supported(struct device *dev, u64 mask) | ||
| 59 | { | ||
| 60 | /* | ||
| 61 | * we fall back to GFP_DMA when the mask isn't all 1s, | ||
| 62 | * so we can't guarantee allocations that must be | ||
| 63 | * within a tighter range than GFP_DMA.. | ||
| 64 | */ | ||
| 65 | if (mask < 0x00ffffff) | ||
| 66 | return 0; | ||
| 67 | return 1; | ||
| 68 | } | ||
| 69 | |||
| 70 | const struct dma_map_ops v32_dma_ops = { | ||
| 71 | .alloc = v32_dma_alloc, | ||
| 72 | .free = v32_dma_free, | ||
| 73 | .map_page = v32_dma_map_page, | ||
| 74 | .map_sg = v32_dma_map_sg, | ||
| 75 | .dma_supported = v32_dma_supported, | ||
| 76 | }; | ||
| 77 | EXPORT_SYMBOL(v32_dma_ops); | ||
diff --git a/arch/cris/include/asm/Kbuild b/arch/cris/include/asm/Kbuild index 460349cb147f..8cf45ac30c1b 100644 --- a/arch/cris/include/asm/Kbuild +++ b/arch/cris/include/asm/Kbuild | |||
| @@ -5,6 +5,7 @@ generic-y += cmpxchg.h | |||
| 5 | generic-y += current.h | 5 | generic-y += current.h |
| 6 | generic-y += device.h | 6 | generic-y += device.h |
| 7 | generic-y += div64.h | 7 | generic-y += div64.h |
| 8 | generic-y += dma-mapping.h | ||
| 8 | generic-y += emergency-restart.h | 9 | generic-y += emergency-restart.h |
| 9 | generic-y += exec.h | 10 | generic-y += exec.h |
| 10 | generic-y += extable.h | 11 | generic-y += extable.h |
diff --git a/arch/cris/include/asm/dma-mapping.h b/arch/cris/include/asm/dma-mapping.h deleted file mode 100644 index 1553bdb30a0c..000000000000 --- a/arch/cris/include/asm/dma-mapping.h +++ /dev/null | |||
| @@ -1,20 +0,0 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | #ifndef _ASM_CRIS_DMA_MAPPING_H | ||
| 3 | #define _ASM_CRIS_DMA_MAPPING_H | ||
| 4 | |||
| 5 | #ifdef CONFIG_PCI | ||
| 6 | extern const struct dma_map_ops v32_dma_ops; | ||
| 7 | |||
| 8 | static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus) | ||
| 9 | { | ||
| 10 | return &v32_dma_ops; | ||
| 11 | } | ||
| 12 | #else | ||
| 13 | static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus) | ||
| 14 | { | ||
| 15 | BUG(); | ||
| 16 | return NULL; | ||
| 17 | } | ||
| 18 | #endif | ||
| 19 | |||
| 20 | #endif | ||
