You are not logged in.

#1 2014-04-22 11:40:59

nanawel
Member
Registered: 2012-05-07
Posts: 88
Website

[SOLVED] Device init is not quick enough (mouse, keyboard & soundcard)

Hi,

I'm trying to set up a multiseat configuration (already discussed here) with my Intel IGP and a GF760. Everything works quite well except for two annoying things that seem to have a common cause:

    - Input devices and multiseat on Xorg
As I need to control 2 different screens, I have 2 different mice, and 2 different keyboards, all USB. Each pair is assigned to its own ServerLayout (see below) so I had to add AutoAddDevices and AllowEmptyInput to prevent Xorg from assigning the wrong device to the wrong screen.
The problem is that after each reboot, it's like the initialization of the USB devices is not always done correctly (it's like Xorg does not *wait* for the input devices to be ready). So in the best case I have one screen with no mouse or keyboard, and in the worst none of them has.

In the logs it looks like this:

/var/log/Xorg.1.log.old:[     2.623] (EE) evdev: K400r-keyboard: Unable to open evdev device "/dev/input/by-id/usb-Logitech_USB_Receiver-if02-event-mouse".
/var/log/Xorg.1.log.old:[     2.623] (EE) PreInit returned 2 for "K400r-keyboard"
/var/log/Xorg.1.log.old:[     2.623] (EE) evdev: K400r-keyboard-multimedia: Unable to open evdev device "/dev/input/by-id/usb-Logitech_USB_Receiver-if02-event-mouse".
/var/log/Xorg.1.log.old:[     2.623] (EE) PreInit returned 2 for "K400r-keyboard-multimedia"
/var/log/Xorg.1.log.old:[     2.623] (EE) evdev: K400r-mouse: Unable to open evdev device "/dev/input/by-id/usb-Logitech_USB_Receiver-if02-mouse".
/var/log/Xorg.1.log.old:[     2.623] (EE) PreInit returned 2 for "K400r-mouse"

What is really a pity is that I just have to restart Lightdm daemon to fix the problem, everytime! I assume that if I disable Lightdm daemon and only run it manually at each boot, it will work ok. Boot process is extremely fast and I'm glad it is, but isn't there some dependency to add in order to be sure USB devices are ready before running Lightdm/Xorg?
I understand that in a more "standard" environment it works ok because the devices are added on-the-fly even after the screen is started. But here AutoAddDevices is false so it cannot work that way.


    - Soundcard with PulseAudio
In the same configuration, I need to share one soundcard between both screens, so I configured PulseAudio as a system-wide daemon. The problem here *again* is that when I list the available outputs after each boot, I can see the HDMI from the IGP and the PCI-X card, but not the integrated chipset.
But, here again if I just restart the daemon, all the cards are visible and usable! How so?

What should I add as a dependency for pulseaudio-daemon in order to be sure the soundcard is ready before starting it?


I cannot find a good documentation whether on Xorg in multiseat or on PulseAudio, so I'm kinda lost here.

Thanks in advance for you help.


Here are the Xorg server layout configurations for my first problem:

50-serverlayout-main.conf (main screen, dual-head)

Section "ServerLayout"
    Identifier     "Layout-Main"
    Screen         "Screen-Main" 0 0
    InputDevice    "Logitech-Illuminated" "CoreKeyboard"
    InputDevice    "Logitech-G100S" "CorePointer"

    Option         "AutoAddDevices"   "false"
    Option         "AllowEmptyInput"  "true"
EndSection

Section "Files"
EndSection

Section "InputDevice"
    Identifier     "Logitech-G100S"
    Driver         "evdev"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/input/by-id/usb-Logitech_G100s_Optical_Gaming_Mouse-event-mouse"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"

    Option         "GrabDevice" "on" # prevent send event to other X-servers
EndSection

Section "InputDevice"
    Identifier     "Logitech-Illuminated"

    Driver         "evdev"
    Option         "XkbLayout" "fr"
    Option         "XkbModel" "pc104"

    Option         "Device" "/dev/input/by-id/usb-Logitech_Logitech_Illuminated_Keyboard-event-kbd"
    Option         "GrabDevice" "on" # prevent send event to other X-servers
EndSection

Section "Monitor"

    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "Monitor0"
    VendorName     "Samsung"
    ModelName      "Samsung SyncMaster 2433"
    HorizSync       30.0 - 81.0
    VertRefresh     56.0 - 60.0
    Option         "DPMS"
EndSection

Section "Monitor"

    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "Monitor1"
    VendorName     "Samsung"
    ModelName      "Samsung SyncMaster 2333sw"
    HorizSync       30.0 - 81.0
    VertRefresh     56.0 - 60.0
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "NVIDIA-GTX760"
    Driver         "nouveau"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 760"
EndSection

