Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2/dist/drm/ttm Fix up ttm.



details:   https://anonhg.NetBSD.org/src/rev/70832fb98b4a
branches:  trunk
changeset: 1028091:70832fb98b4a
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 01:49:50 2021 +0000

description:
Fix up ttm.

diffstat:

 sys/external/bsd/drm2/dist/drm/ttm/ttm_bo_util.c |   8 ++++----
 sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c      |  22 ++++++++++++++++------
 2 files changed, 20 insertions(+), 10 deletions(-)

diffs (102 lines):

diff -r b219cdd009f8 -r 70832fb98b4a sys/external/bsd/drm2/dist/drm/ttm/ttm_bo_util.c
--- a/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo_util.c  Sun Dec 19 01:49:44 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo_util.c  Sun Dec 19 01:49:50 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ttm_bo_util.c,v 1.21 2021/12/18 23:45:44 riastradh Exp $       */
+/*     $NetBSD: ttm_bo_util.c,v 1.22 2021/12/19 01:49:50 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.21 2021/12/18 23:45:44 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ttm_bo_util.c,v 1.22 2021/12/19 01:49:50 riastradh Exp $");
 
 #include <drm/ttm/ttm_bo_driver.h>
 #include <drm/ttm/ttm_placement.h>
@@ -568,9 +568,9 @@
        fbo->base.moving = NULL;
 #ifdef __NetBSD__
        drm_vma_node_init(&fbo->vma_node);
-       uvm_obj_init(&fbo->uvmobj, bo->bdev->driver->ttm_uvm_ops, true, 1);
+       uvm_obj_init(&fbo->base.uvmobj, bo->bdev->driver->ttm_uvm_ops, true, 1);
        rw_obj_hold(bo->uvmobj.vmobjlock);
-       uvm_obj_setlock(&fbo->uvmobj, bo->uvmobj.vmobjlock);
+       uvm_obj_setlock(&fbo->base.uvmobj, bo->uvmobj.vmobjlock);
 #else
        drm_vma_node_reset(&fbo->base.base.vma_node);
 #endif
diff -r b219cdd009f8 -r 70832fb98b4a sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c
--- a/sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c       Sun Dec 19 01:49:44 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c       Sun Dec 19 01:49:50 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ttm_tt.c,v 1.13 2021/12/18 23:45:44 riastradh Exp $    */
+/*     $NetBSD: ttm_tt.c,v 1.14 2021/12/19 01:49:50 riastradh Exp $    */
 
 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
 /**************************************************************************
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ttm_tt.c,v 1.13 2021/12/18 23:45:44 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ttm_tt.c,v 1.14 2021/12/19 01:49:50 riastradh Exp $");
 
 #define pr_fmt(fmt) "[TTM] " fmt
 
@@ -245,11 +245,11 @@
        ttm->page_flags = page_flags;
        ttm->state = tt_unpopulated;
 #ifdef __NetBSD__
-       WARN(size == 0, "zero-size allocation in %s, please file a NetBSD PR",
+       WARN(bo->num_pages == 0,
+           "zero-size allocation in %s, please file a NetBSD PR",
            __func__);  /* paranoia -- can't prove in five minutes */
-       size = MAX(size, 1);
-       ttm->swap_storage = uao_create(roundup2(size, PAGE_SIZE), 0);
-       uao_set_pgfl(ttm->swap_storage, bus_dmamem_pgfl(bdev->dmat));
+       ttm->swap_storage = uao_create(MAX(1, bo->num_pages), 0);
+       uao_set_pgfl(ttm->swap_storage, bus_dmamem_pgfl(ttm->bdev->dmat));
        TAILQ_INIT(&ttm->pglist);
 #else
        ttm->swap_storage = NULL;
@@ -602,6 +602,7 @@
 
 static void ttm_tt_add_mapping(struct ttm_tt *ttm)
 {
+#ifndef __NetBSD__
        pgoff_t i;
 
        if (ttm->page_flags & TTM_PAGE_FLAG_SG)
@@ -609,6 +610,7 @@
 
        for (i = 0; i < ttm->num_pages; ++i)
                ttm->pages[i]->mapping = ttm->bdev->dev_mapping;
+#endif
 }
 
 int ttm_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx)
@@ -621,7 +623,11 @@
        if (ttm->bdev->driver->ttm_tt_populate)
                ret = ttm->bdev->driver->ttm_tt_populate(ttm, ctx);
        else
+#ifdef __NetBSD__
+               panic("no ttm population");
+#else
                ret = ttm_pool_populate(ttm, ctx);
+#endif
        if (!ret)
                ttm_tt_add_mapping(ttm);
        return ret;
@@ -652,5 +658,9 @@
        if (ttm->bdev->driver->ttm_tt_unpopulate)
                ttm->bdev->driver->ttm_tt_unpopulate(ttm);
        else
+#ifdef __NetBSD__
+               panic("no ttm pool unpopulation");
+#else
                ttm_pool_unpopulate(ttm);
+#endif
 }



Home | Main Index | Thread Index | Old Index