Desktop Linux Adventures: Blocking a USB Device from Activity

I've fallen in love again with my "old" Framework Laptop 13. It was originally a Core i7 11th gen 1165G7, 32 GB RAM upgraded to a Core i7 13th gen 1360p, 64 GB RAM with a 2TB Samsung 990 PRO NVMe. Since it's pretty much "maxed out", it is still a great machine even in mid-2024. I'm currently using this machine as my primary machine for work, and a MacBook Pro as the secondary machine. Yup, I like it that much to demote an M3-based machine. (I am also really lucky my company is able to provide me powerful hardware to get my job done.)

I am running Ubuntu 22.04 LTS with kernel 6.5.0, and mostly everything works fine. Well, except video conference calls. The webcam on the laptop works well. Actually, everything on the laptop works just fine on Linux. The hardware support that Linux provides for the Framework 13 or maybe it's just Framework doing their diligence on choosing the right components provides that compatibility which I've come to appreciate. 😄

Unfortunately, for all the greatness of the laptop's compatibility with Linux with its own hardware, I don't sit hunched over using my laptop all day. I connect the laptop to a Level1Techs USB-C KVM and a bunch of other components through the built-in USB hub that the KVM provides. 

Now you can start to imagine this can all become a problem. It becomes a scavenger hunt of "which device is going to burn me?" as I switch between computers with the KVM. 

Since getting back on my Framework laptop, and using Linux more often these days, I've had issues with my audio just failing on me whenever I plugged, and unplugged from my KVM. The side effects include: no audio at all, inability to specify an output/input device on GNOME settings, lock ups when trying to restart audio services and random GNOME freezes. These symptoms which I experienced made it really hard to narrow down the problem. For example, GNOME would often just not show the device in the sound panel, and my sound extension up at the top corner would just not be visible when attempting to adjust the volume of my speakers. 

On top of all this, my Logitech MX Brio webcam (a really good webcam, by the way) would not activate, and simply plugging it into my laptop would also destroy all audio capability.

Sometimes, if I was lucky, plugging in either my KVM or webcam, these would just result in still having audio, but with no ability to control the volume. At least I would get to finish my YouTube video, or current conference call, haha. That's if I was lucky. 🤦

Ugh, was it my KVM? Was it my webcam?

Anyway, I tried lots of things... Like instead of using PulseAudio, I decided to use Pipewire. I also tried restarting all the necessary audio services using commands I just searched up on the internet like this:

systemctl --user restart pipewire.service
systemctl --user restart pipewire-pulse.service

Nope. These things just didn't work.

I'd like to mention again that whenever this type occurred, my GNOME shell would just lock up and not be able to load any GNOME-related apps. At first, I blamed this on Ubuntu being on GNOME 42.9. Then, when I got desperate and irrational, I made up stuff and said it was because I was on Wayland. Then I switched to X11. Of course, all that didn't help and I still had issues.

Anyway, this audio issue would always seem to fix itself after restarting the computer. One would assume that logging out would help. But no, not a logout. A FULL RESTART is necessary. Yes, the issue was that annoying!

One night, I decided it was time to just put some care into my computer and decided to get to the bottom of it all. The first thing I did was to reproduce the issue while watching dmesg logs through this command:

sudo dmesg -w

As I was reproducing the issue, I came to see lots and lots of these repeatedly:

[  242.275704] usb 3-5.1.1: 1:1: cannot set freq 48000 to ep 0x82
[  247.395930] usb 3-5.1.1: 2:1: cannot set freq 48000 to ep 0x82

 

Huh, that's interesting. So I started watching dmesg again when I rebooted, and things were quiet again. Like before, I reproduced the issue, and again, experienced the same symptoms of lost audio, GNOME freezing and interestingly, enough, found those same messages again!

Wow, so this was a little bit of confirmation that I was finally onto something. Perhaps this specific usb 3-5.1.1 device was locking up my system for some reason whenever USB-like devices were plugged in. I had initially assumed that my nice expensive webcam was simply not compatible, but I think it was just coincidence now.

Looking at lsusb -t -v , I saw this output:

