<div class="gmail_quote">2012/12/3 Prathyush K <span dir="ltr"><<a href="mailto:prathyush.k@samsung.com" target="_blank">prathyush.k@samsung.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Changelog v2:<br>
<br>
Implement copy sgt code in exynos_get_sgt itself instead of calling<br>
sg_clone_table.<br>
<br></blockquote><div><br>Now we are working on dmabuf feature update that adds attach and detach callbacks and with this patch, exynos_get_sgt function will be removed.<br>For this, please refer to the below link,<br>        <a href="http://git.kernel.org/?p=linux/kernel/git/daeinki/drm-exynos.git;a=commit;h=a9626efd74cb9133d31f4f42e16a59d3e2cfb03e">http://git.kernel.org/?p=linux/kernel/git/daeinki/drm-exynos.git;a=commit;h=a9626efd74cb9133d31f4f42e16a59d3e2cfb03e</a><br>
<br>And this patch would resolve the performance deterioration to v4l2's streaming service.<br>The performance issue are induced when v4l2's qbuf and dqbuf are called repeatedly with gem buffer imported.(dmabuf fd -> vb2 buffer)<br>
So unmapping would be done by dma_buf_detach instead of dma_buf_unmap_attachment.<br>For this, we are testing it and if works fine then this patch will be posted.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Changelog v1:<br>
<br>
During map_dma_buf, a new sgt needs to be created before being mapped to<br>
another device's address space. Currently, this sgt is created by calling<br>
dma_get_sgtable which creates a sgt from pages. This will be time consuming<br>
if the map/unmap calls are done repeatedly for very large buffers.<br>
<br>
Instead, we can just use the sgt which was already created during<br>
buffer allocation and create the new sgt by copying the sgls from the<br>
existing sgt.<br>
<br>
And this patch is based on exynos-drm-next-iommu branch of<br>
git://<a href="http://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos" target="_blank">git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos</a><br>
<br>
Signed-off-by: Prathyush K <<a href="mailto:prathyush.k@samsung.com">prathyush.k@samsung.com</a>><br>
---<br>
 drivers/gpu/drm/exynos/exynos_drm_dmabuf.c |   18 +++++++++++++++---<br>
 1 files changed, 15 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c<br>
index d9307bd..91c7db1 100644<br>
--- a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c<br>
+++ b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c<br>
@@ -34,19 +34,31 @@ static struct sg_table *exynos_get_sgt(struct drm_device *drm_dev,<br>
                                        struct exynos_drm_gem_buf *buf)<br>
 {<br>
        struct sg_table *sgt = NULL;<br>
+       struct scatterlist *s, *s_out;<br>
+       unsigned int i;<br>
        int ret;<br>
<br>
+       if (!buf->sgt) {<br>
+               DRM_ERROR("no sg table.\n");<br>
+               goto out;<br>
+       }<br>
+<br>
        sgt = kzalloc(sizeof(*sgt), GFP_KERNEL);<br>
        if (!sgt)<br>
                goto out;<br>
<br>
-       ret = dma_get_sgtable(drm_dev->dev, sgt, buf->kvaddr,<br>
-                               buf->dma_addr, buf->size);<br>
+       ret = sg_alloc_table(sgt, buf->sgt->orig_nents, GFP_KERNEL);<br>
        if (ret < 0) {<br>
-               DRM_ERROR("failed to get sgtable.\n");<br>
+               DRM_ERROR("failed to alloc table\n");<br>
                goto err_free_sgt;<br>
        }<br>
<br>
+       s_out = sgt->sgl;<br>
+       for_each_sg(buf->sgt->sgl, s, buf->sgt->orig_nents, i) {<br>
+               sg_set_page(s_out, sg_page(s), s->length, s->offset);<br>
+               s_out = sg_next(s_out);<br>
+       }<br>
+<br>
        return sgt;<br>
<br>
 err_free_sgt:<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.0.4<br>
<br>
_______________________________________________<br>
dri-devel mailing list<br>
<a href="mailto:dri-devel@lists.freedesktop.org">dri-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/dri-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/dri-devel</a><br>
</font></span></blockquote></div><br>