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/ttm drm: Nix use of uvm pglist. Just ...



details:   https://anonhg.NetBSD.org/src/rev/88a98ae10756
branches:  trunk
changeset: 1028633:88a98ae10756
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 11:32:53 2021 +0000

description:
drm: Nix use of uvm pglist.  Just use arrays of page pointers.

diffstat:

 sys/external/bsd/drm2/dist/drm/drm_gem.c                        |  17 +-
 sys/external/bsd/drm2/dist/drm/drm_prime.c                      |  53 +---------
 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_clflush.c      |   6 +-
 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_dmabuf.c       |   6 +-
 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c         |  15 +-
 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_object_types.h |   4 +-
 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_shmem.c        |  13 +-
 sys/external/bsd/drm2/dist/drm/i915/i915_gem_fence_reg.c        |  36 +++---
 sys/external/bsd/drm2/dist/drm/i915/i915_gem_fence_reg.h        |   6 +-
 sys/external/bsd/drm2/dist/drm/i915/i915_gem_gtt.c              |   9 +-
 sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c                     |  21 +--
 sys/external/bsd/drm2/dist/include/drm/drm_cache.h              |   4 +-
 sys/external/bsd/drm2/dist/include/drm/drm_prime.h              |   3 +-
 sys/external/bsd/drm2/dist/include/drm/ttm/ttm_tt.h             |   3 +-
 sys/external/bsd/drm2/drm/drm_cache.c                           |  22 +---
 sys/external/bsd/drm2/include/drm/bus_dma_hacks.h               |  29 +++--
 sys/external/bsd/drm2/ttm/ttm_bus_dma.c                         |   8 +-
 17 files changed, 100 insertions(+), 155 deletions(-)

diffs (truncated from 683 to 300 lines):

diff -r cc328ad0cd00 -r 88a98ae10756 sys/external/bsd/drm2/dist/drm/drm_gem.c
--- a/sys/external/bsd/drm2/dist/drm/drm_gem.c  Sun Dec 19 11:32:44 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/drm_gem.c  Sun Dec 19 11:32:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_gem.c,v 1.21 2021/12/19 11:26:14 riastradh Exp $   */
+/*     $NetBSD: drm_gem.c,v 1.22 2021/12/19 11:32:53 riastradh Exp $   */
 
 /*
  * Copyright © 2008 Intel Corporation
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_gem.c,v 1.21 2021/12/19 11:26:14 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_gem.c,v 1.22 2021/12/19 11:32:53 riastradh Exp $");
 
 #include <linux/types.h>
 #include <linux/slab.h>
@@ -600,7 +600,6 @@
 struct page **
 drm_gem_get_pages(struct drm_gem_object *obj)
 {
-       struct pglist pglist;
        struct vm_page *vm_page;
        struct page **pages;
        unsigned i, npages;
@@ -615,15 +614,17 @@
                goto fail0;
        }
 
-       TAILQ_INIT(&pglist);
        /* XXX errno NetBSD->Linux */
-       ret = -uvm_obj_wirepages(obj->filp, 0, obj->size, &pglist);
+       ret = -uvm_obj_wirepages(obj->filp, 0, obj->size, NULL);
        if (ret)
                goto fail1;
 
-       i = 0;
-       TAILQ_FOREACH(vm_page, &pglist, pageq.queue)
-               pages[i++] = container_of(vm_page, struct page, p_vmp);
+       rw_enter(obj->filp->vmobjlock, RW_READER);
+       for (i = 0; i < npages; i++) {
+               vm_page = uvm_pagelookup(obj->filp, ptoa(i));
+               pages[i] = container_of(vm_page, struct page, p_vmp);
+       }
+       rw_exit(obj->filp->vmobjlock);
 
        return pages;
 
