drm/ttm: Add release_notify callback to ttm_bo_driver
authorFelix Kuehling <Felix.Kuehling@amd.com>
Tue, 9 Jul 2019 23:09:42 +0000 (19:09 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 2 Aug 2019 15:18:04 +0000 (10:18 -0500)
This notifies the driver that a BO is about to be released.

Releasing a BO also invokes the move_notify callback from
ttm_bo_cleanup_memtype_use, but that happens too late for anything
that would add fences to the BO and require a delayed delete.

Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Christian König <christian.koenig@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 a7fd5a4955c969fe8842ee067ac1b52b62a6567a..939b9258d5135b4b3654b2cfa0fb508e99706bd9 100644 (file)
@@ -671,6 +671,9 @@ static void ttm_bo_release(struct kref *kref)
        struct ttm_bo_device *bdev = bo->bdev;
        struct ttm_mem_type_manager *man = &bdev->man[bo->mem.mem_type];
 
+       if (bo->bdev->driver->release_notify)
+               bo->bdev->driver->release_notify(bo);
+
        drm_vma_offset_remove(&bdev->vma_manager, &bo->vma_node);
        ttm_mem_io_lock(man, false);
        ttm_mem_io_free_vm(bo);
index a2d810a2504d3dd2775e6524d47ecbc51cfe4e1b..81077e5b4b7ed48149bb95004a85cced3b77ebf4 100644 (file)
@@ -390,6 +390,16 @@ struct ttm_bo_driver {
         * notify driver that a BO was deleted from LRU.
         */
        void (*del_from_lru_notify)(struct ttm_buffer_object *bo);
+
+       /**
+        * Notify the driver that we're about to release a BO
+        *
+        * @bo: BO that is about to be released
+        *
+        * Gives the driver a chance to do any cleanup, including
+        * adding fences that may force a delayed delete
+        */
+       void (*release_notify)(struct ttm_buffer_object *bo);
 };
 
 /**