diff options
author | Jan Glauber <jang@linux.vnet.ibm.com> | 2012-11-29 08:33:30 -0500 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2012-11-30 11:47:23 -0500 |
commit | 828b35f60eb0148f994bb13e328df94578b07142 (patch) | |
tree | 2e06065339ebbfb9aab46f3167fe77ac952ac6fa /arch/s390/include/asm/dma-mapping.h | |
parent | 9a4da8a5b109906a64bed5aaeb83bf4edb1f5888 (diff) |
s390/pci: DMA support
Add DMA IOMMU support using 4K page table entries. Implement dma_map_ops.
Signed-off-by: Jan Glauber <jang@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/include/asm/dma-mapping.h')
-rw-r--r-- | arch/s390/include/asm/dma-mapping.h | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/arch/s390/include/asm/dma-mapping.h b/arch/s390/include/asm/dma-mapping.h new file mode 100644 index 000000000000..8a32f7dfd3af --- /dev/null +++ b/arch/s390/include/asm/dma-mapping.h | |||
@@ -0,0 +1,76 @@ | |||
1 | #ifndef _ASM_S390_DMA_MAPPING_H | ||
2 | #define _ASM_S390_DMA_MAPPING_H | ||
3 | |||
4 | #include <linux/kernel.h> | ||
5 | #include <linux/types.h> | ||
6 | #include <linux/mm.h> | ||
7 | #include <linux/scatterlist.h> | ||
8 | #include <linux/dma-attrs.h> | ||
9 | #include <linux/dma-debug.h> | ||
10 | #include <linux/io.h> | ||
11 | |||
12 | #define DMA_ERROR_CODE (~(dma_addr_t) 0x0) | ||
13 | |||
14 | extern struct dma_map_ops s390_dma_ops; | ||
15 | |||
16 | static inline struct dma_map_ops *get_dma_ops(struct device *dev) | ||
17 | { | ||
18 | return &s390_dma_ops; | ||
19 | } | ||
20 | |||
21 | extern int dma_set_mask(struct device *dev, u64 mask); | ||
22 | extern int dma_is_consistent(struct device *dev, dma_addr_t dma_handle); | ||
23 | extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size, | ||
24 | enum dma_data_direction direction); | ||
25 | |||
26 | #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) | ||
27 | #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) | ||
28 | |||
29 | #include <asm-generic/dma-mapping-common.h> | ||
30 | |||
31 | static inline int dma_supported(struct device *dev, u64 mask) | ||
32 | { | ||
33 | struct dma_map_ops *dma_ops = get_dma_ops(dev); | ||
34 | |||
35 | if (dma_ops->dma_supported == NULL) | ||
36 | return 1; | ||
37 | return dma_ops->dma_supported(dev, mask); | ||
38 | } | ||
39 | |||
40 | static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) | ||
41 | { | ||
42 | if (!dev->dma_mask) | ||
43 | return 0; | ||
44 | return addr + size - 1 <= *dev->dma_mask; | ||
45 | } | ||
46 | |||
47 | static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) | ||
48 | { | ||
49 | struct dma_map_ops *dma_ops = get_dma_ops(dev); | ||
50 | |||
51 | if (dma_ops->mapping_error) | ||
52 | return dma_ops->mapping_error(dev, dma_addr); | ||
53 | return (dma_addr == 0UL); | ||
54 | } | ||
55 | |||
56 | static inline void *dma_alloc_coherent(struct device *dev, size_t size, | ||
57 | dma_addr_t *dma_handle, gfp_t flag) | ||
58 | { | ||
59 | struct dma_map_ops *ops = get_dma_ops(dev); | ||
60 | void *ret; | ||
61 | |||
62 | ret = ops->alloc(dev, size, dma_handle, flag, NULL); | ||
63 | debug_dma_alloc_coherent(dev, size, *dma_handle, ret); | ||
64 | return ret; | ||
65 | } | ||
66 | |||
67 | static inline void dma_free_coherent(struct device *dev, size_t size, | ||
68 | void *cpu_addr, dma_addr_t dma_handle) | ||
69 | { | ||
70 | struct dma_map_ops *dma_ops = get_dma_ops(dev); | ||
71 | |||
72 | dma_ops->free(dev, size, cpu_addr, dma_handle, NULL); | ||
73 | debug_dma_free_coherent(dev, size, cpu_addr, dma_handle); | ||
74 | } | ||
75 | |||
76 | #endif /* _ASM_S390_DMA_MAPPING_H */ | ||