Bug 194718 - vt(4): Keyboard not working properly when not using kbdmux(4)
Summary: vt(4): Keyboard not working properly when not using kbdmux(4)
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords: vt
Depends on:
Blocks:
 
Reported: 2014-10-31 17:24 UTC by Jean-Sébastien Pédron
Modified: 2015-07-07 16:12 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jean-Sébastien Pédron freebsd_committer freebsd_triage 2014-10-31 17:24:00 UTC
When using kbdmux(4), which is the default in all supported versions of FreeBSD, the keyboard is working properly in the console and in an X session:

$ kbdcontrol -i < /dev/ttyv0 
kbd1:
    kbdmux0, type:AT 101/102 (2)

$ xev
(...)
KeyPress event, serial 30, synthetic NO, window 0x2600001,
    root 0x2c3, subw 0x0, time 25050869, (525,686), root:(1486,706),
    state 0x10, keycode 45 (keysym 0x6b, k), same_screen YES,
    XLookupString gives 1 bytes: (6b) "k"
    XmbLookupString gives 1 bytes: (6b) "k"
    XFilterEvent returns: False

KeyRelease event, serial 33, synthetic NO, window 0x2600001,
    root 0x2c3, subw 0x0, time 25050973, (525,686), root:(1486,706),
    state 0x10, keycode 45 (keysym 0x6b, k), same_screen YES,
    XLookupString gives 1 bytes: (6b) "k"
    XFilterEvent returns: False

However, when kbdmux is disabled through "hint.kbdmux.0.disabled=1" in /boot/loader.conf, the keyboard isn't reported correctly by kbdcontrol:

$ kbdcontrol -i < /dev/ttyv0 
kbd0:
    0, type:generic (0)

And under X, the keyboard doesn't work at all. After the first keystroke, xev(1) receives invalid keyboard events in an infinite loop:
KeyPress event, serial 30, synthetic NO, window 0x1200001,
    root 0x80, subw 0x0, time 81112, (639,380), root:(640,400),
    state 0x0, keycode 203 (keysym 0x0, NoSymbol), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 33, synthetic NO, window 0x1200001,
    root 0x80, subw 0x0, time 81804, (639,380), root:(640,400),
    state 0x0, keycode 203 (keysym 0x0, NoSymbol), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 33, synthetic NO, window 0x1200001,
    root 0x80, subw 0x0, time 81804, (639,380), root:(640,400),
    state 0x0, keycode 203 (keysym 0x0, NoSymbol), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 33, synthetic NO, window 0x1200001,
    root 0x80, subw 0x0, time 81845, (639,380), root:(640,400),
    state 0x0, keycode 203 (keysym 0x0, NoSymbol), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

Even the first keystroke is incorrect (here, it should be 'k').

The same situation tested with syscons works. kbdcontrol reports that atkbd0 is connected.
Comment 1 commit-hook freebsd_committer freebsd_triage 2014-11-02 16:05:32 UTC
A commit references this bug:

Author: dumbbell
Date: Sun Nov  2 16:04:49 UTC 2014
New revision: 273973
URL: https://svnweb.freebsd.org/changeset/base/273973

Log:
  vt(4): Fix keyboard allocation when kbdmux(4) isn't used

  The problem was that only the kbdmux keyboard index was saved in
  vd->vd_keyboard. This index is -1 when kbdmux isn't used. In this
  case, the keyboard was correctly allocated, but the returned index was
  discarded.

  PR:		194718
  MFC after:	1 week

Changes:
  head/sys/dev/vt/vt_core.c
Comment 2 commit-hook freebsd_committer freebsd_triage 2014-11-22 17:11:21 UTC
A commit references this bug:

Author: dumbbell
Date: Sat Nov 22 17:10:57 UTC 2014
New revision: 274861
URL: https://svnweb.freebsd.org/changeset/base/274861

Log:
  vt(4): Fix keyboard allocation when kbdmux(4) isn't used

  The problem was that only the kbdmux keyboard index was saved in
  vd->vd_keyboard. This index is -1 when kbdmux isn't used. In this
  case, the keyboard was correctly allocated, but the returned index was
  discarded.

  PR:		194718
  MFC of:		r273973

Changes:
_U  stable/10/
  stable/10/sys/dev/vt/vt_core.c