diff options
-rw-r--r-- | arch/arm64/mm/dma-mapping.c | 7 | ||||
-rw-r--r-- | drivers/iommu/dma-iommu.c | 23 | ||||
-rw-r--r-- | include/linux/dma-iommu.h | 1 |
3 files changed, 11 insertions, 20 deletions
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c index 3c2c088a3562..4c0f498069e8 100644 --- a/arch/arm64/mm/dma-mapping.c +++ b/arch/arm64/mm/dma-mapping.c | |||
@@ -233,7 +233,7 @@ static void *__iommu_alloc_attrs(struct device *dev, size_t size, | |||
233 | return NULL; | 233 | return NULL; |
234 | 234 | ||
235 | *handle = iommu_dma_map_page(dev, page, 0, iosize, ioprot); | 235 | *handle = iommu_dma_map_page(dev, page, 0, iosize, ioprot); |
236 | if (iommu_dma_mapping_error(dev, *handle)) { | 236 | if (*handle == DMA_MAPPING_ERROR) { |
237 | if (coherent) | 237 | if (coherent) |
238 | __free_pages(page, get_order(size)); | 238 | __free_pages(page, get_order(size)); |
239 | else | 239 | else |
@@ -250,7 +250,7 @@ static void *__iommu_alloc_attrs(struct device *dev, size_t size, | |||
250 | return NULL; | 250 | return NULL; |
251 | 251 | ||
252 | *handle = iommu_dma_map_page(dev, page, 0, iosize, ioprot); | 252 | *handle = iommu_dma_map_page(dev, page, 0, iosize, ioprot); |
253 | if (iommu_dma_mapping_error(dev, *handle)) { | 253 | if (*handle == DMA_MAPPING_ERROR) { |
254 | dma_release_from_contiguous(dev, page, | 254 | dma_release_from_contiguous(dev, page, |
255 | size >> PAGE_SHIFT); | 255 | size >> PAGE_SHIFT); |
256 | return NULL; | 256 | return NULL; |
@@ -410,7 +410,7 @@ static dma_addr_t __iommu_map_page(struct device *dev, struct page *page, | |||
410 | dma_addr_t dev_addr = iommu_dma_map_page(dev, page, offset, size, prot); | 410 | dma_addr_t dev_addr = iommu_dma_map_page(dev, page, offset, size, prot); |
411 | 411 | ||
412 | if (!coherent && !(attrs & DMA_ATTR_SKIP_CPU_SYNC) && | 412 | if (!coherent && !(attrs & DMA_ATTR_SKIP_CPU_SYNC) && |
413 | !iommu_dma_mapping_error(dev, dev_addr)) | 413 | dev_addr != DMA_MAPPING_ERROR) |
414 | __dma_map_area(page_address(page) + offset, size, dir); | 414 | __dma_map_area(page_address(page) + offset, size, dir); |
415 | 415 | ||
416 | return dev_addr; | 416 | return dev_addr; |
@@ -493,7 +493,6 @@ static const struct dma_map_ops iommu_dma_ops = { | |||
493 | .sync_sg_for_device = __iommu_sync_sg_for_device, | 493 | .sync_sg_for_device = __iommu_sync_sg_for_device, |
494 | .map_resource = iommu_dma_map_resource, | 494 | .map_resource = iommu_dma_map_resource, |
495 | .unmap_resource = iommu_dma_unmap_resource, | 495 | .unmap_resource = iommu_dma_unmap_resource, |
496 | .mapping_error = iommu_dma_mapping_error, | ||
497 | }; | 496 | }; |
498 | 497 | ||
499 | static int __init __iommu_dma_init(void) | 498 | static int __init __iommu_dma_init(void) |
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index d1b04753b204..60c7e9e9901e 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c | |||
@@ -32,8 +32,6 @@ | |||
32 | #include <linux/scatterlist.h> | 32 | #include <linux/scatterlist.h> |
33 | #include <linux/vmalloc.h> | 33 | #include <linux/vmalloc.h> |
34 | 34 | ||
35 | #define IOMMU_MAPPING_ERROR 0 | ||
36 | |||
37 | struct iommu_dma_msi_page { | 35 | struct iommu_dma_msi_page { |
38 | struct list_head list; | 36 | struct list_head list; |
39 | dma_addr_t iova; | 37 | dma_addr_t iova; |
@@ -523,7 +521,7 @@ void iommu_dma_free(struct device *dev, struct page **pages, size_t size, | |||
523 | { | 521 | { |
524 | __iommu_dma_unmap(iommu_get_dma_domain(dev), *handle, size); | 522 | __iommu_dma_unmap(iommu_get_dma_domain(dev), *handle, size); |
525 | __iommu_dma_free_pages(pages, PAGE_ALIGN(size) >> PAGE_SHIFT); | 523 | __iommu_dma_free_pages(pages, PAGE_ALIGN(size) >> PAGE_SHIFT); |
526 | *handle = IOMMU_MAPPING_ERROR; | 524 | *handle = DMA_MAPPING_ERROR; |
527 | } | 525 | } |
528 | 526 | ||
529 | /** | 527 | /** |
@@ -556,7 +554,7 @@ struct page **iommu_dma_alloc(struct device *dev, size_t size, gfp_t gfp, | |||
556 | dma_addr_t iova; | 554 | dma_addr_t iova; |
557 | unsigned int count, min_size, alloc_sizes = domain->pgsize_bitmap; | 555 | unsigned int count, min_size, alloc_sizes = domain->pgsize_bitmap; |
558 | 556 | ||
559 | *handle = IOMMU_MAPPING_ERROR; | 557 | *handle = DMA_MAPPING_ERROR; |
560 | 558 | ||
561 | min_size = alloc_sizes & -alloc_sizes; | 559 | min_size = alloc_sizes & -alloc_sizes; |
562 | if (min_size < PAGE_SIZE) { | 560 | if (min_size < PAGE_SIZE) { |
@@ -649,11 +647,11 @@ static dma_addr_t __iommu_dma_map(struct device *dev, phys_addr_t phys, | |||
649 | 647 | ||
650 | iova = iommu_dma_alloc_iova(domain, size, dma_get_mask(dev), dev); | 648 | iova = iommu_dma_alloc_iova(domain, size, dma_get_mask(dev), dev); |
651 | if (!iova) | 649 | if (!iova) |
652 | return IOMMU_MAPPING_ERROR; | 650 | return DMA_MAPPING_ERROR; |
653 | 651 | ||
654 | if (iommu_map(domain, iova, phys - iova_off, size, prot)) { | 652 | if (iommu_map(domain, iova, phys - iova_off, size, prot)) { |
655 | iommu_dma_free_iova(cookie, iova, size); | 653 | iommu_dma_free_iova(cookie, iova, size); |
656 | return IOMMU_MAPPING_ERROR; | 654 | return DMA_MAPPING_ERROR; |
657 | } | 655 | } |
658 | return iova + iova_off; | 656 | return iova + iova_off; |
659 | } | 657 | } |
@@ -694,7 +692,7 @@ static int __finalise_sg(struct device *dev, struct scatterlist *sg, int nents, | |||
694 | 692 | ||
695 | s->offset += s_iova_off; | 693 | s->offset += s_iova_off; |
696 | s->length = s_length; | 694 | s->length = s_length; |
697 | sg_dma_address(s) = IOMMU_MAPPING_ERROR; | 695 | sg_dma_address(s) = DMA_MAPPING_ERROR; |
698 | sg_dma_len(s) = 0; | 696 | sg_dma_len(s) = 0; |
699 | 697 | ||
700 | /* | 698 | /* |
@@ -737,11 +735,11 @@ static void __invalidate_sg(struct scatterlist *sg, int nents) | |||
737 | int i; | 735 | int i; |
738 | 736 | ||
739 | for_each_sg(sg, s, nents, i) { | 737 | for_each_sg(sg, s, nents, i) { |
740 | if (sg_dma_address(s) != IOMMU_MAPPING_ERROR) | 738 | if (sg_dma_address(s) != DMA_MAPPING_ERROR) |
741 | s->offset += sg_dma_address(s); | 739 | s->offset += sg_dma_address(s); |
742 | if (sg_dma_len(s)) | 740 | if (sg_dma_len(s)) |
743 | s->length = sg_dma_len(s); | 741 | s->length = sg_dma_len(s); |
744 | sg_dma_address(s) = IOMMU_MAPPING_ERROR; | 742 | sg_dma_address(s) = DMA_MAPPING_ERROR; |
745 | sg_dma_len(s) = 0; | 743 | sg_dma_len(s) = 0; |
746 | } | 744 | } |
747 | } | 745 | } |
@@ -858,11 +856,6 @@ void iommu_dma_unmap_resource(struct device *dev, dma_addr_t handle, | |||
858 | __iommu_dma_unmap(iommu_get_dma_domain(dev), handle, size); | 856 | __iommu_dma_unmap(iommu_get_dma_domain(dev), handle, size); |
859 | } | 857 | } |
860 | 858 | ||
861 | int iommu_dma_mapping_error(struct device *dev, dma_addr_t dma_addr) | ||
862 | { | ||
863 | return dma_addr == IOMMU_MAPPING_ERROR; | ||
864 | } | ||
865 | |||
866 | static struct iommu_dma_msi_page *iommu_dma_get_msi_page(struct device *dev, | 859 | static struct iommu_dma_msi_page *iommu_dma_get_msi_page(struct device *dev, |
867 | phys_addr_t msi_addr, struct iommu_domain *domain) | 860 | phys_addr_t msi_addr, struct iommu_domain *domain) |
868 | { | 861 | { |
@@ -882,7 +875,7 @@ static struct iommu_dma_msi_page *iommu_dma_get_msi_page(struct device *dev, | |||
882 | return NULL; | 875 | return NULL; |
883 | 876 | ||
884 | iova = __iommu_dma_map(dev, msi_addr, size, prot, domain); | 877 | iova = __iommu_dma_map(dev, msi_addr, size, prot, domain); |
885 | if (iommu_dma_mapping_error(dev, iova)) | 878 | if (iova == DMA_MAPPING_ERROR) |
886 | goto out_free_page; | 879 | goto out_free_page; |
887 | 880 | ||
888 | INIT_LIST_HEAD(&msi_page->list); | 881 | INIT_LIST_HEAD(&msi_page->list); |
diff --git a/include/linux/dma-iommu.h b/include/linux/dma-iommu.h index e8ca5e654277..e760dc5d1fa8 100644 --- a/include/linux/dma-iommu.h +++ b/include/linux/dma-iommu.h | |||
@@ -69,7 +69,6 @@ dma_addr_t iommu_dma_map_resource(struct device *dev, phys_addr_t phys, | |||
69 | size_t size, enum dma_data_direction dir, unsigned long attrs); | 69 | size_t size, enum dma_data_direction dir, unsigned long attrs); |
70 | void iommu_dma_unmap_resource(struct device *dev, dma_addr_t handle, | 70 | void iommu_dma_unmap_resource(struct device *dev, dma_addr_t handle, |
71 | size_t size, enum dma_data_direction dir, unsigned long attrs); | 71 | size_t size, enum dma_data_direction dir, unsigned long attrs); |
72 | int iommu_dma_mapping_error(struct device *dev, dma_addr_t dma_addr); | ||
73 | 72 | ||
74 | /* The DMA API isn't _quite_ the whole story, though... */ | 73 | /* The DMA API isn't _quite_ the whole story, though... */ |
75 | void iommu_dma_map_msi_msg(int irq, struct msi_msg *msg); | 74 | void iommu_dma_map_msi_msg(int irq, struct msi_msg *msg); |