Commit b8b5c139 authored by Inki Dae's avatar Inki Dae

drm/exynos: consider DMA_NONE flag to dmabuf import

This patch considers DMA_NONE flag for other drivers not using
dma mapping framework with iommu such as 3d gpu driver or others.

For example, there might be 3d gpu driver that has its own iommu
hw unit and iommu table mapping mechnism. So in this case,
the dmabuf buffer imported into this driver needs just only
sg table to map the buffer with its own iommu table itself.

So this patch makes dma_buf_map_attachment ignore dma_map_sg call
and just return sg table containing pages if dma_data_direction
is DMA_NONE.
Signed-off-by: default avatarInki Dae <inki.dae@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
parent 420ae1e2
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
struct exynos_drm_dmabuf_attachment { struct exynos_drm_dmabuf_attachment {
struct sg_table sgt; struct sg_table sgt;
enum dma_data_direction dir; enum dma_data_direction dir;
bool is_mapped;
}; };
static int exynos_gem_attach_dma_buf(struct dma_buf *dmabuf, static int exynos_gem_attach_dma_buf(struct dma_buf *dmabuf,
...@@ -72,17 +73,10 @@ static struct sg_table * ...@@ -72,17 +73,10 @@ static struct sg_table *
DRM_DEBUG_PRIME("%s\n", __FILE__); DRM_DEBUG_PRIME("%s\n", __FILE__);
if (WARN_ON(dir == DMA_NONE))
return ERR_PTR(-EINVAL);
/* just return current sgt if already requested. */ /* just return current sgt if already requested. */
if (exynos_attach->dir == dir) if (exynos_attach->dir == dir && exynos_attach->is_mapped)
return &exynos_attach->sgt; return &exynos_attach->sgt;
/* reattaching is not allowed. */
if (WARN_ON(exynos_attach->dir != DMA_NONE))
return ERR_PTR(-EBUSY);
buf = gem_obj->buffer; buf = gem_obj->buffer;
if (!buf) { if (!buf) {
DRM_ERROR("buffer is null.\n"); DRM_ERROR("buffer is null.\n");
...@@ -107,14 +101,17 @@ static struct sg_table * ...@@ -107,14 +101,17 @@ static struct sg_table *
wr = sg_next(wr); wr = sg_next(wr);
} }
nents = dma_map_sg(attach->dev, sgt->sgl, sgt->orig_nents, dir); if (dir != DMA_NONE) {
if (!nents) { nents = dma_map_sg(attach->dev, sgt->sgl, sgt->orig_nents, dir);
DRM_ERROR("failed to map sgl with iommu.\n"); if (!nents) {
sg_free_table(sgt); DRM_ERROR("failed to map sgl with iommu.\n");
sgt = ERR_PTR(-EIO); sg_free_table(sgt);
goto err_unlock; sgt = ERR_PTR(-EIO);
goto err_unlock;
}
} }
exynos_attach->is_mapped = true;
exynos_attach->dir = dir; exynos_attach->dir = dir;
attach->priv = exynos_attach; attach->priv = exynos_attach;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment