Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/iommu: remove the mapping_error dma_map_ops method

The powerpc iommu code already returns (~(dma_addr_t)0x0) on mapping
failures, so we can switch over to returning DMA_MAPPING_ERROR and let
the core dma-mapping code handle the rest.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>

+15 -27
-4
arch/powerpc/include/asm/iommu.h
··· 143 143 144 144 #ifdef CONFIG_PPC64 145 145 146 - #define IOMMU_MAPPING_ERROR (~(dma_addr_t)0x0) 147 - 148 146 static inline void set_iommu_table_base(struct device *dev, 149 147 struct iommu_table *base) 150 148 { ··· 239 241 return 0; 240 242 } 241 243 #endif /* !CONFIG_IOMMU_API */ 242 - 243 - int dma_iommu_mapping_error(struct device *dev, dma_addr_t dma_addr); 244 244 245 245 #else 246 246
-6
arch/powerpc/kernel/dma-iommu.c
··· 106 106 return mask; 107 107 } 108 108 109 - int dma_iommu_mapping_error(struct device *dev, dma_addr_t dma_addr) 110 - { 111 - return dma_addr == IOMMU_MAPPING_ERROR; 112 - } 113 - 114 109 struct dma_map_ops dma_iommu_ops = { 115 110 .alloc = dma_iommu_alloc_coherent, 116 111 .free = dma_iommu_free_coherent, ··· 116 121 .map_page = dma_iommu_map_page, 117 122 .unmap_page = dma_iommu_unmap_page, 118 123 .get_required_mask = dma_iommu_get_required_mask, 119 - .mapping_error = dma_iommu_mapping_error, 120 124 }; 121 125 EXPORT_SYMBOL(dma_iommu_ops);
+14 -14
arch/powerpc/kernel/iommu.c
··· 197 197 if (unlikely(npages == 0)) { 198 198 if (printk_ratelimit()) 199 199 WARN_ON(1); 200 - return IOMMU_MAPPING_ERROR; 200 + return DMA_MAPPING_ERROR; 201 201 } 202 202 203 203 if (should_fail_iommu(dev)) 204 - return IOMMU_MAPPING_ERROR; 204 + return DMA_MAPPING_ERROR; 205 205 206 206 /* 207 207 * We don't need to disable preemption here because any CPU can ··· 277 277 } else { 278 278 /* Give up */ 279 279 spin_unlock_irqrestore(&(pool->lock), flags); 280 - return IOMMU_MAPPING_ERROR; 280 + return DMA_MAPPING_ERROR; 281 281 } 282 282 } 283 283 ··· 309 309 unsigned long attrs) 310 310 { 311 311 unsigned long entry; 312 - dma_addr_t ret = IOMMU_MAPPING_ERROR; 312 + dma_addr_t ret = DMA_MAPPING_ERROR; 313 313 int build_fail; 314 314 315 315 entry = iommu_range_alloc(dev, tbl, npages, NULL, mask, align_order); 316 316 317 - if (unlikely(entry == IOMMU_MAPPING_ERROR)) 318 - return IOMMU_MAPPING_ERROR; 317 + if (unlikely(entry == DMA_MAPPING_ERROR)) 318 + return DMA_MAPPING_ERROR; 319 319 320 320 entry += tbl->it_offset; /* Offset into real TCE table */ 321 321 ret = entry << tbl->it_page_shift; /* Set the return dma address */ ··· 327 327 328 328 /* tbl->it_ops->set() only returns non-zero for transient errors. 329 329 * Clean up the table bitmap in this case and return 330 - * IOMMU_MAPPING_ERROR. For all other errors the functionality is 330 + * DMA_MAPPING_ERROR. For all other errors the functionality is 331 331 * not altered. 332 332 */ 333 333 if (unlikely(build_fail)) { 334 334 __iommu_free(tbl, ret, npages); 335 - return IOMMU_MAPPING_ERROR; 335 + return DMA_MAPPING_ERROR; 336 336 } 337 337 338 338 /* Flush/invalidate TLB caches if necessary */ ··· 477 477 DBG(" - vaddr: %lx, size: %lx\n", vaddr, slen); 478 478 479 479 /* Handle failure */ 480 - if (unlikely(entry == IOMMU_MAPPING_ERROR)) { 480 + if (unlikely(entry == DMA_MAPPING_ERROR)) { 481 481 if (!(attrs & DMA_ATTR_NO_WARN) && 482 482 printk_ratelimit()) 483 483 dev_info(dev, "iommu_alloc failed, tbl %p " ··· 544 544 */ 545 545 if (outcount < incount) { 546 546 outs = sg_next(outs); 547 - outs->dma_address = IOMMU_MAPPING_ERROR; 547 + outs->dma_address = DMA_MAPPING_ERROR; 548 548 outs->dma_length = 0; 549 549 } 550 550 ··· 562 562 npages = iommu_num_pages(s->dma_address, s->dma_length, 563 563 IOMMU_PAGE_SIZE(tbl)); 564 564 __iommu_free(tbl, vaddr, npages); 565 - s->dma_address = IOMMU_MAPPING_ERROR; 565 + s->dma_address = DMA_MAPPING_ERROR; 566 566 s->dma_length = 0; 567 567 } 568 568 if (s == outs) ··· 776 776 unsigned long mask, enum dma_data_direction direction, 777 777 unsigned long attrs) 778 778 { 779 - dma_addr_t dma_handle = IOMMU_MAPPING_ERROR; 779 + dma_addr_t dma_handle = DMA_MAPPING_ERROR; 780 780 void *vaddr; 781 781 unsigned long uaddr; 782 782 unsigned int npages, align; ··· 796 796 dma_handle = iommu_alloc(dev, tbl, vaddr, npages, direction, 797 797 mask >> tbl->it_page_shift, align, 798 798 attrs); 799 - if (dma_handle == IOMMU_MAPPING_ERROR) { 799 + if (dma_handle == DMA_MAPPING_ERROR) { 800 800 if (!(attrs & DMA_ATTR_NO_WARN) && 801 801 printk_ratelimit()) { 802 802 dev_info(dev, "iommu_alloc failed, tbl %p " ··· 868 868 io_order = get_iommu_order(size, tbl); 869 869 mapping = iommu_alloc(dev, tbl, ret, nio_pages, DMA_BIDIRECTIONAL, 870 870 mask >> tbl->it_page_shift, io_order, 0); 871 - if (mapping == IOMMU_MAPPING_ERROR) { 871 + if (mapping == DMA_MAPPING_ERROR) { 872 872 free_pages((unsigned long)ret, order); 873 873 return NULL; 874 874 }
-1
arch/powerpc/platforms/cell/iommu.c
··· 654 654 .dma_supported = dma_suported_and_switch, 655 655 .map_page = dma_fixed_map_page, 656 656 .unmap_page = dma_fixed_unmap_page, 657 - .mapping_error = dma_iommu_mapping_error, 658 657 }; 659 658 660 659 static void cell_dma_dev_setup(struct device *dev)
+1 -2
arch/powerpc/platforms/pseries/vio.c
··· 519 519 { 520 520 struct vio_dev *viodev = to_vio_dev(dev); 521 521 struct iommu_table *tbl; 522 - dma_addr_t ret = IOMMU_MAPPING_ERROR; 522 + dma_addr_t ret = DMA_MAPPING_ERROR; 523 523 524 524 tbl = get_iommu_table_base(dev); 525 525 if (vio_cmo_alloc(viodev, roundup(size, IOMMU_PAGE_SIZE(tbl)))) { ··· 625 625 .unmap_page = vio_dma_iommu_unmap_page, 626 626 .dma_supported = vio_dma_iommu_dma_supported, 627 627 .get_required_mask = vio_dma_get_required_mask, 628 - .mapping_error = dma_iommu_mapping_error, 629 628 }; 630 629 631 630 /**