powerpc/iommu: return error code from .map_sg() ops
The .map_sg() op now expects an error code instead of zero on failure. Propagate the error up if vio_dma_iommu_map_sg() fails. ppc_iommu_map_sg() may fail either because of iommu_range_alloc() or because of tbl->it_ops->set(). The former only supports returning an error with DMA_MAPPING_ERROR and an examination of the latter indicates that it may return arch-specific errors (for example, tce_buildmulti_pSeriesLP()). Hence, coalesce all of those errors into -EIO, per the documentation on dma_map_sgtable(). Signed-off-by: Martin Oliveira <martin.oliveira@eideticom.com> Signed-off-by: Logan Gunthorpe <logang@deltatee.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Geoff Levand <geoff@infradead.org> Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
af82fe8566
commit
c4e0e892ab
|
@ -473,7 +473,7 @@ int ppc_iommu_map_sg(struct device *dev, struct iommu_table *tbl,
|
||||||
BUG_ON(direction == DMA_NONE);
|
BUG_ON(direction == DMA_NONE);
|
||||||
|
|
||||||
if ((nelems == 0) || !tbl)
|
if ((nelems == 0) || !tbl)
|
||||||
return 0;
|
return -EINVAL;
|
||||||
|
|
||||||
outs = s = segstart = &sglist[0];
|
outs = s = segstart = &sglist[0];
|
||||||
outcount = 1;
|
outcount = 1;
|
||||||
|
@ -599,7 +599,7 @@ int ppc_iommu_map_sg(struct device *dev, struct iommu_table *tbl,
|
||||||
if (s == outs)
|
if (s == outs)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -663,7 +663,7 @@ static int ps3_ioc0_map_sg(struct device *_dev, struct scatterlist *sg,
|
||||||
unsigned long attrs)
|
unsigned long attrs)
|
||||||
{
|
{
|
||||||
BUG();
|
BUG();
|
||||||
return 0;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ps3_sb_unmap_sg(struct device *_dev, struct scatterlist *sg,
|
static void ps3_sb_unmap_sg(struct device *_dev, struct scatterlist *sg,
|
||||||
|
|
|
@ -560,7 +560,8 @@ static int vio_dma_iommu_map_sg(struct device *dev, struct scatterlist *sglist,
|
||||||
for_each_sg(sglist, sgl, nelems, count)
|
for_each_sg(sglist, sgl, nelems, count)
|
||||||
alloc_size += roundup(sgl->length, IOMMU_PAGE_SIZE(tbl));
|
alloc_size += roundup(sgl->length, IOMMU_PAGE_SIZE(tbl));
|
||||||
|
|
||||||
if (vio_cmo_alloc(viodev, alloc_size))
|
ret = vio_cmo_alloc(viodev, alloc_size);
|
||||||
|
if (ret)
|
||||||
goto out_fail;
|
goto out_fail;
|
||||||
ret = ppc_iommu_map_sg(dev, tbl, sglist, nelems, dma_get_mask(dev),
|
ret = ppc_iommu_map_sg(dev, tbl, sglist, nelems, dma_get_mask(dev),
|
||||||
direction, attrs);
|
direction, attrs);
|
||||||
|
@ -577,7 +578,7 @@ out_deallocate:
|
||||||
vio_cmo_dealloc(viodev, alloc_size);
|
vio_cmo_dealloc(viodev, alloc_size);
|
||||||
out_fail:
|
out_fail:
|
||||||
atomic_inc(&viodev->cmo.allocs_failed);
|
atomic_inc(&viodev->cmo.allocs_failed);
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vio_dma_iommu_unmap_sg(struct device *dev,
|
static void vio_dma_iommu_unmap_sg(struct device *dev,
|
||||||
|
|
Loading…
Reference in New Issue