diff -r cc328ad0cd00 -r 88a98ae10756 sys/external/bsd/drm2/dist/drm/drm_prime.c
--- a/sys/external/bsd/drm2/dist/drm/drm_prime.c        Sun Dec 19 11:32:44 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/drm_prime.c        Sun Dec 19 11:32:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_prime.c,v 1.14 2021/12/19 10:38:22 riastradh Exp $ */
+/*     $NetBSD: drm_prime.c,v 1.15 2021/12/19 11:32:53 riastradh Exp $ */
 
 /*
  * Copyright © 2012 Red Hat
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_prime.c,v 1.14 2021/12/19 10:38:22 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_prime.c,v 1.15 2021/12/19 11:32:53 riastradh Exp $");
 
 #include <linux/export.h>
 #include <linux/dma-buf.h>
@@ -89,31 +89,6 @@
 }
 
 static int
-sg_alloc_table_from_pglist(struct sg_table *sgt, const struct pglist *pglist,
-    unsigned npages, bus_size_t offset, bus_size_t size, gfp_t gfp)
-{
-       struct vm_page *pg;
-       unsigned i;
-
-       KASSERT(offset == 0);
-       KASSERT(size == npages << PAGE_SHIFT);
-
-       sgt->sgt_pgs = kcalloc(npages, sizeof(sgt->sgt_pgs[0]), gfp);
-       if (sgt->sgt_pgs == NULL)
-               return -ENOMEM;
-       sgt->sgt_npgs = npages;
-
-       i = 0;
-       TAILQ_FOREACH(pg, pglist, pageq.queue) {
-               KASSERT(i < npages);
-               sgt->sgt_pgs[i] = VM_PAGE_TO_PHYS(pg);
-       }
-       KASSERT(i == npages);
-
-       return 0;
-}
-
-static int
 sg_alloc_table_from_bus_dmamem(struct sg_table *sgt, bus_dma_tag_t dmat,
     const bus_dma_segment_t *segs, int nsegs, gfp_t gfp)
 {
@@ -1239,30 +1214,6 @@
        return ERR_PTR(ret);
 }
 
-struct sg_table *
-drm_prime_pglist_to_sg(struct pglist *pglist, unsigned npages)
-{
-       struct sg_table *sg;
-       int ret;
-
-       sg = kmalloc(sizeof(*sg), GFP_KERNEL);
-       if (sg == NULL) {
-               ret = -ENOMEM;
-               goto out;
-       }
-
-       ret = sg_alloc_table_from_pglist(sg, pglist, 0, npages << PAGE_SHIFT,
-           npages, GFP_KERNEL);
-       if (ret)
-               goto out;
-
-       return sg;
-
-out:
-       kfree(sg);
-       return ERR_PTR(ret);
-}
-
 bus_size_t
 drm_prime_sg_size(struct sg_table *sg)
 {
diff -r cc328ad0cd00 -r 88a98ae10756 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_clflush.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_clflush.c        Sun Dec 19 11:32:44 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_clflush.c        Sun Dec 19 11:32:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_gem_clflush.c,v 1.3 2021/12/19 11:26:35 riastradh Exp $   */
+/*     $NetBSD: i915_gem_clflush.c,v 1.4 2021/12/19 11:32:53 riastradh Exp $   */
 
 /*
  * SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_clflush.c,v 1.3 2021/12/19 11:26:35 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_clflush.c,v 1.4 2021/12/19 11:32:53 riastradh Exp $");
 
 #include "display/intel_frontbuffer.h"
 
@@ -25,7 +25,7 @@
 {
        GEM_BUG_ON(!i915_gem_object_has_pages(obj));
 #ifdef __NetBSD__
-       drm_clflush_pglist(&obj->mm.pageq);
+       drm_clflush_pages(obj->mm.pagearray, obj->base.size >> PAGE_SHIFT);
 #else
        drm_clflush_sg(obj->mm.pages);
 #endif
diff -r cc328ad0cd00 -r 88a98ae10756 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_dmabuf.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_dmabuf.c Sun Dec 19 11:32:44 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_dmabuf.c Sun Dec 19 11:32:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_gem_dmabuf.c,v 1.4 2021/12/19 11:27:20 riastradh Exp $    */
+/*     $NetBSD: i915_gem_dmabuf.c,v 1.5 2021/12/19 11:32:53 riastradh Exp $    */
 
 /*
  * SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_dmabuf.c,v 1.4 2021/12/19 11:27:20 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_dmabuf.c,v 1.5 2021/12/19 11:32:53 riastradh Exp $");
 
 #include <linux/dma-buf.h>
 #include <linux/highmem.h>
@@ -41,7 +41,7 @@
                goto err;
 
 #ifdef __NetBSD__
-       st = drm_prime_pglist_to_sg(&obj->mm.pageq,
+       st = drm_prime_pages_to_sg(obj->mm.pagearray,
            obj->base.size >> PAGE_SHIFT);
        if (IS_ERR(st))
                goto err_unpin_pages;
diff -r cc328ad0cd00 -r 88a98ae10756 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c   Sun Dec 19 11:32:44 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c   Sun Dec 19 11:32:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_gem_mman.c,v 1.4 2021/12/19 11:26:35 riastradh Exp $      */
+/*     $NetBSD: i915_gem_mman.c,v 1.5 2021/12/19 11:32:53 riastradh Exp $      */
 
 /*
  * SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_mman.c,v 1.4 2021/12/19 11:26:35 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_mman.c,v 1.5 2021/12/19 11:32:53 riastradh Exp $");
 
 #include <linux/anon_inodes.h>
 #include <linux/mman.h>
@@ -508,7 +508,9 @@
        spin_lock(&obj->mmo.lock);
 #ifdef __NetBSD__
        enum i915_mmap_type t;
-       struct vm_page *pg;
+       struct page *page;
+       struct vm_page *vm_page;
+       unsigned i;
 
        (void)mmo;
        (void)mn;
@@ -519,8 +521,11 @@
                 * XXX Gotta take some uvm object's lock, outside the
                 * spin lock, probably?
                 */
