All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joonyoung Shim <jy0922.shim@samsung.com>
To: dri-devel@lists.freedesktop.org
Cc: sw0312.kim@samsung.com
Subject: [PATCH 8/9] drm/exynos: use DMA_ERROR_CODE
Date: Tue, 13 Oct 2015 16:00:53 +0900	[thread overview]
Message-ID: <1444719654-10639-9-git-send-email-jy0922.shim@samsung.com> (raw)
In-Reply-To: <1444719654-10639-1-git-send-email-jy0922.shim@samsung.com>

The dma_addr of gem will be DMA_ERROR_CODE if gem is created and
will keep DMA_ERROR_CODE if gem has EXYNOS_BO_NONCONTIG flag on
non-iommu.

Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
---
 drivers/gpu/drm/exynos/exynos_drm_gem.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c
index 96a69468283b..01c5e0854016 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
@@ -44,7 +44,9 @@ static int exynos_drm_get_pages(struct exynos_drm_gem *exynos_gem)
 		goto err;
 	}
 
-	exynos_gem->dma_addr = sg_dma_address(sgt->sgl);
+	if (is_drm_iommu_supported(dev))
+		exynos_gem->dma_addr = sg_dma_address(sgt->sgl);
+
 	exynos_gem->sgt = sgt;
 	exynos_gem->pages = pages;
 
@@ -127,11 +129,6 @@ static int exynos_drm_alloc_buf(struct exynos_drm_gem *exynos_gem)
 	struct drm_device *dev = exynos_gem->base.dev;
 	int ret;
 
-	if (exynos_gem->dma_addr) {
-		DRM_DEBUG_KMS("already allocated.\n");
-		return 0;
-	}
-
 	if (!is_drm_iommu_supported(dev)) {
 		if (!(exynos_gem->flags & EXYNOS_BO_NONCONTIG))
 			return exynos_drm_alloc_dma(exynos_gem);
@@ -150,11 +147,6 @@ static void exynos_drm_free_buf(struct exynos_drm_gem *exynos_gem)
 {
 	struct drm_device *dev = exynos_gem->base.dev;
 
-	if (!exynos_gem->dma_addr) {
-		DRM_DEBUG_KMS("dma_addr is invalid.\n");
-		return;
-	}
-
 	if (!is_drm_iommu_supported(dev)) {
 		if (!(exynos_gem->flags & EXYNOS_BO_NONCONTIG))
 			return exynos_drm_free_dma(exynos_gem);
@@ -256,6 +248,8 @@ static struct exynos_drm_gem *exynos_drm_gem_init(struct drm_device *dev,
 		return ERR_PTR(ret);
 	}
 
+	exynos_gem->dma_addr = DMA_ERROR_CODE;
+
 	DRM_DEBUG_KMS("created file object = 0x%x\n", (unsigned int)obj->filp);
 
 	return exynos_gem;
@@ -594,18 +588,18 @@ exynos_drm_gem_prime_import_sg_table(struct drm_device *dev,
 		return ERR_PTR(ret);
 	}
 
-	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))
+	if (sgt->nents == 1 || is_drm_iommu_supported(dev)) {
 		exynos_gem->flags &= ~EXYNOS_BO_NONCONTIG;
-	else
+		exynos_gem->dma_addr = sg_dma_address(sgt->sgl);
+	} else {
 		exynos_gem->flags |= EXYNOS_BO_NONCONTIG;
+	}
 
 	npages = exynos_gem->size >> PAGE_SHIFT;
 	exynos_gem->pages = drm_malloc_ab(npages, sizeof(struct page *));
-- 
1.9.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2015-10-13  7:01 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-13  7:00 [PATCH 0/9] drm/exynos: update codes related with gem Joonyoung Shim
2015-10-13  7:00 ` [PATCH 1/9] drm/exynos: eliminate useless codes of exynos_drm_gem.h Joonyoung Shim
2015-10-13  7:00 ` [PATCH 2/9] drm/exynos: use directly DMA mapping APIs on g2d Joonyoung Shim
2015-10-13  7:00 ` [PATCH 3/9] drm/exynos: remove using non-consistent DMA attribute Joonyoung Shim
2015-10-13  7:00 ` [PATCH 4/9] drm/exynos: split buffer allocation using DMA mapping API on non-iommu Joonyoung Shim
2015-10-13  7:00 ` [PATCH 5/9] drm/exynos: introduce buffer allocation using drm_gem_get/put_pages() Joonyoung Shim
2015-10-13  7:00 ` [PATCH 6/9] drm/exynos: switch to new buffer allocation Joonyoung Shim
2015-10-19 12:20   ` Inki Dae
2015-10-20  6:03     ` Joonyoung Shim
2015-10-13  7:00 ` [PATCH 7/9] drm/exynos: always use EXYNOS_BO_CONTIG flag on iommu Joonyoung Shim
2015-10-13  7:00 ` Joonyoung Shim [this message]
2015-10-13  7:00 ` [PATCH 9/9] drm/exynos: add ioctls for cpu access of gem object from user Joonyoung Shim
2015-10-13  8:27 ` [PATCH 0/9] drm/exynos: update codes related with gem Daniel Vetter
2015-10-13  8:37   ` Joonyoung Shim
2015-10-13  9:32     ` Joonyoung Shim
2015-10-13 12:29       ` Daniel Vetter
2015-10-14  0:33         ` Joonyoung Shim
2015-10-14  7:43           ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1444719654-10639-9-git-send-email-jy0922.shim@samsung.com \
    --to=jy0922.shim@samsung.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sw0312.kim@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.