diff mbox

[3/3] drm/exynos: clone new sgt instead of creating from pages

Message ID 1352284139-9497-3-git-send-email-prathyush.k@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Prathyush K Nov. 7, 2012, 10:28 a.m. UTC
During map_dma_buf, a new sgt needs to be created before being mapped to
another device's address space. Currently, this sgt is created from
the pages of the gem buffer everytime by calling dma_get_sgtable. This
will be time consuming if the map/unmap calls are done repeatedly for
very large buffers.

Instead, we can just clone the sgt which was already created during
buffer allocation and create the new sgt. This is done by calling
'sg_clone_table'. This will be much faster than creating from pages.

Signed-off-by: Prathyush K <prathyush.k@samsung.com>
---
 drivers/gpu/drm/exynos/exynos_drm_dmabuf.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

Comments

Inki Dae Nov. 7, 2012, 4:39 p.m. UTC | #1
2012/11/7 Prathyush K <prathyush.k@samsung.com>

> During map_dma_buf, a new sgt needs to be created before being mapped to
> another device's address space. Currently, this sgt is created from
> the pages of the gem buffer everytime by calling dma_get_sgtable. This
> will be time consuming if the map/unmap calls are done repeatedly for
> very large buffers.
>
> Instead, we can just clone the sgt which was already created during
> buffer allocation and create the new sgt. This is done by calling
> 'sg_clone_table'. This will be much faster than creating from pages.
>
> Signed-off-by: Prathyush K <prathyush.k@samsung.com>
> ---
>  drivers/gpu/drm/exynos/exynos_drm_dmabuf.c |   10 +++++++---
>  1 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
> b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
> index d9307bd..56efdd5 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
> @@ -40,10 +40,14 @@ static struct sg_table *exynos_get_sgt(struct
> drm_device *drm_dev,
>         if (!sgt)
>                 goto out;
>
> -       ret = dma_get_sgtable(drm_dev->dev, sgt, buf->kvaddr,
> -                               buf->dma_addr, buf->size);
> +       if (!buf->sgt) {
> +               DRM_ERROR("sgt is null.\n");
> +               goto err_free_sgt;
> +       }
> +
> +       ret = sg_clone_table(buf->sgt, sgt, GFP_KERNEL);
>

I think it's good idea but may need review enough. Let me sleep on it.

Thanks,
Inki Dae



>         if (ret < 0) {
> -               DRM_ERROR("failed to get sgtable.\n");
> +               DRM_ERROR("failed to clone sgtable.\n");
>                 goto err_free_sgt;
>         }
>
> --
> 1.7.0.4
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
index d9307bd..56efdd5 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
@@ -40,10 +40,14 @@  static struct sg_table *exynos_get_sgt(struct drm_device *drm_dev,
 	if (!sgt)
 		goto out;
 
-	ret = dma_get_sgtable(drm_dev->dev, sgt, buf->kvaddr,
-				buf->dma_addr, buf->size);
+	if (!buf->sgt) {
+		DRM_ERROR("sgt is null.\n");
+		goto err_free_sgt;
+	}
+
+	ret = sg_clone_table(buf->sgt, sgt, GFP_KERNEL);
 	if (ret < 0) {
-		DRM_ERROR("failed to get sgtable.\n");
+		DRM_ERROR("failed to clone sgtable.\n");
 		goto err_free_sgt;
 	}