lsusb -t -v
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 10000M
    ID 1d6b:0003 Linux Foundation 3.0 root hub
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/12p, 480M
    ID 1d6b:0002 Linux Foundation 2.0 root hub
    |__ Port 4: Dev 2, If 0, Class=Human Interface Device, Driver=usbhid, 12M
        ID 1050:0407 Yubico.com Yubikey 4/5 OTP+U2F+CCID
    |__ Port 4: Dev 2, If 1, Class=Human Interface Device, Driver=usbhid, 12M
        ID 1050:0407 Yubico.com Yubikey 4/5 OTP+U2F+CCID
    |__ Port 4: Dev 2, If 2, Class=Chip/SmartCard, Driver=, 12M
        ID 1050:0407 Yubico.com Yubikey 4/5 OTP+U2F+CCID
    |__ Port 5: Dev 3, If 0, Class=Hub, Driver=hub/4p, 480M
        ID 05e3:0610 Genesys Logic, Inc. Hub
        |__ Port 2: Dev 7, If 3, Class=Human Interface Device, Driver=usbhid, 12M
            ID 046d:c548 Logitech, Inc.
        |__ Port 2: Dev 7, If 1, Class=Human Interface Device, Driver=usbhid, 12M
            ID 046d:c548 Logitech, Inc.
        |__ Port 2: Dev 7, If 2, Class=Human Interface Device, Driver=usbhid, 12M
            ID 046d:c548 Logitech, Inc.
        |__ Port 2: Dev 7, If 0, Class=Human Interface Device, Driver=usbhid, 12M
            ID 046d:c548 Logitech, Inc.
        |__ Port 1: Dev 5, If 0, Class=Hub, Driver=hub/7p, 12M
            ID 09ea:0130
            |__ Port 1: Dev 8, If 0, Class=Audio, Driver=snd-usb-audio, 12M
                ID 0d8c:0016 C-Media Electronics, Inc.
            |__ Port 1: Dev 8, If 3, Class=Human Interface Device, Driver=usbhid, 12M
                ID 0d8c:0016 C-Media Electronics, Inc.
            |__ Port 1: Dev 8, If 1, Class=Audio, Driver=snd-usb-audio, 12M
                ID 0d8c:0016 C-Media Electronics, Inc.
            |__ Port 1: Dev 8, If 2, Class=Audio, Driver=snd-usb-audio, 12M
                ID 0d8c:0016 C-Media Electronics, Inc.
            |__ Port 6: Dev 11, If 0, Class=Human Interface Device, Driver=usbhid, 12M
                ID 09eb:0131 IM Networks, Inc.
            |__ Port 6: Dev 11, If 1, Class=Human Interface Device, Driver=usbhid, 12M
                ID 09eb:0131 IM Networks, Inc.
        |__ Port 4: Dev 10, If 0, Class=Hub, Driver=hub/4p, 480M
            ID 0451:8142 Texas Instruments, Inc. TUSB8041 4-Port Hub
            |__ Port 3: Dev 13, If 2, Class=Human Interface Device, Driver=usbhid, 12M
                ID 29ea:0360 Kinesis Corporation
            |__ Port 3: Dev 13, If 0, Class=Human Interface Device, Driver=usbhid, 12M
                ID 29ea:0360 Kinesis Corporation
            |__ Port 3: Dev 13, If 1, Class=Human Interface Device, Driver=usbhid, 12M
                ID 29ea:0360 Kinesis Corporation
            |__ Port 4: Dev 14, If 3, Class=CDC Data, Driver=cdc_acm, 12M
                ID 043e:9a8a LG Electronics USA, Inc.
            |__ Port 4: Dev 14, If 1, Class=Human Interface Device, Driver=usbhid, 12M
                ID 043e:9a8a LG Electronics USA, Inc.
            |__ Port 4: Dev 14, If 2, Class=Communications, Driver=cdc_acm, 12M
                ID 043e:9a8a LG Electronics USA, Inc.
            |__ Port 4: Dev 14, If 0, Class=Human Interface Device, Driver=usbhid, 12M
                ID 043e:9a8a LG Electronics USA, Inc.
    |__ Port 7: Dev 4, If 0, Class=Video, Driver=uvcvideo, 480M
        ID 0bda:5634 Realtek Semiconductor Corp.
    |__ Port 7: Dev 4, If 1, Class=Video, Driver=uvcvideo, 480M
        ID 0bda:5634 Realtek Semiconductor Corp.
    |__ Port 9: Dev 6, If 0, Class=Vendor Specific Class, Driver=, 12M
        ID 27c6:609c Shenzhen Goodix Technology Co.,Ltd.
    |__ Port 10: Dev 9, If 0, Class=Wireless, Driver=btusb, 12M
        ID 8087:0032 Intel Corp. AX210 Bluetooth
    |__ Port 10: Dev 9, If 1, Class=Wireless, Driver=btusb, 12M
        ID 8087:0032 Intel Corp. AX210 Bluetooth
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 20000M/x2
    ID 1d6b:0003 Linux Foundation 3.0 root hub
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/1p, 480M
    ID 1d6b:0002 Linux Foundation 2.0 root hub

Okay, although a lot of information, it all did seem useful... The log message said usb 3-5.1.1. That means this specific device lives in Bus 03, Port 5. Taking some time to comprehend and filter all that, I was at least able to view it easier...

/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/12p, 480M
    ID 1d6b:0002 Linux Foundation 2.0 root hub
    |__ Port 5: Dev 3, If 0, Class=Hub, Driver=hub/4p, 480M
        ID 05e3:0610 Genesys Logic, Inc. Hub
        |__ Port 2: Dev 7, If 3, Class=Human Interface Device, Driver=usbhid, 12M
            ID 046d:c548 Logitech, Inc.
        |__ Port 2: Dev 7, If 1, Class=Human Interface Device, Driver=usbhid, 12M
            ID 046d:c548 Logitech, Inc.
        |__ Port 2: Dev 7, If 2, Class=Human Interface Device, Driver=usbhid, 12M
            ID 046d:c548 Logitech, Inc.
        |__ Port 2: Dev 7, If 0, Class=Human Interface Device, Driver=usbhid, 12M
            ID 046d:c548 Logitech, Inc.
        |__ Port 1: Dev 5, If 0, Class=Hub, Driver=hub/7p, 12M
            ID 09ea:0130
            |__ Port 1: Dev 8, If 0, Class=Audio, Driver=snd-usb-audio, 12M
                ID 0d8c:0016 C-Media Electronics, Inc.
            |__ Port 1: Dev 8, If 3, Class=Human Interface Device, Driver=usbhid, 12M
                ID 0d8c:0016 C-Media Electronics, Inc.
            |__ Port 1: Dev 8, If 1, Class=Audio, Driver=snd-usb-audio, 12M
                ID 0d8c:0016 C-Media Electronics, Inc.
            |__ Port 1: Dev 8, If 2, Class=Audio, Driver=snd-usb-audio, 12M
                ID 0d8c:0016 C-Media Electronics, Inc.
            |__ Port 6: Dev 11, If 0, Class=Human Interface Device, Driver=usbhid, 12M
                ID 09eb:0131 IM Networks, Inc.
            |__ Port 6: Dev 11, If 1, Class=Human Interface Device, Driver=usbhid, 12M
                ID 09eb:0131 IM Networks, Inc.
        |__ Port 4: Dev 10, If 0, Class=Hub, Driver=hub/4p, 480M
            ID 0451:8142 Texas Instruments, Inc. TUSB8041 4-Port Hub
            |__ Port 3: Dev 13, If 2, Class=Human Interface Device, Driver=usbhid, 12M
                ID 29ea:0360 Kinesis Corporation
            |__ Port 3: Dev 13, If 0, Class=Human Interface Device, Driver=usbhid, 12M
                ID 29ea:0360 Kinesis Corporation
            |__ Port 3: Dev 13, If 1, Class=Human Interface Device, Driver=usbhid, 12M
                ID 29ea:0360 Kinesis Corporation
            |__ Port 4: Dev 14, If 3, Class=CDC Data, Driver=cdc_acm, 12M
                ID 043e:9a8a LG Electronics USA, Inc.
            |__ Port 4: Dev 14, If 1, Class=Human Interface Device, Driver=usbhid, 12M
                ID 043e:9a8a LG Electronics USA, Inc.
            |__ Port 4: Dev 14, If 2, Class=Communications, Driver=cdc_acm, 12M
                ID 043e:9a8a LG Electronics USA, Inc.
            |__ Port 4: Dev 14, If 0, Class=Human Interface Device, Driver=usbhid, 12M
                ID 043e:9a8a LG Electronics USA, Inc.

