Not able to disconnect/reconnect USB switch in Plasma

Hello,

I am trying out KDE Plasma on FreeBSD. I use a USB switch to be able to switch between my desktop computer and my work laptop with the same mouse and keyboard.

The USB swith is connected to a mouse, a keyboard, a USB headset and a webcam.

When I switch from KDE FreeBSD on the desktop computer to the work computer, and then switch back, I don’t get mouse and keyboard input back.

Interestingly this problem doesn’t happen when using Windowmaker or in the loging manager SDDM.

This is the Xorg log when the problem doesn’t happen in Windomaker, we can see that Xorg detect the device disconnection and reconnection:

Code:
[  1089.351] (II) config/udev: removing device Logitech USB Laser Mouse
[  1089.351] (II) event3  - Logitech USB Laser Mouse, class 0/0, rev 2.00/56.01, addr 13: device removed
[  1089.352] (II) UnloadModule: "libinput"
[  1089.352] (II) config/udev: removing device A4Tech LDLC AZERTY+
[  1089.352] (II) event4  - A4Tech LDLC AZERTY+, class 0/0, rev 2.00/1.05, addr 14: device removed
[  1089.352] (II) UnloadModule: "libinput"
[  1095.802] (II) config/udev: Adding input device Logitech USB Laser Mouse (/dev/input/event3)
[  1095.802] (**) Logitech USB Laser Mouse: Applying InputClass "evdev pointer catchall"
[  1095.802] (**) Logitech USB Laser Mouse: Applying InputClass "libinput pointer catchall"
[  1095.802] (II) Using input driver 'libinput' for 'Logitech USB Laser Mouse'
[  1095.802] (**) Logitech USB Laser Mouse: always reports core events
[  1095.802] (**) Option "Device" "/dev/input/event3"
[  1095.802] (**) Option "_source" "server/udev"
[  1095.804] (II) event3  - Logitech USB Laser Mouse, class 0/0, rev 2.00/56.01, addr 18: is tagged by udev as: Mouse
[  1095.805] (II) event3  - Logitech USB Laser Mouse, class 0/0, rev 2.00/56.01, addr 18: device is a pointer
[  1095.805] (II) event3  - Logitech USB Laser Mouse, class 0/0, rev 2.00/56.01, addr 18: device removed
[  1095.806] (**) Option "config_info" "udev:/dev/input/event3"
[  1095.806] (II) XINPUT: Adding extended input device "Logitech USB Laser Mouse" (type: MOUSE, id 9)
[  1095.806] (**) Option "AccelerationScheme" "none"
[  1095.806] (**) Logitech USB Laser Mouse: (accel) selected scheme none/0
[  1095.806] (**) Logitech USB Laser Mouse: (accel) acceleration factor: 2.000
[  1095.806] (**) Logitech USB Laser Mouse: (accel) acceleration threshold: 4
[  1095.808] (II) event3  - Logitech USB Laser Mouse, class 0/0, rev 2.00/56.01, addr 18: is tagged by udev as: Mouse
[  1095.809] (II) event3  - Logitech USB Laser Mouse, class 0/0, rev 2.00/56.01, addr 18: device is a pointer
[  1096.400] (II) config/udev: Adding input device A4Tech LDLC AZERTY+ (/dev/input/event4)
[  1096.400] (**) A4Tech LDLC AZERTY+: Applying InputClass "evdev keyboard catchall"
[  1096.400] (**) A4Tech LDLC AZERTY+: Applying InputClass "Evdev keyboard"
[  1096.400] (**) A4Tech LDLC AZERTY+: Applying InputClass "libinput keyboard catchall"
[  1096.400] (**) A4Tech LDLC AZERTY+: Applying InputClass "system-keyboard"
[  1096.400] (II) Using input driver 'libinput' for 'A4Tech LDLC AZERTY+'
[  1096.400] (**) A4Tech LDLC AZERTY+: always reports core events
[  1096.400] (**) Option "Device" "/dev/input/event4"
[  1096.400] (**) Option "_source" "server/udev"
[  1096.402] (II) event4  - A4Tech LDLC AZERTY+, class 0/0, rev 2.00/1.05, addr 19: is tagged by udev as: Keyboard
[  1096.403] (II) event4  - A4Tech LDLC AZERTY+, class 0/0, rev 2.00/1.05, addr 19: device is a keyboard
[  1096.403] (II) event4  - A4Tech LDLC AZERTY+, class 0/0, rev 2.00/1.05, addr 19: device removed
[  1096.404] (**) Option "config_info" "udev:/dev/input/event4"
[  1096.404] (II) XINPUT: Adding extended input device "A4Tech LDLC AZERTY+" (type: KEYBOARD, id 10)
[  1096.404] (**) Option "xkb_rules" "evdev"
[  1096.404] (**) Option "xkb_layout" "fr"
[  1096.404] (**) Option "xkb_variant" "afnor"
[  1096.406] (II) event4  - A4Tech LDLC AZERTY+, class 0/0, rev 2.00/1.05, addr 19: is tagged by udev as: Keyboard
[  1096.407] (II) event4  - A4Tech LDLC AZERTY+, class 0/0, rev 2.00/1.05, addr 19: device is a keyboard