Section "Screen"
    Identifier     "Screen-Main"
    Device         "NVIDIA-GTX760"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

51-serverlayout-aux.conf (secondary screen, single-head)

Section "ServerLayout"
    Identifier     "Layout-Aux"
    Screen         "Screen-Aux" 0 0
    InputDevice    "K400r-keyboard" "CoreKeyboard"
    InputDevice    "K400r-keyboard-multimedia" "SendCoreEvents"
    InputDevice    "K400r-mouse" "CorePointer"

    Option         "AutoAddDevices"   "false"
    Option         "AllowEmptyInput"  "true"
EndSection

Section "Files"
EndSection

Section "InputDevice"
    Identifier     "K400r-mouse"
    Driver         "evdev"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/input/by-id/usb-Logitech_USB_Receiver-if02-mouse"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"

    Option         "GrabDevice" "on" # prevent send event to other X-servers
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "K400r-keyboard"
#    Driver         "kbd"

    Driver         "evdev"
    Option         "XkbLayout" "fr"
    Option         "XkbModel" "pc104"

    Option         "Device" "/dev/input/by-id/usb-Logitech_USB_Receiver-if02-event-mouse"
    Option         "GrabDevice" "on" # prevent send event to other X-servers
EndSection

Section "InputDevice"
    Identifier     "K400r-keyboard-multimedia"
    Driver         "evdev"
    Option         "Device" "/dev/input/by-id/usb-Logitech_USB_Receiver-if02-event-mouse"
    Option         "XkbModel" "evdev"
    Option         "GrabDevice" "on"
EndSection

Section "Monitor"
    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "Monitor1"
    VendorName     "Compaq"
    ModelName      "Compaq Q2159"
    HorizSync       30.0 - 81.0
    VertRefresh     56.0 - 60.0
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Intel-I915"
    Driver         "intel"
    VendorName     "Intel"
    BoardName      "Intel IGP"
    BusID          "PCI:0:2:0"
EndSection

Section "Screen"
    Identifier     "Screen-Aux"
    Device         "Intel-I915"
    Monitor        "Monitor1"
    DefaultDepth    24
EndSection

Last edited by nanawel (2014-04-29 07:04:17)

Offline

#2 2014-04-23 03:19:41

schnoopay
Member
From: USA
Registered: 2014-03-09
Posts: 22

Re: [SOLVED] Device init is not quick enough (mouse, keyboard & soundcard)

I had a similar issue with my video cards and found the solution in the wiki here.

I would suppose if you create similar udev rules for your input devices and sound card you could delay LightDM and pulseaudio the same way.

Offline

#3 2014-04-23 07:29:38

nanawel
Member
Registered: 2012-05-07
Posts: 88
Website

Re: [SOLVED] Device init is not quick enough (mouse, keyboard & soundcard)

schnoopay wrote:

I had a similar issue with my video cards and found the solution in the wiki here.

Thanks! That looks like a possible solution. I'll give it a shot and let you know!

Offline

#4 2014-04-26 15:53:55

nanawel
Member
Registered: 2012-05-07
Posts: 88
Website

Re: [SOLVED] Device init is not quick enough (mouse, keyboard & soundcard)

You were perfectly right, so here's what I did:

First, I've created some udev rules in order to identify devices easier and set them as dependencies for each systemd service.

/etc/udev/rules.d/99-input-tagging.rules

ACTION=="add", KERNEL=="event*", SUBSYSTEM=="input", TAG+="systemd", , ENV{SYSTEMD_ALIAS}+="/sys/subsystem/input/devices/$env{ID_SERIAL}"

/etc/udev/rules.d/99-soundcard-tagging.rules

ACTION=="add", KERNEL=="card*", SUBSYSTEM=="sound", TAG+="systemd", ENV{SYSTEMD_ALIAS}+="/sys/subsystem/sound/devices/$attr{id}"

That way I have (after rebooting):

$ systemctl list-units
[...]
sys-subsystem-input-devices-Logitech_G100s_Optical_Gaming_Mouse.device                           loaded active plugged   G100s_Optical_Gaming_Mouse
sys-subsystem-input-devices-Logitech_Logitech_Illuminated_Keyboard.device                        loaded active plugged   Logitech_Illuminated_Keyboard
sys-subsystem-input-devices-Logitech_USB_Receiver.device                                         loaded active plugged   USB_Receiver
sys-subsystem-sound-devices-DGX.device                                                           loaded active plugged   /sys/subsystem/sound/devices/DGX
sys-subsystem-sound-devices-PCH.device                                                           loaded active plugged   /sys/subsystem/sound/devices/PCH

DGX is an Asus Xonar DGX plugged into a PCI-X port, and PCH is the integrated sound chipset on the motherboard.

Then in /etc/systemd/system I've added the dependencies through unit files:

/etc/systemd/system/display-manager.service.d/10-wait-for-input-devices.conf

[Unit]
Wants=sys-subsystem-input-devices-Logitech_Logitech_Illuminated_Keyboard.device sys-subsystem-input-devices-Logitech_G100s_Optical_Gaming_Mouse.device sys-subsystem-input-devices-Logitech_USB_Receiver.device
After=sys-subsystem-input-devices-Logitech_Logitech_Illuminated_Keyboard.device sys-subsystem-input-devices-Logitech_G100s_Optical_Gaming_Mouse.device sys-subsystem-input-devices-Logitech_USB_Receiver.device

/etc/systemd/system/display-manager.service.d/10-wait-for-pulseaudio.conf

[Unit]
Wants=pulseaudio.service
After=pulseaudio.service

/etc/systemd/system/pulseaudio.service.d/10-wait-for-soundcards.conf

[Unit]
Wants=sys-subsystem-sound-devices-PCH.device sys-subsystem-sound-devices-DGX.device
After=sys-subsystem-sound-devices-PCH.device sys-subsystem-sound-devices-DGX.device

So now Pulseaudio waits for soundcards to be ready before starting (that way it is supposed to detect correctly the available outputs), and Lightdm/Xorg the input devices (mice and keyboards) to be ready too before starting (avoiding to be "locked" in front of the login window). I also made it wait for Pulseaudio (just in case).

I have to say, it works quite well, but not perfectly. I already had one case where Pulseaudio did not start (or at least was not available from my session). Rebooting fixed it, but it's annoying.
I don't know if it fixed anything yet but I've added dbus as a dependency:

$ mkdir /etc/systemd/system/pulseaudio.service.wants && ln -s /usr/lib/systemd/system/dbus.service /etc/systemd/system/pulseaudio.service.wants

I also had a case where after startup the mouse from the second seat was controling both seats. Here again rebooting fixed it, but it's sooo annoying too.

For information, I'm using the AUR package pulseaudio-systemd (which basically consists of a systemd unit file with the right parameters for pulseaudio binary).


Would you have any idea on the dependencies I should add? I'll keep on digging and post updates if I have some.

Thanks again


PS: I read on the Gentoo forum that there is a better way to assign devices to seat by also using udev tags. I'll try that too soon.

Last edited by nanawel (2014-04-29 06:54:07)

Offline

#5 2014-04-28 22:40:02

schnoopay
Member
From: USA
Registered: 2014-03-09
Posts: 22

Re: [SOLVED] Device init is not quick enough (mouse, keyboard & soundcard)

To be honest it looks to me like everything should be working. As a really bad hack you could add "ExecStartPre=/usr/bin/sleep 5" to one of the display manager lines which would simply delay the starting of the DM for 5 seconds, but I really hate that idea. It might be useful to try it just to see if you are, indeed, still having the DM starting too soon.

Getting the devices assigned to seats by udev sounds like a really good idea, but I do not understand why your current method isn't working quite right.

Offline

#6 2014-04-29 07:03:45

nanawel
Member
Registered: 2012-05-07
Posts: 88
Website

Re: [SOLVED] Device init is not quick enough (mouse, keyboard & soundcard)

It *seems* that since I added the dbus dependency I no longer have issues with Pulseaudio. I rebooted a dozen times since then and it looks ok.
I could not reproduce the issue with inputs either, and now everytime the login screen appears all inputs are working fine.

However, I'm not so confident and keeping in mind it's a random behaviour due to startup times, I'll have to wait a few weeks to consider the issue fixed.

Thanks for your help anyway

Offline

#7 2014-04-30 12:17:26

schnoopay
Member
From: USA
Registered: 2014-03-09
Posts: 22

Re: [SOLVED] Device init is not quick enough (mouse, keyboard & soundcard)

I'm glad it appears to be working. One thing I was wondering is if you really needed to reboot if the input config wasn't applied or if killing the X server was all you actuallu needed to do, but I guess if it's behaving we'll never know. =]

Offline

#8 2014-04-30 12:39:32

nanawel
Member
Registered: 2012-05-07
Posts: 88
Website

Re: [SOLVED] Device init is not quick enough (mouse, keyboard & soundcard)

schnoopay wrote:

I'm glad it appears to be working. One thing I was wondering is if you really needed to reboot if the input config wasn't applied or if killing the X server was all you actuallu needed to do, but I guess if it's behaving we'll never know. =]

Actually as I said in my first message, restarting services always made things work, so yes I could have done that. But my point was to make sure that *at boot* everything work immediately, specially the input devices because with no inputs... you can't restart services (except through SSH but you need another machine for that).

And BTW, rebooting takes something like 20 seconds with this configuration, so it's not a big waste of time smile

Offline

Board footer

Powered by FluxBB