summaryrefslogtreecommitdiffstats
path: root/drivers/xen/swiotlb-xen.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2017-05-21 07:23:27 -0400
committerChristoph Hellwig <hch@lst.de>2017-06-20 05:13:00 -0400
commit4d048dbc057b989966b25011385bb9d825e932ea (patch)
tree38dedc7f276df530302f689b9aa0f3e9d85e2bbe /drivers/xen/swiotlb-xen.c
parentdceb1a6819ab2c8b5564354543447b1af4fccedd (diff)
xen-swiotlb: implement ->mapping_error
DMA_ERROR_CODE is going to go away, so don't rely on it. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers/xen/swiotlb-xen.c')
-rw-r--r--drivers/xen/swiotlb-xen.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index a0f006daab48..c3a04b2d7532 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -67,6 +67,8 @@ static unsigned long dma_alloc_coherent_mask(struct device *dev,
67} 67}
68#endif 68#endif
69 69
70#define XEN_SWIOTLB_ERROR_CODE (~(dma_addr_t)0x0)
71
70static char *xen_io_tlb_start, *xen_io_tlb_end; 72static char *xen_io_tlb_start, *xen_io_tlb_end;
71static unsigned long xen_io_tlb_nslabs; 73static unsigned long xen_io_tlb_nslabs;
72/* 74/*
@@ -410,7 +412,7 @@ static dma_addr_t xen_swiotlb_map_page(struct device *dev, struct page *page,
410 map = swiotlb_tbl_map_single(dev, start_dma_addr, phys, size, dir, 412 map = swiotlb_tbl_map_single(dev, start_dma_addr, phys, size, dir,
411 attrs); 413 attrs);
412 if (map == SWIOTLB_MAP_ERROR) 414 if (map == SWIOTLB_MAP_ERROR)
413 return DMA_ERROR_CODE; 415 return XEN_SWIOTLB_ERROR_CODE;
414 416
415 dev_addr = xen_phys_to_bus(map); 417 dev_addr = xen_phys_to_bus(map);
416 xen_dma_map_page(dev, pfn_to_page(map >> PAGE_SHIFT), 418 xen_dma_map_page(dev, pfn_to_page(map >> PAGE_SHIFT),
@@ -425,7 +427,7 @@ static dma_addr_t xen_swiotlb_map_page(struct device *dev, struct page *page,
425 attrs |= DMA_ATTR_SKIP_CPU_SYNC; 427 attrs |= DMA_ATTR_SKIP_CPU_SYNC;
426 swiotlb_tbl_unmap_single(dev, map, size, dir, attrs); 428 swiotlb_tbl_unmap_single(dev, map, size, dir, attrs);
427 429
428 return DMA_ERROR_CODE; 430 return XEN_SWIOTLB_ERROR_CODE;
429} 431}
430 432
431/* 433/*
@@ -715,6 +717,11 @@ xen_swiotlb_get_sgtable(struct device *dev, struct sg_table *sgt,
715 return dma_common_get_sgtable(dev, sgt, cpu_addr, handle, size); 717 return dma_common_get_sgtable(dev, sgt, cpu_addr, handle, size);
716} 718}
717 719
720static int xen_swiotlb_mapping_error(struct device *dev, dma_addr_t dma_addr)
721{
722 return dma_addr == XEN_SWIOTLB_ERROR_CODE;
723}
724
718const struct dma_map_ops xen_swiotlb_dma_ops = { 725const struct dma_map_ops xen_swiotlb_dma_ops = {
719 .alloc = xen_swiotlb_alloc_coherent, 726 .alloc = xen_swiotlb_alloc_coherent,
720 .free = xen_swiotlb_free_coherent, 727 .free = xen_swiotlb_free_coherent,
@@ -730,4 +737,5 @@ const struct dma_map_ops xen_swiotlb_dma_ops = {
730 .set_dma_mask = xen_swiotlb_set_dma_mask, 737 .set_dma_mask = xen_swiotlb_set_dma_mask,
731 .mmap = xen_swiotlb_dma_mmap, 738 .mmap = xen_swiotlb_dma_mmap,
732 .get_sgtable = xen_swiotlb_get_sgtable, 739 .get_sgtable = xen_swiotlb_get_sgtable,
740 .mapping_error = xen_swiotlb_mapping_error,
733}; 741};