Source-Changes-HG archive

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

[src/trunk]: src/sys/external/bsd i915: hack hack hack



details:   https://anonhg.NetBSD.org/src/rev/4340d9e0ad8e
branches:  trunk
changeset: 1028668:4340d9e0ad8e
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 11:38:37 2021 +0000

description:
i915: hack hack hack

diffstat:

 sys/external/bsd/common/include/linux/printk.h                  |  10 +-
 sys/external/bsd/drm2/dist/drm/i915/gt/intel_engine_cs.c        |  53 +++++++--
 sys/external/bsd/drm2/dist/drm/i915/gt/intel_engine_heartbeat.c |  12 +-
 sys/external/bsd/drm2/dist/drm/i915/gt/intel_engine_user.c      |   6 +-
 sys/external/bsd/drm2/dist/drm/i915/i915_priolist_types.h       |   4 +-
 sys/external/bsd/drm2/i915drm/files.i915drmkms                  |  11 +-
 sys/external/bsd/drm2/include/linux/hardirq.h                   |  20 ++-
 sys/external/bsd/drm2/include/linux/lockdep.h                   |  13 ++-
 sys/external/bsd/drm2/include/linux/spinlock.h                  |  12 ++-
 9 files changed, 104 insertions(+), 37 deletions(-)

diffs (truncated from 417 to 300 lines):

diff -r 8c61ca3ff4fc -r 4340d9e0ad8e sys/external/bsd/common/include/linux/printk.h
--- a/sys/external/bsd/common/include/linux/printk.h    Sun Dec 19 11:38:26 2021 +0000
+++ b/sys/external/bsd/common/include/linux/printk.h    Sun Dec 19 11:38:37 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: printk.h,v 1.10 2021/12/19 10:57:05 riastradh Exp $    */
+/*     $NetBSD: printk.h,v 1.11 2021/12/19 11:38:37 riastradh Exp $    */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -67,12 +67,12 @@
 #define        DUMP_PREFIX_OFFSET      1
 #define        DUMP_PREFIX_ADDRESS     2
 
-static inline void
+static inline size_t
 hex_dump_to_buffer(const void *buf, size_t buf_size, int bytes_per_line,
     int bytes_per_group, char *output, size_t output_size, bool ascii __unused)
 {
        const uint8_t *bytes = buf;
-       size_t i = 0, n;
+       int i = 0, t = 0, n;
 
        KASSERT(output_size >= 1);
        KASSERT((bytes_per_line == 16) || (bytes_per_line == 32));
@@ -83,6 +83,7 @@
        output[output_size - 1] = '\0';
        while (i < buf_size) {
                n = snprintf(output, output_size, "%02x", bytes[i++]);
+               t += n;
                if (n >= output_size)
                        break;
                output += n; output_size -= n;
@@ -92,10 +93,13 @@
                        n = snprintf(output, output_size, " ");
                else
                        n = 0;
+               t += n;
                if (n >= output_size)
                        break;
                output += n; output_size -= n;
        }
+
+       return t;
 }
 
 static inline void
diff -r 8c61ca3ff4fc -r 4340d9e0ad8e sys/external/bsd/drm2/dist/drm/i915/gt/intel_engine_cs.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gt/intel_engine_cs.c  Sun Dec 19 11:38:26 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gt/intel_engine_cs.c  Sun Dec 19 11:38:37 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intel_engine_cs.c,v 1.4 2021/12/19 11:08:40 riastradh Exp $    */
+/*     $NetBSD: intel_engine_cs.c,v 1.5 2021/12/19 11:38:37 riastradh Exp $    */
 
 /*
  * Copyright © 2016 Intel Corporation
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intel_engine_cs.c,v 1.4 2021/12/19 11:08:40 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intel_engine_cs.c,v 1.5 2021/12/19 11:38:37 riastradh Exp $");
 
 #include <drm/drm_print.h>
 
@@ -1059,14 +1059,22 @@
        struct tasklet_struct *t = &engine->execlists.tasklet;
 
        if (__tasklet_is_scheduled(t)) {
+#ifdef __NetBSD__
+               int s = splsoftserial();
+#else
                local_bh_disable();
+#endif
                if (tasklet_trylock(t)) {
                        /* Must wait for any GPU reset in progress. */
                        if (__tasklet_is_enabled(t))
                                t->func(t->data);
                        tasklet_unlock(t);
                }
+#ifdef __NetBSD__
+               splx(s);
+#else
                local_bh_enable();
+#endif
        }
 
        /* Otherwise flush the tasklet if it was running on another cpu */
