1

Struggling with some devices often not functioning upon suspend, I came across the SE U&L question of reloading drivers.

In my case, a few devices are not detected, and I can see the driver (displaylink-driver.service) is loaded but inactive/dead.  So, is it possible to start drivers up again?

$ lsusb
# missing usb devices (detected by $ lsusb before the issue)
Bus 004 Device 005: ID 17ef:a357 Lenovo USB3.1 Hub             
Bus 004 Device 004: ID 17ef:a359 Lenovo ThinkPad Lan
Bus 004 Device 003: ID 17e9:6015 DisplayLink ThinkPad Hybrid USB-C with USB-A Dock
Bus 004 Device 002: ID 17ef:a356 Lenovo USB3.1 Hub

$ sudo systemctl status displaylink-driver.service ● displaylink-driver.service - DisplayLink Driver Service Loaded: loaded (/lib/systemd/system/displaylink-driver.service; static) Active: inactive (dead)

May 26 14:50:56 debija systemd[1]: Starting DisplayLink Driver Service... May 26 14:50:56 debija systemd[1]: Started DisplayLink Driver Service. May 26 18:03:21 debija systemd[1]: Stopping DisplayLink Driver Service... May 26 18:03:22 debija systemd[1]: displaylink-driver.service: Succeeded. May 26 18:03:22 debija systemd[1]: Stopped DisplayLink Driver Service. May 26 18:03:22 debija systemd[1]: displaylink-driver.service: Consumed 41min 25.761s CPU time.

Johan
  • 399
  • A bit confused by what it means that a driver is "dead". Could you describe the actual situation you want to do this in? (Please edit your question do describe it.) – Marcus Müller May 27 '23 at 06:32
  • @MarcusMüller thanks for your question. Please see the updated question with system control status of the displaylink driver service – Johan May 27 '23 at 08:43
  • So, an external docking station... Is Thunderbolt involved, or is it connected just by USB? In other words, does lspci show any difference between working vs. not? If it does, the TB might need a tbtadm approve-all or similar after waking from suspend. – telcoM May 30 '23 at 08:09
  • @telcoM thanks for input! There is usb-c involved that supplies power to laptop and connects to dock ports/devices. Dunno about TB. The dock includes the possibility for usb-c to usb-a conversion; but if I used that, I would need to supply power through the usb-c anyway besides having the laptop connected to the dock. I cannot find tbtadm on my system, nor does apt search tbtadm return anything. Please see the output of lspci in the question about the problem: https://unix.stackexchange.com/questions/746739/why-after-suspend-only-sometimes-not-detect-usb-or-deactivates-driver-and-how – Johan May 30 '23 at 09:53
  • 1
    tbtadm might be in a package named thunderbolt-tools. I guess the dock fundamentally connects using the Thunderbolt protocol, and the "missing" USB devices are provided by a Thunderbolt-to-USB adapter within the dock. Once all the hardware connections are properly woken up from suspend (+ re-authorized if necessary), the missing USB devices should come back and be usable again, so restarting the DisplayLink driver service would have to be the last step in the wake-up process. – telcoM May 30 '23 at 10:24
  • 1
    DisplayLink driver runs mostly in userspace as a systemd service, but it also uses a kernel module (evdi) that allows to create a "virtual display device" with a userspace backend. But here it looks like the death of the driver service might be a consequence of the DisplayLink USB hardware not being accessible any more after the wakeup. – telcoM May 30 '23 at 10:37
  • @telcoM these are wonderful comments, thank you. You were right that I needed apt install thunderbolt-tools. $ sudo tbtadm approve-all returns Found domain "/sys/bus/thunderbolt/devices/domain0". But lsusb still does not detect the four devices. – Johan May 30 '23 at 12:53
  • Then, unfortunately, it might be a firmware issue. On Macs, thunderbolt-tools are absolutely needed - but on PCs, the system firmware can do most of that job. But if the firmware retains control of the Thunderbolt controller(s), and fails to wake them correctly after suspend, tbtadm might not be able to fix it. Then a BIOS update might be your only hope. But just for information, try tbtadm devices in both working and non-working states. Any info at all? Differences? – telcoM May 30 '23 at 13:11
  • @telcoM, okay, I don't understand. tbtadm devices show no output when the whole thing works as desired (before suspending twice). It seems so odd it won't get back after second suspend, but the first it will. I'm glad I just got hibernate to work, then I can use that as an alternative. Btw, I did not do anything else than tbtadm approve-all && lsusb -- did I have to do anything else? Did you notice I have installed tlp, and there are possible solutions like autosuspend, blacklist etc.? Would you assert these are not solutions in my case? – Johan May 30 '23 at 14:12

1 Answers1

2

Yep, sudo rmmod driver-name && sudo modprobe driver-name. This removes the driver (aka the module or the collection of modules) and loads it again.

Some devices are served by multiple drivers, for instance bluetooth or audio, in this case you need to rmmod drv1 drv2 drv3. You'll need to repeat it until it says "not loaded" for each driver for the specified command.

If rmmod fails for some reasons, normally you can only reboot to revive it. There's of course rmmod -f but it often leads to a system crash.

Unlike with rmmod, you can modprobe only one driver at a time. In most cases modprobe drv-name is enough as the command normally handles dependencies and will load all the required drivers automatically.

Use lsmod to see which modules you have loaded and running.

To know what drivers serve the device, use sudo lspci -vvv showing which PCI/PCIe devices use which drivers. For USB devices you could use lshw cf. Find out which modules are associated with a usb device?.

Now, displaylink-driver.service is not a driver. It is a service. And systemctl is not meant to work with device drivers. It's a service manager. In general, running rmmod smth for the first time and it says not currently loaded, it probably means the specified driver was never used in the first place. I'm not sure how services and drivers are related as they normally aren't. There are very specific services which load drivers, e.g. vboxdrv which is part of VirtualBox but that's it. It even contains "drv" in its name. Services in Linux are meant to start various background jobs (console applications, daemons, servers, etc.) There's a service called systemd-modules-load.service which loads additional modules which aren't automatically loaded.

Johan
  • 399
  • I get: `$ sudo rmmod displaylink-driver.service rmmod: ERROR: Module displaylink_driver is not currently loaded

    sudo modprobe displaylink-driver.service modprobe: FATAL: Module displaylink-driver.service not found in directory /lib/modules/5.10.0-23-amd64`

    – Johan May 27 '23 at 14:35
  • Thanks. Do you mind toucing upon 1) how to know what drivers serve the device? 2) will you explain why removing a module restarts a driver? – Johan May 27 '23 at 14:51
  • 1
  • sudo lspci -vvv shows which PCI/PCIe devices use which drivers. For USB devices you could use lshw or https://unix.stackexchange.com/questions/60078/find-out-which-modules-are-associated-with-a-usb-device 2) Removing the module (often) does nothing (in reality a lot can be done, there's a special kernel routine module_exit() for that): https://linux-kernel-labs.github.io/refs/heads/master/labs/kernel_modules.html It's when you load it again, the driver starts from scratch.
  • – Artem S. Tashkinov May 27 '23 at 15:08
  • 1
    If if you run rmmod smth for the first time and it says not currently loaded, it probably means the specified driver was never used in the first place. Use lsmod to see which modules you have loaded and running. Lastly mind that module and driver for the Linux kernel often mean the same but there are exceptions. For instance, a proprietary NVIDIA driver consists of several specific separate modules: nvidia, nvidia_modeset, nvidia_drm, nvidia_uvm - however all four of them are normally loaded automatically (remember the dependencies). – Artem S. Tashkinov May 27 '23 at 15:15
  • If the driver was never used, how come sudo systemctl status drv/module show "loaded"? – Johan May 27 '23 at 15:22
  • 1
    systemctl is not meant to work with device drivers. It's a service manager. It's amazing I've spent an hour explaining and typing all of this, and not heard a single "thank you". I will just see myself out. Too tired of this. Dunno what happened to being grateful, perhaps I'm just old. – Artem S. Tashkinov May 27 '23 at 15:31
  • So while I may detect inactive services using systemctl, is reactivating services a different question (not driver/module) or would services have to be reactivated at the driver/module level (identified using lshw)? – Johan May 27 '23 at 15:46
  • Thank you. I tried to write succinctly, and I am prompted not to write "thank you" in this comment box (but now I did it anyway). That's why I marked your comments with arrow up ^. And yes, I did write "Thanks" in my second comment :-) – Johan May 27 '23 at 16:02
  • I'm not sure how services and drivers are related as they normally aren't. There are very specific services which load drivers, e.g. vboxdrv which is part of VirtualBox but that's it. It even contains "drv" in its name ;-) All good. Services in Linux are meant to start various background jobs (console applications, daemons, servers, etc.) There's a service called systemd-modules-load.service which loads additional modules which aren't automatically loaded. – Artem S. Tashkinov May 27 '23 at 22:13
  • systemd-udev and kmod load modules by default. More on it here: https://wiki.archlinux.org/title/Kernel_module https://docs.fedoraproject.org/en-US/fedora/latest/system-administrators-guide/kernel-module-driver-configuration/Working_with_Kernel_Modules/ https://unix.stackexchange.com/questions/90027/what-is-the-sequence-loading-linux-kernel-module-on-startup-how-priority-is-set – Artem S. Tashkinov May 27 '23 at 22:13
  • Do you mind if I edit your answer to update it with all the information you provided in the comments? – Johan May 28 '23 at 07:39
  • 1
    You're welcome. Anyone can edit anyone's answers here. :-) – Artem S. Tashkinov May 28 '23 at 09:22
  • I suggested an edit informed by your comments. Please have a look and see if it is correct. I believe you answered my question, but you also explained that your answer is not immediately helpful in my case, since I experience a deactivated/dead service, not driver. I would have to go more in depth with the drivers of the usb devices/dock to understand how to eventually get the monitors up and running upon suspend. – Johan May 28 '23 at 10:10