From patchwork Mon Nov 19 08:25:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathyush K X-Patchwork-Id: 1763451 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 CD89FDFF38 for ; Mon, 19 Nov 2012 08:25:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 91612E6026 for ; Mon, 19 Nov 2012 00:25:19 -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 CB02EE6048 for ; Mon, 19 Nov 2012 00:03:24 -0800 (PST) Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MDQ00HDC6D3ZF90@mailout4.samsung.com> for dri-devel@lists.freedesktop.org; Mon, 19 Nov 2012 17:03:10 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.122]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id F2.08.12699.EB7E9A05; Mon, 19 Nov 2012 17:03:10 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-de-50a9e7bea05e Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id B2.08.12699.DB7E9A05; Mon, 19 Nov 2012 17:03:10 +0900 (KST) Received: from localhost.localdomain ([107.108.73.106]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MDQ00E0Y6BA8LB0@mmp1.samsung.com> for dri-devel@lists.freedesktop.org; Mon, 19 Nov 2012 17:03:09 +0900 (KST) From: Prathyush K To: dri-devel@lists.freedesktop.org Subject: [PATCH v3] drm/exynos: add exynos drm specific fb_mmap function Date: Mon, 19 Nov 2012 13:55:28 +0530 Message-id: <1353313528-21700-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+NgFjrELMWRmVeSWpSXmKPExsWyRsSkSnff85UBBtcXcVhc+fqezYHR4373 caYAxigum5TUnMyy1CJ9uwSujOW/HrEWPBOq2DBzJVsD40X+LkZODgkBE4lPc5qZIGwxiQv3 1rN1MXJxCAksZZSY8OsLM0zRxcULWCASixglZs/rY4dwVjNJzPh+hwWkik1AW+LXnLusILaI gLLE34mrGEFsZgEJiSPtZ9lAbGEBD4lbU2YDxTk4WARUJb5vzgUxeQXcJW59KoDYpSDRuuwQ O4jNIiAg8W3yIRaQEgkBWYlNB6DO2cImsfGgJoQtKXFwxQ2WCYyCCxgZVjGKphYkFxQnpeca 6RUn5haX5qXrJefnbmIEBtTpf8+kdzCuarA4xCjAwajEw+sxYWWAEGtiWXFl7iFGCQ5mJRHe lFlAId6UxMqq1KL8+KLSnNTiQ4w+QIdMZJYSTc4HBnteSbyhsYm5qbGppZGRmakpDmElcd5m j5QAIYH0xJLU7NTUgtQimHFMHJxSDYyzTE3N6nVuPI80vGVpd267ofR9r+2+00xOhujMfV+3 s9/kySTzgC0bpHalrPbkMeFhN5hyKH6t7r209GdvznQ+T1p8sP9g0p9nKdOeLZe4q7vT8cOU e283tN5rk5Q3XJ79KPmVtM3ab4lp839VHX/2Y8L9eyv0bade+1PIeujiT97w0hny9ck1SizF GYmGWsxFxYkAFHMtH1UCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrILMWRmVeSWpSXmKPExsVy+t9jAd19z1cGGOyzsLjy9T2bA6PH/e7j TAGMUQ2MNhmpiSmpRQqpecn5KZl56bZK3sHxzvGmZgaGuoaWFuZKCnmJuam2Si4+AbpumTlA U5UUyhJzSoFCAYnFxUr6dpgmhIa46VrANEbo+oYEwfUYGaCBhDWMGct/PWIteCZUsWHmSrYG xov8XYycHBICJhIXFy9ggbDFJC7cW8/WxcjFISSwiFFi9rw+dghnNZPEjO93wKrYBLQlfs25 ywpiiwgoS/yduIoRxGYWkJA40n6WDcQWFvCQuDVlNlCcg4NFQFXi++ZcEJNXwF3i1qcCiF0K Eq3LDrFPYORewMiwilE0tSC5oDgpPddIrzgxt7g0L10vOT93EyM4XJ9J72Bc1WBxiFGAg1GJ h9djwsoAIdbEsuLK3EOMEhzMSiK8KbOAQrwpiZVVqUX58UWlOanFhxh9gHZPZJYSTc4HxlJe SbyhsYm5qbGppYmFiZklDmElcd5mj5QAIYH0xJLU7NTUgtQimHFMHJxSDYxb/MpFim/UPm29 PO2i0RYeIYPeI6b2kvqcsT4PTh1aX6XF7/HOLe1P7uJFcqYXDzXc3+etmmyxfX1JPe+W+Tzz WNIUQ5WFTs+p1eVbn7yp9LbtM8fAar/IS6p1fH3hb9wsY6rVt7nqvTgnuO9hZdvhDo/l/b3+ 1dt+bv3u2njaprlb64ODhhJLcUaioRZzUXEiALdhZ32EAgAA 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 v3: Passing the actual buffer size instead of vm_size to dma_mmap_attrs. Changelog v2: Extracting the private data from fb_info structure to obtain the exynos gem buffer structure. Now, dma address is obtained from the exynos gem buffer structure and not from smem_start. Also calling dma_mmap_attrs (instead of dma_mmap_writecombine) with the same attributes used during allocation. Changelog v1: This patch adds a exynos drm specific implementation of fb_mmap which supports mapping a non-contiguous buffer to user space. This new function does not assume that the frame buffer is contiguous and calls dma_mmap_writecombine for mapping the buffer to user space. dma_mmap_writecombine will be able to map a contiguous buffer as well as non-contig buffer depending on whether an IOMMU mapping is created for drm or not. 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..a6f8cc2 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, buffer->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,