All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Airlie <airlied@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: christian.koenig@amd.com, bskeggs@redhat.com
Subject: [PATCH 6/7] drm/ttm: split bound/populated flags.
Date: Tue, 15 Sep 2020 12:40:06 +1000	[thread overview]
Message-ID: <20200915024007.67163-7-airlied@gmail.com> (raw)
In-Reply-To: <20200915024007.67163-1-airlied@gmail.com>

From: Dave Airlie <airlied@redhat.com>

Move bound up into the bo object, and keep populated with the tt
object.

The ghost object handling needs to follow the flags at the bo
level now instead of it being part of the ttm tt object.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/ttm/ttm_bo_util.c | 15 +++++++++++----
 include/drm/ttm/ttm_bo_api.h      |  1 +
 include/drm/ttm/ttm_bo_driver.h   |  6 +++---
 include/drm/ttm/ttm_tt.h          | 12 ++++--------
 4 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 4c5c9a333c74..6b0320252a60 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -572,10 +572,13 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
 		 * bo to be unbound and destroyed.
 		 */
 
-		if (man->use_tt)
+		if (man->use_tt) {
 			ghost_obj->ttm = NULL;
-		else
+			ttm_bo_tt_set_unbound(ghost_obj);
+		} else {
 			bo->ttm = NULL;
+			ttm_bo_tt_set_unbound(bo);
+		}
 
 		dma_resv_unlock(&ghost_obj->base._resv);
 		ttm_bo_put(ghost_obj);
@@ -628,10 +631,13 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo,
 		 * bo to be unbound and destroyed.
 		 */
 
-		if (to->use_tt)
+		if (to->use_tt) {
 			ghost_obj->ttm = NULL;
-		else
+			ttm_bo_tt_set_unbound(ghost_obj);
+		} else {
 			bo->ttm = NULL;
+			ttm_bo_tt_set_unbound(bo);
+		}
 
 		dma_resv_unlock(&ghost_obj->base._resv);
 		ttm_bo_put(ghost_obj);
@@ -695,6 +701,7 @@ int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo)
 	memset(&bo->mem, 0, sizeof(bo->mem));
 	bo->mem.mem_type = TTM_PL_SYSTEM;
 	bo->ttm = NULL;
+	ttm_bo_tt_set_unbound(bo);
 
 	dma_resv_unlock(&ghost->base._resv);
 	ttm_bo_put(ghost);
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index 36ff64e2736c..1d20a7f15a7a 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -141,6 +141,7 @@ struct ttm_buffer_object {
 	struct ttm_resource mem;
 	struct file *persistent_swap_storage;
 	struct ttm_tt *ttm;
+	bool ttm_bound;
 	bool evicted;
 	bool deleted;
 
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 0112619f6172..0677e2582ff8 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -700,17 +700,17 @@ void ttm_bo_tt_unbind(struct ttm_buffer_object *bo);
 
 static inline bool ttm_bo_tt_is_bound(struct ttm_buffer_object *bo)
 {
-	return bo->ttm->_state == tt_bound;
+	return bo->ttm_bound;
 }
 
 static inline void ttm_bo_tt_set_unbound(struct ttm_buffer_object *bo)
 {
-	bo->ttm->_state = tt_unbound;
+	bo->ttm_bound = false;
 }
 
 static inline void ttm_bo_tt_set_bound(struct ttm_buffer_object *bo)
 {
-	bo->ttm->_state = tt_bound;
+	bo->ttm_bound = true;
 }
 /**
  * ttm_bo_tt_destroy.
diff --git a/include/drm/ttm/ttm_tt.h b/include/drm/ttm/ttm_tt.h
index 1ac56730d952..94e16238c93d 100644
--- a/include/drm/ttm/ttm_tt.h
+++ b/include/drm/ttm/ttm_tt.h
@@ -70,26 +70,22 @@ struct ttm_tt {
 	struct sg_table *sg; /* for SG objects via dma-buf */
 	struct file *swap_storage;
 	enum ttm_caching_state caching_state;
-	enum {
-		tt_bound,
-		tt_unbound,
-		tt_unpopulated,
-	} _state;
+	bool populated;
 };
 
 static inline bool ttm_tt_is_populated(struct ttm_tt *tt)
 {
-	return tt->_state != tt_unpopulated;
+	return tt->populated;
 }
 
 static inline void ttm_tt_set_unpopulated(struct ttm_tt *tt)
 {
-	tt->_state = tt_unpopulated;
+	tt->populated = false;
 }
 
 static inline void ttm_tt_set_populated(struct ttm_tt *tt)
 {
-	tt->_state = tt_unbound;
+	tt->populated = true;
 }
 
 /**
-- 
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-09-15  2:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-15  2:40 Dave Airlie
2020-09-15  2:40 ` [PATCH 1/7] drm/ttm/tt: add wrappers to set tt state Dave Airlie
2020-09-15  2:40 ` [PATCH 2/7] drm/ttm: wrap tt destroy Dave Airlie
2020-09-15  7:47   ` Christian König
2020-09-15  2:40 ` [PATCH 3/7] drm/ttm: tt destroy move null check to outer function Dave Airlie
2020-09-15  2:40 ` [PATCH 4/7] drm/ttm: split populate out from binding Dave Airlie
2020-09-15  7:50   ` Christian König
2020-09-15  2:40 ` [PATCH 5/7] drm/ttm: move ttm binding/unbinding out of ttm_tt paths Dave Airlie
2020-09-15  2:40 ` Dave Airlie [this message]
2020-09-15  2:40 ` [PATCH 7/7] drm/ttm: move populated state into page flags Dave Airlie
2020-09-15  7:53 ` 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=20200915024007.67163-7-airlied@gmail.com \
    --to=airlied@gmail.com \
    --cc=PATCH@freedesktop.org \
    --cc=bskeggs@redhat.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=drm@freedesktop.org \
    /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.