While in Plasma, no reconnection event is detected:

Code:
[  1241.569] (II) config/udev: removing device Logitech USB Laser Mouse
[  1241.569] (II) event3  - Logitech USB Laser Mouse, class 0/0, rev 2.00/56.01, addr 18: device removed
[  1241.582] (II) UnloadModule: "libinput"
[  1241.582] (II) config/udev: removing device A4Tech LDLC AZERTY+
[  1241.582] (II) event4  - A4Tech LDLC AZERTY+, class 0/0, rev 2.00/1.05, addr 19: device removed
[  1241.584] (II) UnloadModule: "libinput"

There is some interesting messages in dmesg:

Code:
Apr 20 19:11:35 gen3 kernel: ugen0.2: <vendor 0x1a40 USB 2.0 Hub> at usbus0 (disconnected)
Apr 20 19:11:35 gen3 kernel: uhub1: at uhub0, port 9, addr 22 (disconnected)
Apr 20 19:11:35 gen3 kernel: ugen0.3: <Logitech USB Laser Mouse> at usbus0 (disconnected)
Apr 20 19:11:35 gen3 kernel: ums0: at uhub1, port 1, addr 23 (disconnected)
Apr 20 19:11:35 gen3 kernel: ums0: detached
Apr 20 19:11:35 gen3 kernel: ugen0.4: <A4Tech LDLC AZERTY+> at usbus0 (disconnected)
Apr 20 19:11:35 gen3 kernel: ukbd0: at uhub1, port 2, addr 24 (disconnected)
Apr 20 19:11:35 gen3 kernel: ukbd0: detached
Apr 20 19:11:35 gen3 kernel: uhid0: at uhub1, port 2, addr 24 (disconnected)
Apr 20 19:11:35 gen3 kernel: uhid0: detached
Apr 20 19:11:35 gen3 kernel: ugen0.5: <vendor 0x046d product 0x081b> at usbus0 (disconnected)
Apr 20 19:11:35 gen3 kernel: uaudio0: at uhub1, port 3, addr 25 (disconnected)
Apr 20 19:11:35 gen3 kernel: pcm7: unregister: mixer busy
Apr 20 19:11:35 gen3 kernel: pcm7: Waiting for sound application to exit!
Apr 20 19:11:37 gen3 kernel: pcm7: unregister: mixer busy
Apr 20 19:11:37 gen3 kernel: pcm7: Waiting for sound application to exit!
Apr 20 19:11:39 gen3 kernel: pcm7: unregister: mixer busy




