On Wed, Jan 23, 2008 at 02:55:59PM -0500, Joe Marcus Clarke wrote:ng=20 boot=20 her=20 an=20 s:146 cture not tch ? sp. =20 =20 =46rom my reading of the code, scp would be non-NULL after the first open of the corresponding /dev/ttyvX. sc_attach_unit() creates the scp for the console and the consolectl devices. VT_WAITACTIVE ioctl is performed on arbitrary syscons /dev node, and can wait for any other screens, in particular, the screens that are not opened at the moment (the reason for the reported panic). The patch I posted may be improved by making the VT_WAITACTIVE ioctl to wait for the scp being allocated, and only then for the screen to be switched too. Please, test. diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index e0c9725..3127ae6 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -178,6 +178,7 @@ static int scparam(struct tty *tp, struct termios *t); static void scstart(struct tty *tp); static void scinit(int unit, int flags); static scr_stat *sc_get_stat(struct cdev *devptr); +static void sc_set_stat(struct cdev *devptr, scr_stat *st); static void scterm(int unit, int flags); static void scshutdown(void *arg, int howto); static u_int scgetc(sc_softc_t *sc, u_int flags); @@ -421,7 +422,7 @@ sc_attach_unit(int unit, int flags) UID_ROOT, GID_WHEEL, 0600, "ttyv%r", vc + unit * MAXCONS); sc_alloc_tty(sc->dev[vc]); if (vc =3D=3D 0 && sc->dev =3D=3D main_devs) - SC_STAT(sc->dev[0]) =3D &main_console; + sc_set_stat(sc->dev[0], &main_console); } /* * The first vty already has struct tty and scr_stat initialized @@ -434,7 +435,7 @@ sc_attach_unit(int unit, int flags) UID_ROOT, GID_WHEEL, 0600, "consolectl"); sc_console_tty =3D sc_alloc_tty(dev); ttyconsolemode(sc_console_tty, 0); - SC_STAT(dev) =3D sc_console; + sc_set_stat(dev, sc_console); =20 return 0; } @@ -525,7 +526,8 @@ scopen(struct cdev *dev, int flag, int mode, struct thr= ead *td) =20 scp =3D sc_get_stat(dev); if (scp =3D=3D NULL) { - scp =3D SC_STAT(dev) =3D alloc_scp(sc, SC_VTY(dev)); + scp =3D alloc_scp(sc, SC_VTY(dev)); + sc_set_stat(dev, scp); if (ISGRAPHSC(scp)) sc_set_pixel_mode(scp, NULL, COL, ROW, 16, 8); } @@ -1063,6 +1065,7 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, i= nt flag, struct thread *td) #endif case VT_WAITACTIVE: /* wait for switch to occur */ i =3D (*(int *)data =3D=3D 0) ? scp->index : (*(int *)data - 1); + wait_active: if ((i < sc->first_vty) || (i >=3D sc->first_vty + sc->vtys)) return EINVAL; s =3D spltty(); @@ -1071,6 +1074,12 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, = int flag, struct thread *td) if (error) return error; scp =3D sc_get_stat(SC_DEV(sc, i)); + if (scp =3D=3D NULL) { + error =3D tsleep(&(dev)->si_drv1, PZERO | PCATCH, "waitvt0", 0); + if (error) + return (error); + goto wait_active; + } if (scp =3D=3D scp->sc->cur_scp) return 0; error =3D tsleep(&scp->smode, PZERO | PCATCH, "waitvt", 0); @@ -2769,7 +2778,7 @@ scinit(int unit, int flags) UID_ROOT, GID_WHEEL, 0600, "ttyv%r", unit * MAXCONS); sc_alloc_tty(sc->dev[0]); scp =3D alloc_scp(sc, sc->first_vty); - SC_STAT(sc->dev[0]) =3D scp; + sc_set_stat(sc->dev[0], scp); } sc->cur_scp =3D scp; =20 @@ -3662,6 +3671,14 @@ sc_get_stat(struct cdev *devptr) return (SC_STAT(devptr)); } =20 +static void +sc_set_stat(struct cdev *devptr, scr_stat *st) +{ + + SC_STAT(devptr) =3D st; + wakeup(&devptr->si_drv1); +} + /* * Allocate active keyboard. Try to allocate "kbdmux" keyboard first, and, * if found, add all non-busy keyboards to "kbdmux". Otherwise look for
| Greg Kroah-Hartman | [PATCH 005/196] Chinese: add translation of SubmittingDrivers |
| Linus Torvalds | Linux 2.6.25-rc4 |
| Bart Van Assche | Integration of SCST in the mainstream Linux kernel |
| Andrew Morton | 2.6.23-rc6-mm1 |
git: | |
| Arjan van de Ven | Re: [GIT]: Networking |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
| Andrew Morton | Re: [BUG] New Kernel Bugs |
| Radu Rendec | htb parallelism on multi-core platforms |
