staging: ion: add dma_map_sg/dma_umap_sg to map_dma_buf
authorMark Yao <mark.yao@rock-chips.com>
Fri, 26 Jun 2015 00:42:30 +0000 (08:42 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Fri, 24 Mar 2017 02:57:03 +0000 (10:57 +0800)
Change-Id: Ibb1da3afd35a4411f096e8cbd7a17d35fc216cba
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
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,