Module Name:    src
Committed By:   riastradh
Date:           Sun Dec 19 11:39:25 UTC 2021

Modified Files:
        src/sys/external/bsd/common/include/linux: list.h
        src/sys/external/bsd/drm2/dist/drm/i915: i915_scheduler.c
        src/sys/external/bsd/drm2/dist/drm/i915/gt: intel_engine_cs.c
        src/sys/external/bsd/drm2/i915drm: files.i915drmkms
        src/sys/external/bsd/drm2/include/linux: llist.h notifier.h
        src/sys/external/bsd/drm2/linux: files.drmkms_linux
Added Files:
        src/sys/external/bsd/drm2/linux: linux_notifier.c

Log Message:
i915: more work


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/external/bsd/common/include/linux/list.h
cvs rdiff -u -r1.5 -r1.6 \
    src/sys/external/bsd/drm2/dist/drm/i915/i915_scheduler.c
cvs rdiff -u -r1.5 -r1.6 \
    src/sys/external/bsd/drm2/dist/drm/i915/gt/intel_engine_cs.c
cvs rdiff -u -r1.76 -r1.77 src/sys/external/bsd/drm2/i915drm/files.i915drmkms
cvs rdiff -u -r1.4 -r1.5 src/sys/external/bsd/drm2/include/linux/llist.h
cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/drm2/include/linux/notifier.h
cvs rdiff -u -r1.32 -r1.33 src/sys/external/bsd/drm2/linux/files.drmkms_linux
cvs rdiff -u -r0 -r1.1 src/sys/external/bsd/drm2/linux/linux_notifier.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/common/include/linux/list.h
diff -u src/sys/external/bsd/common/include/linux/list.h:1.31 src/sys/external/bsd/common/include/linux/list.h:1.32
--- src/sys/external/bsd/common/include/linux/list.h:1.31	Sun Dec 19 11:38:03 2021
+++ src/sys/external/bsd/common/include/linux/list.h	Sun Dec 19 11:39:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: list.h,v 1.31 2021/12/19 11:38:03 riastradh Exp $	*/
+/*	$NetBSD: list.h,v 1.32 2021/12/19 11:39:24 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -47,6 +47,8 @@
 #include <linux/kernel.h>
 #include <linux/types.h>
 
+#define	POISON_INUSE	0x5a	/* XXX */
+
 /*
  * Doubly-linked lists.  Type defined in <linux/types.h>.
  */

