Skip to content

Commit 524a669

Browse files
author
Christoph Hellwig
committed
iommu/vt-d: remove the mapping_error dma_map_ops method
Return DMA_MAPPING_ERROR instead of 0 on a dma mapping failure 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>
1 parent 964f231 commit 524a669

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

drivers/iommu/intel-iommu.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3617,7 +3617,7 @@ static dma_addr_t __intel_map_page(struct device *dev, struct page *page,
36173617

36183618
domain = get_valid_domain_for_dev(dev);
36193619
if (!domain)
3620-
return 0;
3620+
return DMA_MAPPING_ERROR;
36213621

36223622
iommu = domain_get_iommu(domain);
36233623
size = aligned_nrpages(paddr, size);
@@ -3655,7 +3655,7 @@ static dma_addr_t __intel_map_page(struct device *dev, struct page *page,
36553655
free_iova_fast(&domain->iovad, iova_pfn, dma_to_mm_pfn(size));
36563656
pr_err("Device %s request: %zx@%llx dir %d --- failed\n",
36573657
dev_name(dev), size, (unsigned long long)paddr, dir);
3658-
return 0;
3658+
return DMA_MAPPING_ERROR;
36593659
}
36603660

36613661
static dma_addr_t intel_map_page(struct device *dev, struct page *page,
@@ -3756,7 +3756,7 @@ static void *intel_alloc_coherent(struct device *dev, size_t size,
37563756

37573757
*dma_handle = __intel_map_page(dev, page, 0, size, DMA_BIDIRECTIONAL,
37583758
dev->coherent_dma_mask);
3759-
if (*dma_handle)
3759+
if (*dma_handle != DMA_MAPPING_ERROR)
37603760
return page_address(page);
37613761
if (!dma_release_from_contiguous(dev, page, size >> PAGE_SHIFT))
37623762
__free_pages(page, order);
@@ -3865,19 +3865,13 @@ static int intel_map_sg(struct device *dev, struct scatterlist *sglist, int nele
38653865
return nelems;
38663866
}
38673867

3868-
static int intel_mapping_error(struct device *dev, dma_addr_t dma_addr)
3869-
{
3870-
return !dma_addr;
3871-
}
3872-
38733868
static const struct dma_map_ops intel_dma_ops = {
38743869
.alloc = intel_alloc_coherent,
38753870
.free = intel_free_coherent,
38763871
.map_sg = intel_map_sg,
38773872
.unmap_sg = intel_unmap_sg,
38783873
.map_page = intel_map_page,
38793874
.unmap_page = intel_unmap_page,
3880-
.mapping_error = intel_mapping_error,
38813875
.dma_supported = dma_direct_supported,
38823876
};
38833877

0 commit comments

Comments
 (0)