Apr 20 19:16:44 gen3 kernel: pcm7: unregister: mixer busy
Apr 20 19:16:44 gen3 kernel: pcm7: Waiting for sound application to exit!
Apr 20 19:16:46 gen3 kernel: pcm7: unregister: mixer busy
Apr 20 19:16:46 gen3 kernel: pcm7: Waiting for sound application to exit!
Apr 20 19:16:48 gen3 kernel: pcm7: unregister: mixer busy
Apr 20 19:16:48 gen3 kernel: pcm7: Waiting for sound application to exit!
Apr 20 19:16:48 gen3 devd[73807]: notify_clients: send() failed; dropping unresponsive client
Apr 20 19:16:48 gen3 kernel: pid 37576 (kglobalaccel5), jid 0, uid 1001: exited on signal 6 (core dumped)
Apr 20 19:16:50 gen3 kernel: pid 38073 (drkonqi), jid 0, uid 1001: exited on signal 6 (core dumped)
Apr 20 19:16:50 gen3 kernel: pcm7: detached
Apr 20 19:16:50 gen3 kernel: uaudio0: detached
Apr 20 19:16:50 gen3 kernel: ugen0.6: <Creative Technology Creative USB Headset> at usbus0 (disconnected)
Apr 20 19:16:50 gen3 kernel: uaudio1: at uhub1, port 4, addr 26 (disconnected)
Apr 20 19:16:50 gen3 kernel: pcm8: detached
Apr 20 19:16:50 gen3 kernel: uaudio1: detached
Apr 20 19:16:50 gen3 kernel: uhid1: at uhub1, port 4, addr 26 (disconnected)
Apr 20 19:16:50 gen3 kernel: uhid1: detached
Apr 20 19:16:50 gen3 kernel: uhub1: detached
Apr 20 19:16:51 gen3 kernel: ugen0.2: <vendor 0x1a40 USB 2.0 Hub> at usbus0
Apr 20 19:16:51 gen3 kernel: uhub1 on uhub0
Apr 20 19:16:51 gen3 kernel: uhub1: <vendor 0x1a40 USB 2.0 Hub, class 9/0, rev 2.00/1.11, addr 27> on usbus0
Apr 20 19:16:52 gen3 kernel: uhub1: 4 ports with 4 removable, self powered
Apr 20 19:16:53 gen3 kernel: ugen0.3: <Logitech USB Laser Mouse> at usbus0
Apr 20 19:16:53 gen3 kernel: ums0 on uhub1
Apr 20 19:16:53 gen3 kernel: ums0: <Logitech USB Laser Mouse, class 0/0, rev 2.00/56.01, addr 28> on usbus0
Apr 20 19:16:53 gen3 kernel: ums0: 8 buttons and [XYZT] coordinates ID=0
Apr 20 19:16:53 gen3 kernel: ugen0.4: <A4Tech LDLC AZERTY+> at usbus0
Apr 20 19:16:53 gen3 kernel: ukbd0 on uhub1
Apr 20 19:16:53 gen3 kernel: ukbd0: <A4Tech LDLC AZERTY+, class 0/0, rev 2.00/1.05, addr 29> on usbus0
Apr 20 19:16:53 gen3 kernel: kbd2 at ukbd0
Apr 20 19:16:53 gen3 kernel: uhid0 on uhub1
Apr 20 19:16:53 gen3 kernel: uhid0: <A4Tech LDLC AZERTY+, class 0/0, rev 2.00/1.05, addr 29> on usbus0
Apr 20 19:16:54 gen3 kernel: ugen0.5: <vendor 0x046d product 0x081b> at usbus0
Apr 20 19:16:54 gen3 kernel: uaudio0 on uhub1
Apr 20 19:16:54 gen3 kernel: uaudio0: <vendor 0x046d product 0x081b, class 239/2, rev 2.00/0.12, addr 30> on usbus0
Apr 20 19:16:54 gen3 kernel: uaudio0: No playback.
Apr 20 19:16:54 gen3 kernel: uaudio0: Record: 48000 Hz, 1 ch, 16-bit S-LE PCM format, 2x8ms buffer.
Apr 20 19:16:54 gen3 kernel: uaudio0: Record: 32000 Hz, 1 ch, 16-bit S-LE PCM format, 2x8ms buffer.
Apr 20 19:16:54 gen3 kernel: uaudio0: Record: 24000 Hz, 1 ch, 16-bit S-LE PCM format, 2x8ms buffer.
Apr 20 19:16:54 gen3 kernel: uaudio0: Record: 16000 Hz, 1 ch, 16-bit S-LE PCM format, 2x8ms buffer.
Apr 20 19:16:54 gen3 kernel: uaudio0: No MIDI sequencer.
Apr 20 19:16:54 gen3 kernel: pcm7: <USB audio> on uaudio0
Apr 20 19:16:54 gen3 kernel: uaudio0: No HID volume keys found.
Apr 20 19:16:55 gen3 kernel: ugen0.6: <Creative Technology Creative USB Headset> at usbus0
Apr 20 19:16:55 gen3 kernel: uaudio1 on uhub1
Apr 20 19:16:55 gen3 kernel: uaudio1: <Creative Technology Creative USB Headset, class 0/0, rev 2.00/1.10, addr 31> on usbus0
Apr 20 19:16:55 gen3 kernel: uaudio1: Play: 48000 Hz, 2 ch, 24-bit S-LE PCM format, 2x8ms buffer.
Apr 20 19:16:55 gen3 kernel: uaudio1: Play: 44100 Hz, 2 ch, 24-bit S-LE PCM format, 2x8ms buffer.
Apr 20 19:16:55 gen3 kernel: uaudio1: Record: 48000 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
Apr 20 19:16:55 gen3 kernel: uaudio1: Record: 44100 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
Apr 20 19:16:55 gen3 kernel: uaudio1: No MIDI sequencer.
Apr 20 19:16:55 gen3 kernel: pcm8: <USB audio> on uaudio1
Apr 20 19:16:55 gen3 kernel: uaudio1: HID volume keys found

