]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/ttm: move default BO destructor into VMWGFX v2
authorChristian König <christian.koenig@amd.com>
Fri, 18 Feb 2022 09:05:40 +0000 (10:05 +0100)
committerChristian König <christian.koenig@amd.com>
Mon, 9 May 2022 12:49:50 +0000 (14:49 +0200)
It's the only driver using this.

v2: use BUG_ON() in vmw_bo_create() as suggested by Zack

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Zack Rusin <zackr@vmware.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220329110243.6335-5-christian.koenig@amd.com
drivers/gpu/drm/ttm/ttm_bo.c
drivers/gpu/drm/vmwgfx/vmwgfx_bo.c

index 75d308ec173d34d0a3e47f5706868e5f491826b9..296af2b89951abdc4fd12a7769bba284551713af 100644 (file)
 
 #include "ttm_module.h"
 
-/* default destructor */
-static void ttm_bo_default_destroy(struct ttm_buffer_object *bo)
-{
-       kfree(bo);
-}
-
 static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo,
                                        struct ttm_placement *placement)
 {
@@ -936,8 +930,7 @@ int ttm_bo_init_reserved(struct ttm_device *bdev,
        bool locked;
        int ret;
 
-       bo->destroy = destroy ? destroy : ttm_bo_default_destroy;
-
+       bo->destroy = destroy;
        kref_init(&bo->kref);
        INIT_LIST_HEAD(&bo->ddestroy);
        bo->bdev = bdev;
index eb94433067ba82ade6ebd65f941af33394093895..85a66014c2b6ca2f4354024cf0e674f8d1b4811d 100644 (file)
@@ -393,6 +393,12 @@ void vmw_bo_bo_free(struct ttm_buffer_object *bo)
        kfree(vmw_bo);
 }
 
+/* default destructor */
+static void vmw_bo_default_destroy(struct ttm_buffer_object *bo)
+{
+       kfree(bo);
+}
+
 /**
  * vmw_bo_create_kernel - Create a pinned BO for internal kernel use.
  *
@@ -425,7 +431,7 @@ int vmw_bo_create_kernel(struct vmw_private *dev_priv, unsigned long size,
 
        ret = ttm_bo_init_reserved(&dev_priv->bdev, bo, size,
                                   ttm_bo_type_kernel, placement, 0,
-                                  &ctx, NULL, NULL, NULL);
+                                  &ctx, NULL, NULL, vmw_bo_default_destroy);
        if (unlikely(ret))
                goto error_free;
 
@@ -448,6 +454,8 @@ int vmw_bo_create(struct vmw_private *vmw,
 {
        int ret;
 
+       BUG_ON(!bo_free);
+
        *p_bo = kmalloc(sizeof(**p_bo), GFP_KERNEL);
        if (unlikely(!*p_bo)) {
                DRM_ERROR("Failed to allocate a buffer.\n");