Subject: wsfb and two virtual displays and VT_ACTIVATE failed and properly
To: None <tech-x11@netbsd.org>
From: Jeremy C. Reed <reed@reedmedia.net>
List: tech-x11
Date: 12/21/2006 09:10:41
This email has two do with two questions but related to maybe same 
problem. I am using Xorg from Xorg, but feel free to share advice or 
answers for XFree86 or Xorg from NetBSD is applicable.

I am using wsfb on wsdisplay on vesafb.

1) Does wsfb support allow starting X on two different displays (on same 
hardware)?

When I was already in X (:0), I did a "Xorg :2". It failed with:

(WW) xf86OpenConsole: VT_ACTIVATE failed

The X display I was at disappeared (but X and apps were still running).

Also the "Xorg :2" process was running (but not seen).

All I could see was now the non-X normal text console. It showed some X 
startup messages from before.

Killing the second Xorg process failed, so sent it a sigkill. I had to ssh 
in and reboot to use the keyboard and display again.

2) How can I troubleshoot the "VT_ACTIVATE failed"? I also have that 
problem when Xorg fails at startup (due to configuration error) it doesn't 
reset correctly so, next time starting does the "VT_ACTIVATE failed".

Here are some notes and kdump details:

I commented out the Mouse Protocol and Option for my InputDevice in my 
xorg.conf.

Both xserver 1.1.99.903 and older xserver 1.1.1 fail with:

(EE) Mouse0: No Protocol specified
(EE) PreInit failed for input device "Mouse0"
(II) UnloadModule: "mouse"
(**) Option "CoreKeyboard"
...
(WW) No core pointer registered
(II) XINPUT: Adding extended input device "Keyboard0" (type: KEYBOARD)
(WW) Couldn't load XKB keymap, falling back to pre-XKB keymap
No core pointer

Fatal server error:
failed to initialize core devices

Which is fine. (I know I can use -allowMouseOpenFail or MouseOpenFail but 
that is not related to my problem.)

The end of my ktracing follows:

   696      1 Xorg     CALL  clock_gettime(3,0xbfbfeb00)
   696      1 Xorg     RET   clock_gettime 0
   696      1 Xorg     CALL  ioctl(6,_IO('K',0x42),0)
   696      1 Xorg     RET   ioctl 0
   696      1 Xorg     CALL  write(2,0x81b6440,0x10)
   696      1 Xorg     GIO   fd 2 wrote 16 bytes
       "No core pointer
       "
   696      1 Xorg     RET   write 16/0x10
   696      1 Xorg     CALL  write(0,0x81b6440,0x10)
   696      1 Xorg     GIO   fd 0 wrote 16 bytes
       "No core pointer
       "
   696      1 Xorg     RET   write 16/0x10
   696      1 Xorg     CALL  write(2,0x81b6440,0x15)
   696      1 Xorg     GIO   fd 2 wrote 21 bytes
       "
	Fatal server error:
       "
   696      1 Xorg     RET   write 21/0x15
   696      1 Xorg     CALL  write(0,0x81b6440,0x15)
   696      1 Xorg     GIO   fd 0 wrote 21 bytes
       "
	Fatal server error:
       "
   696      1 Xorg     RET   write 21/0x15
   696      1 Xorg     CALL  write(2,0x81b6440,0x21)
   696      1 Xorg     GIO   fd 2 wrote 33 bytes
       "failed to initialize core devices"
   696      1 Xorg     RET   write 33/0x21
   696      1 Xorg     CALL  write(0,0x81b6440,0x21)
   696      1 Xorg     GIO   fd 0 wrote 33 bytes
       "failed to initialize core devices"
   696      1 Xorg     RET   write 33/0x21
   696      1 Xorg     CALL  write(2,0x81b6440,1)
   696      1 Xorg     GIO   fd 2 wrote 1 bytes
       "
       "
   696      1 Xorg     RET   write 1
   696      1 Xorg     CALL  write(0,0x81b6440,1)
   696      1 Xorg     GIO   fd 0 wrote 1 bytes
       "
       "
   696      1 Xorg     RET   write 1
   696      1 Xorg     CALL  unlink(0x81b5fa0)
   696      1 Xorg     NAMI  "/tmp/.X0-lock"
   696      1 Xorg     RET   unlink 0
   696      1 Xorg     CALL  __sigprocmask14(1,0xbfbfec14,0xbfbfec04)
   696      1 Xorg     RET   __sigprocmask14 0
   696      1 Xorg     CALL  ioctl(6,_IO('K',0xa),0)
   696      1 Xorg     RET   ioctl 0
   696      1 Xorg     CALL  ioctl(6,_IOR('v',0x3,0x8),0xbfbfec90)
   696      1 Xorg     GIO   fd 6 read 8 bytes
       "\^A\0\^^\0\^^\0\^^\0"
   696      1 Xorg     RET   ioctl 0
   696      1 Xorg     CALL  ioctl(6,_IOW('v',0x2,0x8),0xbfbfec90)
   696      1 Xorg     GIO   fd 6 wrote 8 bytes
       "\0\0\^^\0\^^\0\^^\0"
   696      1 Xorg     RET   ioctl 0
   696      1 Xorg     CALL  ioctl(6,_IO('v',0x5),1)
   696      1 Xorg     RET   ioctl 0
   696      1 Xorg     CALL  close(6)
   696      1 Xorg     RET   close 0
   696      1 Xorg     CALL  close(0)
   696      1 Xorg     RET   close 0
   696      1 Xorg     CALL  exit(1)

