From: Prathyush K Subject: [PATCH 3/3] drm/exynos: clone new sgt instead of creating from pages Date: Wed, 07 Nov 2012 15:58:59 +0530 Message-ID: <1352284139-9497-3-git-send-email-prathyush.k@samsung.com> References: <1352284139-9497-1-git-send-email-prathyush.k@samsung.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by gabe.freedesktop.org (Postfix) with ESMTP id 8DEDC9E787 for ; Wed, 7 Nov 2012 02:09:57 -0800 (PST) Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MD40085A48FYEY0@mailout4.samsung.com> for dri-devel@lists.freedesktop.org; Wed, 07 Nov 2012 19:09:56 +0900 (KST) Received: from localhost.localdomain ([107.108.73.106]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MD4004XW45KF180@mmp2.samsung.com> for dri-devel@lists.freedesktop.org; Wed, 07 Nov 2012 19:09:56 +0900 (KST) In-reply-to: <1352284139-9497-1-git-send-email-prathyush.k@samsung.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org 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 --- 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); 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