It looks like that the disconnect event is being held for the USB headset, as the audio device is kept busy. This also holds the reconnect event from happening apparently.

When I kill Plasma by restarting SDDM, the audio device is disconnected, and then the USB devices reconnect is detected, even if I reconnected the swith 3 minutes before.

So in a nutshell, it looks like Plasma is keeping the USB device open, which blocks any new USB event from happening, thus blocking the reconnection event for the USB mouse and keyboard.

Any idea on how to solve that?

Thanks!
 
I ran into a similar problem in my FreeBSD system running FreeBSD 13.0-RELEASE for AMD64 and the KDE Plasma plasma5-plasma-5.22.4 metaport installed. If I attempt to disconnect my USB keyboard and mouse while KDE is running, then KDE is unable to detect the subsequent re-connection of my USB keyboard and mouse. I'm also wondering how I can solve this problem, since I have two computers on my desk and I'd like to be able to hot-swap the keyboard and mouse any time I want to switch between systems.
 
thats pulseaudio blocking the usb audio device. Kill it with fire and everything works as expected again...
 
Thank you for your responses. I ended up resolving this problem in a different way: I ran into this same issue on Windows 10. What was happening was that there was some type of conflict between my BIOS's default security settings for USB ports and the operating systems whenever I tried removing and reinserting USB devices. By setting security to "None" for my USB devices, both Windows 10 and FreeBSD 13 are able to correctly handle the hot-swapping of my USB devices.
 
Unfortunately that solution appeared to have been short-lived; I just tried hot-swapping my USB hub containing my keyboard and mouse after an uptime of over 12 hours, and unfortunately it was undetected when I plugged it back in. I ended up performing an ACPI reboot. I don't know what's going on.
 
pulseaudio -k

This doesn't solve the problem because it ist still randomly started e.g. by firefox or other software that "supports but doesn't need" pulseaudio, which is massively annoying, especially because pulseaudio can't be deactivated by any config flag.

A permanent solution until pulseaudio is finally removed as a hard dependency for some packages that actually don't need it but drag it in anyways:
# rm /usr/local/bin/pulseaudio && ln -s /bin/true /usr/local/bin/pulseaudio && chflags schg /usr/local/bin/pulseaudio
 
Might also try changing ; autospawn = yes to autospawn = no in /usr/local/etc/pulse/client.conf to disable pulseaudio. Might need a reboot afterwards.
 
Might also try changing ; autospawn = yes to autospawn = no in /usr/local/etc/pulse/client.conf to disable pulseaudio. Might need a reboot afterwards.
This won't stop it from being launched by other applications. Has been discussed in various other threads...
 
This won't stop it from being launched by other applications. Has been discussed in various other threads...
Thanks.

chmod -x /usr/local/bin/pulseaudio (with root privileges) should be adequate to stop it from being launched.
 