Interesting! So I was looking at a USB hub now. Hm, at this point, things were starting to look familiar. My KVM has a bunch of USB ports, and plugging in my KVM was seemingly causing all these issues... Was I getting warmer?

Now I was able to look at Bus 03, Port 5, but what about the 1.1 part of the log? I decided to look for that next. Since I was looking at a hub, the 1.1 had to mean Port 1 of that hub!

/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/12p, 480M
    ID 1d6b:0002 Linux Foundation 2.0 root hub
    |__ Port 5: Dev 3, If 0, Class=Hub, Driver=hub/4p, 480M
        ID 05e3:0610 Genesys Logic, Inc. Hub
        |__ Port 1: Dev 5, If 0, Class=Hub, Driver=hub/7p, 12M
            ID 09ea:0130
            |__ Port 1: Dev 8, If 0, Class=Audio, Driver=snd-usb-audio, 12M
                ID 0d8c:0016 C-Media Electronics, Inc.
            |__ Port 1: Dev 8, If 3, Class=Human Interface Device, Driver=usbhid, 12M
                ID 0d8c:0016 C-Media Electronics, Inc.
            |__ Port 1: Dev 8, If 1, Class=Audio, Driver=snd-usb-audio, 12M
                ID 0d8c:0016 C-Media Electronics, Inc.
            |__ Port 1: Dev 8, If 2, Class=Audio, Driver=snd-usb-audio, 12M
                ID 0d8c:0016 C-Media Electronics, Inc.
            |__ Port 6: Dev 11, If 0, Class=Human Interface Device, Driver=usbhid, 12M
                ID 09eb:0131 IM Networks, Inc.
            |__ Port 6: Dev 11, If 1, Class=Human Interface Device, Driver=usbhid, 12M
                ID 09eb:0131 IM Networks, Inc.

Looks like I found a potential culprit! So this specific device above by C-Media Electronics is a sound device, and is built into the KVM so that I can switch between audio. It's actually internally a USB audio device. 

At this point, I was pretty confident that this was the cause of all my troubles. Something was happening where my OS was waiting for this sound device to be ready, or something. Whatever the case, I don't use it anyway. Now, what to do?

The solution was to have a udev rule to "block" this specific device from even being active. I note down the vendor and device ID. That's easy by looking at the same lsusb output:

        |__ Port 1: Dev 5, If 0, Class=Hub, Driver=hub/7p, 12M
            ID 09ea:0130

In this case, the vendor and device ID is formatted as: abcd:wxyz. For this device, we have:

  • Vendor ID: 09ea
  • Device ID: 0130

So I created a udev rule under /etc/udev/rules.d called 80-l1-kvm-audio.rules:

 # Level1Techs KVM USB Audio should be disabled
 SUBSYSTEM=="usb", ATTRS{idVendor}=="0d8c", ATTRS{idProduct}=="0016", ATTR{authorized}="0"

After creating this, I just restarted the computer and tried to reproduce the issue again...

EVERYTHING WORKED. AMAZING! 

Just to make sure, I executed lsusb -t -v again to see if the offending sound device from my KVM was still active. Seeing the filtered output:

lsusb -t -v
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/12p, 480M
    ID 1d6b:0002 Linux Foundation 2.0 root hub
    |__ Port 5: Dev 6, If 0, Class=Hub, Driver=hub/4p, 480M
        ID 05e3:0610 Genesys Logic, Inc. Hub
        |__ Port 1: Dev 7, If 0, Class=Hub, Driver=hub/7p, 12M
            ID 09ea:0130
            |__ Port 6: Dev 9, If 0, Class=Human Interface Device, Driver=usbhid, 12M
                ID 09eb:0131 IM Networks, Inc.
            |__ Port 6: Dev 9, If 1, Class=Human Interface Device, Driver=usbhid, 12M
                ID 09eb:0131 IM Networks, Inc.

I can now see that we no longer have anything on 1.1.  ðŸ˜Œ