Module Name:    src
Committed By:   riastradh
Date:           Sun Dec 19 11:34:29 UTC 2021

Modified Files:
        src/sys/external/bsd/drm2/dist/drm/ttm: ttm_bo_util.c

Log Message:
drm/ttm: Thread the needle of buffer transfer object initialization.

Kinda finicky here!


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 \
    src/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo_util.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo_util.c
diff -u src/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo_util.c:1.27 src/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo_util.c:1.28
--- src/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo_util.c:1.27	Sun Dec 19 11:25:57 2021
+++ src/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo_util.c	Sun Dec 19 11:34:29 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ttm_bo_util.c,v 1.27 2021/12/19 11:25:57 riastradh Exp $	*/
+/*	$NetBSD: ttm_bo_util.c,v 1.28 2021/12/19 11:34:29 riastradh Exp $	*/
 
 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
 /**************************************************************************
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ttm_bo_util.c,v 1.27 2021/12/19 11:25:57 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ttm_bo_util.c,v 1.28 2021/12/19 11:34:29 riastradh Exp $");
 
 #include <drm/ttm/ttm_bo_driver.h>
 #include <drm/ttm/ttm_placement.h>
@@ -521,6 +521,18 @@ static void ttm_transfered_destroy(struc
 
 	fbo = container_of(bo, struct ttm_transfer_obj, base);
 	ttm_bo_put(fbo->bo);
+	dma_resv_fini(&fbo->base.base._resv);
+	if (ttm_bo_uses_embedded_gem_object(bo)) {
+		/*
+		 * Initialization is unconditional, but we don't go
+		 * through drm_gem_object_release, and destruction in
+		 * ttm_bo_release is conditional, so do this
+		 * conditionally with the reverse sense.
+		 *
+		 * Yes, this is a kludge.
+		 */
+		drm_vma_node_destroy(&fbo->base.base.vma_node);
+	}
 	kfree(fbo);
 }
 
@@ -567,8 +579,7 @@ static int ttm_buffer_object_transfer(st
 	INIT_LIST_HEAD(&fbo->base.io_reserve_lru);
 	fbo->base.moving = NULL;
 #ifdef __NetBSD__
-	if (!ttm_bo_uses_embedded_gem_object(bo))
-		drm_vma_node_init(&fbo->base.base.vma_node);
+	drm_vma_node_init(&fbo->base.base.vma_node);
 	uvm_obj_init(&fbo->base.uvmobj, bo->bdev->driver->ttm_uvm_ops, true, 1);
 	rw_obj_hold(bo->uvmobj.vmobjlock);
 	uvm_obj_setlock(&fbo->base.uvmobj, bo->uvmobj.vmobjlock);

Reply via email to