This doesn't solve the problem because it ist still randomly started e.g. by firefox or other software that "supports but doesn't need" pulseaudio, which is massively annoying, especially because pulseaudio can't be deactivated by any config flag.

Even if you build a package with PULSEAUDIO=off ?
 
Some packages don't give you that choice (i.e. you have to choose pulse or alsa even if it can use oss) and/or still pull in pulseaudio because of some library dependencies (i guess).
 
… USB headset …

paulez I'm partly reading between the lines.

If you force deletion of KMix then restart the computer and avoid reinstallation of KMix: is there less trouble?

pkg delete -f kmix

FreeBSD bug 258579 – audio/kmix consider making multimedia/kdemultimedia not dependent upon KMix

Also (if you're new to FreeBSD, this will be peculiar): quit the audio application before attempting to switch or disconnect the USB headset.

For example, if you were listening to something in Firefox, it's not enough to pause/stop playback. Need to either:
  • simply quit Firefox; or
  • if you know which firefox process was used for playback, kill that one process (then deal with crashed tabs).
 
PulseAudio

… won't stop it from being launched by other applications. …

In the context of this thread – KDE Plasma – I had no problem involving PulseAudio after doing what was suggested by Vull.

<https://forums.FreeBSD.org/threads/80412/post-519408>

… dependencies (i guess).

Code:
% pkg rquery %ro audio/pulseaudio | sort
accessibility/speech-dispatcher
audio/alsa-plugins
audio/bambootracker
audio/cava
audio/cli-visualizer
audio/drumstick
audio/fossmixer
audio/giada
audio/gstreamer1-plugins-pulse
audio/gtick
audio/myxer
audio/ncpamixer
audio/paman
audio/pamixer
audio/paprefs
audio/pavucontrol
audio/pavucontrol-qt
audio/pavumeter
audio/plasma5-plasma-pa
audio/psindustrializer
audio/pulseaudio-module-sndio
audio/pulseaudio-module-xrdp
audio/pulseaudio-qt
audio/py-pulsectl
audio/rtaudio
audio/soundtracker
audio/xfce4-pulseaudio-plugin
audio/zrythm
comms/cubicsdr
comms/qsstv
comms/twpsk
deskutils/spice-gtk
deskutils/xfce4-volumed-pulse
devel/aws-sdk-cpp
devel/efl
emulators/dolphin-emu
graphics/libprojectm
lang/squeak
multimedia/aegisub
multimedia/audacious-plugins
multimedia/audacious-plugins
multimedia/avidemux
multimedia/avidemux-cli
multimedia/avidemux-plugins
multimedia/avidemux-qt5
multimedia/gmerlin
multimedia/kooha
multimedia/obs-studio
multimedia/simplescreenrecorder
multimedia/snapcast
multimedia/webcamoid
multimedia/wf-recorder
net/gtk-vnc
net/guacamole-server
sysutils/cinnamon-settings-daemon
sysutils/gnome-control-center
sysutils/gnome-settings-daemon
x11-wm/e16
x11-wm/enlightenment
x11-wm/lxqt-panel
x11-wm/qtile
x11/cinnamon-desktop
x11/gnome-shell
x11/polybar
x11/wapanel
x11/waybar
x11/wf-shell
%
 

well, then both my desktops and my laptop (all without pulseaudio) are magical... because I constantly plug/unplug a USB DAC and/or a USB headset on them and the only thing besides changing the default device via "sysctl hw.snd.default_unit=N" is pause/resume e.g. the youtube video or music I've been playing...
 
For the record I had the same issue with a new FreeBSD 13.0 install and Xfce after installing Pulseaudio. Removing Pulseaudio resolves the issue, so that would confirm the hypothesis that it is locking the USB audio device.

paulez I'm partly reading between the lines.

If you force deletion of KMix then restart the computer and avoid reinstallation of KMix: is there less trouble?

pkg delete -f kmix

FreeBSD bug 258579 – audio/kmix consider making multimedia/kdemultimedia not dependent upon KMix
Sorry I am not able to test as I don't use KDE anymore. However I am using gtk-mixer as mentioned in the related forum post, and it is not causing this locking problem.
 
Back
Top