drm/ttm: split bound/populated flags.
authorDave Airlie <airlied@redhat.com>
Tue, 15 Sep 2020 01:42:30 +0000 (11:42 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 15 Sep 2020 23:35:47 +0000 (09:35 +1000)
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.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200915024007.67163-7-airlied@gmail.com
drivers/gpu/drm/ttm/ttm_bo_util.c
include/drm/ttm/ttm_bo_api.h
include/drm/ttm/ttm_bo_driver.h
include/drm/ttm/ttm_tt.h

index d6634a5caba24c6dc4fd6e005920cb907a3c4da3..980368049d6897576a200208f88f4826949e0e1f 100644 (file)
@@ -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);
index 36ff64e2736cd9526da946d54381817c75870235..1d20a7f15a7aaa87b369f2bc5a500af97850cb61 100644 (file)
@@ -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;
 
index d2bea22f35ae0472e8696fee8057ff5186f4e3c7..e66672f703a38f95dc39107cec90b20349ab8aeb 100644 (file)
@@ -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.
index 1ac56730d9524a5234bee5c62aeb8a40d6caa5ae..94e16238c93d94a6466d09f1e9f0c135102a58c4 100644 (file)
@@ -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;
 }
 
 /**