aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2009-08-09 22:53:12 -0400
committerIngo Molnar <mingo@elte.hu>2009-08-10 03:34:58 -0400
commitbc0a14f154069cc4e42ea903c2c2b9984a94e4b7 (patch)
tree85b1baa32fbb42d094c66b51ee3e576e77298d29
parentbe02ff9940c0106dea1470462401a07c5d52e086 (diff)
sparc: Use dma_map_ops struct
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Tested-by: Robert Reif <reif@earthlink.net> Acked-by: David S. Miller <davem@davemloft.net> Cc: tony.luck@intel.com Cc: fenghua.yu@intel.com LKML-Reference: <1249872797-1314-4-git-send-email-fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--arch/sparc/include/asm/dma-mapping.h43
-rw-r--r--arch/sparc/kernel/dma.c16
-rw-r--r--arch/sparc/kernel/iommu.c16
-rw-r--r--arch/sparc/kernel/pci_sun4v.c14
4 files changed, 36 insertions, 53 deletions
diff --git a/arch/sparc/include/asm/dma-mapping.h b/arch/sparc/include/asm/dma-mapping.h
index 204e4bf64438..893f3ecc9750 100644
--- a/arch/sparc/include/asm/dma-mapping.h
+++ b/arch/sparc/include/asm/dma-mapping.h
@@ -13,36 +13,7 @@ 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) 13#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
14#define dma_is_consistent(d, h) (1) 14#define dma_is_consistent(d, h) (1)
15 15
16struct dma_ops { 16extern const struct dma_map_ops *dma_ops;
17 void *(*alloc_coherent)(struct device *dev, size_t size,
18 dma_addr_t *dma_handle, gfp_t flag);
19 void (*free_coherent)(struct device *dev, size_t size,
20 void *cpu_addr, dma_addr_t dma_handle);
21 dma_addr_t (*map_page)(struct device *dev, struct page *page,
22 unsigned long offset, size_t size,
23 enum dma_data_direction direction);
24 void (*unmap_page)(struct device *dev, dma_addr_t dma_addr,
25 size_t size,
26 enum dma_data_direction direction);
27 int (*map_sg)(struct device *dev, struct scatterlist *sg, int nents,
28 enum dma_data_direction direction);
29 void (*unmap_sg)(struct device *dev, struct scatterlist *sg,
30 int nhwentries,
31 enum dma_data_direction direction);
32 void (*sync_single_for_cpu)(struct device *dev,
33 dma_addr_t dma_handle, size_t size,
34 enum dma_data_direction direction);
35 void (*sync_single_for_device)(struct device *dev,
36 dma_addr_t dma_handle, size_t size,
37 enum dma_data_direction direction);
38 void (*sync_sg_for_cpu)(struct device *dev, struct scatterlist *sg,
39 int nelems,
40 enum dma_data_direction direction);
41 void (*sync_sg_for_device)(struct device *dev,
42 struct scatterlist *sg, int nents,
43 enum dma_data_direction dir);
44};
45extern const struct dma_ops *dma_ops;
46 17
47static inline void *dma_alloc_coherent(struct device *dev, size_t size, 18static inline void *dma_alloc_coherent(struct device *dev, size_t size,
48 dma_addr_t *dma_handle, gfp_t flag) 19 dma_addr_t *dma_handle, gfp_t flag)
@@ -62,40 +33,40 @@ static inline dma_addr_t dma_map_single(struct device *dev, void *cpu_addr,
62{ 33{
63 return dma_ops->map_page(dev, virt_to_page(cpu_addr), 34 return dma_ops->map_page(dev, virt_to_page(cpu_addr),
64 (unsigned long)cpu_addr & ~PAGE_MASK, size, 35 (unsigned long)cpu_addr & ~PAGE_MASK, size,
65 direction); 36 direction, NULL);
66} 37}
67 38
68static inline void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, 39static inline void dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
69 size_t size, 40 size_t size,
70 enum dma_data_direction direction) 41 enum dma_data_direction direction)
71{ 42{
72 dma_ops->unmap_page(dev, dma_addr, size, direction); 43 dma_ops->unmap_page(dev, dma_addr, size, direction, NULL);
73} 44}
74 45
75static inline dma_addr_t dma_map_page(struct device *dev, struct page *page, 46static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
76 unsigned long offset, size_t size, 47 unsigned long offset, size_t size,
77 enum dma_data_direction direction) 48 enum dma_data_direction direction)
78{ 49{
79 return dma_ops->map_page(dev, page, offset, size, direction); 50 return dma_ops->map_page(dev, page, offset, size, direction, NULL);
80} 51}
81 52
82static inline void dma_unmap_page(struct device *dev, dma_addr_t dma_address, 53static inline void dma_unmap_page(struct device *dev, dma_addr_t dma_address,
83 size_t size, 54 size_t size,
84 enum dma_data_direction direction) 55 enum dma_data_direction direction)
85{ 56{
86 dma_ops->unmap_page(dev, dma_address, size, direction); 57 dma_ops->unmap_page(dev, dma_address, size, direction, NULL);
87} 58}
88 59
89static inline int dma_map_sg(struct device *dev, struct scatterlist *sg, 60static inline int dma_map_sg(struct device *dev, struct scatterlist *sg,
90 int nents, enum dma_data_direction direction) 61 int nents, enum dma_data_direction direction)
91{ 62{
92 return dma_ops->map_sg(dev, sg, nents, direction); 63 return dma_ops->map_sg(dev, sg, nents, direction, NULL);
93} 64}
94 65
95static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg, 66static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
96 int nents, enum dma_data_direction direction) 67 int nents, enum dma_data_direction direction)
97{ 68{
98 dma_ops->unmap_sg(dev, sg, nents, direction); 69 dma_ops->unmap_sg(dev, sg, nents, direction, NULL);
99} 70}
100 71
101static inline void dma_sync_single_for_cpu(struct device *dev, 72static inline void dma_sync_single_for_cpu(struct device *dev,
diff --git a/arch/sparc/kernel/dma.c b/arch/sparc/kernel/dma.c
index 524c32f97c55..473a3fc7ab5b 100644
--- a/arch/sparc/kernel/dma.c
+++ b/arch/sparc/kernel/dma.c
@@ -60,7 +60,8 @@ static void dma32_free_coherent(struct device *dev, size_t size,
60 60
61static dma_addr_t dma32_map_page(struct device *dev, struct page *page, 61static dma_addr_t dma32_map_page(struct device *dev, struct page *page,
62 unsigned long offset, size_t size, 62 unsigned long offset, size_t size,
63 enum dma_data_direction direction) 63 enum dma_data_direction direction,
64 struct dma_attrs *attrs)
64{ 65{
65#ifdef CONFIG_PCI 66#ifdef CONFIG_PCI
66 if (dev->bus == &pci_bus_type) 67 if (dev->bus == &pci_bus_type)
@@ -72,7 +73,8 @@ static dma_addr_t dma32_map_page(struct device *dev, struct page *page,
72} 73}
73 74
74static void dma32_unmap_page(struct device *dev, dma_addr_t dma_address, 75static void dma32_unmap_page(struct device *dev, dma_addr_t dma_address,
75 size_t size, enum dma_data_direction direction) 76 size_t size, enum dma_data_direction direction,
77 struct dma_attrs *attrs)
76{ 78{
77#ifdef CONFIG_PCI 79#ifdef CONFIG_PCI
78 if (dev->bus == &pci_bus_type) { 80 if (dev->bus == &pci_bus_type) {
@@ -85,7 +87,8 @@ static void dma32_unmap_page(struct device *dev, dma_addr_t dma_address,
85} 87}
86 88
87static int dma32_map_sg(struct device *dev, struct scatterlist *sg, 89static int dma32_map_sg(struct device *dev, struct scatterlist *sg,
88 int nents, enum dma_data_direction direction) 90 int nents, enum dma_data_direction direction,
91 struct dma_attrs *attrs)
89{ 92{
90#ifdef CONFIG_PCI 93#ifdef CONFIG_PCI
91 if (dev->bus == &pci_bus_type) 94 if (dev->bus == &pci_bus_type)
@@ -95,7 +98,8 @@ static int dma32_map_sg(struct device *dev, struct scatterlist *sg,
95} 98}
96 99
97void dma32_unmap_sg(struct device *dev, struct scatterlist *sg, 100void dma32_unmap_sg(struct device *dev, struct scatterlist *sg,
98 int nents, enum dma_data_direction direction) 101 int nents, enum dma_data_direction direction,
102 struct dma_attrs *attrs)
99{ 103{
100#ifdef CONFIG_PCI 104#ifdef CONFIG_PCI
101 if (dev->bus == &pci_bus_type) { 105 if (dev->bus == &pci_bus_type) {
@@ -161,7 +165,7 @@ static void dma32_sync_sg_for_device(struct device *dev,
161 BUG(); 165 BUG();
162} 166}
163 167
164static const struct dma_ops dma32_dma_ops = { 168static const struct dma_map_ops dma32_dma_ops = {
165 .alloc_coherent = dma32_alloc_coherent, 169 .alloc_coherent = dma32_alloc_coherent,
166 .free_coherent = dma32_free_coherent, 170 .free_coherent = dma32_free_coherent,
167 .map_page = dma32_map_page, 171 .map_page = dma32_map_page,
@@ -174,5 +178,5 @@ static const struct dma_ops dma32_dma_ops = {
174 .sync_sg_for_device = dma32_sync_sg_for_device, 178 .sync_sg_for_device = dma32_sync_sg_for_device,
175}; 179};
176 180
177const struct dma_ops *dma_ops = &dma32_dma_ops; 181const struct dma_map_ops *dma_ops = &dma32_dma_ops;
178EXPORT_SYMBOL(dma_ops); 182EXPORT_SYMBOL(dma_ops);
diff --git a/arch/sparc/kernel/iommu.c b/arch/sparc/kernel/iommu.c
index 0aeaefe696b9..a9f0ad955186 100644
--- a/arch/sparc/kernel/iommu.c
+++ b/arch/sparc/kernel/iommu.c
@@ -353,7 +353,8 @@ static void dma_4u_free_coherent(struct device *dev, size_t size,
353 353
354static dma_addr_t dma_4u_map_page(struct device *dev, struct page *page, 354static dma_addr_t dma_4u_map_page(struct device *dev, struct page *page,
355 unsigned long offset, size_t sz, 355 unsigned long offset, size_t sz,
356 enum dma_data_direction direction) 356 enum dma_data_direction direction,
357 struct dma_attrs *attrs)
357{ 358{
358 struct iommu *iommu; 359 struct iommu *iommu;
359 struct strbuf *strbuf; 360 struct strbuf *strbuf;
@@ -474,7 +475,8 @@ do_flush_sync:
474} 475}
475 476
476static void dma_4u_unmap_page(struct device *dev, dma_addr_t bus_addr, 477static void dma_4u_unmap_page(struct device *dev, dma_addr_t bus_addr,
477 size_t sz, enum dma_data_direction direction) 478 size_t sz, enum dma_data_direction direction,
479 struct dma_attrs *attrs)
478{ 480{
479 struct iommu *iommu; 481 struct iommu *iommu;
480 struct strbuf *strbuf; 482 struct strbuf *strbuf;
@@ -520,7 +522,8 @@ static void dma_4u_unmap_page(struct device *dev, dma_addr_t bus_addr,
520} 522}
521 523
522static int dma_4u_map_sg(struct device *dev, struct scatterlist *sglist, 524static int dma_4u_map_sg(struct device *dev, struct scatterlist *sglist,
523 int nelems, enum dma_data_direction direction) 525 int nelems, enum dma_data_direction direction,
526 struct dma_attrs *attrs)
524{ 527{
525 struct scatterlist *s, *outs, *segstart; 528 struct scatterlist *s, *outs, *segstart;
526 unsigned long flags, handle, prot, ctx; 529 unsigned long flags, handle, prot, ctx;
@@ -691,7 +694,8 @@ static unsigned long fetch_sg_ctx(struct iommu *iommu, struct scatterlist *sg)
691} 694}
692 695
693static void dma_4u_unmap_sg(struct device *dev, struct scatterlist *sglist, 696static void dma_4u_unmap_sg(struct device *dev, struct scatterlist *sglist,
694 int nelems, enum dma_data_direction direction) 697 int nelems, enum dma_data_direction direction,
698 struct dma_attrs *attrs)
695{ 699{
696 unsigned long flags, ctx; 700 unsigned long flags, ctx;
697 struct scatterlist *sg; 701 struct scatterlist *sg;
@@ -822,7 +826,7 @@ static void dma_4u_sync_sg_for_cpu(struct device *dev,
822 spin_unlock_irqrestore(&iommu->lock, flags); 826 spin_unlock_irqrestore(&iommu->lock, flags);
823} 827}
824 828
825static const struct dma_ops sun4u_dma_ops = { 829static const struct dma_map_ops sun4u_dma_ops = {
826 .alloc_coherent = dma_4u_alloc_coherent, 830 .alloc_coherent = dma_4u_alloc_coherent,
827 .free_coherent = dma_4u_free_coherent, 831 .free_coherent = dma_4u_free_coherent,
828 .map_page = dma_4u_map_page, 832 .map_page = dma_4u_map_page,
@@ -833,7 +837,7 @@ static const struct dma_ops sun4u_dma_ops = {
833 .sync_sg_for_cpu = dma_4u_sync_sg_for_cpu, 837 .sync_sg_for_cpu = dma_4u_sync_sg_for_cpu,
834}; 838};
835 839
836const struct dma_ops *dma_ops = &sun4u_dma_ops; 840const struct dma_map_ops *dma_ops = &sun4u_dma_ops;
837EXPORT_SYMBOL(dma_ops); 841EXPORT_SYMBOL(dma_ops);
838 842
839int dma_supported(struct device *dev, u64 device_mask) 843int 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 2485eaa23101..c4f7dce577dd 100644
--- a/arch/sparc/kernel/pci_sun4v.c
+++ b/arch/sparc/kernel/pci_sun4v.c
@@ -232,7 +232,8 @@ static void dma_4v_free_coherent(struct device *dev, size_t size, void *cpu,
232 232
233static dma_addr_t dma_4v_map_page(struct device *dev, struct page *page, 233static dma_addr_t dma_4v_map_page(struct device *dev, struct page *page,
234 unsigned long offset, size_t sz, 234 unsigned long offset, size_t sz,
235 enum dma_data_direction direction) 235 enum dma_data_direction direction,
236 struct dma_attrs *attrs)
236{ 237{
237 struct iommu *iommu; 238 struct iommu *iommu;
238 unsigned long flags, npages, oaddr; 239 unsigned long flags, npages, oaddr;
@@ -296,7 +297,8 @@ iommu_map_fail:
296} 297}
297 298
298static void dma_4v_unmap_page(struct device *dev, dma_addr_t bus_addr, 299static void dma_4v_unmap_page(struct device *dev, dma_addr_t bus_addr,
299 size_t sz, enum dma_data_direction direction) 300 size_t sz, enum dma_data_direction direction,
301 struct dma_attrs *attrs)
300{ 302{
301 struct pci_pbm_info *pbm; 303 struct pci_pbm_info *pbm;
302 struct iommu *iommu; 304 struct iommu *iommu;
@@ -336,7 +338,8 @@ static void dma_4v_unmap_page(struct device *dev, dma_addr_t bus_addr,
336} 338}
337 339
338static int dma_4v_map_sg(struct device *dev, struct scatterlist *sglist, 340static int dma_4v_map_sg(struct device *dev, struct scatterlist *sglist,
339 int nelems, enum dma_data_direction direction) 341 int nelems, enum dma_data_direction direction,
342 struct dma_attrs *attrs)
340{ 343{
341 struct scatterlist *s, *outs, *segstart; 344 struct scatterlist *s, *outs, *segstart;
342 unsigned long flags, handle, prot; 345 unsigned long flags, handle, prot;
@@ -478,7 +481,8 @@ iommu_map_failed:
478} 481}
479 482
480static void dma_4v_unmap_sg(struct device *dev, struct scatterlist *sglist, 483static void dma_4v_unmap_sg(struct device *dev, struct scatterlist *sglist,
481 int nelems, enum dma_data_direction direction) 484 int nelems, enum dma_data_direction direction,
485 struct dma_attrs *attrs)
482{ 486{
483 struct pci_pbm_info *pbm; 487 struct pci_pbm_info *pbm;
484 struct scatterlist *sg; 488 struct scatterlist *sg;
@@ -535,7 +539,7 @@ static void dma_4v_sync_sg_for_cpu(struct device *dev,
535 /* Nothing to do... */ 539 /* Nothing to do... */
536} 540}
537 541
538static const struct dma_ops sun4v_dma_ops = { 542static const struct dma_map_ops sun4v_dma_ops = {
539 .alloc_coherent = dma_4v_alloc_coherent, 543 .alloc_coherent = dma_4v_alloc_coherent,
540 .free_coherent = dma_4v_free_coherent, 544 .free_coherent = dma_4v_free_coherent,
541 .map_page = dma_4v_map_page, 545 .map_page = dma_4v_map_page,