Index: src/sys/external/bsd/drm2/dist/drm/i915/i915_scheduler.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/i915_scheduler.c:1.5 src/sys/external/bsd/drm2/dist/drm/i915/i915_scheduler.c:1.6
--- src/sys/external/bsd/drm2/dist/drm/i915/i915_scheduler.c:1.5	Sun Dec 19 11:37:50 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/i915_scheduler.c	Sun Dec 19 11:39:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: i915_scheduler.c,v 1.5 2021/12/19 11:37:50 riastradh Exp $	*/
+/*	$NetBSD: i915_scheduler.c,v 1.6 2021/12/19 11:39:24 riastradh Exp $	*/
 
 /*
  * SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_scheduler.c,v 1.5 2021/12/19 11:37:50 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_scheduler.c,v 1.6 2021/12/19 11:39:24 riastradh Exp $");
 
 #include <linux/mutex.h>
 
@@ -116,15 +116,19 @@ static const rb_tree_ops_t i915_priolist
 	.rbto_node_offset = offsetof(struct i915_priolist, node),
 };
 
+#endif
+
 void
 i915_sched_init(struct intel_engine_execlists *execlists)
 {
 
+#ifdef __NetBSD__
 	rb_tree_init(&execlists->queue.rb_root.rbr_tree,
 	    &i915_priolist_rb_ops);
-}
-
+#else
+	execlists->queue = RB_ROOT_CACHED;
 #endif
+}
 
 struct list_head *
 i915_sched_lookup_priolist(struct intel_engine_cs *engine, int prio)

Index: src/sys/external/bsd/drm2/dist/drm/i915/gt/intel_engine_cs.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/gt/intel_engine_cs.c:1.5 src/sys/external/bsd/drm2/dist/drm/i915/gt/intel_engine_cs.c:1.6
--- src/sys/external/bsd/drm2/dist/drm/i915/gt/intel_engine_cs.c:1.5	Sun Dec 19 11:38:37 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/gt/intel_engine_cs.c	Sun Dec 19 11:39:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: intel_engine_cs.c,v 1.5 2021/12/19 11:38:37 riastradh Exp $	*/
+/*	$NetBSD: intel_engine_cs.c,v 1.6 2021/12/19 11:39:24 riastradh Exp $	*/
 
 /*
  * Copyright © 2016 Intel Corporation
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intel_engine_cs.c,v 1.5 2021/12/19 11:38:37 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intel_engine_cs.c,v 1.6 2021/12/19 11:39:24 riastradh Exp $");
 
 #include <drm/drm_print.h>
 
@@ -490,7 +490,7 @@ void intel_engine_init_execlists(struct 
 		memset(execlists->inflight, 0, sizeof(execlists->inflight));
 
 	execlists->queue_priority_hint = INT_MIN;
-	execlists->queue = RB_ROOT_CACHED;
+	i915_sched_init(execlists);
 }
 
 static void cleanup_status_page(struct intel_engine_cs *engine)

Index: src/sys/external/bsd/drm2/i915drm/files.i915drmkms
diff -u src/sys/external/bsd/drm2/i915drm/files.i915drmkms:1.76 src/sys/external/bsd/drm2/i915drm/files.i915drmkms:1.77
--- src/sys/external/bsd/drm2/i915drm/files.i915drmkms:1.76	Sun Dec 19 11:38:37 2021
+++ src/sys/external/bsd/drm2/i915drm/files.i915drmkms	Sun Dec 19 11:39:24 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.i915drmkms,v 1.76 2021/12/19 11:38:37 riastradh Exp $
+#	$NetBSD: files.i915drmkms,v 1.77 2021/12/19 11:39:24 riastradh Exp $
 
 version	20180827
 
@@ -13,10 +13,7 @@ attach	intelfb at intelfbbus
 # overflow is OK.
 makeoptions 	i915drmkms	"COPTS.i915drmkms"+="-fwrapv"
 
-makeoptions	intelfb		"CPPFLAGS.intelfb"+="-I$S/external/bsd/drm2/i915drm"
 makeoptions	i915drmkms	"CPPFLAGS.i915drmkms"+="-I$S/external/bsd/drm2/i915drm"
-
-makeoptions	intelfb		"CPPFLAGS.intelfb"+="-I$S/external/bsd/drm2/dist/drm/i915"
 makeoptions	i915drmkms	"CPPFLAGS.i915drmkms"+="-I$S/external/bsd/drm2/dist/drm/i915"
 
 makeoptions	i915drmkms	"CPPFLAGS.i915drmkms"+="-DCONFIG_DRM_FBDEV_EMULATION=1"
@@ -50,6 +47,9 @@ makeoptions 	i915drmkms 	"CWARNFLAGS.int
 makeoptions 	i915drmkms 	"CWARNFLAGS.intel_display.c"+="${${ACTIVE_CC} == gcc && ${HAVE_GCC:U0} >= 7:? -Wno-implicit-fallthrough :}"
 makeoptions 	i915drmkms 	"CWARNFLAGS.intel_sdvo.c"+="${${ACTIVE_CC} == gcc && ${HAVE_GCC:U0} >= 7:? -Wno-implicit-fallthrough :}"
 
+makeoptions	intelfb		"CPPFLAGS.intelfb"+="${CPPFLAGS.i915drmkms}"
+makeoptions	intelfb		"CWARNFLAGS.intelfb"+="${CWARNFLAGS.i915drmkms}"
+
 file	external/bsd/drm2/i915drm/i915_gem_userptr.c	i915drmkms
 file	external/bsd/drm2/i915drm/i915_gemfs.c	i915drmkms
 file	external/bsd/drm2/i915drm/i915_module.c		i915drmkms

Index: src/sys/external/bsd/drm2/include/linux/llist.h
diff -u src/sys/external/bsd/drm2/include/linux/llist.h:1.4 src/sys/external/bsd/drm2/include/linux/llist.h:1.5
--- src/sys/external/bsd/drm2/include/linux/llist.h:1.4	Sun Dec 19 11:36:48 2021
+++ src/sys/external/bsd/drm2/include/linux/llist.h	Sun Dec 19 11:39:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: llist.h,v 1.4 2021/12/19 11:36:48 riastradh Exp $	*/
+/*	$NetBSD: llist.h,v 1.5 2021/12/19 11:39:24 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -110,6 +110,11 @@ llist_del_first(struct llist_head *head)
 	    llist_entry(_NODE, __typeof__(*(ENTRY)), FIELD));		      \
 })
 
+#define	llist_for_each_safe(NODE, TMP, HEAD)				      \
+	for ((NODE) = (HEAD);						      \
+		(NODE) && ((TMP) = (NODE)->next, 1);			      \
+		(NODE) = (TMP))
+
 #define	llist_for_each_entry(ENTRY, NODE, FIELD)			      \
 	for ((ENTRY) = ((NODE) == NULL ? NULL :				      \
 		    (membar_datadep_consumer(),				      \

Index: src/sys/external/bsd/drm2/include/linux/notifier.h
diff -u src/sys/external/bsd/drm2/include/linux/notifier.h:1.3 src/sys/external/bsd/drm2/include/linux/notifier.h:1.4
--- src/sys/external/bsd/drm2/include/linux/notifier.h:1.3	Mon Aug 27 07:18:18 2018
+++ src/sys/external/bsd/drm2/include/linux/notifier.h	Sun Dec 19 11:39:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: notifier.h,v 1.3 2018/08/27 07:18:18 riastradh Exp $	*/
+/*	$NetBSD: notifier.h,v 1.4 2021/12/19 11:39:24 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -34,30 +34,38 @@
 
 #include <sys/cdefs.h>
 
+#include <sys/pslist.h>
+
+#include <linux/spinlock.h>
+
+/* namespace */
+#define	ATOMIC_INIT_NOTIFIER_HEAD	linux_ATOMIC_INIT_NOTIFIER_HEAD
+#define	ATOMIC_CLEANUP_NOTIFIER_HEAD	linux_ATOMIC_CLEANUP_NOTIFIER_HEAD
+#define	atomic_notifier_call_chain	linux_atomic_notifier_call_chain
+#define	atomic_notifier_chain_register	linux_atomic_notifier_chain_register
+#define	atomic_notifier_chain_unregister linux_atomic_notifier_chain_unregister
+
 #define	NOTIFY_DONE	0
 #define	NOTIFY_OK	1
 
 struct notifier_block {
-	int	(*notifier_call)(struct notifier_block *, unsigned long,
-		    void *);
+	int (*notifier_call)(struct notifier_block *, unsigned long, void *);
+	struct pslist_entry	nb_entry;
 };
 
 struct atomic_notifier_head {
-	char	anh_blahdittyblahblah;
+	spinlock_t		anh_lock;
+	struct pslist_head	anh_list;
 };
 
-static struct atomic_notifier_head panic_notifier_list __unused;
+void ATOMIC_INIT_NOTIFIER_HEAD(struct atomic_notifier_head *);
+void ATOMIC_CLEANUP_NOTIFIER_HEAD(struct atomic_notifier_head *);
 
-static inline void
-atomic_notifier_chain_register(struct atomic_notifier_head *head __unused,
-    struct notifier_block *block __unused)
-{
-}
-
-static inline void
-atomic_notifier_chain_unregister(struct atomic_notifier_head *head __unused,
-    struct notifier_block *block __unused)
-{
-}
+void atomic_notifier_chain_register(struct atomic_notifier_head *,
+    struct notifier_block *);
+void atomic_notifier_chain_unregister(struct atomic_notifier_head *,
+    struct notifier_block *);
+void atomic_notifier_chain_call(struct atomic_notifier_head *, unsigned long,
+    void *);
 
 #endif  /* _LINUX_NOTIFIER_H_ */

Index: src/sys/external/bsd/drm2/linux/files.drmkms_linux
diff -u src/sys/external/bsd/drm2/linux/files.drmkms_linux:1.32 src/sys/external/bsd/drm2/linux/files.drmkms_linux:1.33
--- src/sys/external/bsd/drm2/linux/files.drmkms_linux:1.32	Sun Dec 19 11:33:31 2021
+++ src/sys/external/bsd/drm2/linux/files.drmkms_linux	Sun Dec 19 11:39:24 2021
@@ -1,4 +1,4 @@
-#       $NetBSD: files.drmkms_linux,v 1.32 2021/12/19 11:33:31 riastradh Exp $
+#       $NetBSD: files.drmkms_linux,v 1.33 2021/12/19 11:39:24 riastradh Exp $
 
 define	drmkms_linux: i2cexec, i2c_bitbang
 
@@ -19,6 +19,7 @@ file	external/bsd/drm2/linux/linux_idr.c
 file	external/bsd/drm2/linux/linux_kmap.c		drmkms_linux
 file	external/bsd/drm2/linux/linux_list_sort.c	drmkms_linux
 file	external/bsd/drm2/linux/linux_module.c		drmkms_linux
+file	external/bsd/drm2/linux/linux_notifier.c	drmkms_linux
 file	external/bsd/drm2/linux/linux_pci.c		drmkms_linux
 file	external/bsd/drm2/linux/linux_rwsem.c		drmkms_linux
 file	external/bsd/drm2/linux/linux_sg.c		drmkms_linux

Added files:

Index: src/sys/external/bsd/drm2/linux/linux_notifier.c
diff -u /dev/null src/sys/external/bsd/drm2/linux/linux_notifier.c:1.1
--- /dev/null	Sun Dec 19 11:39:25 2021
+++ src/sys/external/bsd/drm2/linux/linux_notifier.c	Sun Dec 19 11:39:24 2021
@@ -0,0 +1,95 @@
+/*	$NetBSD: linux_notifier.c,v 1.1 2021/12/19 11:39:24 riastradh Exp $	*/
+
+/*-
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: linux_notifier.c,v 1.1 2021/12/19 11:39:24 riastradh Exp $");
+
+#include <sys/types.h>
+
+#include <sys/pserialize.h>
+#include <sys/xcall.h>
+
+#include <linux/notifier.h>
+#include <linux/spinlock.h>
+
+void
+ATOMIC_INIT_NOTIFIER_HEAD(struct atomic_notifier_head *H)
+{
+
+	spin_lock_init(&H->anh_lock);
+	PSLIST_INIT(&H->anh_list);
+}
+
+void
+ATOMIC_CLEANUP_NOTIFIER_HEAD(struct atomic_notifier_head *H)
+{
+
+	PSLIST_DESTROY(&H->anh_list);
+	spin_lock_destroy(&H->anh_lock);
+}
+
+void
+atomic_notifier_chain_register(struct atomic_notifier_head *H,
+    struct notifier_block *B)
+{
+
+	spin_lock(&H->anh_lock);
+	PSLIST_WRITER_INSERT_HEAD(&H->anh_list, B, nb_entry);
+	spin_unlock(&H->anh_lock);
+}
+
+void
+atomic_notifier_chain_unregister(struct atomic_notifier_head *H,
+    struct notifier_block *B)
+{
+
+	spin_lock(&H->anh_lock);
+	PSLIST_WRITER_REMOVE(B, nb_entry);
+	spin_unlock(&H->anh_lock);
+
+	xc_barrier(0);
+}
+
+void
+atomic_notifier_chain_call(struct atomic_notifier_head *H,
+    unsigned long arg0, void *arg1)
+{
+	struct notifier_block *B;
+	int s;
+
+	s = pserialize_read_enter();
+	PSLIST_READER_FOREACH(B, &H->anh_list, struct notifier_block, nb_entry)
+	{
+		if ((*B->notifier_call)(B, arg0, arg1) == NOTIFY_DONE)
+			break;
+	}
+	pserialize_read_exit(s);
+}

Reply via email to