-               TAILQ_FOREACH(pg, &obj->mm.pageq, pageq.queue)
-                       pmap_page_protect(pg, VM_PROT_NONE);
+               for (i = 0; i < obj->base.size >> PAGE_SHIFT; i++) {
+                       page = obj->mm.pagearray[i];
+                       vm_page = &page->p_vmp;
+                       pmap_page_protect(vm_page, VM_PROT_NONE);
+               }
        }
 #else
        rbtree_postorder_for_each_entry_safe(mmo, mn,
diff -r cc328ad0cd00 -r 88a98ae10756 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_object_types.h
--- a/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_object_types.h   Sun Dec 19 11:32:44 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_object_types.h   Sun Dec 19 11:32:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_gem_object_types.h,v 1.4 2021/12/19 11:27:27 riastradh Exp $      */
+/*     $NetBSD: i915_gem_object_types.h,v 1.5 2021/12/19 11:32:53 riastradh Exp $      */
 
 /*
  * SPDX-License-Identifier: MIT
@@ -214,7 +214,7 @@
                struct list_head region_link;
 
 #ifdef __NetBSD__
-               struct pglist pageq;    /* wired pages of normal objects */
+               struct page **pagearray;/* wired pages of normal objects */
                struct sg_table *sg;    /* drm prime objects */
                bus_dma_segment_t *segs;/* internal objects */
                unsigned nsegs;
diff -r cc328ad0cd00 -r 88a98ae10756 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_shmem.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_shmem.c  Sun Dec 19 11:32:44 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_shmem.c  Sun Dec 19 11:32:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_gem_shmem.c,v 1.5 2021/12/19 01:44:57 riastradh Exp $     */
+/*     $NetBSD: i915_gem_shmem.c,v 1.6 2021/12/19 11:32:53 riastradh Exp $     */
 
 /*
  * SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_shmem.c,v 1.5 2021/12/19 01:44:57 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_shmem.c,v 1.6 2021/12/19 11:32:53 riastradh Exp $");
 
 #include <linux/pagevec.h>
 #include <linux/swap.h>
@@ -298,8 +298,13 @@
            (obj->read_domains & I915_GEM_DOMAIN_CPU) == 0 &&
            !(obj->cache_coherent & I915_BO_CACHE_COHERENT_FOR_READ))
 #ifdef __NetBSD__
-               /* XXX Shouldn't realy use obj->... here.  */
-               drm_clflush_pglist(&obj->mm.pageq);
+               /*
+                * XXX Should maybe use bus_dmamap_sync instead --
+                * shouldn't really touch obj->mm here since the caller
+                * already pulled off the pages.
+                */
+               drm_clflush_pages(obj->mm.pagearray,
+                   obj->base.size >> PAGE_SHIFT);
 #else
                drm_clflush_sg(pages);
 #endif
diff -r cc328ad0cd00 -r 88a98ae10756 sys/external/bsd/drm2/dist/drm/i915/i915_gem_fence_reg.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_gem_fence_reg.c  Sun Dec 19 11:32:44 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_gem_fence_reg.c  Sun Dec 19 11:32:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_gem_fence_reg.c,v 1.4 2021/12/19 11:31:26 riastradh Exp $ */
+/*     $NetBSD: i915_gem_fence_reg.c,v 1.5 2021/12/19 11:32:54 riastradh Exp $ */
 
 /*
  * Copyright © 2008-2015 Intel Corporation
@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_fence_reg.c,v 1.4 2021/12/19 11:31:26 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_fence_reg.c,v 1.5 2021/12/19 11:32:54 riastradh Exp $");
 
 #include <linux/bitmap.h>
 #include <drm/i915_drm.h>
@@ -785,36 +785,35 @@
 void
 #ifdef __NetBSD__



Home | Main Index | Thread Index | Old Index