drm/ttm: add optional LRU removal callback v2
authorChristian König <christian.koenig@amd.com>
Wed, 6 Apr 2016 09:12:06 +0000 (11:12 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 5 May 2016 00:21:34 +0000 (20:21 -0400)
Useful for driver specific LRU handling.

v2: fix typo in comment

Reviewed-by: Sinclair Yeh <syeh@vmware.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/ttm/ttm_bo.c
include/drm/ttm/ttm_bo_driver.h

index 34775bf51718f581d09a66c77a0f624058cd5ada..309a72ee7fb4a1a00c11ca68d40625918a83b817 100644 (file)
@@ -186,8 +186,12 @@ EXPORT_SYMBOL(ttm_bo_add_to_lru);
 
 int ttm_bo_del_from_lru(struct ttm_buffer_object *bo)
 {
+       struct ttm_bo_device *bdev = bo->bdev;
        int put_count = 0;
 
+       if (bdev->driver->lru_removal)
+               bdev->driver->lru_removal(bo);
+
        if (!list_empty(&bo->swap)) {
                list_del_init(&bo->swap);
                ++put_count;
@@ -197,11 +201,6 @@ int ttm_bo_del_from_lru(struct ttm_buffer_object *bo)
                ++put_count;
        }
 
-       /*
-        * TODO: Add a driver hook to delete from
-        * driver-specific LRU's here.
-        */
-
        return put_count;
 }
 
@@ -235,6 +234,9 @@ void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo)
 
        lockdep_assert_held(&bo->resv->lock.base);
 
+       if (bdev->driver->lru_removal)
+               bdev->driver->lru_removal(bo);
+
        if (bo->mem.placement & TTM_PL_FLAG_NO_EVICT) {
                list_del_init(&bo->swap);
                list_del_init(&bo->lru);
index d4a568eafef5d5580c3cebcf0cc040805206872a..542f9212727cbd0c5e85f488d139243c85878fc8 100644 (file)
@@ -434,6 +434,12 @@ struct ttm_bo_driver {
         */
        int (*io_mem_reserve)(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem);
        void (*io_mem_free)(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem);
+
+       /**
+        * Optional driver callback for when BO is removed from the LRU.
+        * Called with LRU lock held immediately before the removal.
+        */
+       void (*lru_removal)(struct ttm_buffer_object *bo);
 };
 
 /**