My problem is that my console is not reset correctly. Sometimes, I just 
have a plain text console that is locked up -- can't type and only see 
previous text from the Xorg startup. Or sometimes, I can type, but garbage 
different characters are displayed. (I have had similar problem for 
probably a year or more).

I am guessing that some ioctl() failed above. Or some ioctl was accidently 
skipped.

I am looking at

    OsCleanup() which looks like it just calls UnlockServer (which does 
work).

and AbortDDX(). I read in dmxinit_8c.html: "We must ensure that backend 
and console state is restored in the event the server shutdown wasn't 
clean." And ./hw/xfree86/common/xf86Init.c defines the AbortDDX I think I 
am using: " The attempt is made to restore all original setting of the 
displays. Also all devices are closed."

If you can give me any hints on where to look for 
making sure Xorg properly exits on failure I will look further.

Note that shutting down X normally works fine for me (like exiting my 
window manager) and my console works great after X exits.

If I try starting Xorg again (via a remote login), it fails with:

...
(II) Module pcidata: vendor="X.Org Foundation"
        compiled for 7.1.99.903, module version = 1.0.0
        ABI class: X.Org Video Driver, version 1.0
(--) Using wscons driver in pcvt compatibility mode (version 3.32)
(WW) xf86OpenConsole: VT_ACTIVATE failed

And again my shell is disabled until I kill -9 that. (kill -TERM doesn't 
work.)

