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/i915drm First pass at i915, far from c...



details:   https://anonhg.NetBSD.org/src/rev/fcbd179ece8d
branches:  trunk
changeset: 1027979:fcbd179ece8d
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 01:24:25 2021 +0000

description:
First pass at i915, far from complete.

HEAVILY MODIFIED IN MERGE - maya

diffstat:

 sys/external/bsd/drm2/dist/drm/drm_cache.c                 |    8 +-
 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_context.c |   14 +-
 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_dmabuf.c  |   26 +-
 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_object.h  |   13 +-
 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_pages.c   |   15 +-
 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_shmem.c   |   17 +-
 sys/external/bsd/drm2/dist/drm/i915/gt/gen6_ppgtt.c        |   54 +++-
 sys/external/bsd/drm2/dist/drm/i915/gt/gen8_ppgtt.c        |   86 +++++-
 sys/external/bsd/drm2/dist/drm/i915/gt/intel_ggtt.c        |  183 ++++++++----
 sys/external/bsd/drm2/dist/drm/i915/gt/intel_gtt.c         |   59 ++++-
 sys/external/bsd/drm2/dist/drm/i915/gt/intel_gtt.h         |   15 +-
 sys/external/bsd/drm2/dist/drm/i915/gvt/gtt.h              |   13 +-
 sys/external/bsd/drm2/dist/drm/i915/i915_cmd_parser.c      |   12 +-
 sys/external/bsd/drm2/dist/drm/i915/i915_dma.c             |    7 +-
 sys/external/bsd/drm2/dist/drm/i915/i915_drv.c             |   42 ++-
 sys/external/bsd/drm2/dist/drm/i915/i915_drv.h             |    7 +-
 sys/external/bsd/drm2/dist/drm/i915/i915_gem.c             |   10 +-
 sys/external/bsd/drm2/dist/drm/i915/i915_gem_evict.c       |    9 +-
 sys/external/bsd/drm2/dist/drm/i915/i915_gem_gtt.c         |   33 +-
 sys/external/bsd/drm2/dist/drm/i915/i915_perf_types.h      |    4 +-
 sys/external/bsd/drm2/dist/drm/i915/i915_request.c         |   10 +-
 sys/external/bsd/drm2/dist/drm/i915/i915_scatterlist.h     |    6 +-
 sys/external/bsd/drm2/dist/drm/i915/i915_utils.c           |   26 +-
 sys/external/bsd/drm2/dist/drm/i915/i915_vma.c             |   14 +-
 sys/external/bsd/drm2/dist/drm/i915/i915_vma.h             |   10 +-
 sys/external/bsd/drm2/dist/drm/i915/i915_vma_types.h       |   18 +-
 sys/external/bsd/drm2/i915drm/files.i915drmkms             |    7 +-
 27 files changed, 584 insertions(+), 134 deletions(-)

diffs (truncated from 1886 to 300 lines):

diff -r 0e6c8fa920f9 -r fcbd179ece8d sys/external/bsd/drm2/dist/drm/drm_cache.c
--- a/sys/external/bsd/drm2/dist/drm/drm_cache.c        Sun Dec 19 01:24:13 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/drm_cache.c        Sun Dec 19 01:24:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_cache.c,v 1.3 2021/12/18 23:44:57 riastradh Exp $  */
+/*     $NetBSD: drm_cache.c,v 1.4 2021/12/19 01:24:25 riastradh Exp $  */
 
 /**************************************************************************
  *
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_cache.c,v 1.3 2021/12/18 23:44:57 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_cache.c,v 1.4 2021/12/19 01:24:25 riastradh Exp $");
 
 #include <linux/export.h>
 #include <linux/highmem.h>
@@ -161,7 +161,11 @@
 {
 #if defined(CONFIG_X86)
        if (static_cpu_has(X86_FEATURE_CLFLUSH)) {
+#ifdef __NetBSD__
+               const int size = cpu_info_primary.ci_cflush_lsize;
+#else
                const int size = boot_cpu_data.x86_clflush_size;
+#endif
                void *end = addr + length;
 
                addr = (void *)(((unsigned long)addr) & -size);
diff -r 0e6c8fa920f9 -r fcbd179ece8d sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_context.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_context.c        Sun Dec 19 01:24:13 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_context.c        Sun Dec 19 01:24:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_gem_context.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $   */
+/*     $NetBSD: i915_gem_context.c,v 1.3 2021/12/19 01:24:25 riastradh Exp $   */
 
 /*
  * SPDX-License-Identifier: MIT
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_context.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_context.c,v 1.3 2021/12/19 01:24:25 riastradh Exp $");
 
 #include <linux/log2.h>
 #include <linux/nospec.h>
@@ -803,14 +803,24 @@
                WRITE_ONCE(vm->file, fpriv); /* XXX */
        mutex_unlock(&ctx->mutex);
 
