Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/wscons Revert previous and introduce vcons_earlyinit...



details:   https://anonhg.NetBSD.org/src/rev/4364a7b64e70
branches:  trunk
changeset: 979949:4364a7b64e70
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Jan 17 19:03:32 2021 +0000

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

diffstat:

 sys/dev/wscons/wsdisplay_vcons.c    |  65 +++++++++++++++++++++---------------
 sys/dev/wscons/wsdisplay_vconsvar.h |   6 ++-
 2 files changed, 42 insertions(+), 29 deletions(-)

diffs (135 lines):

diff -r 1e0dee729753 -r 4364a7b64e70 sys/dev/wscons/wsdisplay_vcons.c
--- a/sys/dev/wscons/wsdisplay_vcons.c  Sun Jan 17 17:16:47 2021 +0000
+++ b/sys/dev/wscons/wsdisplay_vcons.c  Sun Jan 17 19:03:32 2021 +0000
@@ -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 @@
 #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 @@
        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;
+       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;
 
-       /*
-        * 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 (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 @@
        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 */
 
diff -r 1e0dee729753 -r 4364a7b64e70 sys/dev/wscons/wsdisplay_vconsvar.h
--- a/sys/dev/wscons/wsdisplay_vconsvar.h       Sun Jan 17 17:16:47 2021 +0000
+++ b/sys/dev/wscons/wsdisplay_vconsvar.h       Sun Jan 17 19:03:32 2021 +0000
@@ -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 @@
 #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,



Home | Main Index | Thread Index | Old Index