aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu/dma-iommu.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/iommu/dma-iommu.c')
-rw-r--r--drivers/iommu/dma-iommu.c23
1 files changed, 8 insertions, 15 deletions
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
37struct iommu_dma_msi_page { 35struct 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
861int iommu_dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
862{
863 return dma_addr == IOMMU_MAPPING_ERROR;
864}
865
866static struct iommu_dma_msi_page *iommu_dma_get_msi_page(struct device *dev, 859static 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);