dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Airlie <airlied@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: kraxel@redhat.com, sroland@vmware.com, bskeggs@redhat.com,
	christian.koenig@amd.com
Subject: [PATCH 19/23] drm/ttm: split bind and populate out.
Date: Wed, 26 Aug 2020 11:44:24 +1000	[thread overview]
Message-ID: <20200826014428.828392-20-airlied@gmail.com> (raw)
In-Reply-To: <20200826014428.828392-1-airlied@gmail.com>

From: Dave Airlie <airlied@redhat.com>

Make populating the backing store an explicit separate step

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c |  7 ++++++-
 drivers/gpu/drm/nouveau/nouveau_bo.c    |  6 +++++-
 drivers/gpu/drm/radeon/radeon_ttm.c     |  7 ++++++-
 drivers/gpu/drm/ttm/ttm_bo.c            |  5 ++++-
 drivers/gpu/drm/ttm/ttm_bo_util.c       |  6 +++++-
 drivers/gpu/drm/ttm/ttm_tt.c            | 16 +++++-----------
 include/drm/ttm/ttm_tt.h                |  3 +--
 7 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 116407c77f02..e8a56e64bc38 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -546,8 +546,13 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict,
 		goto out_cleanup;
 	}
 
+	r = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
+	if (unlikely(r)) {
+		goto out_cleanup;
+	}
+
 	/* Bind the memory to the GTT space */
-	r = ttm_tt_bind(bo->bdev, bo->ttm, &tmp_mem, ctx);
+	r = ttm_tt_bind(bo->bdev, bo->ttm, &tmp_mem);
 	if (unlikely(r)) {
 		goto out_cleanup;
 	}
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 9ac4b37aed87..f6b6ef7a8868 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -876,7 +876,11 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,
 	if (ret)
 		return ret;
 
-	ret = ttm_tt_bind(bo->bdev, bo->ttm, &tmp_reg, &ctx);
+	ret = ttm_tt_populate(bo->bdev, bo->ttm, &ctx);
+	if (ret)
+		goto out;
+
+	ret = ttm_tt_bind(bo->bdev, bo->ttm, &tmp_reg);
 	if (ret)
 		goto out;
 	bo->ttm_bound = true;
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index 71c2a78911cd..6f64f949c202 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -235,7 +235,12 @@ static int radeon_move_vram_ram(struct ttm_buffer_object *bo,
 		goto out_cleanup;
 	}
 