@@ -1091,7 +1099,11 @@
 
        /* Waiting to drain ELSP? */
        if (execlists_active(&engine->execlists)) {
+#ifdef __NetBSD__
+               xc_barrier(XC_HIGHPRI);
+#else
                synchronize_hardirq(engine->i915->drm.pdev->irq);
+#endif
 
                intel_engine_flush_submission(engine);
 
@@ -1180,9 +1192,9 @@
 
        x = print_sched_attr(rq->i915, &rq->sched.attr, buf, x, sizeof(buf));
 
-       drm_printf(m, "%s %llx:%llx%s%s %s @ %dms: %s\n",
+       drm_printf(m, "%s %"PRIx64":%"PRIx64"%s%s %s @ %dms: %s\n",
                   prefix,
-                  rq->fence.context, rq->fence.seqno,
+                  (uint64_t)rq->fence.context, (uint64_t)rq->fence.seqno,
                   i915_request_completed(rq) ? "!" :
                   i915_request_started(rq) ? "*" :
                   "",
@@ -1196,6 +1208,8 @@
                   name);
 }
 
+#define        hexdump intel_hexdump
+
 static void hexdump(struct drm_printer *m, const void *buf, size_t len)
 {
        const size_t rowsize = 8 * sizeof(u32);
@@ -1248,11 +1262,19 @@
 
 static const char *repr_timer(const struct timer_list *t)
 {
+#ifdef __NetBSD__
+       if (!callout_active(__UNCONST(&t->tl_callout)))
+               return "inactive";
+
+       if (callout_pending(__UNCONST(&t->tl_callout)))
+               return "pending";
+#else
        if (!READ_ONCE(t->expires))
                return "inactive";
 
        if (timer_pending(t))
                return "active";
+#endif
 
        return "expired";
 }
@@ -1319,9 +1341,14 @@
                u8 read, write;
 
                drm_printf(m, "\tExeclist tasklet queued? %s (%s), preempt? %s, timeslice? %s\n",
+#ifdef __NetBSD__              /* XXX sigh */
+                          "<abstraction violation>",
+                          "<abstraction violation>",
+#else
                           yesno(test_bit(TASKLET_STATE_SCHED,
                                          &engine->execlists.tasklet.state)),
                           enableddisabled(!atomic_read(&engine->execlists.tasklet.count)),
+#endif
                           repr_timer(&engine->execlists.preempt),
                           repr_timer(&engine->execlists.timer));
 
@@ -1389,10 +1416,10 @@
                                intel_timeline_put(tl);
                }
                rcu_read_unlock();
-#ifdef __linux__
+#ifdef __NetBSD__
+               execlists_active_unlock_bh(execlists, s);
+#else
                execlists_active_unlock_bh(execlists);
-#else
-               execlists_active_unlock_bh(execlists, s);
 #endif
        } else if (INTEL_GEN(dev_priv) > 6) {
                drm_printf(m, "\tPP_DIR_BASE: 0x%08x\n",
@@ -1556,10 +1583,10 @@
        if (!intel_engine_supports_stats(engine))
                return -ENODEV;
 
-#ifdef __linux__
+#ifdef __NetBSD__
+       int s = execlists_active_lock_bh(execlists);
+#else
        execlists_active_lock_bh(execlists);
-#else
-       int s = execlists_active_lock_bh(execlists);
 #endif
        write_seqlock_irqsave(&engine->stats.lock, flags);
 
@@ -1590,10 +1617,10 @@
 
 unlock:
        write_sequnlock_irqrestore(&engine->stats.lock, flags);
-#ifdef __linux__
+#ifdef __NetBSD__
+       execlists_active_unlock_bh(execlists, s);
+#else
        execlists_active_unlock_bh(execlists);
-#else
-       execlists_active_unlock_bh(execlists, s);
 #endif
 
        return err;
diff -r 8c61ca3ff4fc -r 4340d9e0ad8e sys/external/bsd/drm2/dist/drm/i915/gt/intel_engine_heartbeat.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gt/intel_engine_heartbeat.c   Sun Dec 19 11:38:26 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gt/intel_engine_heartbeat.c   Sun Dec 19 11:38:37 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intel_engine_heartbeat.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $     */
+/*     $NetBSD: intel_engine_heartbeat.c,v 1.3 2021/12/19 11:38:37 riastradh Exp $     */
 
 /*
  * SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intel_engine_heartbeat.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intel_engine_heartbeat.c,v 1.3 2021/12/19 11:38:37 riastradh Exp $");
 
 #include "i915_request.h"
 
@@ -95,9 +95,17 @@
                        if (rq->sched.attr.priority >= attr.priority)
                                attr.priority = I915_PRIORITY_BARRIER;
 
+#ifdef __NetBSD__
+                       int s = splsoftserial();
+#else
                        local_bh_disable();
+#endif
                        engine->schedule(rq, &attr);
+#ifdef __NetBSD__
+                       splx(s);
+#else
                        local_bh_enable();
+#endif
                } else {
                        if (IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM))
                                show_heartbeat(rq, engine);
diff -r 8c61ca3ff4fc -r 4340d9e0ad8e sys/external/bsd/drm2/dist/drm/i915/gt/intel_engine_user.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gt/intel_engine_user.c        Sun Dec 19 11:38:26 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gt/intel_engine_user.c        Sun Dec 19 11:38:37 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intel_engine_user.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $  */
+/*     $NetBSD: intel_engine_user.c,v 1.3 2021/12/19 11:38:37 riastradh Exp $  */
 
 /*
  * SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intel_engine_user.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intel_engine_user.c,v 1.3 2021/12/19 11:38:37 riastradh Exp $");
 
 #include <linux/list.h>
 #include <linux/list_sort.h>
@@ -18,6 +18,8 @@
 #include "intel_engine_user.h"
 #include "intel_gt.h"
 
+#include <linux/nbsd-namespace.h>
+
 struct intel_engine_cs *
 intel_engine_lookup_user(struct drm_i915_private *i915, u8 class, u8 instance)
 {
diff -r 8c61ca3ff4fc -r 4340d9e0ad8e sys/external/bsd/drm2/dist/drm/i915/i915_priolist_types.h
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_priolist_types.h Sun Dec 19 11:38:26 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_priolist_types.h Sun Dec 19 11:38:37 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_priolist_types.h,v 1.2 2021/12/18 23:45:28 riastradh Exp $        */
+/*     $NetBSD: i915_priolist_types.h,v 1.3 2021/12/19 11:38:37 riastradh Exp $        */
 
 /*
  * SPDX-License-Identifier: MIT
@@ -27,7 +27,7 @@
 };
 
 #define I915_USER_PRIORITY_SHIFT 2
-#define I915_USER_PRIORITY(x) ((x) << I915_USER_PRIORITY_SHIFT)
+#define I915_USER_PRIORITY(x) ((x) * (1 << I915_USER_PRIORITY_SHIFT))
 
 #define I915_PRIORITY_COUNT BIT(I915_USER_PRIORITY_SHIFT)
 #define I915_PRIORITY_MASK (I915_PRIORITY_COUNT - 1)
diff -r 8c61ca3ff4fc -r 4340d9e0ad8e sys/external/bsd/drm2/i915drm/files.i915drmkms
--- a/sys/external/bsd/drm2/i915drm/files.i915drmkms    Sun Dec 19 11:38:26 2021 +0000
+++ b/sys/external/bsd/drm2/i915drm/files.i915drmkms    Sun Dec 19 11:38:37 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.i915drmkms,v 1.75 2021/12/19 11:38:26 riastradh Exp $
+#      $NetBSD: files.i915drmkms,v 1.76 2021/12/19 11:38:37 riastradh Exp $
 
 version        20180827
 
@@ -33,6 +33,9 @@
 makeoptions    i915drmkms      "CPPFLAGS.i915drmkms"+="-DCONFIG_DRM_I915_FORCE_PROBE=0"
 makeoptions    i915drmkms      "CPPFLAGS.i915drmkms"+="-DCONFIG_DRM_I915_SPIN_REQUEST=0"
 makeoptions    i915drmkms      "CPPFLAGS.i915drmkms"+="-DCONFIG_DRM_I915_SW_FENCE_CHECK_DAG=1" # XXX expensive debug option?
+makeoptions    i915drmkms      "CPPFLAGS.i915drmkms"+="-DCONFIG_DRM_I915_HEARTBEAT_INTERVAL=2500" # milliseconds
+makeoptions    i915drmkms      "CPPFLAGS.i915drmkms"+="-DCONFIG_DRM_I915_STOP_TIMEOUT=100" # milliseconds
+makeoptions    i915drmkms      "CPPFLAGS.i915drmkms"+="-DCONFIG_DRM_I915_PREEMPT_TIMEOUT=640" # milliseconds
 
 makeoptions    i915drmkms      "CWARNFLAGS.i915drmkms"+="-Wno-missing-field-initializers"
 makeoptions    i915drmkms      "CWARNFLAGS.i915drmkms"+="-Wno-pointer-arith"
@@ -89,8 +92,8 @@
 file   external/bsd/drm2/dist/drm/i915/display/intel_dpll_mgr.c        i915drmkms
 file   external/bsd/drm2/dist/drm/i915/display/intel_dsb.c     i915drmkms



Home | Main Index | Thread Index | Old Index