From patchwork Tue Oct 13 07:00:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonyoung Shim X-Patchwork-Id: 7381561 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 196F4BFD59 for ; Tue, 13 Oct 2015 07:01:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 089AD206CD for ; Tue, 13 Oct 2015 07:01:05 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 8D24020719 for ; Tue, 13 Oct 2015 07:01:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D2EEA6E8DB; Tue, 13 Oct 2015 00:00:59 -0700 (PDT) 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 ESMTPS id 03B796E58A for ; Tue, 13 Oct 2015 00:00:58 -0700 (PDT) Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NW500SEVCTJ1970@mailout1.samsung.com> for dri-devel@lists.freedesktop.org; Tue, 13 Oct 2015 16:00:55 +0900 (KST) Received: from epcpsbgm1new.samsung.com ( [172.20.52.114]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 08.F8.05284.72CAC165; Tue, 13 Oct 2015 16:00:55 +0900 (KST) X-AuditID: cbfee68f-f796f6d0000014a4-e9-561cac27a710 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id B4.AE.23663.62CAC165; Tue, 13 Oct 2015 16:00:55 +0900 (KST) Received: from localhost.localdomain ([10.252.81.123]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NW500D04CTI4DN1@mmp2.samsung.com>; Tue, 13 Oct 2015 16:00:54 +0900 (KST) From: Joonyoung Shim To: dri-devel@lists.freedesktop.org Subject: [PATCH 7/9] drm/exynos: always use EXYNOS_BO_CONTIG flag on iommu Date: Tue, 13 Oct 2015 16:00:52 +0900 Message-id: <1444719654-10639-8-git-send-email-jy0922.shim@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1444719654-10639-1-git-send-email-jy0922.shim@samsung.com> References: <1444719654-10639-1-git-send-email-jy0922.shim@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrLLMWRmVeSWpSXmKPExsWyRsSkSFd9jUyYwecVXBZXvr5ns5h0fwKL xYt7F1ksZkx+yebA4nG/+ziTR9+WVYwBTFFcNimpOZllqUX6dglcGdfub2ApeGFS8XxCbQPj Je0uRk4OCQETia0r3zBC2GISF+6tZwOxhQRWMEq8uWQAU/Pj62PWLkYuoPgsRonH71cxQzg/ GCUm/2ljAqliE9CTuLPtOJgtIqAs8XfiKrCpzAKeEitWzQOLCwt4STw4shQsziKgKtH97gSY zSvgLvFt80o2iG1yEiePTWYFsTkFPCSeHtwKdZG7xImjXWBXSAi8ZpOYe+0NG8QgAYlvkw+x dDFyACVkJTYdYIaYIylxcMUNlgmMwgsYGVYxiqYWJBcUJ6UXGesVJ+YWl+al6yXn525iBIbq 6X/P+ncw3j1gfYhRgINRiYf3RaRMmBBrYllxZe4hRlOgDROZpUST84ERkVcSb2hsZmRhamJq bGRuaaYkzrtQ6mewkEB6YklqdmpqQWpRfFFpTmrxIUYmDk6pBkbD74sFuSc1fa/zK0gS2LC6 cfJsRY7QjCdnWqTDD8y8mc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X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It doesn't care whether memory is continuous physically if iommu is supported but we will always use EXYNOS_BO_CONTIG flag on iommu, so it can mean that the memory is continuous memory for device. Signed-off-by: Joonyoung Shim --- drivers/gpu/drm/exynos/exynos_drm_fb.c | 32 ++++--------------------------- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 14 +------------- drivers/gpu/drm/exynos/exynos_drm_gem.c | 31 ++++++++++++++---------------- drivers/gpu/drm/exynos/exynos_drm_gem.h | 2 -- include/uapi/drm/exynos_drm.h | 5 ++++- 5 files changed, 23 insertions(+), 61 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_fb.c b/drivers/gpu/drm/exynos/exynos_drm_fb.c index fcea28bdbc42..8fbae903c7ed 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fb.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fb.c @@ -39,32 +39,6 @@ struct exynos_drm_fb { struct exynos_drm_gem *exynos_gem[MAX_FB_BUFFER]; }; -static int check_fb_gem_memory_type(struct drm_device *drm_dev, - struct exynos_drm_gem *exynos_gem) -{ - unsigned int flags; - - /* - * if exynos drm driver supports iommu then framebuffer can use - * all the buffer types. - */ - if (is_drm_iommu_supported(drm_dev)) - return 0; - - flags = exynos_gem->flags; - - /* - * without iommu support, not support physically non-continuous memory - * for framebuffer. - */ - if (IS_NONCONTIG_BUFFER(flags)) { - DRM_ERROR("cannot use this gem memory type for fb.\n"); - return -EINVAL; - } - - return 0; -} - static void exynos_drm_fb_destroy(struct drm_framebuffer *fb) { struct exynos_drm_fb *exynos_fb = to_exynos_fb(fb); @@ -130,9 +104,11 @@ exynos_drm_framebuffer_init(struct drm_device *dev, return ERR_PTR(-ENOMEM); for (i = 0; i < count; i++) { - ret = check_fb_gem_memory_type(dev, exynos_gem[i]); - if (ret < 0) + /* Not support physically non-continuous memory for FB */ + if (exynos_gem[i]->flags & EXYNOS_BO_NONCONTIG) { + ret = -EINVAL; goto err; + } exynos_fb->exynos_gem[i] = exynos_gem[i]; } diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c index f6118baa8e3e..fcbe43a580c1 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c @@ -124,7 +124,6 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper, struct exynos_drm_gem *exynos_gem; struct drm_device *dev = helper->dev; struct drm_mode_fb_cmd2 mode_cmd = { 0 }; - struct platform_device *pdev = dev->platformdev; unsigned long size; int ret; @@ -142,18 +141,7 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper, size = mode_cmd.pitches[0] * mode_cmd.height; - exynos_gem = exynos_drm_gem_create(dev, EXYNOS_BO_CONTIG, size); - /* - * If physically contiguous memory allocation fails and if IOMMU is - * supported then try to get buffer from non physically contiguous - * memory area. - */ - if (IS_ERR(exynos_gem) && is_drm_iommu_supported(dev)) { - dev_warn(&pdev->dev, "contiguous FB allocation failed, falling back to non-contiguous\n"); - exynos_gem = exynos_drm_gem_create(dev, EXYNOS_BO_NONCONTIG, - size); - } - + exynos_gem = exynos_drm_gem_create(dev, 0, size); if (IS_ERR(exynos_gem)) { ret = PTR_ERR(exynos_gem); goto out; diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c index 163d113df1ab..96a69468283b 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_gem.c +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c @@ -135,6 +135,8 @@ static int exynos_drm_alloc_buf(struct exynos_drm_gem *exynos_gem) if (!is_drm_iommu_supported(dev)) { if (!(exynos_gem->flags & EXYNOS_BO_NONCONTIG)) return exynos_drm_alloc_dma(exynos_gem); + } else { + exynos_gem->flags &= ~EXYNOS_BO_NONCONTIG; } ret = exynos_drm_get_pages(exynos_gem); @@ -440,10 +442,7 @@ int exynos_drm_gem_dumb_create(struct drm_file *file_priv, args->pitch = args->width * ((args->bpp + 7) / 8); args->size = args->pitch * args->height; - if (is_drm_iommu_supported(dev)) - flags = EXYNOS_BO_NONCONTIG | EXYNOS_BO_WC; - else - flags = EXYNOS_BO_CONTIG | EXYNOS_BO_WC; + flags = EXYNOS_BO_WC; exynos_gem = exynos_drm_gem_create(dev, flags, args->size); if (IS_ERR(exynos_gem)) { @@ -597,6 +596,17 @@ exynos_drm_gem_prime_import_sg_table(struct drm_device *dev, exynos_gem->dma_addr = sg_dma_address(sgt->sgl); + /* + * Always physically continuous memory if sgt->nents is 1. It + * doesn't care if IOMMU is supported but EXYNOS_BO_NONCONTIG + * flag will be cleared. It will mean the memory is continuous + * for device. EXYNOS_BO_NONCONTIG flag will be set if not both. + */ + if (sgt->nents == 1 || is_drm_iommu_supported(dev)) + exynos_gem->flags &= ~EXYNOS_BO_NONCONTIG; + else + exynos_gem->flags |= EXYNOS_BO_NONCONTIG; + npages = exynos_gem->size >> PAGE_SHIFT; exynos_gem->pages = drm_malloc_ab(npages, sizeof(struct page *)); if (!exynos_gem->pages) { @@ -611,19 +621,6 @@ exynos_drm_gem_prime_import_sg_table(struct drm_device *dev, exynos_gem->sgt = sgt; - if (sgt->nents == 1) { - /* always physically continuous memory if sgt->nents is 1. */ - exynos_gem->flags |= EXYNOS_BO_CONTIG; - } else { - /* - * this case could be CONTIG or NONCONTIG type but for now - * sets NONCONTIG. - * TODO. we have to find a way that exporter can notify - * the type of its own buffer to importer. - */ - exynos_gem->flags |= EXYNOS_BO_NONCONTIG; - } - return &exynos_gem->base; err_free_large: diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.h b/drivers/gpu/drm/exynos/exynos_drm_gem.h index f47daec776e6..e9eb5631f322 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_gem.h +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.h @@ -16,8 +16,6 @@ #define to_exynos_gem(x) container_of(x, struct exynos_drm_gem, base) -#define IS_NONCONTIG_BUFFER(f) (f & EXYNOS_BO_NONCONTIG) - /* * exynos drm buffer structure. * diff --git a/include/uapi/drm/exynos_drm.h b/include/uapi/drm/exynos_drm.h index 18f0601f84d1..1d7c80734e43 100644 --- a/include/uapi/drm/exynos_drm.h +++ b/include/uapi/drm/exynos_drm.h @@ -76,7 +76,10 @@ struct drm_exynos_vidi_connection { /* memory type definitions. */ enum e_drm_exynos_gem_mem_type { - /* Physically Continuous memory and used as default. */ + /* + * Physically Continuous memory or Continuous memory for device + * on IOMMU. Used as default. + */ EXYNOS_BO_CONTIG = 0 << 0, /* Physically Non-Continuous memory. */ EXYNOS_BO_NONCONTIG = 1 << 0,