drm/ttm: add evict parameter to ttm_bo_driver::move_notify
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Thu, 15 Dec 2016 16:23:49 +0000 (17:23 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 27 Jan 2017 16:13:15 +0000 (11:13 -0500)
Ensure that the driver can listen to evictions even when they don't take the
path through ttm_bo_driver::move.

This is crucial for amdgpu, which relies on an eviction counter to skip
re-binding page tables when possible.

Signed-off-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
drivers/gpu/drm/nouveau/nouveau_bo.c
drivers/gpu/drm/qxl/qxl_ttm.c
drivers/gpu/drm/radeon/radeon_object.c
drivers/gpu/drm/radeon/radeon_object.h
drivers/gpu/drm/ttm/ttm_bo.c
drivers/gpu/drm/virtio/virtgpu_ttm.c
drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c
include/drm/ttm/ttm_bo_driver.h

index bf79b73..c29db99 100644 (file)
@@ -849,6 +849,7 @@ int amdgpu_bo_get_metadata(struct amdgpu_bo *bo, void *buffer,
 }
 
 void amdgpu_bo_move_notify(struct ttm_buffer_object *bo,
+                          bool evict,
                           struct ttm_mem_reg *new_mem)
 {
        struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev);
index 5cbf59e..4306b2f 100644 (file)
@@ -155,7 +155,8 @@ int amdgpu_bo_get_metadata(struct amdgpu_bo *bo, void *buffer,
                           size_t buffer_size, uint32_t *metadata_size,
                           uint64_t *flags);
 void amdgpu_bo_move_notify(struct ttm_buffer_object *bo,
-                                 struct ttm_mem_reg *new_mem);
+                          bool evict,
+                          struct ttm_mem_reg *new_mem);
 int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo);
 void amdgpu_bo_fence(struct amdgpu_bo *bo, struct dma_fence *fence,
                     bool shared);
index dd07ca1..2435183 100644 (file)
@@ -1194,7 +1194,8 @@ out:
 }
 
 static void
-nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem)
+nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, bool evict,
+                    struct ttm_mem_reg *new_mem)
 {
        struct nouveau_bo *nvbo = nouveau_bo(bo);
        struct nvkm_vma *vma;
index bc1c896..4ecf97a 100644 (file)
@@ -366,6 +366,7 @@ static int qxl_bo_move(struct ttm_buffer_object *bo,
 }
 
 static void qxl_bo_move_notify(struct ttm_buffer_object *bo,
+                              bool evict,
                               struct ttm_mem_reg *new_mem)
 {
        struct qxl_bo *qbo;
index 41b72ce..74b2760 100644 (file)
@@ -765,6 +765,7 @@ int radeon_bo_check_tiling(struct radeon_bo *bo, bool has_moved,
 }
 
 void radeon_bo_move_notify(struct ttm_buffer_object *bo,
+                          bool evict,
                           struct ttm_mem_reg *new_mem)
 {
        struct radeon_bo *rbo;
index a10bb3d..9ffd821 100644 (file)
@@ -150,6 +150,7 @@ extern void radeon_bo_get_tiling_flags(struct radeon_bo *bo,
 extern int radeon_bo_check_tiling(struct radeon_bo *bo, bool has_moved,
                                bool force_drop);
 extern void radeon_bo_move_notify(struct ttm_buffer_object *bo,
+                                 bool evict,
                                  struct ttm_mem_reg *new_mem);
 extern int radeon_bo_fault_reserve_notify(struct ttm_buffer_object *bo);
 extern int radeon_bo_get_surface_reg(struct radeon_bo *bo);
index d506361..d4973e9 100644 (file)
@@ -342,7 +342,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
 
                if (bo->mem.mem_type == TTM_PL_SYSTEM) {
                        if (bdev->driver->move_notify)
-                               bdev->driver->move_notify(bo, mem);
+                               bdev->driver->move_notify(bo, evict, mem);
                        bo->mem = *mem;
                        mem->mm_node = NULL;
                        goto moved;
@@ -350,7 +350,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
        }
 
        if (bdev->driver->move_notify)
-               bdev->driver->move_notify(bo, mem);
+               bdev->driver->move_notify(bo, evict, mem);
 
        if (!(old_man->flags & TTM_MEMTYPE_FLAG_FIXED) &&
            !(new_man->flags & TTM_MEMTYPE_FLAG_FIXED))
@@ -366,7 +366,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
                        struct ttm_mem_reg tmp_mem = *mem;
                        *mem = bo->mem;
                        bo->mem = tmp_mem;
-                       bdev->driver->move_notify(bo, mem);
+                       bdev->driver->move_notify(bo, false, mem);
                        bo->mem = *mem;
                        *mem = tmp_mem;
                }
@@ -414,7 +414,7 @@ out_err:
 static void ttm_bo_cleanup_memtype_use(struct ttm_buffer_object *bo)
 {
        if (bo->bdev->driver->move_notify)
-               bo->bdev->driver->move_notify(bo, NULL);
+               bo->bdev->driver->move_notify(bo, false, NULL);
 
        ttm_tt_destroy(bo->ttm);
        bo->ttm = NULL;
index 63b3d5d..07b0de5 100644 (file)
@@ -386,6 +386,7 @@ static int virtio_gpu_bo_move(struct ttm_buffer_object *bo,
 }
 
 static void virtio_gpu_bo_move_notify(struct ttm_buffer_object *tbo,
+                                     bool evict,
                                      struct ttm_mem_reg *new_mem)
 {
        struct virtio_gpu_object *bo;
index c894a48..caa279b 100644 (file)
@@ -825,6 +825,7 @@ static int vmw_ttm_fault_reserve_notify(struct ttm_buffer_object *bo)
  * (currently only resources).
  */
 static void vmw_move_notify(struct ttm_buffer_object *bo,
+                           bool evict,
                            struct ttm_mem_reg *mem)
 {
        vmw_resource_move_notify(bo, mem);
index cdbdb40..8b4bec7 100644 (file)
@@ -431,9 +431,15 @@ struct ttm_bo_driver {
        int (*verify_access)(struct ttm_buffer_object *bo,
                             struct file *filp);
 
-       /* hook to notify driver about a driver move so it
-        * can do tiling things */
+       /**
+        * Hook to notify driver about a driver move so it
+        * can do tiling things and book-keeping.
+        *
+        * @evict: whether this move is evicting the buffer from the graphics
+        * address space
+        */
        void (*move_notify)(struct ttm_buffer_object *bo,
+                           bool evict,
                            struct ttm_mem_reg *new_mem);
        /* notify the driver we are taking a fault on this BO
         * and have reserved it */