+#ifdef __NetBSD__
+       ctx->pid = NULL;
+#else
        ctx->pid = get_task_pid(current, PIDTYPE_PID);
+#endif
        snprintf(ctx->name, sizeof(ctx->name), "%s[%d]",
+#ifdef __NetBSD__
+                curproc->p_comm, (int)curproc->p_pid));
+#else
                 current->comm, pid_nr(ctx->pid));
+#endif
 
        /* And finally expose ourselves to userspace via the idr */
        ret = xa_alloc(&fpriv->context_xa, id, ctx, xa_limit_32b, GFP_KERNEL);
+#ifndef __NetBSD__
        if (ret)
                put_pid(fetch_and_zero(&ctx->pid));
+#endif
 
        return ret;
 }
diff -r 0e6c8fa920f9 -r fcbd179ece8d 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 01:24:13 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_dmabuf.c Sun Dec 19 01:24:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_gem_dmabuf.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $    */
+/*     $NetBSD: i915_gem_dmabuf.c,v 1.3 2021/12/19 01:24:25 riastradh Exp $    */
 
 /*
  * SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_dmabuf.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_dmabuf.c,v 1.3 2021/12/19 01:24:25 riastradh Exp $");
 
 #include <linux/dma-buf.h>
 #include <linux/highmem.h>
@@ -41,7 +41,8 @@
                goto err;
 
 #ifdef __NetBSD__
-       st = drm_prime_pglist_to_sg(&obj->pageq, obj->base.size >> PAGE_SHIFT);
+       st = drm_prime_pglist_to_sg(&obj->mm.pageq,
+           obj->base.size >> PAGE_SHIFT);
        if (IS_ERR(st))
                goto err_unpin;
 #else
@@ -116,11 +117,29 @@
        i915_gem_object_unpin_map(obj);
 }
 
+#ifdef __NetBSD__
+static int i915_gem_dmabuf_mmap(struct dma_buf *dma_buf, off_t *offp,
+    size_t size, int prot, int *flagsp, int *advicep,
+    struct uvm_object **uobjp, int *maxprotp)
+#else
 static int i915_gem_dmabuf_mmap(struct dma_buf *dma_buf, struct vm_area_struct *vma)
+#endif
 {
        struct drm_i915_gem_object *obj = dma_buf_to_obj(dma_buf);
        int ret;
 
+#ifdef __NetBSD__
+       __USE(ret);
+       if (obj->base.size < size)
+               return -EINVAL;
+       if (!obj->base.filp)
+               return -ENODEV;
+       /* XXX review mmap refcount */
+       drm_gem_object_reference(&obj->base);
+       *advicep = UVM_ADV_RANDOM;
+       *uobjp = &obj->base.gemo_uvmobj;
+       *maxprotp = prot;
+#else
        if (obj->base.size < vma->vm_end - vma->vm_start)
                return -EINVAL;
 
@@ -133,6 +152,7 @@
 
        fput(vma->vm_file);
        vma->vm_file = get_file(obj->base.filp);
+#endif
 
        return 0;
 }
