From patchwork Fri Dec 21 08:59:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 1902491 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 A7350DF25A for ; Fri, 21 Dec 2012 08:59:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A0C62E60F7 for ; Fri, 21 Dec 2012 00:59:48 -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 6FE09E601F for ; Fri, 21 Dec 2012 00:59:35 -0800 (PST) Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MFD0033KIAUNK50@mailout3.samsung.com> for dri-devel@lists.freedesktop.org; Fri, 21 Dec 2012 17:59:21 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.44]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 95.34.01231.9E424D05; Fri, 21 Dec 2012 17:59:21 +0900 (KST) X-AuditID: cbfee61a-b7fa66d0000004cf-96-50d424e97a9c Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 55.34.01231.9E424D05; Fri, 21 Dec 2012 17:59:21 +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 <0MFD002YBIAX2630@mmp1.samsung.com> for dri-devel@lists.freedesktop.org; Fri, 21 Dec 2012 17:59:21 +0900 (KST) From: Inki Dae To: airlied@linux.ie, dri-devel@lists.freedesktop.org Subject: [PATCH v2] drm/exynos: consider no iommu support to console framebuffer Date: Fri, 21 Dec 2012 17:59:20 +0900 Message-id: <1356080360-9975-1-git-send-email-inki.dae@samsung.com> X-Mailer: git-send-email 1.7.4.1 In-reply-to: <1356079479-21478-1-git-send-email-inki.dae@samsung.com> References: <1356079479-21478-1-git-send-email-inki.dae@samsung.com> DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrLLMWRmVeSWpSXmKPExsVy+t8zHd2XKlcCDDrei1lc+fqezYHR4373 caYAxigum5TUnMyy1CJ9uwSujJ4Zs9gKFohWbPrcydLA+ECwi5GTQ0LAROLmup/MELaYxIV7 69m6GLk4hASWMUosvPKVEabo/5anTBCJRYwSZ17MY4Vw1jNJNB37D1bFJqAqMXHFfTYQW0TA VKJj0lIWEJtZwE5i14N+dhBbWCBAYtOke0wgNgtQ/acLh8DivALOEqdm3GKD2KYgseDeWzCb U8BVoqenGWy+kICLxONZRxkhegUkvk0+BDSfA6heVmLTAWaQeyQELrNJPLx7ihVijqTEwRU3 WCYwCi9gZFjFKJpakFxQnJSea6hXnJhbXJqXrpecn7uJERKGUjsYVzZYHGIU4GBU4uFlNLsc IMSaWFZcmXuIUYKDWUmEl+krUIg3JbGyKrUoP76oNCe1+BCjD9AlE5mlRJPzgTGSVxJvaGxg bGhoaWhmamlqgENYSZy32SMlQEggPbEkNTs1tSC1CGYcEwenVAOj1fJVQs/j/h4wiDuofn9W ucOO5QWblJ62bY3cmLrkTBDrOuONn4Ln/uw7OPk348pIGb3Zh13FPy5dsHX1FvuDhZb6d/tn +Ke8UWeQyuS4FKgjq36sJ/T4fKE75WrreX65eioVzZVefu/lhotHeNtzxDOWbFeYYMvNqLwo vm/Rs2m1nBaPpXf/V2Ipzkg01GIuKk4EAK0RTlNwAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuphkeLIzCtJLcpLzFFi42I5/e+xgO5LlSsBBgf/Clpc+fqezYHR4373 caYAxqgGRpuM1MSU1CKF1Lzk/JTMvHRbJe/geOd4UzMDQ11DSwtzJYW8xNxUWyUXnwBdt8wc oLFKCmWJOaVAoYDE4mIlfTtME0JD3HQtYBojdH1DguB6jAzQQMI6xoyeGbPYChaIVmz63MnS wPhAsIuRk0NCwETi/5anTBC2mMSFe+vZuhi5OIQEFjFKnHkxjxXCWc8k0XTsPyNIFZuAqsTE FffZQGwRAVOJjklLWUBsZgE7iV0P+tlBbGGBAIlNk+6BTWUBqv904RBYnFfAWeLUjFtsENsU JBbcewtmcwq4SvT0NIPNFxJwkXg86yjjBEbeBYwMqxhFUwuSC4qT0nMN9YoTc4tL89L1kvNz NzGCg/yZ1A7GlQ0WhxgFOBiVeHgZzS4HCLEmlhVX5h5ilOBgVhLhZfoKFOJNSaysSi3Kjy8q zUktPsToA3TVRGYp0eR8YATmlcQbGpuYGVkamRmbmBsb4xBWEudt9kgJEBJITyxJzU5NLUgt ghnHxMEp1cBoeusB+xz7729vmWWtYz2wJUo7yo37o3bVnK0OWfH+H+d4Xn6cI2x8MXiW9GyL MuZrclnTGrrP7fw5VVrSou1yV6PtzbPdB0pmPPssH3m7pLNN+u+U3Z7yeR+L4zilnS+V/zkX k7o17XXH37Lew54n1rjOXch4kXHbs9286urLJdJf/zygwWCqxFKckWioxVxUnAgAWIhkjZ8C AAA= X-CFilter-Loop: Reflected Cc: kyungmin.park@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 no iommu support to kernel space mapping of console framebuffer. Without iommu, we get physical address instead of device address after dma_alloc_attrs function is called. So we should consider the case without iommu when it maps console framebuffer with kernel space. Changelog v2: - calll vunmap function only with iommu support. Signed-off-by: Inki Dae Signed-off-by: Kyungmin Park --- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 22 ++++++++++++++++++---- 1 files changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c index f433eb7..eae064a 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c @@ -34,6 +34,7 @@ #include "exynos_drm_drv.h" #include "exynos_drm_fb.h" #include "exynos_drm_gem.h" +#include "exynos_drm_iommu.h" #define MAX_CONNECTOR 4 #define PREFERRED_BPP 32 @@ -111,9 +112,18 @@ static int exynos_drm_fbdev_update(struct drm_fb_helper *helper, /* map pages with kernel virtual space. */ if (!buffer->kvaddr) { - unsigned int nr_pages = buffer->size >> PAGE_SHIFT; - buffer->kvaddr = vmap(buffer->pages, nr_pages, VM_MAP, + if (is_drm_iommu_supported(dev)) { + unsigned int nr_pages = buffer->size >> PAGE_SHIFT; + + buffer->kvaddr = vmap(buffer->pages, nr_pages, VM_MAP, pgprot_writecombine(PAGE_KERNEL)); + } else { + phys_addr_t dma_addr = buffer->dma_addr; + if (dma_addr) + buffer->kvaddr = phys_to_virt(dma_addr); + else + buffer->kvaddr = (void __iomem *)NULL; + } if (!buffer->kvaddr) { DRM_ERROR("failed to map pages to kernel space.\n"); return -EIO; @@ -128,8 +138,12 @@ static int exynos_drm_fbdev_update(struct drm_fb_helper *helper, dev->mode_config.fb_base = (resource_size_t)buffer->dma_addr; fbi->screen_base = buffer->kvaddr + offset; - fbi->fix.smem_start = (unsigned long) + if (is_drm_iommu_supported(dev)) + fbi->fix.smem_start = (unsigned long) (page_to_phys(sg_page(buffer->sgt->sgl)) + offset); + else + fbi->fix.smem_start = (unsigned long)buffer->dma_addr; + fbi->screen_size = size; fbi->fix.smem_len = size; @@ -320,7 +334,7 @@ static void exynos_drm_fbdev_destroy(struct drm_device *dev, struct exynos_drm_gem_obj *exynos_gem_obj = exynos_fbd->exynos_gem_obj; struct drm_framebuffer *fb; - if (exynos_gem_obj->buffer->kvaddr) + if (is_drm_iommu_supported(dev) && exynos_gem_obj->buffer->kvaddr) vunmap(exynos_gem_obj->buffer->kvaddr); /* release drm framebuffer and real buffer */