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/i915/gem Hack it up: disable ...



details:   https://anonhg.NetBSD.org/src/rev/08944d05ab69
branches:  trunk
changeset: 1028020:08944d05ab69
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 01:39:57 2021 +0000

description:
Hack it up: disable no-fault fast paths, fix fd API, ifdef out stuff.

diffstat:

 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_execbuffer.c |  53 ++++++++++-
 1 files changed, 51 insertions(+), 2 deletions(-)

diffs (166 lines):

diff -r 240e57556af5 -r 08944d05ab69 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_execbuffer.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_execbuffer.c     Sun Dec 19 01:39:48 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_execbuffer.c     Sun Dec 19 01:39:57 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_gem_execbuffer.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $        */
+/*     $NetBSD: i915_gem_execbuffer.c,v 1.3 2021/12/19 01:39:57 riastradh Exp $        */
 
 /*
  * SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_execbuffer.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_execbuffer.c,v 1.3 2021/12/19 01:39:57 riastradh Exp $");
 
 #include <linux/intel-iommu.h>
 #include <linux/dma-resv.h>
@@ -951,7 +951,11 @@
                struct i915_ggtt *ggtt = cache_to_ggtt(cache);
 
                intel_gt_flush_ggtt_writes(ggtt->vm.gt);
+#ifdef __NetBSD__
+               io_mapping_unmap_atomic(&ggtt->iomap, vaddr);
+#else
                io_mapping_unmap_atomic((void __iomem *)vaddr);
+#endif
 
                if (drm_mm_node_allocated(&cache->node)) {
                        ggtt->vm.clear_range(&ggtt->vm,
@@ -1011,7 +1015,12 @@
 
        if (cache->vaddr) {
                intel_gt_flush_ggtt_writes(ggtt->vm.gt);
+#ifdef __NetBSD__
+               io_mapping_unmap_atomic(&ggtt->iomap,
+                   unmask_page(cache->vaddr));
+#else
                io_mapping_unmap_atomic((void __force __iomem *) unmask_page(cache->vaddr));
+#endif
        } else {
                struct i915_vma *vma;
                int err;
@@ -1435,8 +1444,10 @@
 
        urelocs = u64_to_user_ptr(entry->relocs_ptr);
        remain = entry->relocation_count;
+#ifndef _LP64          /* XXX why, gcc, do you make it hard to be safe */
        if (unlikely(remain > N_RELOC(ULONG_MAX)))
                return -EINVAL;
+#endif
 
        /*
         * We must check that the entire relocation array is safe
@@ -1460,9 +1471,13 @@
                 * we would try to acquire the struct mutex again. Obviously
                 * this is bad and so lockdep complains vehemently.
                 */
+#ifdef __NetBSD__              /* XXX copy fastpath */
+               copied = 1;
+#else
                pagefault_disable();
                copied = __copy_from_user_inatomic(r, urelocs, count * sizeof(r[0]));
                pagefault_enable();
+#endif
                if (unlikely(copied)) {
                        remain = -EFAULT;
                        goto out;
@@ -1670,10 +1685,17 @@
        int err = 0;
 
 repeat:
+#ifdef __NetBSD__
+       if (sigispending(curlwp, 0)) {
+               err = -ERESTARTSYS;
+               goto out;
+       }
+#else
        if (signal_pending(current)) {
                err = -ERESTARTSYS;
                goto out;
        }
+#endif
 
        /* We may process another execbuffer during the unlock... */
        eb_reset_vmas(eb);
@@ -1724,9 +1746,13 @@
 
        list_for_each_entry(vma, &eb->relocs, reloc_link) {
                if (!have_copy) {
+#ifdef __NetBSD__
+                       err = -EFAULT;
+#else
                        pagefault_disable();
                        err = eb_relocate_vma(eb, vma);
                        pagefault_enable();
+#endif
                        if (err)
                                goto repeat;
                } else {
@@ -2573,6 +2599,9 @@
        struct dma_fence *exec_fence = NULL;
        struct sync_file *out_fence = NULL;
        int out_fence_fd = -1;
+#ifdef __NetBSD__
+       struct file *fp = NULL;
+#endif
        int err;
 
        BUILD_BUG_ON(__EXEC_INTERNAL_FLAGS & ~__I915_EXEC_ILLEGAL_FLAGS);
@@ -2635,11 +2664,17 @@
        }
 
        if (args->flags & I915_EXEC_FENCE_OUT) {
+#ifdef __NetBSD__
+               err = -fd_allocfile(&fp, &out_fence_fd);
+               if (err)
+                       goto err_in_fence;
+#else
                out_fence_fd = get_unused_fd_flags(O_CLOEXEC);
                if (out_fence_fd < 0) {
                        err = out_fence_fd;
                        goto err_exec_fence;
                }
+#endif
        }
 
        err = eb_create(&eb);
@@ -2748,7 +2783,11 @@
        }
 
        if (out_fence_fd != -1) {
+#ifdef __NetBSD__
+               out_fence = sync_file_create(&eb.request->fence, fp);
+#else
                out_fence = sync_file_create(&eb.request->fence);
+#endif
                if (!out_fence) {
                        err = -ENOMEM;
                        goto err_request;
@@ -2783,7 +2822,13 @@
                        args->rsvd2 |= (u64)out_fence_fd << 32;
                        out_fence_fd = -1;
                } else {
+#ifdef __NetBSD__
+                       fd_abort(curproc, fp, out_fence_fd);
+                       out_fence_fd = -1;
+                       fp = NULL;
+#else
                        fput(out_fence->file);
+#endif
                }
        }
        i915_request_put(eb.request);
@@ -2807,7 +2852,11 @@
        eb_destroy(&eb);
 err_out_fence:
        if (out_fence_fd != -1)
+#ifdef __NetBSD__
+               fd_abort(curproc, fp, out_fence_fd);
+#else
                put_unused_fd(out_fence_fd);
+#endif
 err_exec_fence:
        dma_fence_put(exec_fence);
 err_in_fence:



Home | Main Index | Thread Index | Old Index