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/linux drm: Another pass over i915. Mo...



details:   https://anonhg.NetBSD.org/src/rev/0f94d2247f3b
branches:  trunk
changeset: 1028638:0f94d2247f3b
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 11:33:49 2021 +0000

description:
drm: Another pass over i915.  Most of i915 gem builds now.

diffstat:

 sys/external/bsd/common/include/linux/kernel.h              |   11 +-
 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_phys.c     |   40 +---
 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_region.c   |   63 +++++++-
 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_shmem.c    |   77 ++++++++-
 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_shrinker.c |    6 +-
 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_tiling.c   |    5 +-
 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_userptr.c  |   49 +++++-
 sys/external/bsd/drm2/dist/drm/i915/gt/intel_rps.h          |    4 +-
 sys/external/bsd/drm2/dist/drm/i915/i915_drv.h              |    7 +-
 sys/external/bsd/drm2/dist/drm/i915/i915_gem_fence_reg.c    |   52 +-----
 sys/external/bsd/drm2/dist/drm/i915/i915_gem_fence_reg.h    |    9 +-
 sys/external/bsd/drm2/dist/drm/i915/i915_irq.c              |  101 ++++++++++-
 sys/external/bsd/drm2/dist/drm/i915/i915_memcpy.c           |    6 +-
 sys/external/bsd/drm2/dist/drm/i915/i915_perf.c             |   12 +-
 sys/external/bsd/drm2/dist/drm/i915/i915_scatterlist.h      |   26 ++-
 sys/external/bsd/drm2/dist/drm/i915/intel_uncore.h          |   10 +-
 sys/external/bsd/drm2/i915drm/files.i915drmkms              |    6 +-
 sys/external/bsd/drm2/i915drm/i915_gem_userptr.c            |   11 +-
 sys/external/bsd/drm2/i915drm/i915_module.c                 |    5 +-
 sys/external/bsd/drm2/i915drm/i915_pci_autoconf.c           |    8 +-
 sys/external/bsd/drm2/include/asm/cpufeature.h              |    4 +-
 sys/external/bsd/drm2/include/linux/fs.h                    |    8 +-
 sys/external/bsd/drm2/include/linux/interrupt.h             |    4 +-
 sys/external/bsd/drm2/include/linux/ktime.h                 |    8 +-
 sys/external/bsd/drm2/include/linux/mm.h                    |   10 +-
 sys/external/bsd/drm2/include/linux/pagemap.h               |   11 +-
 sys/external/bsd/drm2/include/linux/scatterlist.h           |    5 +-
 sys/external/bsd/drm2/include/linux/sched/mm.h              |   48 +++++
 sys/external/bsd/drm2/include/linux/shmem_fs.h              |   53 ++++++-
 sys/external/bsd/drm2/linux/linux_sg.c                      |   18 +-
 30 files changed, 516 insertions(+), 161 deletions(-)

diffs (truncated from 1686 to 300 lines):

diff -r 811a1cd769f7 -r 0f94d2247f3b sys/external/bsd/common/include/linux/kernel.h
--- a/sys/external/bsd/common/include/linux/kernel.h    Sun Dec 19 11:33:30 2021 +0000
+++ b/sys/external/bsd/common/include/linux/kernel.h    Sun Dec 19 11:33:49 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kernel.h,v 1.42 2021/12/19 11:33:09 riastradh Exp $    */
+/*     $NetBSD: kernel.h,v 1.43 2021/12/19 11:33:49 riastradh Exp $    */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -261,4 +261,13 @@
 {
 }
 
+#define        DFEINE_STATIC_KEY_FALSE(FLAG)                                         \
+       bool FLAG = false
+
+static inline bool
+static_branch_likely(const bool *flagp)
+{
+       return __predict_true(*flagp);
+}
+
 #endif  /* _LINUX_KERNEL_H_ */