The last 100 lines of my kdump from that are here (including up until I 
kill it):

  7336      1 Xorg     RET   close 0
  7336      1 Xorg     CALL  write(0,0x81b6440,0x2f)
  7336      1 Xorg     GIO   fd 0 wrote 47 bytes
       "(II) Module pcidata: vendor=\"X.Org Foundation\"
       "
  7336      1 Xorg     RET   write 47/0x2f
  7336      1 Xorg     CALL  write(0,0x81b6440,0x14)
  7336      1 Xorg     GIO   fd 0 wrote 20 bytes
       "	compiled for 7.1.99"
  7336      1 Xorg     RET   write 20/0x14
  7336      1 Xorg     CALL  write(0,0x81b6440,4)
  7336      1 Xorg     GIO   fd 0 wrote 4 bytes
       ".903"
  7336      1 Xorg     RET   write 4
  7336      1 Xorg     CALL  write(0,0x81b6440,0x19)
  7336      1 Xorg     GIO   fd 0 wrote 25 bytes
       ", module version = 1.0.0
       "
  7336      1 Xorg     RET   write 25/0x19
  7336      1 Xorg     CALL  write(0,0x81b6440,0x2c)
  7336      1 Xorg     GIO   fd 0 wrote 44 bytes
       "	ABI class: X.Org Video Driver, version 1.0
       "
  7336      1 Xorg     RET   write 44/0x2c
  7336      1 Xorg     CALL  geteuid
  7336      1 Xorg     RET   geteuid 0
  7336      1 Xorg     CALL  getpid
  7336      1 Xorg     RET   getpid 7336/0x1ca8, 22191/0x56af
  7336      1 Xorg     CALL  setpgid(0,0x1ca8)
  7336      1 Xorg     RET   setpgid 0
  7336      1 Xorg     CALL  open(0x818db6f,2,0x81a0fb4)
  7336      1 Xorg     NAMI  "/dev/tty"
  7336      1 Xorg     RET   open 6
  7336      1 Xorg     CALL  ioctl(6,TIOCNOTTY,0)
  7336      1 Xorg     RET   ioctl 0
  7336      1 Xorg     CALL  close(6)
  7336      1 Xorg     RET   close 0
  7336      1 Xorg     CALL  open(0x818db4c,6,0)
  7336      1 Xorg     NAMI  "/dev/ttyv0"
  7336      1 Xorg     RET   open -1 errno 2 No such file or directory
  7336      1 Xorg     CALL  open(0x818dbe1,6,0)
  7336      1 Xorg     NAMI  "/dev/ttyE0"
  7336      1 Xorg     RET   open 6
  7336      1 Xorg     CALL  ioctl(6,_IOWR('V',0x71,0x18),0xbfbfeb70)
  7336      1 Xorg     GIO   fd 6 wrote 24 bytes
       "H\M-m\M-?\M-?\^F\0\0\0\M-AT\M-?\M-;\0\M-B\M->\M-;`\0\0\0\0\0\0\0"
  7336      1 Xorg     GIO   fd 6 read 24 bytes
       "pcvt\0\0\0\0\M-AT\M-?\M-;\0\M-B\M->\M-;\^C\0\0\0 \0\0\0"
  7336      1 Xorg     RET   ioctl 0
  7336      1 Xorg     CALL  ioctl(6,_IOR('v',0x3,0x8),0xbfbfeb94)
  7336      1 Xorg     GIO   fd 6 read 8 bytes
       "\0\0\0\0\0\0\0\0"
  7336      1 Xorg     RET   ioctl 0
  7336      1 Xorg     CALL  ioctl(6,_IOR('v',0x7,0x4),0x81a385c)
  7336      1 Xorg     GIO   fd 6 read 4 bytes
       "\^A\0\0\0"
  7336      1 Xorg     RET   ioctl 0
  7336      1 Xorg     CALL  ioctl(6,_IOR('v',0x1,0x4),0x81a5374)
  7336      1 Xorg     GIO   fd 6 read 4 bytes
       "\^E\0\0\0"
  7336      1 Xorg     RET   ioctl 0
  7336      1 Xorg     CALL  close(6)
  7336      1 Xorg     RET   close 0
  7336      1 Xorg     CALL  open(0xbfbfeb88,6,0)
  7336      1 Xorg     NAMI  "/dev/ttyE4"
  7336      1 Xorg     RET   open 6
  7336      1 Xorg     CALL  ioctl(6,_IOR('v',0x3,0x8),0xbfbfeb94)
  7336      1 Xorg     GIO   fd 6 read 8 bytes
       "\0\0\0\0\0\0\0\0"
  7336      1 Xorg     RET   ioctl 0
  7336      1 Xorg     CALL  write(0,0x81b6440,0x43)
  7336      1 Xorg     GIO   fd 0 wrote 67 bytes
       "(--) Using wscons driver in pcvt compatibility mode (version 3.32)
       "
  7336      1 Xorg     RET   write 67/0x43
  7336      1 Xorg     CALL  ioctl(6,_IO('v',0x5),5)
  7336      1 Xorg     RET   ioctl -1 errno 16 Device busy
  7336      1 Xorg     CALL  write(0,0x81b6440,0x29)
  7336      1 Xorg     GIO   fd 0 wrote 41 bytes
       "(WW) xf86OpenConsole: VT_ACTIVATE failed
       "
  7336      1 Xorg     RET   write 41/0x29
  7336      1 Xorg     CALL  ioctl(6,_IO('v',0x6),5)
  7336      1 Xorg     RET   ioctl -1 errno 4 Interrupted system call
  7336      1 Xorg     PSIG  SIGTERM caught handler=0x81809c4 mask=())
  7336      1 Xorg     CALL  setcontext(0xbfbfe894)
  7336      1 Xorg     RET   setcontext JUSTRETURN
  7336      1 Xorg     CALL  ioctl(6,_IO('v',0x6),5)
  7336      1 Xorg     RET   ioctl -1 errno 4 Interrupted system call
  7336      1 Xorg     PSIG  SIGTERM caught handler=0x81809c4 mask=())
  7336      1 Xorg     CALL  setcontext(0xbfbfe894)
  7336      1 Xorg     RET   setcontext JUSTRETURN
  7336      1 Xorg     CALL  ioctl(6,_IO('v',0x6),5)
  7336      1 Xorg     RET   ioctl -1 errno 4 Interrupted system call
  7336      1 Xorg     PSIG  SIGTERM caught handler=0x81809c4 mask=())
  7336      1 Xorg     CALL  setcontext(0xbfbfe894)
  7336      1 Xorg     RET   setcontext JUSTRETURN
  7336      1 Xorg     CALL  ioctl(6,_IO('v',0x6),5)
  7336      1 Xorg     RET   ioctl RESTART
  7336      1 Xorg     PSIG  SIGKILL SIG_DFL

I have to reboot to get X started (with correct configuration with mouse).

Any hints would be appreciated,

Jeremy C. Reed

p.s. I plan on working on the wsmouse auto-detection on NetBSD but want to 
make sure X exits cleanly (my console will work after) on errors.

p.p.s. Part of this same email was sent to xorg list a few days ago, but 
no response.