-	r = ttm_tt_bind(bo->bdev, bo->ttm, &tmp_mem, &ctx);
+	r = ttm_tt_populate(bo->bdev, bo->ttm, &ctx);
+	if (unlikely(r)) {
+		goto out_cleanup;
+	}
+
+	r = ttm_tt_bind(bo->bdev, bo->ttm, &tmp_mem);
 	if (unlikely(r)) {
 		goto out_cleanup;
 	}
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index bf27d185c23f..bf5f31d9996a 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -282,8 +282,11 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
 			goto out_err;
 
 		if (mem->mem_type != TTM_PL_SYSTEM) {
+			ret = ttm_tt_populate(bdev, bo->ttm, ctx);
+			if (ret)
+				goto out_err;
 			if (bo->ttm_bound == false) {
-				ret = ttm_tt_bind(bdev, bo->ttm, mem, ctx);
+				ret = ttm_tt_bind(bdev, bo->ttm, mem);
 				if (ret)
 					goto out_err;
 				bo->ttm_bound = true;
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 8b50b250da0c..c6262fda1fb8 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -80,7 +80,11 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
 		return ret;
 
 	if (new_mem->mem_type != TTM_PL_SYSTEM) {
-		ret = ttm_tt_bind(bo->bdev, ttm, new_mem, ctx);
+		ret = ttm_tt_populate(bo->bdev, ttm, ctx);
+		if (unlikely(ret != 0))
+			return ret;
+
+		ret = ttm_tt_bind(bo->bdev, ttm, new_mem);
 		if (unlikely(ret != 0))
 			return ret;
 		bo->ttm_bound = true;
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index 8d4f946cd9e0..288fd952bdbe 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -307,22 +307,15 @@ void ttm_tt_unbind(struct ttm_bo_device *bdev, struct ttm_tt *ttm)
 }
 
 int ttm_tt_bind(struct ttm_bo_device *bdev,
-		struct ttm_tt *ttm, struct ttm_resource *bo_mem,
-		struct ttm_operation_ctx *ctx)
+		struct ttm_tt *ttm, struct ttm_resource *bo_mem)
 {
-	int ret = 0;
-
 	if (!ttm)
 		return -EINVAL;
 
-	ret = ttm_tt_populate(bdev, ttm, ctx);
-	if (ret)
-		return ret;
+	if (WARN_ON(!ttm->populated))
+		return -EINVAL;
 
-	ret = bdev->driver->ttm_tt_bind(bdev, ttm, bo_mem);
-	if (unlikely(ret != 0))
-		return ret;
-	return 0;
+	return bdev->driver->ttm_tt_bind(bdev, ttm, bo_mem);
 }
 EXPORT_SYMBOL(ttm_tt_bind);
 
@@ -455,6 +448,7 @@ int ttm_tt_populate(struct ttm_bo_device *bdev,
 		ttm_tt_add_mapping(bdev, ttm);
 	return ret;
 }
+EXPORT_SYMBOL(ttm_tt_populate);
 
 static void ttm_tt_clear_mapping(struct ttm_tt *ttm)
 {
diff --git a/include/drm/ttm/ttm_tt.h b/include/drm/ttm/ttm_tt.h
index 5d10abb1419b..4b35d0e4b9c5 100644
--- a/include/drm/ttm/ttm_tt.h
+++ b/include/drm/ttm/ttm_tt.h
@@ -139,8 +139,7 @@ void ttm_dma_tt_fini(struct ttm_dma_tt *ttm_dma);
  * Bind the pages of @ttm to an aperture location identified by @bo_mem
  */
 int ttm_tt_bind(struct ttm_bo_device *bdev,
-		struct ttm_tt *ttm, struct ttm_resource *bo_mem,
-		struct ttm_operation_ctx *ctx);
+		struct ttm_tt *ttm, struct ttm_resource *bo_mem);
 
 /**
  * ttm_ttm_destroy:
-- 
2.27.0

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

  parent reply	other threads:[~2020-08-26  1:45 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-26  1:44 [00/23] ttm tt refactoring Dave Airlie
2020-08-26  1:44 ` [PATCH 01/23] drm/amdgpu/ttm: remove unused parameter to move blit Dave Airlie
2020-08-26  1:44 ` [PATCH 02/23] drm/radeon/ttm: don't store driver copy of device pointer Dave Airlie
2020-09-01 11:53   ` Daniel Vetter
2020-08-26  1:44 ` [PATCH 03/23] drm/ttm: remove bdev from ttm_tt Dave Airlie
2020-08-26  1:44 ` [PATCH 04/23] drm/ttm: add optional bind/unbind via driver Dave Airlie
2020-08-26  1:44 ` [PATCH 05/23] drm/qxl: move bind/unbind/destroy to the driver function table Dave Airlie
2020-08-26  1:44 ` [PATCH 06/23] drm/ttm/agp: export bind/unbind/destroy for drivers to use Dave Airlie
2020-08-26  1:44 ` [PATCH 07/23] drm/radeon/ttm: move to driver binding/destroy functions Dave Airlie
2020-08-27 11:42   ` Christian König
2020-08-26  1:44 ` [PATCH 08/23] drm/nouveau/ttm: use driver bind/unbind/destroy functions Dave Airlie
2020-08-26  1:44 ` [PATCH 09/23] drm/vmwgfx: move to driver binding functions Dave Airlie
2020-08-26  1:44 ` [PATCH 10/23] drm/amdgpu/ttm: move to driver backend binding funcs Dave Airlie
2020-08-26  1:44 ` [PATCH 11/23] drm/gem_vram/ttm: move to driver backend destroy function Dave Airlie
2020-08-26  5:14   ` Thomas Zimmermann
2020-08-26  1:44 ` [PATCH 12/23] drm/ttm/agp: drop back end bindings from agp Dave Airlie
2020-08-26  1:44 ` [PATCH 13/23] drm/ttm: get rid of agp specific populate/unpopulate paths Dave Airlie
2020-08-26  1:44 ` [PATCH 14/23] drm/ttm/agp: remove bdev from agp helpers Dave Airlie
2020-08-26  1:44 ` [PATCH 15/23] drm/ttm: drop the tt backend function paths Dave Airlie
2020-08-26  1:44 ` [PATCH 16/23] drm/ttm: move sg pointer into ttm_dma_tt Dave Airlie
2020-08-26  1:44 ` [PATCH 17/23] drm/ttm: split populated/bound state flags Dave Airlie
2020-08-27 11:52   ` Christian König
2020-08-26  1:44 ` [PATCH 18/23] drm/ttm: move bound flag and use a utility wrapper Dave Airlie
2020-08-26  1:44 ` Dave Airlie [this message]
2020-08-26  1:44 ` [PATCH 20/23] drm/ttm: add populated accessors Dave Airlie
2020-08-26  1:44 ` [PATCH 21/23] drm/ttm: store populated status in upper page flag bits Dave Airlie
2020-08-26  1:44 ` [PATCH 22/23] drm/ttm: two minor struct reorgs to fill holes Dave Airlie
2020-08-26  1:44 ` [PATCH 23/23] drm/ttm: change ordering of args to map/unmap helpers Dave Airlie
2020-08-27 11:55 ` [00/23] ttm tt refactoring Christian König

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=20200826014428.828392-20-airlied@gmail.com \
    --to=airlied@gmail.com \
    --cc=bskeggs@redhat.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kraxel@redhat.com \
    --cc=sroland@vmware.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox