Module Name:    src
Committed By:   jmcneill
Date:           Sun Jan 17 19:03:32 UTC 2021

Modified Files:
        src/sys/dev/wscons: wsdisplay_vcons.c wsdisplay_vconsvar.h

Log Message:
Revert previous and introduce vcons_earlyinit, which is like vcons_init
except it does not setup a vcons_intr thread.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/dev/wscons/wsdisplay_vcons.c
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/wscons/wsdisplay_vconsvar.h

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

Modified files:

Index: src/sys/dev/wscons/wsdisplay_vcons.c
diff -u src/sys/dev/wscons/wsdisplay_vcons.c:1.46 src/sys/dev/wscons/wsdisplay_vcons.c:1.47
--- src/sys/dev/wscons/wsdisplay_vcons.c:1.46	Sun Jan 17 16:51:12 2021
+++ src/sys/dev/wscons/wsdisplay_vcons.c	Sun Jan 17 19:03:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: wsdisplay_vcons.c,v 1.46 2021/01/17 16:51:12 jmcneill Exp $ */
+/*	$NetBSD: wsdisplay_vcons.c,v 1.47 2021/01/17 19:03:32 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2005, 2006 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.46 2021/01/17 16:51:12 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.47 2021/01/17 19:03:32 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -121,17 +121,18 @@ static void vcons_unlock(struct vcons_sc
 #ifdef VCONS_DRAW_INTR
 static void vcons_intr(void *);
 static void vcons_softintr(void *);
-static int vcons_intr_enable(device_t);
+static void vcons_init_thread(void *);
 #endif
 
-int
-vcons_init(struct vcons_data *vd, void *cookie, struct wsscreen_descr *def,
-    struct wsdisplay_accessops *ao)
+static int
+vcons_init_common(struct vcons_data *vd, void *cookie,
+    struct wsscreen_descr *def, struct wsdisplay_accessops *ao,
+    int enable_intr)
 {
 
 	/* zero out everything so we can rely on untouched fields being 0 */
 	memset(vd, 0, sizeof(struct vcons_data));
-	
+
 	vd->cookie = cookie;
 
 	vd->init_screen = vcons_dummy_init_screen;
@@ -174,26 +175,37 @@ vcons_init(struct vcons_data *vd, void *
 	vd->switch_poll_count = 0;
 #endif
 #ifdef VCONS_DRAW_INTR
-	vd->intr_softint = softint_establish(SOFTINT_SERIAL,
-	    vcons_softintr, vd);
-	callout_init(&vd->intr, CALLOUT_MPSAFE);
-	callout_setfunc(&vd->intr, vcons_intr, vd);
-	vd->intr_valid = 1;
-
-	/*
-	 * Defer intr drawing until after autoconfiguration has completed
-	 * to serialize device attachment messages w/ the initial screen
-	 * redraw as a workaround for the lack of MP-safeness in this
-	 * subsystem. To register with autoconf, we need to create a fake
-	 * device_t and pass that in as a handle to config_interrupts.
-	 */
-	snprintf(vd->fake_dev.dv_xname, sizeof(vd->fake_dev.dv_xname), "vcons");
-	vd->fake_dev.dv_private = vd;
-	config_finalize_register(&vd->fake_dev, vcons_intr_enable);
+	if (enable_intr) {
+		vd->intr_softint = softint_establish(SOFTINT_SERIAL,
+		    vcons_softintr, vd);
+		callout_init(&vd->intr, CALLOUT_MPSAFE);
+		callout_setfunc(&vd->intr, vcons_intr, vd);
+		vd->intr_valid = 1;
+
+		if (kthread_create(PRI_NONE, 0, NULL, vcons_init_thread, vd,
+		    NULL, "vcons_init") != 0) {
+			printf("%s: unable to create thread.\n", __func__);
+			return -1;
+		}
+	}
 #endif
 	return 0;
 }
 
+int
+vcons_init(struct vcons_data *vd, void *cookie,
+    struct wsscreen_descr *def, struct wsdisplay_accessops *ao)
+{
+	return vcons_init_common(vd, cookie, def, ao, 1);
+}
+
+int
+vcons_earlyinit(struct vcons_data *vd, void *cookie,
+    struct wsscreen_descr *def, struct wsdisplay_accessops *ao)
+{
+	return vcons_init_common(vd, cookie, def, ao, 0);
+}
+
 static void
 vcons_lock(struct vcons_screen *scr)
 {
@@ -1498,15 +1510,14 @@ vcons_softintr(void *cookie)
 	callout_schedule(&vd->intr, mstohz(33));
 }
 
-static int
-vcons_intr_enable(device_t fake_dev)
+static void
+vcons_init_thread(void *cookie)
 {
-	struct vcons_data *vd = device_private(fake_dev);
+	struct vcons_data *vd = (struct vcons_data *)cookie;
 
 	vd->use_intr = 2;
 	callout_schedule(&vd->intr, mstohz(33));
-
-	return 0;
+	kthread_exit(0);
 }
 #endif /* VCONS_DRAW_INTR */
 

Index: src/sys/dev/wscons/wsdisplay_vconsvar.h
diff -u src/sys/dev/wscons/wsdisplay_vconsvar.h:1.29 src/sys/dev/wscons/wsdisplay_vconsvar.h:1.30
--- src/sys/dev/wscons/wsdisplay_vconsvar.h:1.29	Sun Jan 17 15:13:15 2021
+++ src/sys/dev/wscons/wsdisplay_vconsvar.h	Sun Jan 17 19:03:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: wsdisplay_vconsvar.h,v 1.29 2021/01/17 15:13:15 jmcneill Exp $ */
+/*	$NetBSD: wsdisplay_vconsvar.h,v 1.30 2021/01/17 19:03:32 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2005, 2006 Michael Lorenz
@@ -143,7 +143,9 @@ struct vcons_data {
 #endif
 };
 
-int	vcons_init(struct vcons_data *, void *cookie, struct wsscreen_descr *,
+int	vcons_init(struct vcons_data *, void *, struct wsscreen_descr *,
+    struct wsdisplay_accessops *);
+int	vcons_earlyinit(struct vcons_data *, void *, struct wsscreen_descr *,
     struct wsdisplay_accessops *);
 
 int	vcons_init_screen(struct vcons_data *, struct vcons_screen *, int,

Reply via email to