From patchwork Mon Dec 3 07:00:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathyush K X-Patchwork-Id: 1832121 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 2E04B3FCA5 for ; Mon, 3 Dec 2012 06:37:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6E6A6E5F20 for ; Sun, 2 Dec 2012 22:37:58 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by gabe.freedesktop.org (Postfix) with ESMTP id 8B568E5CC5 for ; Sun, 2 Dec 2012 22:37:45 -0800 (PST) Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MEF001MHZQOKPK0@mailout3.samsung.com> for dri-devel@lists.freedesktop.org; Mon, 03 Dec 2012 15:37:43 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.124]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id B6.DF.12699.6B84CB05; Mon, 03 Dec 2012 15:37:42 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-b2-50bc48b63e20 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id C5.DF.12699.6B84CB05; Mon, 03 Dec 2012 15:37:42 +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 <0MEF00KC5ZQP7C70@mmp2.samsung.com> for dri-devel@lists.freedesktop.org; Mon, 03 Dec 2012 15:37:42 +0900 (KST) From: Prathyush K To: dri-devel@lists.freedesktop.org Subject: [PATCH v2] drm/exynos: create new sgt from existing sgt Date: Mon, 03 Dec 2012 12:30:44 +0530 Message-id: <1354518044-31990-1-git-send-email-prathyush.k@samsung.com> X-Mailer: git-send-email 1.7.0.4 DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrMLMWRmVeSWpSXmKPExsWyRsSkRnebx54Ag/OTLCyufH3P5sDocb/7 OFMAYxSXTUpqTmZZapG+XQJXRtv5WSwFt/kr7k1oY21g/MjTxcjJISFgItH04xo7hC0mceHe erYuRi4OIYGljBKL5lxl7GLkACvafLYCpEZIYDqjxNo98hA1q5kketa1MYEk2AS0JX7NucsK YosIKEv8nbiKEcRmFpCQONJ+lg3EFhZwkDgwawKYzSKgKnFvy0cWEJtXwF3i0tqLzBBHKEi0 LjvEDlEjIPFt8iEWiBtkJTYdYAbZKyGwh03i3ezLrBD1khIHV9xgmcAouICRYRWjaGpBckFx UnqukV5xYm5xaV66XnJ+7iZGYEid/vdMegfjqgaLQ4wCHIxKPLwPv+wOEGJNLCuuzD3EKMHB rCTCG2W9J0CINyWxsiq1KD++qDQntfgQow/QJROZpUST84HhnlcSb2hsYm5qbGppZGRmaopD WEmct9kjJUBIID2xJDU7NbUgtQhmHBMHp1QDo8XJMy8e8hicZV34X3Qq16slzPrRNhy65izS fx7xpFiezWS84S+QYHVDeHHVn1kVDc/Pm+T2ehZ90TFccElFfxFfb/av+8VZuuqnL75YEZGs 5fb0tNh9XqYre0+mlUc2Xruz8mabIQfDXQWH/tOTp55IPD9d5+kNUSvW2NMbHHc7SXskVD+O UWIpzkg01GIuKk4EABcq+whWAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrELMWRmVeSWpSXmKPExsVy+t9jQd1tHnsCDHoPaVpc+fqezYHR4373 caYAxqgGRpuM1MSU1CKF1Lzk/JTMvHRbJe/geOd4UzMDQ11DSwtzJYW8xNxUWyUXnwBdt8wc oLFKCmWJOaVAoYDE4mIlfTtME0JD3HQtYBojdH1DguB6jAzQQMIaxoy287NYCm7zV9yb0Mba wPiRp4uRg0NCwERi89mKLkZOIFNM4sK99WwgtpDAdEaJtXvkuxi5gOzVTBI969qYQBJsAtoS v+bcZQWxRQSUJf5OXMUIYjMLSEgcaT8L1iws4CBxYNYEMJtFQFXi3paPLCA2r4C7xKW1F5kh lilItC47xD6BkXsBI8MqRtHUguSC4qT0XCO94sTc4tK8dL3k/NxNjOCAfSa9g3FVg8UhRgEO RiUe3odfdgcIsSaWFVfmHmKU4GBWEuGNst4TIMSbklhZlVqUH19UmpNafIjRB2j7RGYp0eR8 YDTllcQbGpuYmxqbWppYmJhZ4hBWEudt9kgJEBJITyxJzU5NLUgtghnHxMEp1cAY9bau5PQ5 R9dTGhFJkXFb7qYnX5VYcVbNsPbmDuZfVTbX3Mr9XhrPN+kO1o8QiT5bVPrqvb/l5Qq3Wket WUZX3V53Lp9+N0spQI6v4tPVTKfWb4f+BYcumP7rpsuUVdx++gZa7j2KlZxvD1oFnXR69fu6 +HStSJt2qVTBH7E6Ox9mzl2WME2JpTgj0VCLuag4EQDFB7KOhQIAAA== X-CFilter-Loop: Reflected X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Changelog v2: Implement copy sgt code in exynos_get_sgt itself instead of calling sg_clone_table. Changelog v1: 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 by calling dma_get_sgtable which creates a sgt from pages. This will be time consuming if the map/unmap calls are done repeatedly for very large buffers. Instead, we can just use the sgt which was already created during buffer allocation and create the new sgt by copying the sgls from the existing sgt. And this patch is based on exynos-drm-next-iommu branch of git://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos Signed-off-by: Prathyush K --- drivers/gpu/drm/exynos/exynos_drm_dmabuf.c | 18 +++++++++++++++--- 1 files changed, 15 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..91c7db1 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c @@ -34,19 +34,31 @@ static struct sg_table *exynos_get_sgt(struct drm_device *drm_dev, struct exynos_drm_gem_buf *buf) { struct sg_table *sgt = NULL; + struct scatterlist *s, *s_out; + unsigned int i; int ret; + if (!buf->sgt) { + DRM_ERROR("no sg table.\n"); + goto out; + } + sgt = kzalloc(sizeof(*sgt), GFP_KERNEL); if (!sgt) goto out; - ret = dma_get_sgtable(drm_dev->dev, sgt, buf->kvaddr, - buf->dma_addr, buf->size); + ret = sg_alloc_table(sgt, buf->sgt->orig_nents, GFP_KERNEL); if (ret < 0) { - DRM_ERROR("failed to get sgtable.\n"); + DRM_ERROR("failed to alloc table\n"); goto err_free_sgt; } + s_out = sgt->sgl; + for_each_sg(buf->sgt->sgl, s, buf->sgt->orig_nents, i) { + sg_set_page(s_out, sg_page(s), s->length, s->offset); + s_out = sg_next(s_out); + } + return sgt; err_free_sgt: