staging: ion: add dma_map_sg/dma_umap_sg to map_dma_buf
[firefly-linux-kernel-4.4.55.git] / drivers / staging / android / ion / ion.c
index 18c2c7c3deb8c07e17ed3ab8b764c2f175a9f062..13c0972669c0d779d85e59f4ab93e582f46ae46f 100644 (file)
@@ -1180,6 +1180,10 @@ static struct sg_table *ion_map_dma_buf(struct dma_buf_attachment *attachment,
        struct ion_buffer *buffer = dmabuf->priv;
 
        ion_buffer_sync_for_device(buffer, attachment->dev, direction);
+       if (!dma_map_sg(attachment->dev, buffer->sg_table->sgl,
+                       buffer->sg_table->nents, direction))
+               return ERR_PTR(-ENOMEM);
+
        return buffer->sg_table;
 }
 
@@ -1187,6 +1191,7 @@ static void ion_unmap_dma_buf(struct dma_buf_attachment *attachment,
                              struct sg_table *table,
                              enum dma_data_direction direction)
 {
+       dma_unmap_sg(attachment->dev, table->sgl, table->nents, direction);
 }
 
 void ion_pages_sync_for_device(struct device *dev, struct page *page,