aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/include/asm/dma-mapping.h24
-rw-r--r--arch/powerpc/kernel/dma-iommu.c10
-rw-r--r--arch/powerpc/kernel/dma-swiotlb.c4
-rw-r--r--arch/powerpc/kernel/dma.c10
-rw-r--r--arch/powerpc/kernel/ibmebus.c10
-rw-r--r--arch/powerpc/kernel/vio.c14
-rw-r--r--arch/powerpc/platforms/cell/iommu.c16
-rw-r--r--arch/powerpc/platforms/ps3/system-bus.c13
8 files changed, 60 insertions, 41 deletions
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index dd70fac57ec8..62678e365ca0 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -22,9 +22,11 @@
22 22
23/* Some dma direct funcs must be visible for use in other dma_ops */ 23/* Some dma direct funcs must be visible for use in other dma_ops */
24extern void *dma_direct_alloc_coherent(struct device *dev, size_t size, 24extern void *dma_direct_alloc_coherent(struct device *dev, size_t size,
25 dma_addr_t *dma_handle, gfp_t flag); 25 dma_addr_t *dma_handle, gfp_t flag,
26 struct dma_attrs *attrs);
26extern void dma_direct_free_coherent(struct device *dev, size_t size, 27extern void dma_direct_free_coherent(struct device *dev, size_t size,
27 void *vaddr, dma_addr_t dma_handle); 28 void *vaddr, dma_addr_t dma_handle,
29 struct dma_attrs *attrs);
28 30
29 31
30#ifdef CONFIG_NOT_COHERENT_CACHE 32#ifdef CONFIG_NOT_COHERENT_CACHE
@@ -130,23 +132,29 @@ static inline int dma_supported(struct device *dev, u64 mask)
130 132
131extern int dma_set_mask(struct device *dev, u64 dma_mask); 133extern int dma_set_mask(struct device *dev, u64 dma_mask);
132 134
133static inline void *dma_alloc_coherent(struct device *dev, size_t size, 135#define dma_alloc_coherent(d,s,h,f) dma_alloc_attrs(d,s,h,f,NULL)
134 dma_addr_t *dma_handle, gfp_t flag) 136
137static inline void *dma_alloc_attrs(struct device *dev, size_t size,
138 dma_addr_t *dma_handle, gfp_t flag,
139 struct dma_attrs *attrs)
135{ 140{
136 struct dma_map_ops *dma_ops = get_dma_ops(dev); 141 struct dma_map_ops *dma_ops = get_dma_ops(dev);
137 void *cpu_addr; 142 void *cpu_addr;
138 143
139 BUG_ON(!dma_ops); 144 BUG_ON(!dma_ops);
140 145
141 cpu_addr = dma_ops->alloc_coherent(dev, size, dma_handle, flag); 146 cpu_addr = dma_ops->alloc(dev, size, dma_handle, flag, attrs);
142 147
143 debug_dma_alloc_coherent(dev, size, *dma_handle, cpu_addr); 148 debug_dma_alloc_coherent(dev, size, *dma_handle, cpu_addr);
144 149
145 return cpu_addr; 150 return cpu_addr;
146} 151}
147 152
148static inline void dma_free_coherent(struct device *dev, size_t size, 153#define dma_free_coherent(d,s,c,h) dma_free_attrs(d,s,c,h,NULL)
149 void *cpu_addr, dma_addr_t dma_handle) 154
155static inline void dma_free_attrs(struct device *dev, size_t size,
156 void *cpu_addr, dma_addr_t dma_handle,
157 struct dma_attrs *attrs)
150{ 158{
151 struct dma_map_ops *dma_ops = get_dma_ops(dev); 159 struct dma_map_ops *dma_ops = get_dma_ops(dev);
152 160
@@ -154,7 +162,7 @@ static inline void dma_free_coherent(struct device *dev, size_t size,
154 162
155 debug_dma_free_coherent(dev, size, cpu_addr, dma_handle); 163 debug_dma_free_coherent(dev, size, cpu_addr, dma_handle);
156 164
157 dma_ops->free_coherent(dev, size, cpu_addr, dma_handle); 165 dma_ops->free(dev, size, cpu_addr, dma_handle, attrs);
158} 166}
159 167
160static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) 168static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
diff --git a/arch/powerpc/kernel/dma-iommu.c b/arch/powerpc/kernel/dma-iommu.c
index 3f6464b4d970..bcfdcd22c766 100644
--- a/arch/powerpc/kernel/dma-iommu.c
+++ b/arch/powerpc/kernel/dma-iommu.c
@@ -17,7 +17,8 @@
17 * to the dma address (mapping) of the first page. 17 * to the dma address (mapping) of the first page.
18 */ 18 */
19static void *dma_iommu_alloc_coherent(struct device *dev, size_t size, 19static void *dma_iommu_alloc_coherent(struct device *dev, size_t size,
20 dma_addr_t *dma_handle, gfp_t flag) 20 dma_addr_t *dma_handle, gfp_t flag,
21 struct dma_attrs *attrs)
21{ 22{
22 return iommu_alloc_coherent(dev, get_iommu_table_base(dev), size, 23 return iommu_alloc_coherent(dev, get_iommu_table_base(dev), size,
23 dma_handle, dev->coherent_dma_mask, flag, 24 dma_handle, dev->coherent_dma_mask, flag,
@@ -25,7 +26,8 @@ static void *dma_iommu_alloc_coherent(struct device *dev, size_t size,
25} 26}
26 27
27static void dma_iommu_free_coherent(struct device *dev, size_t size, 28static void dma_iommu_free_coherent(struct device *dev, size_t size,
28 void *vaddr, dma_addr_t dma_handle) 29 void *vaddr, dma_addr_t dma_handle,
30 struct dma_attrs *attrs)
29{ 31{
30 iommu_free_coherent(get_iommu_table_base(dev), size, vaddr, dma_handle); 32 iommu_free_coherent(get_iommu_table_base(dev), size, vaddr, dma_handle);
31} 33}
@@ -105,8 +107,8 @@ static u64 dma_iommu_get_required_mask(struct device *dev)
105} 107}
106 108
107struct dma_map_ops dma_iommu_ops = { 109struct dma_map_ops dma_iommu_ops = {
108 .alloc_coherent = dma_iommu_alloc_coherent, 110 .alloc = dma_iommu_alloc_coherent,
109 .free_coherent = dma_iommu_free_coherent, 111 .free = dma_iommu_free_coherent,
110 .map_sg = dma_iommu_map_sg, 112 .map_sg = dma_iommu_map_sg,
111 .unmap_sg = dma_iommu_unmap_sg, 113 .unmap_sg = dma_iommu_unmap_sg,
112 .dma_supported = dma_iommu_dma_supported, 114 .dma_supported = dma_iommu_dma_supported,
diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c
index 1ebc9189aada..4ab88dafb235 100644
--- a/arch/powerpc/kernel/dma-swiotlb.c
+++ b/arch/powerpc/kernel/dma-swiotlb.c
@@ -47,8 +47,8 @@ static u64 swiotlb_powerpc_get_required(struct device *dev)
47 * for everything else. 47 * for everything else.
48 */ 48 */
49struct dma_map_ops swiotlb_dma_ops = { 49struct dma_map_ops swiotlb_dma_ops = {
50 .alloc_coherent = dma_direct_alloc_coherent, 50 .alloc = dma_direct_alloc_coherent,
51 .free_coherent = dma_direct_free_coherent, 51 .free = dma_direct_free_coherent,
52 .map_sg = swiotlb_map_sg_attrs, 52 .map_sg = swiotlb_map_sg_attrs,
53 .unmap_sg = swiotlb_unmap_sg_attrs, 53 .unmap_sg = swiotlb_unmap_sg_attrs,
54 .dma_supported = swiotlb_dma_supported, 54 .dma_supported = swiotlb_dma_supported,
diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
index 7d0233c12ee3..b1ec983dcec8 100644
--- a/arch/powerpc/kernel/dma.c
+++ b/arch/powerpc/kernel/dma.c
@@ -26,7 +26,8 @@
26 26
27 27
28void *dma_direct_alloc_coherent(struct device *dev, size_t size, 28void *dma_direct_alloc_coherent(struct device *dev, size_t size,
29 dma_addr_t *dma_handle, gfp_t flag) 29 dma_addr_t *dma_handle, gfp_t flag,
30 struct dma_attrs *attrs)
30{ 31{
31 void *ret; 32 void *ret;
32#ifdef CONFIG_NOT_COHERENT_CACHE 33#ifdef CONFIG_NOT_COHERENT_CACHE
@@ -54,7 +55,8 @@ void *dma_direct_alloc_coherent(struct device *dev, size_t size,
54} 55}
55 56
56void dma_direct_free_coherent(struct device *dev, size_t size, 57void dma_direct_free_coherent(struct device *dev, size_t size,
57 void *vaddr, dma_addr_t dma_handle) 58 void *vaddr, dma_addr_t dma_handle,
59 struct dma_attrs *attrs)
58{ 60{
59#ifdef CONFIG_NOT_COHERENT_CACHE 61#ifdef CONFIG_NOT_COHERENT_CACHE
60 __dma_free_coherent(size, vaddr); 62 __dma_free_coherent(size, vaddr);
@@ -150,8 +152,8 @@ static inline void dma_direct_sync_single(struct device *dev,
150#endif 152#endif
151 153
152struct dma_map_ops dma_direct_ops = { 154struct dma_map_ops dma_direct_ops = {
153 .alloc_coherent = dma_direct_alloc_coherent, 155 .alloc = dma_direct_alloc_coherent,
154 .free_coherent = dma_direct_free_coherent, 156 .free = dma_direct_free_coherent,
155 .map_sg = dma_direct_map_sg, 157 .map_sg = dma_direct_map_sg,
156 .unmap_sg = dma_direct_unmap_sg, 158 .unmap_sg = dma_direct_unmap_sg,
157 .dma_supported = dma_direct_dma_supported, 159 .dma_supported = dma_direct_dma_supported,
diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c
index 79bb282e6501..b01d14eeca8d 100644
--- a/arch/powerpc/kernel/ibmebus.c
+++ b/arch/powerpc/kernel/ibmebus.c
@@ -65,7 +65,8 @@ static struct of_device_id __initdata ibmebus_matches[] = {
65static void *ibmebus_alloc_coherent(struct device *dev, 65static void *ibmebus_alloc_coherent(struct device *dev,
66 size_t size, 66 size_t size,
67 dma_addr_t *dma_handle, 67 dma_addr_t *dma_handle,
68 gfp_t flag) 68 gfp_t flag,
69 struct dma_attrs *attrs)
69{ 70{
70 void *mem; 71 void *mem;
71 72
@@ -77,7 +78,8 @@ static void *ibmebus_alloc_coherent(struct device *dev,
77 78
78static void ibmebus_free_coherent(struct device *dev, 79static void ibmebus_free_coherent(struct device *dev,
79 size_t size, void *vaddr, 80 size_t size, void *vaddr,
80 dma_addr_t dma_handle) 81 dma_addr_t dma_handle,
82 struct dma_attrs *attrs)
81{ 83{
82 kfree(vaddr); 84 kfree(vaddr);
83} 85}
@@ -136,8 +138,8 @@ static u64 ibmebus_dma_get_required_mask(struct device *dev)
136} 138}
137 139
138static struct dma_map_ops ibmebus_dma_ops = { 140static struct dma_map_ops ibmebus_dma_ops = {
139 .alloc_coherent = ibmebus_alloc_coherent, 141 .alloc = ibmebus_alloc_coherent,
140 .free_coherent = ibmebus_free_coherent, 142 .free = ibmebus_free_coherent,
141 .map_sg = ibmebus_map_sg, 143 .map_sg = ibmebus_map_sg,
142 .unmap_sg = ibmebus_unmap_sg, 144 .unmap_sg = ibmebus_unmap_sg,
143 .dma_supported = ibmebus_dma_supported, 145 .dma_supported = ibmebus_dma_supported,
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index b2f7c8480bf6..a3a99901c8ec 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -482,7 +482,8 @@ static void vio_cmo_balance(struct work_struct *work)
482} 482}
483 483
484static void *vio_dma_iommu_alloc_coherent(struct device *dev, size_t size, 484static void *vio_dma_iommu_alloc_coherent(struct device *dev, size_t size,
485 dma_addr_t *dma_handle, gfp_t flag) 485 dma_addr_t *dma_handle, gfp_t flag,
486 struct dma_attrs *attrs)
486{ 487{
487 struct vio_dev *viodev = to_vio_dev(dev); 488 struct vio_dev *viodev = to_vio_dev(dev);
488 void *ret; 489 void *ret;
@@ -492,7 +493,7 @@ static void *vio_dma_iommu_alloc_coherent(struct device *dev, size_t size,
492 return NULL; 493 return NULL;
493 } 494 }
494 495
495 ret = dma_iommu_ops.alloc_coherent(dev, size, dma_handle, flag); 496 ret = dma_iommu_ops.alloc(dev, size, dma_handle, flag, attrs);
496 if (unlikely(ret == NULL)) { 497 if (unlikely(ret == NULL)) {
497 vio_cmo_dealloc(viodev, roundup(size, PAGE_SIZE)); 498 vio_cmo_dealloc(viodev, roundup(size, PAGE_SIZE));
498 atomic_inc(&viodev->cmo.allocs_failed); 499 atomic_inc(&viodev->cmo.allocs_failed);
@@ -502,11 +503,12 @@ static void *vio_dma_iommu_alloc_coherent(struct device *dev, size_t size,
502} 503}
503 504
504static void vio_dma_iommu_free_coherent(struct device *dev, size_t size, 505static void vio_dma_iommu_free_coherent(struct device *dev, size_t size,
505 void *vaddr, dma_addr_t dma_handle) 506 void *vaddr, dma_addr_t dma_handle,
507 struct dma_attrs *attrs)
506{ 508{
507 struct vio_dev *viodev = to_vio_dev(dev); 509 struct vio_dev *viodev = to_vio_dev(dev);
508 510
509 dma_iommu_ops.free_coherent(dev, size, vaddr, dma_handle); 511 dma_iommu_ops.free(dev, size, vaddr, dma_handle, attrs);
510 512
511 vio_cmo_dealloc(viodev, roundup(size, PAGE_SIZE)); 513 vio_cmo_dealloc(viodev, roundup(size, PAGE_SIZE));
512} 514}
@@ -607,8 +609,8 @@ static u64 vio_dma_get_required_mask(struct device *dev)
607} 609}
608 610
609struct dma_map_ops vio_dma_mapping_ops = { 611struct dma_map_ops vio_dma_mapping_ops = {
610 .alloc_coherent = vio_dma_iommu_alloc_coherent, 612 .alloc = vio_dma_iommu_alloc_coherent,
611 .free_coherent = vio_dma_iommu_free_coherent, 613 .free = vio_dma_iommu_free_coherent,
612 .map_sg = vio_dma_iommu_map_sg, 614 .map_sg = vio_dma_iommu_map_sg,
613 .unmap_sg = vio_dma_iommu_unmap_sg, 615 .unmap_sg = vio_dma_iommu_unmap_sg,
614 .map_page = vio_dma_iommu_map_page, 616 .map_page = vio_dma_iommu_map_page,
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index ae9fc7bc17d6..b9f509a34c01 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -564,7 +564,8 @@ static struct iommu_table *cell_get_iommu_table(struct device *dev)
564/* A coherent allocation implies strong ordering */ 564/* A coherent allocation implies strong ordering */
565 565
566static void *dma_fixed_alloc_coherent(struct device *dev, size_t size, 566static void *dma_fixed_alloc_coherent(struct device *dev, size_t size,
567 dma_addr_t *dma_handle, gfp_t flag) 567 dma_addr_t *dma_handle, gfp_t flag,
568 struct dma_attrs *attrs)
568{ 569{
569 if (iommu_fixed_is_weak) 570 if (iommu_fixed_is_weak)
570 return iommu_alloc_coherent(dev, cell_get_iommu_table(dev), 571 return iommu_alloc_coherent(dev, cell_get_iommu_table(dev),
@@ -572,18 +573,19 @@ static void *dma_fixed_alloc_coherent(struct device *dev, size_t size,
572 device_to_mask(dev), flag, 573 device_to_mask(dev), flag,
573 dev_to_node(dev)); 574 dev_to_node(dev));
574 else 575 else
575 return dma_direct_ops.alloc_coherent(dev, size, dma_handle, 576 return dma_direct_ops.alloc(dev, size, dma_handle, flag,
576 flag); 577 attrs);
577} 578}
578 579
579static void dma_fixed_free_coherent(struct device *dev, size_t size, 580static void dma_fixed_free_coherent(struct device *dev, size_t size,
580 void *vaddr, dma_addr_t dma_handle) 581 void *vaddr, dma_addr_t dma_handle,
582 struct dma_attrs *attrs)
581{ 583{
582 if (iommu_fixed_is_weak) 584 if (iommu_fixed_is_weak)
583 iommu_free_coherent(cell_get_iommu_table(dev), size, vaddr, 585 iommu_free_coherent(cell_get_iommu_table(dev), size, vaddr,
584 dma_handle); 586 dma_handle);
585 else 587 else
586 dma_direct_ops.free_coherent(dev, size, vaddr, dma_handle); 588 dma_direct_ops.free(dev, size, vaddr, dma_handle, attrs);
587} 589}
588 590
589static dma_addr_t dma_fixed_map_page(struct device *dev, struct page *page, 591static dma_addr_t dma_fixed_map_page(struct device *dev, struct page *page,
@@ -642,8 +644,8 @@ static int dma_fixed_dma_supported(struct device *dev, u64 mask)
642static int dma_set_mask_and_switch(struct device *dev, u64 dma_mask); 644static int dma_set_mask_and_switch(struct device *dev, u64 dma_mask);
643 645
644struct dma_map_ops dma_iommu_fixed_ops = { 646struct dma_map_ops dma_iommu_fixed_ops = {
645 .alloc_coherent = dma_fixed_alloc_coherent, 647 .alloc = dma_fixed_alloc_coherent,
646 .free_coherent = dma_fixed_free_coherent, 648 .free = dma_fixed_free_coherent,
647 .map_sg = dma_fixed_map_sg, 649 .map_sg = dma_fixed_map_sg,
648 .unmap_sg = dma_fixed_unmap_sg, 650 .unmap_sg = dma_fixed_unmap_sg,
649 .dma_supported = dma_fixed_dma_supported, 651 .dma_supported = dma_fixed_dma_supported,
diff --git a/arch/powerpc/platforms/ps3/system-bus.c b/arch/powerpc/platforms/ps3/system-bus.c
index 880eb9ce22c5..5606fe36faf2 100644
--- a/arch/powerpc/platforms/ps3/system-bus.c
+++ b/arch/powerpc/platforms/ps3/system-bus.c
@@ -515,7 +515,8 @@ core_initcall(ps3_system_bus_init);
515 * to the dma address (mapping) of the first page. 515 * to the dma address (mapping) of the first page.
516 */ 516 */
517static void * ps3_alloc_coherent(struct device *_dev, size_t size, 517static void * ps3_alloc_coherent(struct device *_dev, size_t size,
518 dma_addr_t *dma_handle, gfp_t flag) 518 dma_addr_t *dma_handle, gfp_t flag,
519 struct dma_attrs *attrs)
519{ 520{
520 int result; 521 int result;
521 struct ps3_system_bus_device *dev = ps3_dev_to_system_bus_dev(_dev); 522 struct ps3_system_bus_device *dev = ps3_dev_to_system_bus_dev(_dev);
@@ -552,7 +553,7 @@ clean_none:
552} 553}
553 554
554static void ps3_free_coherent(struct device *_dev, size_t size, void *vaddr, 555static void ps3_free_coherent(struct device *_dev, size_t size, void *vaddr,
555 dma_addr_t dma_handle) 556 dma_addr_t dma_handle, struct dma_attrs *attrs)
556{ 557{
557 struct ps3_system_bus_device *dev = ps3_dev_to_system_bus_dev(_dev); 558 struct ps3_system_bus_device *dev = ps3_dev_to_system_bus_dev(_dev);
558 559
@@ -701,8 +702,8 @@ static u64 ps3_dma_get_required_mask(struct device *_dev)
701} 702}
702 703
703static struct dma_map_ops ps3_sb_dma_ops = { 704static struct dma_map_ops ps3_sb_dma_ops = {
704 .alloc_coherent = ps3_alloc_coherent, 705 .alloc = ps3_alloc_coherent,
705 .free_coherent = ps3_free_coherent, 706 .free = ps3_free_coherent,
706 .map_sg = ps3_sb_map_sg, 707 .map_sg = ps3_sb_map_sg,
707 .unmap_sg = ps3_sb_unmap_sg, 708 .unmap_sg = ps3_sb_unmap_sg,
708 .dma_supported = ps3_dma_supported, 709 .dma_supported = ps3_dma_supported,
@@ -712,8 +713,8 @@ static struct dma_map_ops ps3_sb_dma_ops = {
712}; 713};
713 714
714static struct dma_map_ops ps3_ioc0_dma_ops = { 715static struct dma_map_ops ps3_ioc0_dma_ops = {
715 .alloc_coherent = ps3_alloc_coherent, 716 .alloc = ps3_alloc_coherent,
716 .free_coherent = ps3_free_coherent, 717 .free = ps3_free_coherent,
717 .map_sg = ps3_ioc0_map_sg, 718 .map_sg = ps3_ioc0_map_sg,
718 .unmap_sg = ps3_ioc0_unmap_sg, 719 .unmap_sg = ps3_ioc0_unmap_sg,
719 .dma_supported = ps3_dma_supported, 720 .dma_supported = ps3_dma_supported,