diff -r 811a1cd769f7 -r 0f94d2247f3b sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_phys.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_phys.c   Sun Dec 19 11:33:30 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_phys.c   Sun Dec 19 11:33:49 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_gem_phys.c,v 1.4 2021/12/19 11:33:30 riastradh Exp $      */
+/*     $NetBSD: i915_gem_phys.c,v 1.5 2021/12/19 11:33:49 riastradh Exp $      */
 
 /*
  * SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_phys.c,v 1.4 2021/12/19 11:33:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_phys.c,v 1.5 2021/12/19 11:33:49 riastradh Exp $");
 
 #include <linux/highmem.h>
 #include <linux/shmem_fs.h>
@@ -29,7 +29,7 @@
 static int i915_gem_object_get_pages_phys(struct drm_i915_gem_object *obj)
 {
 #ifdef __NetBSD__
-       struct uvm_object *uobj = obj->base.filp;
+       struct uvm_object *mapping = obj->base.filp;
 #else
        struct address_space *mapping = obj->base.filp->f_mapping;
 #endif
@@ -113,24 +113,9 @@
                struct page *page;
                void *src;
 
-#ifdef __NetBSD__
-               struct vm_page *vm_page;
-
-               /* XXX errno NetBSD->Linux */
-               ret = -uvm_obj_wirepages(uobj, i*PAGE_SIZE, (i + 1)*PAGE_SIZE,
-                   NULL);
-               if (ret)
-                       goto err_st;
-               rw_enter(uobj->vmobjlock, RW_READER);
-               vm_page = uvm_pagelookup(uobj, i*PAGE_SIZE);
-               rw_exit(uobj->vmobjlock);
-               KASSERT(vm_page);
-               page = container_of(vm_page, struct page, p_vmp);
-#else
                page = shmem_read_mapping_page(mapping, i);
                if (IS_ERR(page))
                        goto err_st;
-#endif
 
                src = kmap_atomic(page);
                memcpy(dst, src, PAGE_SIZE);
@@ -138,7 +123,7 @@
                kunmap_atomic(src);
 
 #ifdef __NetBSD__
-               uvm_obj_unwirepages(uobj, i*PAGE_SIZE, (i + 1)*PAGE_SIZE);
+               uvm_obj_unwirepages(mapping, i*PAGE_SIZE, (i + 1)*PAGE_SIZE);
 #else
                put_page(page);
 #endif
