From patchwork Fri Nov 9 08:24:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 1719581 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 AEB0FDF264 for ; Fri, 9 Nov 2012 08:24:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A567BA0B73 for ; Fri, 9 Nov 2012 00:24:22 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by gabe.freedesktop.org (Postfix) with ESMTP id 1AF65A0AE3 for ; Fri, 9 Nov 2012 00:24:11 -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 <0MD700KZ5ON0B4T0@mailout4.samsung.com> for dri-devel@lists.freedesktop.org; Fri, 09 Nov 2012 17:24:09 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.46]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 66.60.01231.9ADBC905; Fri, 09 Nov 2012 17:24:09 +0900 (KST) X-AuditID: cbfee61a-b7fa66d0000004cf-e8-509cbda9c9f6 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 95.60.01231.9ADBC905; Fri, 09 Nov 2012 17:24:09 +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 <0MD700I50OO4S0A0@mmp1.samsung.com> for dri-devel@lists.freedesktop.org; Fri, 09 Nov 2012 17:24:09 +0900 (KST) From: Inki Dae To: airlied@linux.ie, dri-devel@lists.freedesktop.org Subject: [PATCH] drm/exynos: add vm_ops to specific gem mmaper Date: Fri, 09 Nov 2012 17:24:03 +0900 Message-id: <1352449443-19300-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+NgFjrCLMWRmVeSWpSXmKPExsVy+t8zPd2Ve+cEGOz/JGZx5et7NgdGj/vd x5kCGKO4bFJSczLLUov07RK4Mr53N7EVHBaseLB/D3sD40W+LkZODgkBE4kVz+cwQ9hiEhfu rWfrYuTiEBJYxijx9+0HZpiiyyv2MUEkFjFKTFu0iBnCWc8ksXHDUkaQKjYBVYmJK+6zgdgi AqYSHZOWsoDYzAKFEgt7noLZwgJ2EncaL4HZLED156dfAKrn4OAVcJHoXpMLsUxBYsG9t2wQ JQIS3yYfYgEpkRCQldh0AGythMAONonDd+ZBHScpcXDFDZYJjIILGBlWMYqmFiQXFCel5xrq FSfmFpfmpesl5+duYoQEldQOxpUNFocYBTgYlXh4Ex/MDhBiTSwrrsw9xCjBwawkwrtnz5wA Id6UxMqq1KL8+KLSnNTiQ4w+QJdMZJYSTc4HBnxeSbyhsYGxoaGloZmppakBDmElcd5mj5QA IYH0xJLU7NTUgtQimHFMHJxSDYw1pcod726r63k/OlZzI3DmgZ+P65w6179fwFl/l33//ZnP NBLv3Tm5J9f9vKIph5TxJufzjt/nJEdU5nmUXJGaJdn7a+butOU31ILi/vz9fY+HbZ+ur7f5 bzYXNraw/4dYws/xVSkKHlAVkFov+8Jcc5ZC3cTD/06+/xOlbS1/3jU+x/zBlB4lluKMREMt 5qLiRACjjWUdVwIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrMLMWRmVeSWpSXmKPExsVy+t9jAd2Ve+cEGFy4KGhx5et7NgdGj/vd x5kCGKMaGG0yUhNTUosUUvOS81My89JtlbyD453jTc0MDHUNLS3MlRTyEnNTbZVcfAJ03TJz gMYqKZQl5pQChQISi4uV9O0wTQgNcdO1gGmM0PUNCYLrMTJAAwnrGDO+dzexFRwWrHiwfw97 A+NFvi5GTg4JAROJyyv2MUHYYhIX7q1n62Lk4hASWMQoMW3RImYIZz2TxMYNSxlBqtgEVCUm rrjPBmKLCJhKdExaygJiMwsUSizseQpmCwvYSdxpvARmswDVn59+Aaieg4NXwEWie00uxDIF iQX33rJNYORewMiwilE0tSC5oDgpPddQrzgxt7g0L10vOT93EyM4ZJ9J7WBc2WBxiFGAg1GJ hzfxwewAIdbEsuLK3EOMEhzMSiK8e/bMCRDiTUmsrEotyo8vKs1JLT7E6AO0fCKzlGhyPjCe 8kriDY1NzIwsjcyMTcyNjXEIK4nzNnukBAgJpCeWpGanphakFsGMY+LglGpgPLduclTTz5nL 93qKRt617zr/Y+/+rdzhDBGvXpq5RHlwdl/X275qfXzzCaXF4X+fKzzv3xijocowU7E7u+fW ooV8OzX5tizO3diRsKNigte22Y0WlsJ/mJ71X++wTzzuJGvB7TXzTuIRDYHjy3RaVH5tmvHw 1oZaE5sNgTHJL3PK1zWG/Pr9XYmlOCPRUIu5qDgRANgWmNaGAgAA 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 makes it takes a reference to gem object when specific gem mmap is requested. For this, it sets dev->driver->gem_vm_ops to vma->vm_ops. 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: Inki Dae Signed-off-by: Kyungmin Park --- drivers/gpu/drm/exynos/exynos_drm_gem.c | 20 +++++++++++++++++++- 1 files changed, 19 insertions(+), 1 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c index 50d73f1..b7ce8b6 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_gem.c +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c @@ -372,10 +372,13 @@ static int exynos_drm_gem_mmap_buffer(struct file *filp, struct exynos_drm_gem_obj *exynos_gem_obj = to_exynos_gem_obj(obj); struct exynos_drm_gem_buf *buffer; unsigned long vm_size; + int ret; DRM_DEBUG_KMS("%s\n", __FILE__); vma->vm_flags |= VM_IO | VM_DONTEXPAND | VM_DONTDUMP; + vma->vm_private_data = obj; + vma->vm_ops = obj->dev->driver->gem_vm_ops; update_vm_cache_attr(exynos_gem_obj, vma); @@ -391,9 +394,22 @@ static int exynos_drm_gem_mmap_buffer(struct file *filp, if (vm_size > buffer->size) return -EINVAL; - return dma_mmap_attrs(obj->dev->dev, vma, buffer->kvaddr, + ret = dma_mmap_attrs(obj->dev->dev, vma, buffer->kvaddr, buffer->dma_addr, buffer->size, &buffer->dma_attrs); + if (ret < 0) { + DRM_ERROR("failed to mmap.\n"); + return ret; + } + + /* + * take a reference to this mapping of the object. And this reference + * is unreferenced by the corresponding vm_close call. + */ + drm_gem_object_reference(obj); + drm_vm_open_locked(obj->dev, vma); + + return 0; } static const struct file_operations exynos_drm_gem_fops = { @@ -426,6 +442,8 @@ int exynos_drm_gem_mmap_ioctl(struct drm_device *dev, void *data, addr = vm_mmap(obj->filp, 0, args->size, PROT_READ | PROT_WRITE, MAP_SHARED, 0); + /* restore it to drm_file object. */ + obj->filp->private_data = file_priv; drm_gem_object_unreference_unlocked(obj); if (IS_ERR((void *)addr))