diff -r 0e6c8fa920f9 -r fcbd179ece8d sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_object.h
--- a/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_object.h Sun Dec 19 01:24:13 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_object.h Sun Dec 19 01:24:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_gem_object.h,v 1.2 2021/12/18 23:45:30 riastradh Exp $    */
+/*     $NetBSD: i915_gem_object.h,v 1.3 2021/12/19 01:24:25 riastradh Exp $    */
 
 /*
  * SPDX-License-Identifier: MIT
@@ -37,7 +37,11 @@
 
 extern const struct drm_i915_gem_object_ops i915_gem_shmem_ops;
 void __i915_gem_object_release_shmem(struct drm_i915_gem_object *obj,
+#ifdef __NetBSD__
+                                    bus_dmamap_t pages,
+#else
                                     struct sg_table *pages,
+#endif
                                     bool needs_clflush);
 
 int i915_gem_object_attach_phys(struct drm_i915_gem_object *obj, int align);
@@ -276,8 +280,13 @@
                                unsigned long n);
 
 void __i915_gem_object_set_pages(struct drm_i915_gem_object *obj,
+#ifdef __NetBSD__
+                                bus_dmamap_t pages
+#else
                                 struct sg_table *pages,
-                                unsigned int sg_page_sizes);
+                                unsigned int sg_page_sizes
+#endif
+                                );
 
 int ____i915_gem_object_get_pages(struct drm_i915_gem_object *obj);
 int __i915_gem_object_get_pages(struct drm_i915_gem_object *obj);
diff -r 0e6c8fa920f9 -r fcbd179ece8d sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_pages.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_pages.c  Sun Dec 19 01:24:13 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_pages.c  Sun Dec 19 01:24:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_gem_pages.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $     */
+/*     $NetBSD: i915_gem_pages.c,v 1.3 2021/12/19 01:24:25 riastradh Exp $     */
 
 /*
  * SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_pages.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_pages.c,v 1.3 2021/12/19 01:24:25 riastradh Exp $");
 
 #include "i915_drv.h"
 #include "i915_gem_object.h"
@@ -16,8 +16,13 @@
 #include "i915_gem_mman.h"
 
 void __i915_gem_object_set_pages(struct drm_i915_gem_object *obj,
+#ifdef __NetBSD__
+                                bus_dmamap_t pages,
+#else
                                 struct sg_table *pages,
-                                unsigned int sg_page_sizes)
+                                unsigned int sg_page_sizes
+#endif
+                               )
 {
        struct drm_i915_private *i915 = to_i915(obj->base.dev);
        unsigned long supported = INTEL_INFO(i915)->page_sizes;
@@ -36,8 +41,10 @@
                obj->cache_dirty = false;
        }
 
+#ifndef __NetBSD__
        obj->mm.get_page.sg_pos = pages->sgl;
        obj->mm.get_page.sg_idx = 0;
+#endif
 
        obj->mm.pages = pages;
 
@@ -48,8 +55,10 @@
                obj->mm.quirked = true;
        }
 
+#ifndef __NetBSD__
        GEM_BUG_ON(!sg_page_sizes);
        obj->mm.page_sizes.phys = sg_page_sizes;
+#endif
 
        /*
         * Calculate the supported page-sizes which fit into the given
diff -r 0e6c8fa920f9 -r fcbd179ece8d 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 01:24:13 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_shmem.c  Sun Dec 19 01:24:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_gem_shmem.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $     */
+/*     $NetBSD: i915_gem_shmem.c,v 1.3 2021/12/19 01:24:25 riastradh Exp $     */
 
 /*
  * SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_shmem.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_shmem.c,v 1.3 2021/12/19 01:24:25 riastradh Exp $");
 
 #include <linux/pagevec.h>
 #include <linux/swap.h>
@@ -282,7 +282,11 @@
 
 void
 __i915_gem_object_release_shmem(struct drm_i915_gem_object *obj,
+#ifdef __NetBSD__
+                               bus_dmamap_t pages,
+#else
                                struct sg_table *pages,
+#endif
                                bool needs_clflush)
 {
        GEM_BUG_ON(obj->mm.madv == __I915_MADV_PURGED);
@@ -293,13 +297,22 @@
        if (needs_clflush &&
            (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);
+#else
                drm_clflush_sg(pages);
+#endif
 
        __start_cpu_write(obj);
 }
 
 static void
+#ifdef __NetBSD__
+shmem_put_pages(struct drm_i915_gem_object *obj, bus_dmamap_t map)
+#else
 shmem_put_pages(struct drm_i915_gem_object *obj, struct sg_table *pages)
+#endif
 {
        struct sgt_iter sgt_iter;
        struct pagevec pvec;
diff -r 0e6c8fa920f9 -r fcbd179ece8d sys/external/bsd/drm2/dist/drm/i915/gt/gen6_ppgtt.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gt/gen6_ppgtt.c       Sun Dec 19 01:24:13 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gt/gen6_ppgtt.c       Sun Dec 19 01:24:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gen6_ppgtt.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $ */
+/*     $NetBSD: gen6_ppgtt.c,v 1.3 2021/12/19 01:24:25 riastradh Exp $ */
 
 // SPDX-License-Identifier: MIT
 /*
@@ -6,7 +6,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gen6_ppgtt.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gen6_ppgtt.c,v 1.3 2021/12/19 01:24:25 riastradh Exp $");
 
 #include <linux/log2.h>



Home | Main Index | Thread Index | Old Index