From patchwork Fri Nov 16 07:52:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathyush K X-Patchwork-Id: 1753641 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 117DDDF288 for ; Fri, 16 Nov 2012 08:53:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F15D2E5C7B for ; Fri, 16 Nov 2012 00:53: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 7FC89E5BF0 for ; Thu, 15 Nov 2012 23:30:44 -0800 (PST) Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MDK00GHKKUP53R0@mailout1.samsung.com> for dri-devel@lists.freedesktop.org; Fri, 16 Nov 2012 16:30:32 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.124]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 7F.22.01231.89BE5A05; Fri, 16 Nov 2012 16:30:32 +0900 (KST) X-AuditID: cbfee61a-b7fa66d0000004cf-9c-50a5eb988d45 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 4F.22.01231.89BE5A05; Fri, 16 Nov 2012 16:30:32 +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 <0MDK0082EKTCJ590@mmp2.samsung.com> for dri-devel@lists.freedesktop.org; Fri, 16 Nov 2012 16:30:32 +0900 (KST) From: Prathyush K To: dri-devel@lists.freedesktop.org Subject: [PATCH v2] drm/exynos: add exynos drm specific fb_mmap function Date: Fri, 16 Nov 2012 13:22:29 +0530 Message-id: <1353052349-17053-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+NgFjrMLMWRmVeSWpSXmKPExsWyRsSkRnfG66UBBhMXilpc+fqezYHR4373 caYAxigum5TUnMyy1CJ9uwSujN1HD7MUzBWo2HbxN3MD4xHeLkYODgkBE4ldO4FMTiBTTOLC vfVsXYxcHEICSxklHnY8Y4apOdwSDxGfzihx+t5jZghnNZPEkRWXGUG62QS0JX7NucsKYosI KEv8nbgKLM4sICFxpP0sG4gtLOAhsez7WrA4i4CqxIK3u5hAbF4Bd4mXEzewQFyhING67BA7 RI2AxLfJh1ggjpCV2HQAbK+EwB42iTfnmtgh6iUlDq64wTKBUXABI8MqRtHUguSC4qT0XEO9 4sTc4tK8dL3k/NxNjMCQOv3vmdQOxpUNFocYBTgYlXh4BW8vDRBiTSwrrsw9xCjBwawkwjv9 BVCINyWxsiq1KD++qDQntfgQow/QJROZpUST84HhnlcSb2hsYm5qbGppZGRmaopDWEmct9kj JUBIID2xJDU7NbUgtQhmHBMHp1QD4545TILbl5T1/Lsya3IWZ065cvSm+nv66qsfdkddmLq2 Ne7m6qbb5WFF/yfu3ly6vOKGU4318d31mR1fN855dy7js6KG0ps5Z8+//qSzZO4dD6ammHs3 nSVesam9SDSIay95ECjxK7jRNIi788MclowpojKZde2xVz32RNWl7xM5+1T6KIdZnRJLcUai oRZzUXEiAJM8HdRWAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrMLMWRmVeSWpSXmKPExsVy+t9jQd0Zr5cGGNxexmtx5et7NgdGj/vd x5kCGKMaGG0yUhNTUosUUvOS81My89JtlbyD453jTc0MDHUNLS3MlRTyEnNTbZVcfAJ03TJz gMYqKZQl5pQChQISi4uV9O0wTQgNcdO1gGmM0PUNCYLrMTJAAwlrGDN2Hz3MUjBXoGLbxd/M DYxHeLsYOTgkBEwkDrfEdzFyApliEhfurWfrYuTiEBKYzihx+t5jZghnNZPEkRWXGUGq2AS0 JX7NucsKYosIKEv8nbgKLM4sICFxpP0sG4gtLOAhsez7WrA4i4CqxIK3u5hAbF4Bd4mXEzew QGxTkGhddoh9AiP3AkaGVYyiqQXJBcVJ6bmGesWJucWleel6yfm5mxjBIftMagfjygaLQ4wC HIxKPLyCt5cGCLEmlhVX5h5ilOBgVhLhnf4CKMSbklhZlVqUH19UmpNafIjRB2j7RGYp0eR8 YDzllcQbGpuYmxqbWppYmJhZ4hBWEudt9kgJEBJITyxJzU5NLUgtghnHxMEp1cDIfMuvtjW1 6lW8R1lIbcTe00EuNf2Kh42l+di8z+dd/5UeetY4PrU47IjRpElsSmZNM5LUgn88qly5+0nX jub/fyaY6i1U2tARP+vjmc0v53heK+AqaOt+0W+Xe2f7useaV299sDnI68MQE64zq0OP9VzZ D8uyJw7v1eddmeOi1sdW1zpP8o0SS3FGoqEWc1FxIgDSW4NehgIAAA== X-CFilter-Loop: Reflected X-Mailman-Approved-At: Fri, 16 Nov 2012 00:46:26 -0800 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 adds a exynos drm specific implementation of fb_mmap. The root framebuffer is allocated using dma_alloc_attrs which can allocate a contig or noncontig buffer depending on whether an iommu is attached to drm device or not. The default fb_mmap function always assumes the root fb to be contiguous thus failing in case of a non-contig buffer. The exynos drm specific implementation of fb_mmap extracts the private data from the fb_info and calls dma_mmap_attrs with the parameters used while allocating the buffer. Signed-off-by: Prathyush K --- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 30 +++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c index 67eb6ba..62314ca 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c @@ -46,8 +46,38 @@ struct exynos_drm_fbdev { struct exynos_drm_gem_obj *exynos_gem_obj; }; +static int exynos_drm_fb_mmap(struct fb_info *info, + struct vm_area_struct *vma) +{ + struct drm_fb_helper *helper = info->par; + struct exynos_drm_fbdev *exynos_fbd = to_exynos_fbdev(helper); + struct exynos_drm_gem_obj *exynos_gem_obj = exynos_fbd->exynos_gem_obj; + struct exynos_drm_gem_buf *buffer = exynos_gem_obj->buffer; + unsigned long vm_size; + int ret; + + DRM_DEBUG_KMS("%s\n", __func__); + + vma->vm_flags |= VM_IO | VM_DONTEXPAND | VM_DONTDUMP; + + vm_size = vma->vm_end - vma->vm_start; + + if (vm_size > buffer->size) + return -EINVAL; + + ret = dma_mmap_attrs(helper->dev->dev, vma, buffer->kvaddr, + buffer->dma_addr, vm_size, &buffer->dma_attrs); + if (ret < 0) { + DRM_ERROR("failed to mmap.\n"); + return ret; + } + + return 0; +} + static struct fb_ops exynos_drm_fb_ops = { .owner = THIS_MODULE, + .fb_mmap = exynos_drm_fb_mmap, .fb_fillrect = cfb_fillrect, .fb_copyarea = cfb_copyarea, .fb_imageblit = cfb_imageblit,