drm/ttm: add optional bind/unbind via driver.
authorDave Airlie <airlied@redhat.com>
Mon, 7 Sep 2020 20:46:19 +0000 (06:46 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 8 Sep 2020 22:29:43 +0000 (08:29 +1000)
I want to remove the backend funcs

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

index 50a89910402204b87e8e8e9b14d599d9b69a1b54..73c97dcfa512e1a499e1837f4bbcd985bda75122 100644 (file)
@@ -222,7 +222,10 @@ void ttm_tt_destroy(struct ttm_bo_device *bdev, struct ttm_tt *ttm)
                fput(ttm->swap_storage);
 
        ttm->swap_storage = NULL;
-       ttm->func->destroy(bdev, ttm);
+       if (bdev->driver->ttm_tt_destroy)
+               bdev->driver->ttm_tt_destroy(bdev, ttm);
+       else
+               ttm->func->destroy(bdev, ttm);
 }
 
 static void ttm_tt_init_fields(struct ttm_tt *ttm,
@@ -310,7 +313,10 @@ EXPORT_SYMBOL(ttm_dma_tt_fini);
 void ttm_tt_unbind(struct ttm_bo_device *bdev, struct ttm_tt *ttm)
 {
        if (ttm->state == tt_bound) {
-               ttm->func->unbind(bdev, ttm);
+               if (bdev->driver->ttm_tt_unbind)
+                       bdev->driver->ttm_tt_unbind(bdev, ttm);
+               else
+                       ttm->func->unbind(bdev, ttm);
                ttm->state = tt_unbound;
        }
 }
@@ -331,7 +337,10 @@ int ttm_tt_bind(struct ttm_bo_device *bdev,
        if (ret)
                return ret;
 
-       ret = ttm->func->bind(bdev, ttm, bo_mem);
+       if (bdev->driver->ttm_tt_bind)
+               ret = bdev->driver->ttm_tt_bind(bdev, ttm, bo_mem);
+       else
+               ret = ttm->func->bind(bdev, ttm, bo_mem);
        if (unlikely(ret != 0))
                return ret;
 
index ebba282667ba60b8d8d700b5c01e5fe084e4959f..32c0651cc0fd68c6c0e7f38b7914fd4af7515b86 100644 (file)
@@ -90,6 +90,42 @@ struct ttm_bo_driver {
         */
        void (*ttm_tt_unpopulate)(struct ttm_bo_device *bdev, struct ttm_tt *ttm);
 
+       /**
+        * ttm_tt_bind
+        *
+        * @bdev: Pointer to a ttm device
+        * @ttm: Pointer to a struct ttm_tt.
+        * @bo_mem: Pointer to a struct ttm_resource describing the
+        * memory type and location for binding.
+        *
+        * Bind the backend pages into the aperture in the location
+        * indicated by @bo_mem. This function should be able to handle
+        * differences between aperture and system page sizes.
+        */
+       int (*ttm_tt_bind)(struct ttm_bo_device *bdev, struct ttm_tt *ttm, struct ttm_resource *bo_mem);
+
+       /**
+        * ttm_tt_unbind
+        *
+        * @bdev: Pointer to a ttm device
+        * @ttm: Pointer to a struct ttm_tt.
+        *
+        * Unbind previously bound backend pages. This function should be
+        * able to handle differences between aperture and system page sizes.
+        */
+       void (*ttm_tt_unbind)(struct ttm_bo_device *bdev, struct ttm_tt *ttm);
+
+       /**
+        * ttm_tt_destroy
+        *
+        * @bdev: Pointer to a ttm device
+        * @ttm: Pointer to a struct ttm_tt.
+        *
+        * Destroy the backend. This will be call back from ttm_tt_destroy so
+        * don't call ttm_tt_destroy from the callback or infinite loop.
+        */
+       void (*ttm_tt_destroy)(struct ttm_bo_device *bdev, struct ttm_tt *ttm);
+
        /**
         * struct ttm_bo_driver member eviction_valuable
         *