@@ -195,8 +180,7 @@
 
        if (obj->mm.dirty) {
 #ifdef __NetBSD__
-               struct uvm_object *uobj = obj->base.filp;
-               struct vm_page *vm_page;
+               struct uvm_object *mapping = obj->base.filp;
 #else
                struct address_space *mapping = obj->base.filp->f_mapping;
 #endif
@@ -207,20 +191,9 @@
                        struct page *page;
                        char *dst;
 
-#ifdef __NetBSD__
-                       if (uvm_obj_wirepages(uobj, i*PAGE_SIZE,
-                               (i + 1)*PAGE_SIZE, NULL) != 0)
-                               continue;
-                       rw_enter(uobj->vmobjlock, RW_READER);
-                       vm_page = uvm_pagelookup(uobj, i*PAGE_SIZE);
-                       rw_exit(uobj->vmobjlock);
-                       KASSERT(vm_page);
-                       page = container_of(vm_page, struct page, p_vmp);
-#else
                        page = shmem_read_mapping_page(mapping, i);
                        if (IS_ERR(page))
                                continue;
-#endif
 
                        dst = kmap_atomic(page);
                        drm_clflush_virt_range(src, PAGE_SIZE);
@@ -229,7 +202,8 @@
 
                        set_page_dirty(page);
 #ifdef __NetBSD__
-                       uvm_obj_unwirepages(uobj, i*PAGE_SIZE,
+                       /* XXX mark_page_accessed */
+                       uvm_obj_unwirepages(mapping, i*PAGE_SIZE,
                            (i + 1)*PAGE_SIZE);
 #else
                        if (obj->mm.madv == I915_MADV_WILLNEED)
diff -r 811a1cd769f7 -r 0f94d2247f3b sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_region.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_region.c Sun Dec 19 11:33:30 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_region.c Sun Dec 19 11:33:49 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_gem_region.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $    */
+/*     $NetBSD: i915_gem_region.c,v 1.3 2021/12/19 11:33:49 riastradh Exp $    */
 
 // SPDX-License-Identifier: MIT
 /*
@@ -6,7 +6,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_region.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_region.c,v 1.3 2021/12/19 11:33:49 riastradh Exp $");
 
 #include "intel_memory_region.h"
 #include "i915_gem_region.h"
@@ -20,6 +20,10 @@
        __intel_memory_region_put_pages_buddy(obj->mm.region, &obj->mm.blocks);
 
        obj->mm.dirty = false;
+#ifdef __NetBSD__
+       bus_dmamap_unload(obj->base.dev->dmat, pages->sgl->sg_dmamap);
+       bus_dmamap_destroy(obj->base.dev->dmat, pages->sgl->sg_dmamap);
+#endif
        sg_free_table(pages);
        kfree(pages);
 }
@@ -58,6 +62,50 @@
        GEM_BUG_ON(list_empty(blocks));
 
        sg = st->sgl;
+#ifdef __NetBSD__
+       __USE(prev_end);
+       __USE(sg_page_sizes);
+       bus_dma_tag_t dmat = obj->base.dev->dmat;
+       bus_dma_segment_t *segs = NULL;
+       int i = 0, nsegs = 0;
+       bool loaded = false;
+
+       list_for_each_entry(block, blocks, link) {
+               if (nsegs >= INT_MAX ||
+                   nsegs >= SIZE_MAX/sizeof(segs[0]))
+                       goto err;
+               nsegs++;
+       }
+       segs = kmem_zalloc(nsegs * sizeof(segs[0]), KM_SLEEP);
+       list_for_each_entry(block, blocks, link) {
+               u64 block_size, offset;
+
+               block_size = min_t(u64, size,
+                                  i915_buddy_block_size(&mem->mm, block));
+               offset = i915_buddy_block_offset(block);
+
+               segs[i].ds_addr = mem->region.start + offset;
+               segs[i].ds_len = block_size;
+       }
+
+       /* XXX errno NetBSD->Linux */
+       ret = -bus_dmamap_create(dmat, size, nsegs, size, 0, BUS_DMA_WAITOK,
+           &sg->sg_dmamap);
+       if (ret)
+               goto err;
+
+       /* XXX errno NetBSD->Linux */
+       ret = -bus_dmamap_load_raw(dmat, sg->sg_dmamap, segs, nsegs, size,
+           BUS_DMA_WAITOK);
+       if (ret)
+               goto err;
+       loaded = true;
+
+       kmem_free(segs, nsegs * sizeof(segs[0]));
+       segs = NULL;
+
+       __i915_gem_object_set_pages(obj, st, i915_sg_page_sizes(sg));
+#else
        st->nents = 0;
        sg_page_sizes = 0;
        prev_end = (resource_size_t)-1;
@@ -97,9 +145,20 @@
        i915_sg_trim(st);
 
        __i915_gem_object_set_pages(obj, st, sg_page_sizes);
+#endif
 
        return 0;
 
+#ifdef __NetBSD__
+err:
+       if (loaded)
+               bus_dmamap_unload(dmat, st->sgl->sg_dmamap);
+       if (st->sgl->sg_dmamap)
+               bus_dmamap_destroy(dmat, st->sgl->sg_dmamap);
+       if (segs)
+               kmem_free(segs, nsegs * sizeof(segs[0]));
+       __intel_memory_region_put_pages_buddy(mem, blocks);
+#endif
 err_free_sg:
        sg_free_table(st);
        kfree(st);
diff -r 811a1cd769f7 -r 0f94d2247f3b 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:33:30 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_shmem.c  Sun Dec 19 11:33:49 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_gem_shmem.c,v 1.7 2021/12/19 11:33:30 riastradh Exp $     */
+/*     $NetBSD: i915_gem_shmem.c,v 1.8 2021/12/19 11:33:49 riastradh Exp $     */
 
 /*
  * SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_shmem.c,v 1.7 2021/12/19 11:33:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_shmem.c,v 1.8 2021/12/19 11:33:49 riastradh Exp $");
 
 #include <linux/pagevec.h>
 #include <linux/swap.h>
@@ -23,12 +23,14 @@
  * Move pages to appropriate lru and release the pagevec, decrementing the
  * ref count of those pages.
  */
+#ifndef __NetBSD__
 static void check_release_pagevec(struct pagevec *pvec)
 {
        check_move_unevictable_pages(pvec);
        __pagevec_release(pvec);
        cond_resched();
 }
+#endif
 
 static int shmem_get_pages(struct drm_i915_gem_object *obj)
 {
@@ -36,7 +38,11 @@
        struct intel_memory_region *mem = obj->mm.region;
        const unsigned long page_count = obj->base.size / PAGE_SIZE;
        unsigned long i;
+#ifdef __NetBSD__
+       struct uvm_object *mapping;
+#else
        struct address_space *mapping;
+#endif
        struct sg_table *st;
        struct scatterlist *sg;
        struct sgt_iter sgt_iter;
@@ -44,7 +50,9 @@
        unsigned long last_pfn = 0;     /* suppress gcc warning */
        unsigned int max_segment = i915_sg_segment_size();
        unsigned int sg_page_sizes;
+#ifndef __NetBSD__
        struct pagevec pvec;
+#endif
        gfp_t noreclaim;
        int ret;
 
@@ -79,10 +87,14 @@
         *
         * Fail silently without starting the shrinker
         */
+#ifdef __NetBSD__
+       mapping = obj->base.filp;
+#else
        mapping = obj->base.filp->f_mapping;
        mapping_set_unevictable(mapping);
        noreclaim = mapping_gfp_constraint(mapping, ~__GFP_RECLAIM);
        noreclaim |= __GFP_NORETRY | __GFP_NOWARN;
+#endif
 
        sg = st->sgl;
        st->nents = 0;
@@ -116,6 +128,7 @@
                         * defer the oom here by reporting the ENOMEM back
                         * to userspace.
                         */



Home | Main Index | Thread Index | Old Index