From patchwork Fri Jan 11 05:13:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 1963611 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id ADFD6DF2A2 for ; Fri, 11 Jan 2013 05:13:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 80291E6A2C for ; Thu, 10 Jan 2013 21:13:45 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by gabe.freedesktop.org (Postfix) with ESMTP id C21D0E69EA for ; Thu, 10 Jan 2013 21:13:30 -0800 (PST) Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MGG008YX3T4KD30@mailout1.samsung.com> for dri-devel@lists.freedesktop.org; Fri, 11 Jan 2013 14:13:29 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [203.254.230.45]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 3D.40.12699.97F9FE05; Fri, 11 Jan 2013 14:13:29 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-74-50ef9f79a20f Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id AC.40.12699.97F9FE05; Fri, 11 Jan 2013 14:13:29 +0900 (KST) Received: from daeinki-desktop.10.32.193.11 ([10.90.51.53]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MGG00DL63UHJ430@mmp1.samsung.com> for dri-devel@lists.freedesktop.org; Fri, 11 Jan 2013 14:13:29 +0900 (KST) From: Inki Dae To: airlied@linux.ie, dri-devel@lists.freedesktop.org Subject: [PATCH] drm/exynos: consider DMA_NONE flag to dmabuf import Date: Fri, 11 Jan 2013 14:13:29 +0900 Message-id: <1357881209-14971-1-git-send-email-inki.dae@samsung.com> X-Mailer: git-send-email 1.7.4.1 DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrKLMWRmVeSWpSXmKPExsVy+t8zXd3K+e8DDG4dN7e48vU9mwOjx/3u 40wBjFFcNimpOZllqUX6dglcGQsePWcsuC9UsfhlJ2sD4xL+LkZODgkBE4kLl+4wQdhiEhfu rWfrYuTiEBJYxijRvGYXM0zR9qfPmCASixgl7t08xQ7hrGeSeHNvEStIFZuAqsTEFffZQGwR AVOJjklLWUBsZoFCiYU9T8FsYQEXiW2/u8BqWIDqj+09CLaaFyg+ed1UVohtChIL7r2FqhGQ +Db5EFAvB1BcVmLTAWaQvRICW9gkzvybzQ5RLylxcMUNlgmMggsYGVYxiqYWJBcUJ6XnGukV J+YWl+al6yXn525ihISV9A7GVQ0WhxgFOBiVeHgrNd8HCLEmlhVX5h5ilOBgVhLhrakFCvGm JFZWpRblxxeV5qQWH2L0AbpkIrOUaHI+MOTzSuINjQ2MDQ0tDc1MLU0NcAgrifMynnoSICSQ nliSmp2aWpBaBDOOiYNTqoHRR+5czA1xa73fVZZHksVrr918cTks8dauerO3y1ZELP6sctbD ykj3yvz6vWVr6y5zfXhqcHlry0Weu5enzBMWt+FfqfA9afklCTXrK4dUlzyYvaJHIff600i7 9KimJ5IP+iT3RviZuhez2dz4qJKy5UV4x/mqHXtCbdITsi+d2mna/zKitLhNiaU4I9FQi7mo OBEAVNdoZFgCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrCLMWRmVeSWpSXmKPExsVy+t9jAd3K+e8DDG7NNrC48vU9mwOjx/3u 40wBjFENjDYZqYkpqUUKqXnJ+SmZeem2St7B8c7xpmYGhrqGlhbmSgp5ibmptkouPgG6bpk5 QGOVFMoSc0qBQgGJxcVK+naYJoSGuOlawDRG6PqGBMH1GBmggYR1jBkLHj1nLLgvVLH4ZSdr A+MS/i5GTg4JAROJ7U+fMUHYYhIX7q1n62Lk4hASWMQoce/mKXYIZz2TxJt7i1hBqtgEVCUm rrjPBmKLCJhKdExaygJiMwsUSizseQpmCwu4SGz73QVWwwJUf2zvQbANvEDxyeumskJsU5BY cO8t2wRG7gWMDKsYRVMLkguKk9JzjfSKE3OLS/PS9ZLzczcxgoP2mfQOxlUNFocYBTgYlXh4 KzXfBwixJpYVV+YeYpTgYFYS4a2pBQrxpiRWVqUW5ccXleakFh9i9AHaPpFZSjQ5HxhReSXx hsYmZkaWRmbGJubGxjiElcR5GU89CRASSE8sSc1OTS1ILYIZx8TBKdXAaOLiaDXDbnaUd4Se Qv3CZVs+zfuvdjes0erZ/oLPSytCP9Zub3T561HRd0Lma+lxaxueAOs/h96eqcmtyrczivmd ONvTvP7YoaXvNz+esOyU1f5d9hlee8xjzk4pOrNP2KCrz+Xh57km/8In8T/lnF2383CL76oI ocXpf9RDvz+QWb1QZ+I0RyWW4oxEQy3mouJEADAyT+CHAgAA X-CFilter-Loop: Reflected Cc: kyungmin.park@samsung.com, sw0312.kim@samsung.com 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 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 mechanism. 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: Inki Dae Signed-off-by: Kyungmin Park --- drivers/gpu/drm/exynos/exynos_drm_dmabuf.c | 25 +++++++++++-------------- 1 files changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c index 693d4bc..ba0a3aa 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c @@ -19,6 +19,7 @@ struct exynos_drm_dmabuf_attachment { struct sg_table sgt; enum dma_data_direction dir; + bool is_mapped; }; static int exynos_gem_attach_dma_buf(struct dma_buf *dmabuf, @@ -72,17 +73,10 @@ static struct sg_table * DRM_DEBUG_PRIME("%s\n", __FILE__); - if (WARN_ON(dir == DMA_NONE)) - return ERR_PTR(-EINVAL); - /* 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; - /* reattaching is not allowed. */ - if (WARN_ON(exynos_attach->dir != DMA_NONE)) - return ERR_PTR(-EBUSY); - buf = gem_obj->buffer; if (!buf) { DRM_ERROR("buffer is null.\n"); @@ -107,14 +101,17 @@ static struct sg_table * wr = sg_next(wr); } - nents = dma_map_sg(attach->dev, sgt->sgl, sgt->orig_nents, dir); - if (!nents) { - DRM_ERROR("failed to map sgl with iommu.\n"); - sg_free_table(sgt); - sgt = ERR_PTR(-EIO); - goto err_unlock; + if (dir != DMA_NONE) { + nents = dma_map_sg(attach->dev, sgt->sgl, sgt->orig_nents, dir); + if (!nents) { + DRM_ERROR("failed to map sgl with iommu.\n"); + sg_free_table(sgt); + sgt = ERR_PTR(-EIO); + goto err_unlock; + } } + exynos_attach->is_mapped = true; exynos_attach->dir = dir; attach->priv = exynos_attach;