diff options
| -rw-r--r-- | arch/sparc/Kconfig | 1 | ||||
| -rw-r--r-- | arch/sparc/include/asm/dma-mapping.h | 107 | ||||
| -rw-r--r-- | arch/sparc/kernel/dma.c | 4 | ||||
| -rw-r--r-- | arch/sparc/kernel/iommu.c | 4 | ||||
| -rw-r--r-- | arch/sparc/kernel/pci_sun4v.c | 2 |
5 files changed, 19 insertions, 99 deletions
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 3f8b6a92eabd..5f2df99645c9 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig | |||
| @@ -25,6 +25,7 @@ config SPARC | |||
| 25 | select ARCH_WANT_OPTIONAL_GPIOLIB | 25 | select ARCH_WANT_OPTIONAL_GPIOLIB |
| 26 | select RTC_CLASS | 26 | select RTC_CLASS |
| 27 | select RTC_DRV_M48T59 | 27 | select RTC_DRV_M48T59 |
| 28 | select HAVE_DMA_ATTRS | ||
| 28 | 29 | ||
| 29 | config SPARC32 | 30 | config SPARC32 |
| 30 | def_bool !64BIT | 31 | def_bool !64BIT |
diff --git a/arch/sparc/include/asm/dma-mapping.h b/arch/sparc/include/asm/dma-mapping.h index 893f3ecc9750..34c92264208a 100644 --- a/arch/sparc/include/asm/dma-mapping.h +++ b/arch/sparc/include/asm/dma-mapping.h | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #include <linux/scatterlist.h> | 4 | #include <linux/scatterlist.h> |
| 5 | #include <linux/mm.h> | 5 | #include <linux/mm.h> |
| 6 | #include <linux/dma-debug.h> | ||
| 6 | 7 | ||
| 7 | #define DMA_ERROR_CODE (~(dma_addr_t)0x0) | 8 | #define DMA_ERROR_CODE (~(dma_addr_t)0x0) |
| 8 | 9 | ||
| @@ -13,113 +14,31 @@ extern int dma_set_mask(struct device *dev, u64 dma_mask); | |||
| 13 | #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) | 14 | #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) |
| 14 | #define dma_is_consistent(d, h) (1) | 15 | #define dma_is_consistent(d, h) (1) |
| 15 | 16 | ||
| 16 | extern const struct dma_map_ops *dma_ops; | 17 | extern struct dma_map_ops *dma_ops; |
| 17 | 18 | ||
| 18 | static inline void *dma_alloc_coherent(struct device *dev, size_t size, | 19 | static inline struct dma_map_ops *get_dma_ops(struct device *dev) |
| 19 | dma_addr_t *dma_handle, gfp_t flag) | ||
| 20 | { | ||
| 21 | return dma_ops->alloc_coherent(dev, size, dma_handle, flag); | ||
| 22 | } | ||
| 23 | |||
| 24 | static inline void dma_free_coherent(struct device *dev, size_t size, | ||
| 25 | void *cpu_addr, dma_addr_t dma_handle) | ||
| 26 | { | ||
| 27 | dma_ops->free_coherent(dev, size, cpu_addr, dma_handle); | ||
| 28 | } | ||
| 29 | |||
| 30 | static inline dma_addr_t dma_map_single(struct device *dev, void *cpu_addr, | ||
| 31 | size_t size, | ||
| 32 | enum dma_data_direction direction) | ||
| 33 | { | 20 | { |
| 34 | return dma_ops->map_page(dev, virt_to_page(cpu_addr), | 21 | return dma_ops; |
| 35 | (unsigned long)cpu_addr & ~PAGE_MASK, size, | ||
| 36 | direction, NULL); | ||
| 37 | } | 22 | } |
| 38 | 23 | ||
| 39 | static inline void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, | 24 | #include <asm-generic/dma-mapping-common.h> |
| 40 | size_t size, | ||
| 41 | enum dma_data_direction direction) | ||
| 42 | { | ||
| 43 | dma_ops->unmap_page(dev, dma_addr, size, direction, NULL); | ||
| 44 | } | ||
| 45 | |||
| 46 | static inline dma_addr_t dma_map_page(struct device *dev, struct page *page, | ||
| 47 | unsigned long offset, size_t size, | ||
| 48 | enum dma_data_direction direction) | ||
| 49 | { | ||
| 50 | return dma_ops->map_page(dev, page, offset, size, direction, NULL); | ||
| 51 | } | ||
| 52 | 25 | ||
| 53 | static inline void dma_unmap_page(struct device *dev, dma_addr_t dma_address, | 26 | static inline void *dma_alloc_coherent(struct device *dev, size_t size, |
| 54 | size_t size, | 27 | dma_addr_t *dma_handle, gfp_t flag) |
| 55 | enum dma_data_direction direction) | ||
| 56 | { | ||
| 57 | dma_ops->unmap_page(dev, dma_address, size, direction, NULL); | ||
| 58 | } | ||
| 59 | |||
| 60 | static inline int dma_map_sg(struct device *dev, struct scatterlist *sg, | ||
| 61 | int nents, enum dma_data_direction direction) | ||
| 62 | { | ||
| 63 | return dma_ops->map_sg(dev, sg, nents, direction, NULL); | ||
| 64 | } | ||
| 65 | |||
| 66 | static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg, | ||
| 67 | int nents, enum dma_data_direction direction) | ||
| 68 | { | ||
| 69 | dma_ops->unmap_sg(dev, sg, nents, direction, NULL); | ||
| 70 | } | ||
| 71 | |||
| 72 | static inline void dma_sync_single_for_cpu(struct device *dev, | ||
| 73 | dma_addr_t dma_handle, size_t size, | ||
| 74 | enum dma_data_direction direction) | ||
| 75 | { | ||
| 76 | dma_ops->sync_single_for_cpu(dev, dma_handle, size, direction); | ||
| 77 | } | ||
| 78 | |||
| 79 | static inline void dma_sync_single_for_device(struct device *dev, | ||
| 80 | dma_addr_t dma_handle, | ||
| 81 | size_t size, | ||
| 82 | enum dma_data_direction direction) | ||
| 83 | { | ||
| 84 | if (dma_ops->sync_single_for_device) | ||
| 85 | dma_ops->sync_single_for_device(dev, dma_handle, size, | ||
| 86 | direction); | ||
| 87 | } | ||
| 88 | |||
| 89 | static inline void dma_sync_sg_for_cpu(struct device *dev, | ||
| 90 | struct scatterlist *sg, int nelems, | ||
| 91 | enum dma_data_direction direction) | ||
| 92 | { | 28 | { |
| 93 | dma_ops->sync_sg_for_cpu(dev, sg, nelems, direction); | 29 | struct dma_map_ops *ops = get_dma_ops(dev); |
| 94 | } | ||
| 95 | 30 | ||
| 96 | static inline void dma_sync_sg_for_device(struct device *dev, | 31 | return ops->alloc_coherent(dev, size, dma_handle, flag); |
| 97 | struct scatterlist *sg, int nelems, | ||
| 98 | enum dma_data_direction direction) | ||
| 99 | { | ||
| 100 | if (dma_ops->sync_sg_for_device) | ||
| 101 | dma_ops->sync_sg_for_device(dev, sg, nelems, direction); | ||
| 102 | } | 32 | } |
| 103 | 33 | ||
| 104 | static inline void dma_sync_single_range_for_cpu(struct device *dev, | 34 | static inline void dma_free_coherent(struct device *dev, size_t size, |
| 105 | dma_addr_t dma_handle, | 35 | void *cpu_addr, dma_addr_t dma_handle) |
| 106 | unsigned long offset, | ||
| 107 | size_t size, | ||
| 108 | enum dma_data_direction dir) | ||
| 109 | { | 36 | { |
| 110 | dma_sync_single_for_cpu(dev, dma_handle+offset, size, dir); | 37 | struct dma_map_ops *ops = get_dma_ops(dev); |
| 111 | } | ||
| 112 | 38 | ||
| 113 | static inline void dma_sync_single_range_for_device(struct device *dev, | 39 | ops->free_coherent(dev, size, cpu_addr, dma_handle); |
| 114 | dma_addr_t dma_handle, | ||
| 115 | unsigned long offset, | ||
| 116 | size_t size, | ||
| 117 | enum dma_data_direction dir) | ||
| 118 | { | ||
| 119 | dma_sync_single_for_device(dev, dma_handle+offset, size, dir); | ||
| 120 | } | 40 | } |
| 121 | 41 | ||
| 122 | |||
| 123 | static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) | 42 | static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) |
| 124 | { | 43 | { |
| 125 | return (dma_addr == DMA_ERROR_CODE); | 44 | return (dma_addr == DMA_ERROR_CODE); |
diff --git a/arch/sparc/kernel/dma.c b/arch/sparc/kernel/dma.c index 473a3fc7ab5b..15820a918171 100644 --- a/arch/sparc/kernel/dma.c +++ b/arch/sparc/kernel/dma.c | |||
| @@ -165,7 +165,7 @@ static void dma32_sync_sg_for_device(struct device *dev, | |||
| 165 | BUG(); | 165 | BUG(); |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | static const struct dma_map_ops dma32_dma_ops = { | 168 | static struct dma_map_ops dma32_dma_ops = { |
| 169 | .alloc_coherent = dma32_alloc_coherent, | 169 | .alloc_coherent = dma32_alloc_coherent, |
| 170 | .free_coherent = dma32_free_coherent, | 170 | .free_coherent = dma32_free_coherent, |
| 171 | .map_page = dma32_map_page, | 171 | .map_page = dma32_map_page, |
| @@ -178,5 +178,5 @@ static const struct dma_map_ops dma32_dma_ops = { | |||
| 178 | .sync_sg_for_device = dma32_sync_sg_for_device, | 178 | .sync_sg_for_device = dma32_sync_sg_for_device, |
| 179 | }; | 179 | }; |
| 180 | 180 | ||
| 181 | const struct dma_map_ops *dma_ops = &dma32_dma_ops; | 181 | struct dma_map_ops *dma_ops = &dma32_dma_ops; |
| 182 | EXPORT_SYMBOL(dma_ops); | 182 | EXPORT_SYMBOL(dma_ops); |
diff --git a/arch/sparc/kernel/iommu.c b/arch/sparc/kernel/iommu.c index a9f0ad955186..74b289cab552 100644 --- a/arch/sparc/kernel/iommu.c +++ b/arch/sparc/kernel/iommu.c | |||
| @@ -826,7 +826,7 @@ static void dma_4u_sync_sg_for_cpu(struct device *dev, | |||
| 826 | spin_unlock_irqrestore(&iommu->lock, flags); | 826 | spin_unlock_irqrestore(&iommu->lock, flags); |
| 827 | } | 827 | } |
| 828 | 828 | ||
| 829 | static const struct dma_map_ops sun4u_dma_ops = { | 829 | static struct dma_map_ops sun4u_dma_ops = { |
| 830 | .alloc_coherent = dma_4u_alloc_coherent, | 830 | .alloc_coherent = dma_4u_alloc_coherent, |
| 831 | .free_coherent = dma_4u_free_coherent, | 831 | .free_coherent = dma_4u_free_coherent, |
| 832 | .map_page = dma_4u_map_page, | 832 | .map_page = dma_4u_map_page, |
| @@ -837,7 +837,7 @@ static const struct dma_map_ops sun4u_dma_ops = { | |||
| 837 | .sync_sg_for_cpu = dma_4u_sync_sg_for_cpu, | 837 | .sync_sg_for_cpu = dma_4u_sync_sg_for_cpu, |
| 838 | }; | 838 | }; |
| 839 | 839 | ||
| 840 | const struct dma_map_ops *dma_ops = &sun4u_dma_ops; | 840 | struct dma_map_ops *dma_ops = &sun4u_dma_ops; |
| 841 | EXPORT_SYMBOL(dma_ops); | 841 | EXPORT_SYMBOL(dma_ops); |
| 842 | 842 | ||
| 843 | int dma_supported(struct device *dev, u64 device_mask) | 843 | int dma_supported(struct device *dev, u64 device_mask) |
diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c index c4f7dce577dd..ee800f927929 100644 --- a/arch/sparc/kernel/pci_sun4v.c +++ b/arch/sparc/kernel/pci_sun4v.c | |||
| @@ -539,7 +539,7 @@ static void dma_4v_sync_sg_for_cpu(struct device *dev, | |||
| 539 | /* Nothing to do... */ | 539 | /* Nothing to do... */ |
| 540 | } | 540 | } |
| 541 | 541 | ||
| 542 | static const struct dma_map_ops sun4v_dma_ops = { | 542 | static struct dma_map_ops sun4v_dma_ops = { |
| 543 | .alloc_coherent = dma_4v_alloc_coherent, | 543 | .alloc_coherent = dma_4v_alloc_coherent, |
| 544 | .free_coherent = dma_4v_free_coherent, | 544 | .free_coherent = dma_4v_free_coherent, |
| 545 | .map_page = dma_4v_map_page, | 545 | .map_page = dma_4v_map_page, |
