diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2009-01-05 09:59:02 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-01-06 08:06:57 -0500 |
commit | 160c1d8e40866edfeae7d68816b7005d70acf391 (patch) | |
tree | 37dd78b2ea28a3953a46d401bd9657005eb444d7 /arch/ia64 | |
parent | f0402a262e1a4c03fc66b83659823bdcaac3c41a (diff) |
x86, ia64: convert to use generic dma_map_ops struct
This converts X86 and IA64 to use include/linux/dma-mapping.h.
It's a bit large but pretty boring. The major change for X86 is
converting 'int dir' to 'enum dma_data_direction dir' in DMA mapping
operations. The major changes for IA64 is using map_page and
unmap_page instead of map_single and unmap_single.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Acked-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/ia64')
-rw-r--r-- | arch/ia64/dig/Makefile | 4 | ||||
-rw-r--r-- | arch/ia64/dig/dig_vtd_iommu.c | 77 | ||||
-rw-r--r-- | arch/ia64/hp/common/hwsw_iommu.c | 6 | ||||
-rw-r--r-- | arch/ia64/hp/common/sba_iommu.c | 46 | ||||
-rw-r--r-- | arch/ia64/include/asm/dma-mapping.h | 107 | ||||
-rw-r--r-- | arch/ia64/include/asm/machvec.h | 12 | ||||
-rw-r--r-- | arch/ia64/kernel/dma-mapping.c | 4 | ||||
-rw-r--r-- | arch/ia64/kernel/machvec.c | 8 | ||||
-rw-r--r-- | arch/ia64/kernel/pci-dma.c | 49 | ||||
-rw-r--r-- | arch/ia64/kernel/pci-swiotlb.c | 32 | ||||
-rw-r--r-- | arch/ia64/sn/pci/pci_dma.c | 58 |
11 files changed, 167 insertions, 236 deletions
diff --git a/arch/ia64/dig/Makefile b/arch/ia64/dig/Makefile index 5c0283830bd6..2f7caddf093e 100644 --- a/arch/ia64/dig/Makefile +++ b/arch/ia64/dig/Makefile | |||
@@ -7,8 +7,8 @@ | |||
7 | 7 | ||
8 | obj-y := setup.o | 8 | obj-y := setup.o |
9 | ifeq ($(CONFIG_DMAR), y) | 9 | ifeq ($(CONFIG_DMAR), y) |
10 | obj-$(CONFIG_IA64_GENERIC) += machvec.o machvec_vtd.o dig_vtd_iommu.o | 10 | obj-$(CONFIG_IA64_GENERIC) += machvec.o machvec_vtd.o |
11 | else | 11 | else |
12 | obj-$(CONFIG_IA64_GENERIC) += machvec.o | 12 | obj-$(CONFIG_IA64_GENERIC) += machvec.o |
13 | endif | 13 | endif |
14 | obj-$(CONFIG_IA64_DIG_VTD) += dig_vtd_iommu.o | 14 | |
diff --git a/arch/ia64/dig/dig_vtd_iommu.c b/arch/ia64/dig/dig_vtd_iommu.c deleted file mode 100644 index fdb8ba9f4992..000000000000 --- a/arch/ia64/dig/dig_vtd_iommu.c +++ /dev/null | |||
@@ -1,77 +0,0 @@ | |||
1 | #include <linux/types.h> | ||
2 | #include <linux/kernel.h> | ||
3 | #include <linux/module.h> | ||
4 | #include <linux/dma-mapping.h> | ||
5 | #include <linux/intel-iommu.h> | ||
6 | |||
7 | void * | ||
8 | vtd_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, | ||
9 | gfp_t flags) | ||
10 | { | ||
11 | return intel_alloc_coherent(dev, size, dma_handle, flags); | ||
12 | } | ||
13 | EXPORT_SYMBOL_GPL(vtd_alloc_coherent); | ||
14 | |||
15 | void | ||
16 | vtd_free_coherent(struct device *dev, size_t size, void *vaddr, | ||
17 | dma_addr_t dma_handle) | ||
18 | { | ||
19 | intel_free_coherent(dev, size, vaddr, dma_handle); | ||
20 | } | ||
21 | EXPORT_SYMBOL_GPL(vtd_free_coherent); | ||
22 | |||
23 | dma_addr_t | ||
24 | vtd_map_single_attrs(struct device *dev, void *addr, size_t size, | ||
25 | int dir, struct dma_attrs *attrs) | ||
26 | { | ||
27 | return intel_map_single(dev, (phys_addr_t)addr, size, dir); | ||
28 | } | ||
29 | EXPORT_SYMBOL_GPL(vtd_map_single_attrs); | ||
30 | |||
31 | void | ||
32 | vtd_unmap_single_attrs(struct device *dev, dma_addr_t iova, size_t size, | ||
33 | int dir, struct dma_attrs *attrs) | ||
34 | { | ||
35 | intel_unmap_single(dev, iova, size, dir); | ||
36 | } | ||
37 | EXPORT_SYMBOL_GPL(vtd_unmap_single_attrs); | ||
38 | |||
39 | int | ||
40 | vtd_map_sg_attrs(struct device *dev, struct scatterlist *sglist, int nents, | ||
41 | int dir, struct dma_attrs *attrs) | ||
42 | { | ||
43 | return intel_map_sg(dev, sglist, nents, dir); | ||
44 | } | ||
45 | EXPORT_SYMBOL_GPL(vtd_map_sg_attrs); | ||
46 | |||
47 | void | ||
48 | vtd_unmap_sg_attrs(struct device *dev, struct scatterlist *sglist, | ||
49 | int nents, int dir, struct dma_attrs *attrs) | ||
50 | { | ||
51 | intel_unmap_sg(dev, sglist, nents, dir); | ||
52 | } | ||
53 | EXPORT_SYMBOL_GPL(vtd_unmap_sg_attrs); | ||
54 | |||
55 | int | ||
56 | vtd_dma_mapping_error(struct device *dev, dma_addr_t dma_addr) | ||
57 | { | ||
58 | return 0; | ||
59 | } | ||
60 | EXPORT_SYMBOL_GPL(vtd_dma_mapping_error); | ||
61 | |||
62 | extern int iommu_dma_supported(struct device *dev, u64 mask); | ||
63 | |||
64 | struct dma_mapping_ops vtd_dma_ops = { | ||
65 | .alloc_coherent = vtd_alloc_coherent, | ||
66 | .free_coherent = vtd_free_coherent, | ||
67 | .map_single_attrs = vtd_map_single_attrs, | ||
68 | .unmap_single_attrs = vtd_unmap_single_attrs, | ||
69 | .map_sg_attrs = vtd_map_sg_attrs, | ||
70 | .unmap_sg_attrs = vtd_unmap_sg_attrs, | ||
71 | .sync_single_for_cpu = machvec_dma_sync_single, | ||
72 | .sync_sg_for_cpu = machvec_dma_sync_sg, | ||
73 | .sync_single_for_device = machvec_dma_sync_single, | ||
74 | .sync_sg_for_device = machvec_dma_sync_sg, | ||
75 | .dma_supported_op = iommu_dma_supported, | ||
76 | .mapping_error = vtd_dma_mapping_error, | ||
77 | }; | ||
diff --git a/arch/ia64/hp/common/hwsw_iommu.c b/arch/ia64/hp/common/hwsw_iommu.c index e5bbeba77810..e4a80d82e3d8 100644 --- a/arch/ia64/hp/common/hwsw_iommu.c +++ b/arch/ia64/hp/common/hwsw_iommu.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/swiotlb.h> | 17 | #include <linux/swiotlb.h> |
18 | #include <asm/machvec.h> | 18 | #include <asm/machvec.h> |
19 | 19 | ||
20 | extern struct dma_mapping_ops sba_dma_ops, swiotlb_dma_ops; | 20 | extern struct dma_map_ops sba_dma_ops, swiotlb_dma_ops; |
21 | 21 | ||
22 | /* swiotlb declarations & definitions: */ | 22 | /* swiotlb declarations & definitions: */ |
23 | extern int swiotlb_late_init_with_default_size (size_t size); | 23 | extern int swiotlb_late_init_with_default_size (size_t size); |
@@ -30,10 +30,10 @@ extern int swiotlb_late_init_with_default_size (size_t size); | |||
30 | static inline int use_swiotlb(struct device *dev) | 30 | static inline int use_swiotlb(struct device *dev) |
31 | { | 31 | { |
32 | return dev && dev->dma_mask && | 32 | return dev && dev->dma_mask && |
33 | !sba_dma_ops.dma_supported_op(dev, *dev->dma_mask); | 33 | !sba_dma_ops.dma_supported(dev, *dev->dma_mask); |
34 | } | 34 | } |
35 | 35 | ||
36 | struct dma_mapping_ops *hwsw_dma_get_ops(struct device *dev) | 36 | struct dma_map_ops *hwsw_dma_get_ops(struct device *dev) |
37 | { | 37 | { |
38 | if (use_swiotlb(dev)) | 38 | if (use_swiotlb(dev)) |
39 | return &swiotlb_dma_ops; | 39 | return &swiotlb_dma_ops; |
diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c index 29e7206f3dc6..129b62eb39e5 100644 --- a/arch/ia64/hp/common/sba_iommu.c +++ b/arch/ia64/hp/common/sba_iommu.c | |||
@@ -909,11 +909,13 @@ sba_mark_invalid(struct ioc *ioc, dma_addr_t iova, size_t byte_cnt) | |||
909 | * | 909 | * |
910 | * See Documentation/DMA-mapping.txt | 910 | * See Documentation/DMA-mapping.txt |
911 | */ | 911 | */ |
912 | static dma_addr_t | 912 | static dma_addr_t sba_map_page(struct device *dev, struct page *page, |
913 | sba_map_single_attrs(struct device *dev, void *addr, size_t size, int dir, | 913 | unsigned long poff, size_t size, |
914 | struct dma_attrs *attrs) | 914 | enum dma_data_direction dir, |
915 | struct dma_attrs *attrs) | ||
915 | { | 916 | { |
916 | struct ioc *ioc; | 917 | struct ioc *ioc; |
918 | void *addr = page_address(page) + poff; | ||
917 | dma_addr_t iovp; | 919 | dma_addr_t iovp; |
918 | dma_addr_t offset; | 920 | dma_addr_t offset; |
919 | u64 *pdir_start; | 921 | u64 *pdir_start; |
@@ -992,6 +994,14 @@ sba_map_single_attrs(struct device *dev, void *addr, size_t size, int dir, | |||
992 | return SBA_IOVA(ioc, iovp, offset); | 994 | return SBA_IOVA(ioc, iovp, offset); |
993 | } | 995 | } |
994 | 996 | ||
997 | static dma_addr_t sba_map_single_attrs(struct device *dev, void *addr, | ||
998 | size_t size, enum dma_data_direction dir, | ||
999 | struct dma_attrs *attrs) | ||
1000 | { | ||
1001 | return sba_map_page(dev, virt_to_page(addr), | ||
1002 | (unsigned long)addr & ~PAGE_MASK, size, dir, attrs); | ||
1003 | } | ||
1004 | |||
995 | #ifdef ENABLE_MARK_CLEAN | 1005 | #ifdef ENABLE_MARK_CLEAN |
996 | static SBA_INLINE void | 1006 | static SBA_INLINE void |
997 | sba_mark_clean(struct ioc *ioc, dma_addr_t iova, size_t size) | 1007 | sba_mark_clean(struct ioc *ioc, dma_addr_t iova, size_t size) |
@@ -1026,8 +1036,8 @@ sba_mark_clean(struct ioc *ioc, dma_addr_t iova, size_t size) | |||
1026 | * | 1036 | * |
1027 | * See Documentation/DMA-mapping.txt | 1037 | * See Documentation/DMA-mapping.txt |
1028 | */ | 1038 | */ |
1029 | static void sba_unmap_single_attrs(struct device *dev, dma_addr_t iova, size_t size, | 1039 | static void sba_unmap_page(struct device *dev, dma_addr_t iova, size_t size, |
1030 | int dir, struct dma_attrs *attrs) | 1040 | enum dma_data_direction dir, struct dma_attrs *attrs) |
1031 | { | 1041 | { |
1032 | struct ioc *ioc; | 1042 | struct ioc *ioc; |
1033 | #if DELAYED_RESOURCE_CNT > 0 | 1043 | #if DELAYED_RESOURCE_CNT > 0 |
@@ -1095,6 +1105,12 @@ static void sba_unmap_single_attrs(struct device *dev, dma_addr_t iova, size_t s | |||
1095 | #endif /* DELAYED_RESOURCE_CNT == 0 */ | 1105 | #endif /* DELAYED_RESOURCE_CNT == 0 */ |
1096 | } | 1106 | } |
1097 | 1107 | ||
1108 | void sba_unmap_single_attrs(struct device *dev, dma_addr_t iova, size_t size, | ||
1109 | enum dma_data_direction dir, struct dma_attrs *attrs) | ||
1110 | { | ||
1111 | sba_unmap_page(dev, iova, size, dir, attrs); | ||
1112 | } | ||
1113 | |||
1098 | /** | 1114 | /** |
1099 | * sba_alloc_coherent - allocate/map shared mem for DMA | 1115 | * sba_alloc_coherent - allocate/map shared mem for DMA |
1100 | * @dev: instance of PCI owned by the driver that's asking. | 1116 | * @dev: instance of PCI owned by the driver that's asking. |
@@ -1423,7 +1439,8 @@ sba_coalesce_chunks(struct ioc *ioc, struct device *dev, | |||
1423 | * See Documentation/DMA-mapping.txt | 1439 | * See Documentation/DMA-mapping.txt |
1424 | */ | 1440 | */ |
1425 | static int sba_map_sg_attrs(struct device *dev, struct scatterlist *sglist, | 1441 | static int sba_map_sg_attrs(struct device *dev, struct scatterlist *sglist, |
1426 | int nents, int dir, struct dma_attrs *attrs) | 1442 | int nents, enum dma_data_direction dir, |
1443 | struct dma_attrs *attrs) | ||
1427 | { | 1444 | { |
1428 | struct ioc *ioc; | 1445 | struct ioc *ioc; |
1429 | int coalesced, filled = 0; | 1446 | int coalesced, filled = 0; |
@@ -1514,7 +1531,8 @@ static int sba_map_sg_attrs(struct device *dev, struct scatterlist *sglist, | |||
1514 | * See Documentation/DMA-mapping.txt | 1531 | * See Documentation/DMA-mapping.txt |
1515 | */ | 1532 | */ |
1516 | static void sba_unmap_sg_attrs(struct device *dev, struct scatterlist *sglist, | 1533 | static void sba_unmap_sg_attrs(struct device *dev, struct scatterlist *sglist, |
1517 | int nents, int dir, struct dma_attrs *attrs) | 1534 | int nents, enum dma_data_direction dir, |
1535 | struct dma_attrs *attrs) | ||
1518 | { | 1536 | { |
1519 | #ifdef ASSERT_PDIR_SANITY | 1537 | #ifdef ASSERT_PDIR_SANITY |
1520 | struct ioc *ioc; | 1538 | struct ioc *ioc; |
@@ -2062,7 +2080,7 @@ static struct acpi_driver acpi_sba_ioc_driver = { | |||
2062 | }, | 2080 | }, |
2063 | }; | 2081 | }; |
2064 | 2082 | ||
2065 | extern struct dma_mapping_ops swiotlb_dma_ops; | 2083 | extern struct dma_map_ops swiotlb_dma_ops; |
2066 | 2084 | ||
2067 | static int __init | 2085 | static int __init |
2068 | sba_init(void) | 2086 | sba_init(void) |
@@ -2176,18 +2194,18 @@ sba_page_override(char *str) | |||
2176 | 2194 | ||
2177 | __setup("sbapagesize=",sba_page_override); | 2195 | __setup("sbapagesize=",sba_page_override); |
2178 | 2196 | ||
2179 | struct dma_mapping_ops sba_dma_ops = { | 2197 | struct dma_map_ops sba_dma_ops = { |
2180 | .alloc_coherent = sba_alloc_coherent, | 2198 | .alloc_coherent = sba_alloc_coherent, |
2181 | .free_coherent = sba_free_coherent, | 2199 | .free_coherent = sba_free_coherent, |
2182 | .map_single_attrs = sba_map_single_attrs, | 2200 | .map_page = sba_map_page, |
2183 | .unmap_single_attrs = sba_unmap_single_attrs, | 2201 | .unmap_page = sba_unmap_page, |
2184 | .map_sg_attrs = sba_map_sg_attrs, | 2202 | .map_sg = sba_map_sg_attrs, |
2185 | .unmap_sg_attrs = sba_unmap_sg_attrs, | 2203 | .unmap_sg = sba_unmap_sg_attrs, |
2186 | .sync_single_for_cpu = machvec_dma_sync_single, | 2204 | .sync_single_for_cpu = machvec_dma_sync_single, |
2187 | .sync_sg_for_cpu = machvec_dma_sync_sg, | 2205 | .sync_sg_for_cpu = machvec_dma_sync_sg, |
2188 | .sync_single_for_device = machvec_dma_sync_single, | 2206 | .sync_single_for_device = machvec_dma_sync_single, |
2189 | .sync_sg_for_device = machvec_dma_sync_sg, | 2207 | .sync_sg_for_device = machvec_dma_sync_sg, |
2190 | .dma_supported_op = sba_dma_supported, | 2208 | .dma_supported = sba_dma_supported, |
2191 | .mapping_error = sba_dma_mapping_error, | 2209 | .mapping_error = sba_dma_mapping_error, |
2192 | }; | 2210 | }; |
2193 | 2211 | ||
diff --git a/arch/ia64/include/asm/dma-mapping.h b/arch/ia64/include/asm/dma-mapping.h index bac3159379f7..d6230f514536 100644 --- a/arch/ia64/include/asm/dma-mapping.h +++ b/arch/ia64/include/asm/dma-mapping.h | |||
@@ -9,73 +9,21 @@ | |||
9 | #include <linux/scatterlist.h> | 9 | #include <linux/scatterlist.h> |
10 | #include <asm/swiotlb.h> | 10 | #include <asm/swiotlb.h> |
11 | 11 | ||
12 | struct dma_mapping_ops { | 12 | extern struct dma_map_ops *dma_ops; |
13 | int (*mapping_error)(struct device *dev, | ||
14 | dma_addr_t dma_addr); | ||
15 | void* (*alloc_coherent)(struct device *dev, size_t size, | ||
16 | dma_addr_t *dma_handle, gfp_t gfp); | ||
17 | void (*free_coherent)(struct device *dev, size_t size, | ||
18 | void *vaddr, dma_addr_t dma_handle); | ||
19 | dma_addr_t (*map_single)(struct device *hwdev, unsigned long ptr, | ||
20 | size_t size, int direction); | ||
21 | void (*unmap_single)(struct device *dev, dma_addr_t addr, | ||
22 | size_t size, int direction); | ||
23 | dma_addr_t (*map_single_attrs)(struct device *dev, void *cpu_addr, | ||
24 | size_t size, int direction, | ||
25 | struct dma_attrs *attrs); | ||
26 | void (*unmap_single_attrs)(struct device *dev, | ||
27 | dma_addr_t dma_addr, | ||
28 | size_t size, int direction, | ||
29 | struct dma_attrs *attrs); | ||
30 | void (*sync_single_for_cpu)(struct device *hwdev, | ||
31 | dma_addr_t dma_handle, size_t size, | ||
32 | int direction); | ||
33 | void (*sync_single_for_device)(struct device *hwdev, | ||
34 | dma_addr_t dma_handle, size_t size, | ||
35 | int direction); | ||
36 | void (*sync_single_range_for_cpu)(struct device *hwdev, | ||
37 | dma_addr_t dma_handle, unsigned long offset, | ||
38 | size_t size, int direction); | ||
39 | void (*sync_single_range_for_device)(struct device *hwdev, | ||
40 | dma_addr_t dma_handle, unsigned long offset, | ||
41 | size_t size, int direction); | ||
42 | void (*sync_sg_for_cpu)(struct device *hwdev, | ||
43 | struct scatterlist *sg, int nelems, | ||
44 | int direction); | ||
45 | void (*sync_sg_for_device)(struct device *hwdev, | ||
46 | struct scatterlist *sg, int nelems, | ||
47 | int direction); | ||
48 | int (*map_sg)(struct device *hwdev, struct scatterlist *sg, | ||
49 | int nents, int direction); | ||
50 | void (*unmap_sg)(struct device *hwdev, | ||
51 | struct scatterlist *sg, int nents, | ||
52 | int direction); | ||
53 | int (*map_sg_attrs)(struct device *dev, | ||
54 | struct scatterlist *sg, int nents, | ||
55 | int direction, struct dma_attrs *attrs); | ||
56 | void (*unmap_sg_attrs)(struct device *dev, | ||
57 | struct scatterlist *sg, int nents, | ||
58 | int direction, | ||
59 | struct dma_attrs *attrs); | ||
60 | int (*dma_supported_op)(struct device *hwdev, u64 mask); | ||
61 | int is_phys; | ||
62 | }; | ||
63 | |||
64 | extern struct dma_mapping_ops *dma_ops; | ||
65 | extern struct ia64_machine_vector ia64_mv; | 13 | extern struct ia64_machine_vector ia64_mv; |
66 | extern void set_iommu_machvec(void); | 14 | extern void set_iommu_machvec(void); |
67 | 15 | ||
68 | static inline void *dma_alloc_coherent(struct device *dev, size_t size, | 16 | static inline void *dma_alloc_coherent(struct device *dev, size_t size, |
69 | dma_addr_t *daddr, gfp_t gfp) | 17 | dma_addr_t *daddr, gfp_t gfp) |
70 | { | 18 | { |
71 | struct dma_mapping_ops *ops = platform_dma_get_ops(dev); | 19 | struct dma_map_ops *ops = platform_dma_get_ops(dev); |
72 | return ops->alloc_coherent(dev, size, daddr, gfp | GFP_DMA); | 20 | return ops->alloc_coherent(dev, size, daddr, gfp | GFP_DMA); |
73 | } | 21 | } |
74 | 22 | ||
75 | static inline void dma_free_coherent(struct device *dev, size_t size, | 23 | static inline void dma_free_coherent(struct device *dev, size_t size, |
76 | void *caddr, dma_addr_t daddr) | 24 | void *caddr, dma_addr_t daddr) |
77 | { | 25 | { |
78 | struct dma_mapping_ops *ops = platform_dma_get_ops(dev); | 26 | struct dma_map_ops *ops = platform_dma_get_ops(dev); |
79 | ops->free_coherent(dev, size, caddr, daddr); | 27 | ops->free_coherent(dev, size, caddr, daddr); |
80 | } | 28 | } |
81 | 29 | ||
@@ -87,8 +35,10 @@ static inline dma_addr_t dma_map_single_attrs(struct device *dev, | |||
87 | enum dma_data_direction dir, | 35 | enum dma_data_direction dir, |
88 | struct dma_attrs *attrs) | 36 | struct dma_attrs *attrs) |
89 | { | 37 | { |
90 | struct dma_mapping_ops *ops = platform_dma_get_ops(dev); | 38 | struct dma_map_ops *ops = platform_dma_get_ops(dev); |
91 | return ops->map_single_attrs(dev, caddr, size, dir, attrs); | 39 | return ops->map_page(dev, virt_to_page(caddr), |
40 | (unsigned long)caddr & ~PAGE_MASK, size, | ||
41 | dir, attrs); | ||
92 | } | 42 | } |
93 | 43 | ||
94 | static inline void dma_unmap_single_attrs(struct device *dev, dma_addr_t daddr, | 44 | static inline void dma_unmap_single_attrs(struct device *dev, dma_addr_t daddr, |
@@ -96,8 +46,8 @@ static inline void dma_unmap_single_attrs(struct device *dev, dma_addr_t daddr, | |||
96 | enum dma_data_direction dir, | 46 | enum dma_data_direction dir, |
97 | struct dma_attrs *attrs) | 47 | struct dma_attrs *attrs) |
98 | { | 48 | { |
99 | struct dma_mapping_ops *ops = platform_dma_get_ops(dev); | 49 | struct dma_map_ops *ops = platform_dma_get_ops(dev); |
100 | ops->unmap_single_attrs(dev, daddr, size, dir, attrs); | 50 | ops->unmap_page(dev, daddr, size, dir, attrs); |
101 | } | 51 | } |
102 | 52 | ||
103 | #define dma_map_single(d, a, s, r) dma_map_single_attrs(d, a, s, r, NULL) | 53 | #define dma_map_single(d, a, s, r) dma_map_single_attrs(d, a, s, r, NULL) |
@@ -107,8 +57,8 @@ static inline int dma_map_sg_attrs(struct device *dev, struct scatterlist *sgl, | |||
107 | int nents, enum dma_data_direction dir, | 57 | int nents, enum dma_data_direction dir, |
108 | struct dma_attrs *attrs) | 58 | struct dma_attrs *attrs) |
109 | { | 59 | { |
110 | struct dma_mapping_ops *ops = platform_dma_get_ops(dev); | 60 | struct dma_map_ops *ops = platform_dma_get_ops(dev); |
111 | return ops->map_sg_attrs(dev, sgl, nents, dir, attrs); | 61 | return ops->map_sg(dev, sgl, nents, dir, attrs); |
112 | } | 62 | } |
113 | 63 | ||
114 | static inline void dma_unmap_sg_attrs(struct device *dev, | 64 | static inline void dma_unmap_sg_attrs(struct device *dev, |
@@ -116,8 +66,8 @@ static inline void dma_unmap_sg_attrs(struct device *dev, | |||
116 | enum dma_data_direction dir, | 66 | enum dma_data_direction dir, |
117 | struct dma_attrs *attrs) | 67 | struct dma_attrs *attrs) |
118 | { | 68 | { |
119 | struct dma_mapping_ops *ops = platform_dma_get_ops(dev); | 69 | struct dma_map_ops *ops = platform_dma_get_ops(dev); |
120 | ops->unmap_sg_attrs(dev, sgl, nents, dir, attrs); | 70 | ops->unmap_sg(dev, sgl, nents, dir, attrs); |
121 | } | 71 | } |
122 | 72 | ||
123 | #define dma_map_sg(d, s, n, r) dma_map_sg_attrs(d, s, n, r, NULL) | 73 | #define dma_map_sg(d, s, n, r) dma_map_sg_attrs(d, s, n, r, NULL) |
@@ -127,7 +77,7 @@ static inline void dma_sync_single_for_cpu(struct device *dev, dma_addr_t daddr, | |||
127 | size_t size, | 77 | size_t size, |
128 | enum dma_data_direction dir) | 78 | enum dma_data_direction dir) |
129 | { | 79 | { |
130 | struct dma_mapping_ops *ops = platform_dma_get_ops(dev); | 80 | struct dma_map_ops *ops = platform_dma_get_ops(dev); |
131 | ops->sync_single_for_cpu(dev, daddr, size, dir); | 81 | ops->sync_single_for_cpu(dev, daddr, size, dir); |
132 | } | 82 | } |
133 | 83 | ||
@@ -135,7 +85,7 @@ static inline void dma_sync_sg_for_cpu(struct device *dev, | |||
135 | struct scatterlist *sgl, | 85 | struct scatterlist *sgl, |
136 | int nents, enum dma_data_direction dir) | 86 | int nents, enum dma_data_direction dir) |
137 | { | 87 | { |
138 | struct dma_mapping_ops *ops = platform_dma_get_ops(dev); | 88 | struct dma_map_ops *ops = platform_dma_get_ops(dev); |
139 | ops->sync_sg_for_cpu(dev, sgl, nents, dir); | 89 | ops->sync_sg_for_cpu(dev, sgl, nents, dir); |
140 | } | 90 | } |
141 | 91 | ||
@@ -144,7 +94,7 @@ static inline void dma_sync_single_for_device(struct device *dev, | |||
144 | size_t size, | 94 | size_t size, |
145 | enum dma_data_direction dir) | 95 | enum dma_data_direction dir) |
146 | { | 96 | { |
147 | struct dma_mapping_ops *ops = platform_dma_get_ops(dev); | 97 | struct dma_map_ops *ops = platform_dma_get_ops(dev); |
148 | ops->sync_single_for_device(dev, daddr, size, dir); | 98 | ops->sync_single_for_device(dev, daddr, size, dir); |
149 | } | 99 | } |
150 | 100 | ||
@@ -153,20 +103,29 @@ static inline void dma_sync_sg_for_device(struct device *dev, | |||
153 | int nents, | 103 | int nents, |
154 | enum dma_data_direction dir) | 104 | enum dma_data_direction dir) |
155 | { | 105 | { |
156 | struct dma_mapping_ops *ops = platform_dma_get_ops(dev); | 106 | struct dma_map_ops *ops = platform_dma_get_ops(dev); |
157 | ops->sync_sg_for_device(dev, sgl, nents, dir); | 107 | ops->sync_sg_for_device(dev, sgl, nents, dir); |
158 | } | 108 | } |
159 | 109 | ||
160 | static inline int dma_mapping_error(struct device *dev, dma_addr_t daddr) | 110 | static inline int dma_mapping_error(struct device *dev, dma_addr_t daddr) |
161 | { | 111 | { |
162 | struct dma_mapping_ops *ops = platform_dma_get_ops(dev); | 112 | struct dma_map_ops *ops = platform_dma_get_ops(dev); |
163 | return ops->mapping_error(dev, daddr); | 113 | return ops->mapping_error(dev, daddr); |
164 | } | 114 | } |
165 | 115 | ||
166 | #define dma_map_page(dev, pg, off, size, dir) \ | 116 | static inline dma_addr_t dma_map_page(struct device *dev, struct page *page, |
167 | dma_map_single(dev, page_address(pg) + (off), (size), (dir)) | 117 | size_t offset, size_t size, |
168 | #define dma_unmap_page(dev, dma_addr, size, dir) \ | 118 | enum dma_data_direction dir) |
169 | dma_unmap_single(dev, dma_addr, size, dir) | 119 | { |
120 | struct dma_map_ops *ops = platform_dma_get_ops(dev); | ||
121 | return ops->map_page(dev, page, offset, size, dir, NULL); | ||
122 | } | ||
123 | |||
124 | static inline void dma_unmap_page(struct device *dev, dma_addr_t addr, | ||
125 | size_t size, enum dma_data_direction dir) | ||
126 | { | ||
127 | dma_unmap_single(dev, addr, size, dir); | ||
128 | } | ||
170 | 129 | ||
171 | /* | 130 | /* |
172 | * Rest of this file is part of the "Advanced DMA API". Use at your own risk. | 131 | * Rest of this file is part of the "Advanced DMA API". Use at your own risk. |
@@ -180,8 +139,8 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t daddr) | |||
180 | 139 | ||
181 | static inline int dma_supported(struct device *dev, u64 mask) | 140 | static inline int dma_supported(struct device *dev, u64 mask) |
182 | { | 141 | { |
183 | struct dma_mapping_ops *ops = platform_dma_get_ops(dev); | 142 | struct dma_map_ops *ops = platform_dma_get_ops(dev); |
184 | return ops->dma_supported_op(dev, mask); | 143 | return ops->dma_supported(dev, mask); |
185 | } | 144 | } |
186 | 145 | ||
187 | static inline int | 146 | static inline int |
diff --git a/arch/ia64/include/asm/machvec.h b/arch/ia64/include/asm/machvec.h index 95e1708fa4e3..e8442c7e4cc8 100644 --- a/arch/ia64/include/asm/machvec.h +++ b/arch/ia64/include/asm/machvec.h | |||
@@ -11,7 +11,6 @@ | |||
11 | #define _ASM_IA64_MACHVEC_H | 11 | #define _ASM_IA64_MACHVEC_H |
12 | 12 | ||
13 | #include <linux/types.h> | 13 | #include <linux/types.h> |
14 | #include <linux/swiotlb.h> | ||
15 | 14 | ||
16 | /* forward declarations: */ | 15 | /* forward declarations: */ |
17 | struct device; | 16 | struct device; |
@@ -24,6 +23,7 @@ struct task_struct; | |||
24 | struct pci_dev; | 23 | struct pci_dev; |
25 | struct msi_desc; | 24 | struct msi_desc; |
26 | struct dma_attrs; | 25 | struct dma_attrs; |
26 | enum dma_data_direction; | ||
27 | 27 | ||
28 | typedef void ia64_mv_setup_t (char **); | 28 | typedef void ia64_mv_setup_t (char **); |
29 | typedef void ia64_mv_cpu_init_t (void); | 29 | typedef void ia64_mv_cpu_init_t (void); |
@@ -45,7 +45,7 @@ typedef void ia64_mv_kernel_launch_event_t(void); | |||
45 | 45 | ||
46 | /* DMA-mapping interface: */ | 46 | /* DMA-mapping interface: */ |
47 | typedef void ia64_mv_dma_init (void); | 47 | typedef void ia64_mv_dma_init (void); |
48 | typedef struct dma_mapping_ops *ia64_mv_dma_get_ops(struct device *); | 48 | typedef struct dma_map_ops *ia64_mv_dma_get_ops(struct device *); |
49 | 49 | ||
50 | /* | 50 | /* |
51 | * WARNING: The legacy I/O space is _architected_. Platforms are | 51 | * WARNING: The legacy I/O space is _architected_. Platforms are |
@@ -97,8 +97,10 @@ machvec_noop_bus (struct pci_bus *bus) | |||
97 | 97 | ||
98 | extern void machvec_setup (char **); | 98 | extern void machvec_setup (char **); |
99 | extern void machvec_timer_interrupt (int, void *); | 99 | extern void machvec_timer_interrupt (int, void *); |
100 | extern void machvec_dma_sync_single (struct device *, dma_addr_t, size_t, int); | 100 | extern void machvec_dma_sync_single(struct device *, dma_addr_t, size_t, |
101 | extern void machvec_dma_sync_sg (struct device *, struct scatterlist *, int, int); | 101 | enum dma_data_direction); |
102 | extern void machvec_dma_sync_sg(struct device *, struct scatterlist *, int, | ||
103 | enum dma_data_direction); | ||
102 | extern void machvec_tlb_migrate_finish (struct mm_struct *); | 104 | extern void machvec_tlb_migrate_finish (struct mm_struct *); |
103 | 105 | ||
104 | # if defined (CONFIG_IA64_HP_SIM) | 106 | # if defined (CONFIG_IA64_HP_SIM) |
@@ -250,7 +252,7 @@ extern void machvec_init_from_cmdline(const char *cmdline); | |||
250 | # endif /* CONFIG_IA64_GENERIC */ | 252 | # endif /* CONFIG_IA64_GENERIC */ |
251 | 253 | ||
252 | extern void swiotlb_dma_init(void); | 254 | extern void swiotlb_dma_init(void); |
253 | extern struct dma_mapping_ops *dma_get_ops(struct device *); | 255 | extern struct dma_map_ops *dma_get_ops(struct device *); |
254 | 256 | ||
255 | /* | 257 | /* |
256 | * Define default versions so we can extend machvec for new platforms without having | 258 | * Define default versions so we can extend machvec for new platforms without having |
diff --git a/arch/ia64/kernel/dma-mapping.c b/arch/ia64/kernel/dma-mapping.c index 427f69617226..7060e13fa421 100644 --- a/arch/ia64/kernel/dma-mapping.c +++ b/arch/ia64/kernel/dma-mapping.c | |||
@@ -1,9 +1,9 @@ | |||
1 | #include <linux/dma-mapping.h> | 1 | #include <linux/dma-mapping.h> |
2 | 2 | ||
3 | struct dma_mapping_ops *dma_ops; | 3 | struct dma_map_ops *dma_ops; |
4 | EXPORT_SYMBOL(dma_ops); | 4 | EXPORT_SYMBOL(dma_ops); |
5 | 5 | ||
6 | struct dma_mapping_ops *dma_get_ops(struct device *dev) | 6 | struct dma_map_ops *dma_get_ops(struct device *dev) |
7 | { | 7 | { |
8 | return dma_ops; | 8 | return dma_ops; |
9 | } | 9 | } |
diff --git a/arch/ia64/kernel/machvec.c b/arch/ia64/kernel/machvec.c index 7ccb228ceedc..d41a40ef80c0 100644 --- a/arch/ia64/kernel/machvec.c +++ b/arch/ia64/kernel/machvec.c | |||
@@ -1,5 +1,5 @@ | |||
1 | #include <linux/module.h> | 1 | #include <linux/module.h> |
2 | 2 | #include <linux/dma-mapping.h> | |
3 | #include <asm/machvec.h> | 3 | #include <asm/machvec.h> |
4 | #include <asm/system.h> | 4 | #include <asm/system.h> |
5 | 5 | ||
@@ -75,14 +75,16 @@ machvec_timer_interrupt (int irq, void *dev_id) | |||
75 | EXPORT_SYMBOL(machvec_timer_interrupt); | 75 | EXPORT_SYMBOL(machvec_timer_interrupt); |
76 | 76 | ||
77 | void | 77 | void |
78 | machvec_dma_sync_single (struct device *hwdev, dma_addr_t dma_handle, size_t size, int dir) | 78 | machvec_dma_sync_single(struct device *hwdev, dma_addr_t dma_handle, size_t size, |
79 | enum dma_data_direction dir) | ||
79 | { | 80 | { |
80 | mb(); | 81 | mb(); |
81 | } | 82 | } |
82 | EXPORT_SYMBOL(machvec_dma_sync_single); | 83 | EXPORT_SYMBOL(machvec_dma_sync_single); |
83 | 84 | ||
84 | void | 85 | void |
85 | machvec_dma_sync_sg (struct device *hwdev, struct scatterlist *sg, int n, int dir) | 86 | machvec_dma_sync_sg(struct device *hwdev, struct scatterlist *sg, int n, |
87 | enum dma_data_direction dir) | ||
86 | { | 88 | { |
87 | mb(); | 89 | mb(); |
88 | } | 90 | } |
diff --git a/arch/ia64/kernel/pci-dma.c b/arch/ia64/kernel/pci-dma.c index 640669eba5d4..b30209ec8c6e 100644 --- a/arch/ia64/kernel/pci-dma.c +++ b/arch/ia64/kernel/pci-dma.c | |||
@@ -41,21 +41,7 @@ struct device fallback_dev = { | |||
41 | .dma_mask = &fallback_dev.coherent_dma_mask, | 41 | .dma_mask = &fallback_dev.coherent_dma_mask, |
42 | }; | 42 | }; |
43 | 43 | ||
44 | extern struct dma_mapping_ops vtd_dma_ops; | 44 | extern struct dma_map_ops intel_dma_ops; |
45 | |||
46 | void __init pci_iommu_alloc(void) | ||
47 | { | ||
48 | dma_ops = &vtd_dma_ops; | ||
49 | /* | ||
50 | * The order of these functions is important for | ||
51 | * fall-back/fail-over reasons | ||
52 | */ | ||
53 | detect_intel_iommu(); | ||
54 | |||
55 | #ifdef CONFIG_SWIOTLB | ||
56 | pci_swiotlb_init(); | ||
57 | #endif | ||
58 | } | ||
59 | 45 | ||
60 | static int __init pci_iommu_init(void) | 46 | static int __init pci_iommu_init(void) |
61 | { | 47 | { |
@@ -81,10 +67,10 @@ iommu_dma_init(void) | |||
81 | 67 | ||
82 | int iommu_dma_supported(struct device *dev, u64 mask) | 68 | int iommu_dma_supported(struct device *dev, u64 mask) |
83 | { | 69 | { |
84 | struct dma_mapping_ops *ops = platform_dma_get_ops(dev); | 70 | struct dma_map_ops *ops = platform_dma_get_ops(dev); |
85 | 71 | ||
86 | if (ops->dma_supported_op) | 72 | if (ops->dma_supported) |
87 | return ops->dma_supported_op(dev, mask); | 73 | return ops->dma_supported(dev, mask); |
88 | 74 | ||
89 | /* Copied from i386. Doesn't make much sense, because it will | 75 | /* Copied from i386. Doesn't make much sense, because it will |
90 | only work for pci_alloc_coherent. | 76 | only work for pci_alloc_coherent. |
@@ -113,4 +99,31 @@ int iommu_dma_supported(struct device *dev, u64 mask) | |||
113 | } | 99 | } |
114 | EXPORT_SYMBOL(iommu_dma_supported); | 100 | EXPORT_SYMBOL(iommu_dma_supported); |
115 | 101 | ||
102 | static int vtd_dma_mapping_error(struct device *dev, dma_addr_t dma_addr) | ||
103 | { | ||
104 | return 0; | ||
105 | } | ||
106 | |||
107 | void __init pci_iommu_alloc(void) | ||
108 | { | ||
109 | dma_ops = &intel_dma_ops; | ||
110 | |||
111 | dma_ops->sync_single_for_cpu = machvec_dma_sync_single; | ||
112 | dma_ops->sync_sg_for_cpu = machvec_dma_sync_sg; | ||
113 | dma_ops->sync_single_for_device = machvec_dma_sync_single; | ||
114 | dma_ops->sync_sg_for_device = machvec_dma_sync_sg; | ||
115 | dma_ops->dma_supported = iommu_dma_supported; | ||
116 | dma_ops->mapping_error = vtd_dma_mapping_error; | ||
117 | |||
118 | /* | ||
119 | * The order of these functions is important for | ||
120 | * fall-back/fail-over reasons | ||
121 | */ | ||
122 | detect_intel_iommu(); | ||
123 | |||
124 | #ifdef CONFIG_SWIOTLB | ||
125 | pci_swiotlb_init(); | ||
126 | #endif | ||
127 | } | ||
128 | |||
116 | #endif | 129 | #endif |
diff --git a/arch/ia64/kernel/pci-swiotlb.c b/arch/ia64/kernel/pci-swiotlb.c index 9f172c864377..6bf8f66786bd 100644 --- a/arch/ia64/kernel/pci-swiotlb.c +++ b/arch/ia64/kernel/pci-swiotlb.c | |||
@@ -16,24 +16,36 @@ EXPORT_SYMBOL(swiotlb); | |||
16 | /* Set this to 1 if there is a HW IOMMU in the system */ | 16 | /* Set this to 1 if there is a HW IOMMU in the system */ |
17 | int iommu_detected __read_mostly; | 17 | int iommu_detected __read_mostly; |
18 | 18 | ||
19 | struct dma_mapping_ops swiotlb_dma_ops = { | 19 | static dma_addr_t swiotlb_map_page(struct device *dev, struct page *page, |
20 | unsigned long offset, size_t size, | ||
21 | enum dma_data_direction dir, | ||
22 | struct dma_attrs *attrs) | ||
23 | { | ||
24 | return swiotlb_map_single_attrs(dev, page_address(page) + offset, size, | ||
25 | dir, attrs); | ||
26 | } | ||
27 | |||
28 | static void swiotlb_unmap_page(struct device *dev, dma_addr_t dma_handle, | ||
29 | size_t size, enum dma_data_direction dir, | ||
30 | struct dma_attrs *attrs) | ||
31 | { | ||
32 | swiotlb_unmap_single_attrs(dev, dma_handle, size, dir, attrs); | ||
33 | } | ||
34 | |||
35 | struct dma_map_ops swiotlb_dma_ops = { | ||
20 | .alloc_coherent = swiotlb_alloc_coherent, | 36 | .alloc_coherent = swiotlb_alloc_coherent, |
21 | .free_coherent = swiotlb_free_coherent, | 37 | .free_coherent = swiotlb_free_coherent, |
22 | .map_single = swiotlb_map_single, | 38 | .map_page = swiotlb_map_page, |
23 | .unmap_single = swiotlb_unmap_single, | 39 | .unmap_page = swiotlb_unmap_page, |
24 | .map_single_attrs = swiotlb_map_single_attrs, | 40 | .map_sg = swiotlb_map_sg_attrs, |
25 | .unmap_single_attrs = swiotlb_unmap_single_attrs, | 41 | .unmap_sg = swiotlb_unmap_sg_attrs, |
26 | .map_sg_attrs = swiotlb_map_sg_attrs, | ||
27 | .unmap_sg_attrs = swiotlb_unmap_sg_attrs, | ||
28 | .sync_single_for_cpu = swiotlb_sync_single_for_cpu, | 42 | .sync_single_for_cpu = swiotlb_sync_single_for_cpu, |
29 | .sync_single_for_device = swiotlb_sync_single_for_device, | 43 | .sync_single_for_device = swiotlb_sync_single_for_device, |
30 | .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu, | 44 | .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu, |
31 | .sync_single_range_for_device = swiotlb_sync_single_range_for_device, | 45 | .sync_single_range_for_device = swiotlb_sync_single_range_for_device, |
32 | .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu, | 46 | .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu, |
33 | .sync_sg_for_device = swiotlb_sync_sg_for_device, | 47 | .sync_sg_for_device = swiotlb_sync_sg_for_device, |
34 | .map_sg = swiotlb_map_sg, | 48 | .dma_supported = swiotlb_dma_supported, |
35 | .unmap_sg = swiotlb_unmap_sg, | ||
36 | .dma_supported_op = swiotlb_dma_supported, | ||
37 | .mapping_error = swiotlb_dma_mapping_error, | 49 | .mapping_error = swiotlb_dma_mapping_error, |
38 | }; | 50 | }; |
39 | 51 | ||
diff --git a/arch/ia64/sn/pci/pci_dma.c b/arch/ia64/sn/pci/pci_dma.c index efdd69490009..9c788f9cedfd 100644 --- a/arch/ia64/sn/pci/pci_dma.c +++ b/arch/ia64/sn/pci/pci_dma.c | |||
@@ -10,7 +10,6 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/dma-attrs.h> | ||
14 | #include <linux/dma-mapping.h> | 13 | #include <linux/dma-mapping.h> |
15 | #include <asm/dma.h> | 14 | #include <asm/dma.h> |
16 | #include <asm/sn/intr.h> | 15 | #include <asm/sn/intr.h> |
@@ -171,10 +170,12 @@ static void sn_dma_free_coherent(struct device *dev, size_t size, void *cpu_addr | |||
171 | * TODO: simplify our interface; | 170 | * TODO: simplify our interface; |
172 | * figure out how to save dmamap handle so can use two step. | 171 | * figure out how to save dmamap handle so can use two step. |
173 | */ | 172 | */ |
174 | static dma_addr_t sn_dma_map_single_attrs(struct device *dev, void *cpu_addr, | 173 | static dma_addr_t sn_dma_map_page(struct device *dev, struct page *page, |
175 | size_t size, int direction, | 174 | unsigned long offset, size_t size, |
176 | struct dma_attrs *attrs) | 175 | enum dma_data_direction dir, |
176 | struct dma_attrs *attrs) | ||
177 | { | 177 | { |
178 | void *cpu_addr = page_address(page) + offset; | ||
178 | dma_addr_t dma_addr; | 179 | dma_addr_t dma_addr; |
179 | unsigned long phys_addr; | 180 | unsigned long phys_addr; |
180 | struct pci_dev *pdev = to_pci_dev(dev); | 181 | struct pci_dev *pdev = to_pci_dev(dev); |
@@ -212,20 +213,20 @@ static dma_addr_t sn_dma_map_single_attrs(struct device *dev, void *cpu_addr, | |||
212 | * by @dma_handle into the coherence domain. On SN, we're always cache | 213 | * by @dma_handle into the coherence domain. On SN, we're always cache |
213 | * coherent, so we just need to free any ATEs associated with this mapping. | 214 | * coherent, so we just need to free any ATEs associated with this mapping. |
214 | */ | 215 | */ |
215 | static void sn_dma_unmap_single_attrs(struct device *dev, dma_addr_t dma_addr, | 216 | static void sn_dma_unmap_page(struct device *dev, dma_addr_t dma_addr, |
216 | size_t size, int direction, | 217 | size_t size, enum dma_data_direction dir, |
217 | struct dma_attrs *attrs) | 218 | struct dma_attrs *attrs) |
218 | { | 219 | { |
219 | struct pci_dev *pdev = to_pci_dev(dev); | 220 | struct pci_dev *pdev = to_pci_dev(dev); |
220 | struct sn_pcibus_provider *provider = SN_PCIDEV_BUSPROVIDER(pdev); | 221 | struct sn_pcibus_provider *provider = SN_PCIDEV_BUSPROVIDER(pdev); |
221 | 222 | ||
222 | BUG_ON(dev->bus != &pci_bus_type); | 223 | BUG_ON(dev->bus != &pci_bus_type); |
223 | 224 | ||
224 | provider->dma_unmap(pdev, dma_addr, direction); | 225 | provider->dma_unmap(pdev, dma_addr, dir); |
225 | } | 226 | } |
226 | 227 | ||
227 | /** | 228 | /** |
228 | * sn_dma_unmap_sg_attrs - unmap a DMA scatterlist | 229 | * sn_dma_unmap_sg - unmap a DMA scatterlist |
229 | * @dev: device to unmap | 230 | * @dev: device to unmap |
230 | * @sg: scatterlist to unmap | 231 | * @sg: scatterlist to unmap |
231 | * @nhwentries: number of scatterlist entries | 232 | * @nhwentries: number of scatterlist entries |
@@ -234,9 +235,9 @@ static void sn_dma_unmap_single_attrs(struct device *dev, dma_addr_t dma_addr, | |||
234 | * | 235 | * |
235 | * Unmap a set of streaming mode DMA translations. | 236 | * Unmap a set of streaming mode DMA translations. |
236 | */ | 237 | */ |
237 | static void sn_dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sgl, | 238 | static void sn_dma_unmap_sg(struct device *dev, struct scatterlist *sgl, |
238 | int nhwentries, int direction, | 239 | int nhwentries, enum dma_data_direction dir, |
239 | struct dma_attrs *attrs) | 240 | struct dma_attrs *attrs) |
240 | { | 241 | { |
241 | int i; | 242 | int i; |
242 | struct pci_dev *pdev = to_pci_dev(dev); | 243 | struct pci_dev *pdev = to_pci_dev(dev); |
@@ -246,14 +247,14 @@ static void sn_dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sgl, | |||
246 | BUG_ON(dev->bus != &pci_bus_type); | 247 | BUG_ON(dev->bus != &pci_bus_type); |
247 | 248 | ||
248 | for_each_sg(sgl, sg, nhwentries, i) { | 249 | for_each_sg(sgl, sg, nhwentries, i) { |
249 | provider->dma_unmap(pdev, sg->dma_address, direction); | 250 | provider->dma_unmap(pdev, sg->dma_address, dir); |
250 | sg->dma_address = (dma_addr_t) NULL; | 251 | sg->dma_address = (dma_addr_t) NULL; |
251 | sg->dma_length = 0; | 252 | sg->dma_length = 0; |
252 | } | 253 | } |
253 | } | 254 | } |
254 | 255 | ||
255 | /** | 256 | /** |
256 | * sn_dma_map_sg_attrs - map a scatterlist for DMA | 257 | * sn_dma_map_sg - map a scatterlist for DMA |
257 | * @dev: device to map for | 258 | * @dev: device to map for |
258 | * @sg: scatterlist to map | 259 | * @sg: scatterlist to map |
259 | * @nhwentries: number of entries | 260 | * @nhwentries: number of entries |
@@ -267,8 +268,9 @@ static void sn_dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sgl, | |||
267 | * | 268 | * |
268 | * Maps each entry of @sg for DMA. | 269 | * Maps each entry of @sg for DMA. |
269 | */ | 270 | */ |
270 | static int sn_dma_map_sg_attrs(struct device *dev, struct scatterlist *sgl, | 271 | static int sn_dma_map_sg(struct device *dev, struct scatterlist *sgl, |
271 | int nhwentries, int direction, struct dma_attrs *attrs) | 272 | int nhwentries, enum dma_data_direction dir, |
273 | struct dma_attrs *attrs) | ||
272 | { | 274 | { |
273 | unsigned long phys_addr; | 275 | unsigned long phys_addr; |
274 | struct scatterlist *saved_sg = sgl, *sg; | 276 | struct scatterlist *saved_sg = sgl, *sg; |
@@ -305,8 +307,7 @@ static int sn_dma_map_sg_attrs(struct device *dev, struct scatterlist *sgl, | |||
305 | * Free any successfully allocated entries. | 307 | * Free any successfully allocated entries. |
306 | */ | 308 | */ |
307 | if (i > 0) | 309 | if (i > 0) |
308 | sn_dma_unmap_sg_attrs(dev, saved_sg, i, | 310 | sn_dma_unmap_sg(dev, saved_sg, i, dir, attrs); |
309 | direction, attrs); | ||
310 | return 0; | 311 | return 0; |
311 | } | 312 | } |
312 | 313 | ||
@@ -317,25 +318,26 @@ static int sn_dma_map_sg_attrs(struct device *dev, struct scatterlist *sgl, | |||
317 | } | 318 | } |
318 | 319 | ||
319 | static void sn_dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, | 320 | static void sn_dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, |
320 | size_t size, int direction) | 321 | size_t size, enum dma_data_direction dir) |
321 | { | 322 | { |
322 | BUG_ON(dev->bus != &pci_bus_type); | 323 | BUG_ON(dev->bus != &pci_bus_type); |
323 | } | 324 | } |
324 | 325 | ||
325 | static void sn_dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, | 326 | static void sn_dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, |
326 | size_t size, int direction) | 327 | size_t size, |
328 | enum dma_data_direction dir) | ||
327 | { | 329 | { |
328 | BUG_ON(dev->bus != &pci_bus_type); | 330 | BUG_ON(dev->bus != &pci_bus_type); |
329 | } | 331 | } |
330 | 332 | ||
331 | static void sn_dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, | 333 | static void sn_dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, |
332 | int nelems, int direction) | 334 | int nelems, enum dma_data_direction dir) |
333 | { | 335 | { |
334 | BUG_ON(dev->bus != &pci_bus_type); | 336 | BUG_ON(dev->bus != &pci_bus_type); |
335 | } | 337 | } |
336 | 338 | ||
337 | static void sn_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, | 339 | static void sn_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, |
338 | int nelems, int direction) | 340 | int nelems, enum dma_data_direction dir) |
339 | { | 341 | { |
340 | BUG_ON(dev->bus != &pci_bus_type); | 342 | BUG_ON(dev->bus != &pci_bus_type); |
341 | } | 343 | } |
@@ -455,19 +457,19 @@ int sn_pci_legacy_write(struct pci_bus *bus, u16 port, u32 val, u8 size) | |||
455 | return ret; | 457 | return ret; |
456 | } | 458 | } |
457 | 459 | ||
458 | static struct dma_mapping_ops sn_dma_ops = { | 460 | static struct dma_map_ops sn_dma_ops = { |
459 | .alloc_coherent = sn_dma_alloc_coherent, | 461 | .alloc_coherent = sn_dma_alloc_coherent, |
460 | .free_coherent = sn_dma_free_coherent, | 462 | .free_coherent = sn_dma_free_coherent, |
461 | .map_single_attrs = sn_dma_map_single_attrs, | 463 | .map_page = sn_dma_map_page, |
462 | .unmap_single_attrs = sn_dma_unmap_single_attrs, | 464 | .unmap_page = sn_dma_unmap_page, |
463 | .map_sg_attrs = sn_dma_map_sg_attrs, | 465 | .map_sg = sn_dma_map_sg, |
464 | .unmap_sg_attrs = sn_dma_unmap_sg_attrs, | 466 | .unmap_sg = sn_dma_unmap_sg, |
465 | .sync_single_for_cpu = sn_dma_sync_single_for_cpu, | 467 | .sync_single_for_cpu = sn_dma_sync_single_for_cpu, |
466 | .sync_sg_for_cpu = sn_dma_sync_sg_for_cpu, | 468 | .sync_sg_for_cpu = sn_dma_sync_sg_for_cpu, |
467 | .sync_single_for_device = sn_dma_sync_single_for_device, | 469 | .sync_single_for_device = sn_dma_sync_single_for_device, |
468 | .sync_sg_for_device = sn_dma_sync_sg_for_device, | 470 | .sync_sg_for_device = sn_dma_sync_sg_for_device, |
469 | .mapping_error = sn_dma_mapping_error, | 471 | .mapping_error = sn_dma_mapping_error, |
470 | .dma_supported_op = sn_dma_supported, | 472 | .dma_supported = sn_dma_supported, |
471 | }; | 473 | }; |
472 | 474 | ||
473 | void sn_dma_init(void) | 475 | void sn_dma_init(void) |