Activate Thunderbolt docking station automatically

I have a laptop with a USB-C port and a docking station from the same manufacturer. The docking station has a few USB ports, audio connections, network interface, and a display port.
Generally, this docking station works fine when it was connected during boot (cold boot or reboot).
I’m using bolt to authorize the device. The service is running.

However, when the notebook is already running, or it was suspended or hibernated, and I plug it in nothing happens except charging the battery.
journalctl -fk doesn’t show anything (really no new line) when it’s connected or disconnected. The only thing that works is charging.

This happened since before kernel 5 was a thing, so the kernel version should not be important here.

The current workaround is running lspci after which it recognizes that it is plugged in and it works.

I doubt that a systemd-timer running lspci every few seconds is the best way to go here, right?

From the arch forums, I have found these kernel parameters:
pci=realloc,assign-busses,hpbussize=0x33 intel_iommu=on,igfx_off
which seems sometimes to work without that lspci workaround, sometimes not.
I don’t understand this line, so I don’t know what to change.

From the archforum (or was it the wiki), I also found this line to rescan connected devices:
echo 1 | sudo tee /sys/bus/pci/rescan
But this kills the connection to the NVMe and I have to REISUB.

inxi -Fazy
System:
  Kernel: 6.1.0-1-MANJARO arch: x86_64 bits: 64 compiler: gcc v: 12.2.0
    parameters: initrd=\intel-ucode.img initrd=\initramfs-6.1-x86_64.img
    root=UUID=820eeb04-e930-491c-9751-b39b8c1b13aa
    resume=/dev/mapper/volgroup0-rootvol resume_offset=99213311 rw quiet
    systemd.show_status=0 lsm=landlock,lockdown,yama,apparmor,bpf apparmor=1
    audit=0 pci=realloc,assign-busses,hpbussize=0x33 intel_iommu=on,igfx_off
  Desktop: i3 v: 4.21.1 info: i3bar vt: 9 dm: LightDM v: 1.32.0
    Distro: Manjaro Linux base: Arch Linux
Machine:
  Type: Laptop System: SCHENKER product: SCHENKER_SLIM_13_14_SSL13_14L18 v: N/A
    serial: <superuser required> Chassis: No Enclosure type: 10
    serial: <superuser required>
  Mobo: SCHENKER model: N13_N140ZU serial: <superuser required> UEFI: INSYDE
    v: 1.07.12RTR1 date: 01/06/2020
Battery:
  ID-1: BAT0 charge: 29.5 Wh (86.5%) condition: 34.1/35.3 Wh (96.5%)
    volts: 12.9 min: 11.4 model: Notebook BAT type: Li-ion serial: <filter>
    status: charging
CPU:
  Info: model: Intel Core i7-8565U bits: 64 type: MT MCP arch: Whiskey Lake
    gen: core 8 level: v3 note: check built: 2018 process: Intel 14nm family: 6
    model-id: 0x8E (142) stepping: 0xB (11) microcode: 0xF0
  Topology: cpus: 1x cores: 4 tpc: 2 threads: 8 smt: enabled cache:
    L1: 256 KiB desc: d-4x32 KiB; i-4x32 KiB L2: 1024 KiB desc: 4x256 KiB
    L3: 8 MiB desc: 1x8 MiB
  Speed (MHz): avg: 1815 high: 1833 min/max: 400/4600 scaling:
    driver: intel_pstate governor: powersave cores: 1: 1815 2: 1815 3: 1833
    4: 1813 5: 1825 6: 1804 7: 1815 8: 1801 bogomips: 32012
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
  Vulnerabilities:
  Type: itlb_multihit status: KVM: VMX disabled
  Type: l1tf status: Not affected
  Type: mds mitigation: Clear CPU buffers; SMT vulnerable
  Type: meltdown status: Not affected
  Type: mmio_stale_data mitigation: Clear CPU buffers; SMT vulnerable
  Type: retbleed mitigation: IBRS
  Type: spec_store_bypass mitigation: Speculative Store Bypass disabled via
    prctl
  Type: spectre_v1 mitigation: usercopy/swapgs barriers and __user pointer
    sanitization
  Type: spectre_v2 mitigation: IBRS, IBPB: conditional, RSB filling,
    PBRSB-eIBRS: Not affected
  Type: srbds mitigation: Microcode
  Type: tsx_async_abort status: Not affected
Graphics:
  Device-1: Intel WhiskeyLake-U GT2 [UHD Graphics 620] vendor: CLEVO/KAPOK
    driver: i915 v: kernel arch: Gen-9.5 process: Intel 14nm built: 2016-20
    ports: active: DP-1,HDMI-A-2,eDP-1 empty: HDMI-A-1 bus-ID: 00:02.0
    chip-ID: 8086:3ea0 class-ID: 0300
  Device-2: Chicony USB2.0 Camera type: USB driver: uvcvideo bus-ID: 1-7:3
    chip-ID: 04f2:b65c class-ID: 0e02 serial: <filter>
  Device-3: Logitech HD Webcam C525 type: USB driver: snd-usb-audio,uvcvideo
    bus-ID: 5-1:2 chip-ID: 046d:0826 class-ID: 0e02 serial: <filter>
  Display: x11 server: X.Org v: 21.1.4 with: Xwayland v: 22.1.5
    compositor: Picom v: git-98a5c driver: X: loaded: modesetting
    alternate: fbdev,vesa dri: iris gpu: i915 display-ID: :1 screens: 1
  Screen-1: 0 s-res: 6400x1440 s-dpi: 96 s-size: 1688x380mm (66.46x14.96")
    s-diag: 1730mm (68.12")
  Monitor-1: DP-1 pos: primary,center model: Acer EB321HQU serial: <filter>
    built: 2016 res: 2560x1440 hz: 60 dpi: 93 gamma: 1.2
    size: 699x393mm (27.52x15.47") diag: 802mm (31.6") ratio: 16:9 modes:
    max: 2560x1440 min: 720x400
  Monitor-2: HDMI-A-2 mapped: HDMI-2 pos: left model: Samsung SyncMaster
    serial: <filter> built: 2010 res: 1920x1080 hz: 60 dpi: 102 gamma: 1.2
    size: 477x268mm (18.78x10.55") diag: 547mm (21.5") ratio: 16:9 modes:
    max: 1920x1080 min: 640x480
  Monitor-3: eDP-1 pos: right model: ChiMei InnoLux 0x14d2 built: 2016
    res: 1920x1080 hz: 60 dpi: 158 gamma: 1.2 size: 309x173mm (12.17x6.81")
    diag: 354mm (13.9") ratio: 16:9 modes: 1920x1080
  API: OpenGL v: 4.6 Mesa 22.2.3 renderer: Mesa Intel UHD Graphics 620 (WHL
    GT2) direct render: Yes
Audio:
  Device-1: Intel Cannon Point-LP High Definition Audio vendor: CLEVO/KAPOK
    driver: snd_hda_intel v: kernel bus-ID: 5-1:2 chip-ID: 046d:0826
    alternate: snd_soc_skl,snd_sof_pci_intel_cnl class-ID: 0e02 bus-ID: 00:1f.3
    chip-ID: 8086:9dc8 serial: <filter> class-ID: 0403
  Device-2: Logitech HD Webcam C525 type: USB driver: snd-usb-audio,uvcvideo
  Device-3: Texas Instruments PCM2912A Audio Codec type: USB
    driver: snd-usb-audio bus-ID: 5-4:4 chip-ID: 08bb:2912 class-ID: 0102
  Sound API: ALSA v: k6.1.0-1-MANJARO running: yes
  Sound Server-1: PulseAudio v: 16.1 running: no
  Sound Server-2: PipeWire v: 0.3.61 running: yes
Network:
  Device-1: Intel Cannon Point-LP CNVi [Wireless-AC] driver: iwlwifi v: kernel
    bus-ID: 00:14.3 chip-ID: 8086:9df0 class-ID: 0280
  IF: wlp0s20f3 state: up mac: <filter>
  Device-2: Intel I210 Gigabit Network driver: igb v: kernel pcie: gen: 1
    speed: 2.5 GT/s lanes: 1 port: N/A bus-ID: 07:00.0 chip-ID: 8086:1533
    class-ID: 0200
  IF: enp7s0 state: up speed: 1000 Mbps duplex: full mac: <filter>
  Device-3: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet
    vendor: CLEVO/KAPOK driver: r8169 v: kernel pcie: gen: 1 speed: 2.5 GT/s
    lanes: 1 port: 3000 bus-ID: 38:00.1 chip-ID: 10ec:8168 class-ID: 0200
  IF: enp56s0f1 state: down mac: <filter>
  IF-ID-1: bond0 state: up speed: 1000 Mbps duplex: full mac: <filter>
  IF-ID-2: bonding_masters state: N/A speed: N/A duplex: N/A mac: N/A
  IF-ID-3: docker0 state: down mac: <filter>
  IF-ID-4: wg-ghoofypi state: down mac: N/A
  IF-ID-5: wg-ottobeuren state: down mac: N/A
Bluetooth:
  Device-1: Intel Bluetooth 9460/9560 Jefferson Peak (JfP) type: USB
    driver: N/A bus-ID: 1-10:4 chip-ID: 8087:0aaa class-ID: e001
  Report: This feature requires one of these tools: hciconfig/bt-adapter
Drives:
  Local Storage: total: 1.38 TiB used: 321.28 GiB (22.8%)
  SMART Message: Unable to run smartctl. Root privileges required.
  ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Samsung model: SSD 970 PRO 512GB
    size: 476.94 GiB block-size: physical: 512 B logical: 512 B speed: 31.6 Gb/s
    lanes: 4 type: SSD serial: <filter> rev: 1B2QEXP7 temp: 34.9 C scheme: GPT
  ID-2: /dev/sda maj-min: 8:0 vendor: Samsung model: SSD 860 EVO 1TB
    size: 931.51 GiB block-size: physical: 512 B logical: 512 B speed: 6.0 Gb/s
    type: SSD serial: <filter> rev: 1B6Q
Partition:
  ID-1: / raw-size: 476.43 GiB size: 467.88 GiB (98.21%)
    used: 92.52 GiB (19.8%) fs: ext4 dev: /dev/dm-1 maj-min: 254:1
    mapped: volgroup0-rootvol
  ID-2: /boot raw-size: 512 MiB size: 511 MiB (99.80%)
    used: 100.8 MiB (19.7%) fs: vfat dev: /dev/nvme0n1p1 maj-min: 259:1
  ID-3: /home raw-size: 931.51 GiB size: 915.82 GiB (98.31%)
    used: 228.67 GiB (25.0%) fs: ext4 dev: /dev/dm-2 maj-min: 254:2
    mapped: crypthome
Swap:
  Kernel: swappiness: 10 (default 60) cache-pressure: 50 (default 100)
  ID-1: swap-1 type: file size: 32.23 GiB used: 1.2 MiB (0.0%) priority: -2
    file: /swapfile
Sensors:
  System Temperatures: cpu: 72.0 C pch: 66.0 C mobo: N/A
  Fan Speeds (RPM): N/A
Info:
  Processes: 348 Uptime: 1d 1h 49m wakeups: 1 Memory: 31.06 GiB
  used: 17.19 GiB (55.4%) Init: systemd v: 252 default: graphical
  tool: systemctl Compilers: gcc: 12.2.0 clang: 14.0.6 Packages: 2124
  pm: pacman pkgs: 2099 libs: 309 tools: pamac pm: flatpak pkgs: 25 Shell: Zsh
  v: 5.9 running-in: kitty inxi: 3.3.23

Hello @mithrial :wink:

From what I read here: /lib/udev/rules.d/90-bolt.rules

ACTION=="remove", GOTO="bolt_end"

# start bolt service if we have a thunderbolt device connected
SUBSYSTEM=="thunderbolt", TAG+="systemd", ENV{SYSTEMD_WANTS}+="bolt.service"

LABEL="bolt_end"

it should trigger it when connected.

Eventually you need to trigger it again?

sudo udevadm trigger --subsystem-match="thunderbolt" --verbose

I don’t user thunderbolt, so cannot test it.

Eventually you can monitor the udev events when this happens?

sudo udevadm monitor --subsystem-match="thunderbolt"

Yesterday, I closed the lid, the system suspended.

Today, I opened the lid and the DP-connected screen came on, however, the connected USB devices (mouse, keyboard, webcam) and ethernet didn’t.

This is the journal for opening the lid:

journalctl -b
Dez 02 08:31:37 user kernel: ACPI: PM: Waking up from system sleep state S3
Dez 02 08:31:37 user kernel: ACPI: EC: interrupt unblocked
Dez 02 08:31:37 user kernel: rtsx_pci 0000:38:00.0: Unable to change power state from D3cold to D0, device inaccessible
Dez 02 08:31:37 user kernel: r8169 0000:38:00.1: Unable to change power state from D3cold to D0, device inaccessible
Dez 02 08:31:37 user kernel: pcieport 0000:01:00.0: Unable to change power state from D3cold to D0, device inaccessible
Dez 02 08:31:37 user kernel: pcieport 0000:02:00.0: Unable to change power state from D3cold to D0, device inaccessible
Dez 02 08:31:37 user kernel: pcieport 0000:02:01.0: Unable to change power state from D3cold to D0, device inaccessible
Dez 02 08:31:37 user kernel: pcieport 0000:02:02.0: Unable to change power state from D3cold to D0, device inaccessible
Dez 02 08:31:37 user kernel: pcieport 0000:04:00.0: Unable to change power state from D3cold to D0, device inaccessible
Dez 02 08:31:37 user kernel: pcieport 0000:05:02.0: Unable to change power state from D3cold to D0, device inaccessible
Dez 02 08:31:37 user kernel: pcieport 0000:05:04.0: Unable to change power state from D3cold to D0, device inaccessible
Dez 02 08:31:37 user kernel: pcieport 0000:05:00.0: Unable to change power state from D3cold to D0, device inaccessible
Dez 02 08:31:37 user kernel: pcieport 0000:05:01.0: Unable to change power state from D3cold to D0, device inaccessible
Dez 02 08:31:37 user kernel: igb 0000:07:00.0: Unable to change power state from D3cold to D0, device inaccessible
Dez 02 08:31:37 user kernel: xhci_hcd 0000:06:00.0: Unable to change power state from D3cold to D0, device inaccessible
Dez 02 08:31:37 user kernel: xhci_hcd 0000:08:00.0: Unable to change power state from D3cold to D0, device inaccessible
Dez 02 08:31:37 user kernel: xhci_hcd 0000:37:00.0: Unable to change power state from D3cold to D0, device inaccessible
Dez 02 08:31:37 user kernel: thunderbolt 0000:03:00.0: Unable to change power state from D3cold to D0, device inaccessible
Dez 02 08:31:37 user kernel: ACPI: EC: event unblocked
Dez 02 08:31:37 user kernel: iwlwifi 0000:00:14.3: RF_KILL bit toggled to enable radio.
Dez 02 08:31:37 user kernel: sd 0:0:0:0: [sda] Starting disk
Dez 02 08:31:37 user kernel: i915 0000:00:02.0: [drm] GuC firmware i915/kbl_guc_70.1.1.bin version 70.1.1
Dez 02 08:31:37 user kernel: i915 0000:00:02.0: [drm] HuC firmware i915/kbl_huc_4.0.0.bin version 4.0.0
Dez 02 08:31:37 user kernel: pcieport 0000:00:1c.0: pciehp: Slot(4): Card not present
Dez 02 08:31:37 user kernel: xhci_hcd 0000:37:00.0: remove, state 4
Dez 02 08:31:37 user kernel: usb usb4: USB disconnect, device number 1
Dez 02 08:31:37 user kernel: igb 0000:07:00.0: Unable to change power state from D3cold to D0, device inaccessible
Dez 02 08:31:37 user kernel: xhci_hcd 0000:06:00.0: Unable to change power state from D3cold to D0, device inaccessible
Dez 02 08:31:37 user kernel: xhci_hcd 0000:08:00.0: Unable to change power state from D3cold to D0, device inaccessible
Dez 02 08:31:37 user kernel: xhci_hcd 0000:06:00.0: Controller not ready at resume -19
Dez 02 08:31:37 user kernel: xhci_hcd 0000:08:00.0: Controller not ready at resume -19
Dez 02 08:31:37 user kernel: xhci_hcd 0000:06:00.0: PCI post-resume error -19!
Dez 02 08:31:37 user kernel: xhci_hcd 0000:08:00.0: PCI post-resume error -19!
Dez 02 08:31:37 user kernel: xhci_hcd 0000:06:00.0: HC died; cleaning up
Dez 02 08:31:37 user kernel: xhci_hcd 0000:08:00.0: HC died; cleaning up
Dez 02 08:31:37 user kernel: igb 0000:07:00.0: PM: dpm_run_callback(): pci_pm_resume+0x0/0xf0 returns -19
Dez 02 08:31:37 user kernel: xhci_hcd 0000:06:00.0: PM: dpm_run_callback(): pci_pm_resume+0x0/0xf0 returns -19
Dez 02 08:31:37 user kernel: xhci_hcd 0000:08:00.0: PM: dpm_run_callback(): pci_pm_resume+0x0/0xf0 returns -19
Dez 02 08:31:37 user kernel: igb 0000:07:00.0: PM: failed to resume async: error -19
Dez 02 08:31:37 user kernel: xhci_hcd 0000:06:00.0: PM: failed to resume async: error -19
Dez 02 08:31:37 user kernel: xhci_hcd 0000:08:00.0: PM: failed to resume async: error -19
Dez 02 08:31:37 user kernel: xhci_hcd 0000:37:00.0: USB bus 4 deregistered
Dez 02 08:31:37 user kernel: xhci_hcd 0000:37:00.0: remove, state 4
Dez 02 08:31:37 user kernel: usb usb3: USB disconnect, device number 1
Dez 02 08:31:37 user kernel: xhci_hcd 0000:37:00.0: Host halt failed, -19
Dez 02 08:31:37 user kernel: xhci_hcd 0000:37:00.0: Host not accessible, reset failed.
Dez 02 08:31:37 user kernel: xhci_hcd 0000:37:00.0: USB bus 3 deregistered
Dez 02 08:31:37 user kernel: xhci_hcd 0000:08:00.0: remove, state 4
Dez 02 08:31:37 user kernel: usb usb8: USB disconnect, device number 1
Dez 02 08:31:37 user kernel: xhci_hcd 0000:08:00.0: USB bus 8 deregistered
Dez 02 08:31:37 user kernel: xhci_hcd 0000:08:00.0: remove, state 4
Dez 02 08:31:37 user kernel: usb usb7: USB disconnect, device number 1
Dez 02 08:31:37 user kernel: usb 7-2: USB disconnect, device number 2
Dez 02 08:31:37 user kernel: xhci_hcd 0000:08:00.0: Host halt failed, -19
Dez 02 08:31:37 user kernel: xhci_hcd 0000:08:00.0: Host not accessible, reset failed.
Dez 02 08:31:37 user kernel: xhci_hcd 0000:08:00.0: USB bus 7 deregistered
Dez 02 08:31:37 user kernel: igb 0000:07:00.0: removed PHC on enp7s0
Dez 02 08:31:37 user kernel: igb 0000:07:00.0 enp7s0: PCIe link lost
Dez 02 08:31:37 user kernel: nvme nvme0: Shutdown timeout set to 8 seconds
Dez 02 08:31:37 user kernel: nvme nvme0: 8/0/0 default/read/poll queues
Dez 02 08:31:37 user kernel: i915 0000:00:02.0: [drm] HuC authenticated
Dez 02 08:31:37 user kernel: i915 0000:00:02.0: [drm] GuC submission disabled
Dez 02 08:31:37 user kernel: i915 0000:00:02.0: [drm] GuC SLPC disabled
Dez 02 08:31:37 user kernel: i915 0000:00:02.0: [drm] [ENCODER:94:DDI A/PHY A] is disabled/in DSI mode with an ungated DDI clock, gate it
Dez 02 08:31:37 user kernel: i915 0000:00:02.0: [drm] [ENCODER:102:DDI B/PHY B] is disabled/in DSI mode with an ungated DDI clock, gate it
Dez 02 08:31:37 user kernel: i915 0000:00:02.0: [drm] [ENCODER:118:DDI C/PHY C] is disabled/in DSI mode with an ungated DDI clock, gate it
Dez 02 08:31:37 user kernel: rtsx_pci 0000:38:00.0: PM: dpm_run_callback(): pci_pm_resume+0x0/0xf0 returns -110
Dez 02 08:31:37 user kernel: rtsx_pci 0000:38:00.0: PM: failed to resume async: error -110
Dez 02 08:31:37 user kernel: r8169 0000:38:00.1 enp56s0f1: Link is Down
Dez 02 08:31:37 user kernel: bond0: (slave enp7s0): Releasing backup interface
Dez 02 08:31:37 user kernel: usb 1-10: reset full-speed USB device number 4 using xhci_hcd
Dez 02 08:31:37 user kernel: ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
Dez 02 08:31:37 user kernel: ata1.00: supports DRM functions and may not be fully accessible
Dez 02 08:31:37 user kernel: ata1.00: supports DRM functions and may not be fully accessible
Dez 02 08:31:37 user kernel: ata1.00: configured for UDMA/133
Dez 02 08:31:37 user kernel: ahci 0000:00:17.0: port does not support device sleep
Dez 02 08:31:37 user kernel: ata1.00: Enabling discard_zeroes_data
Dez 02 08:31:37 user kernel: usb 1-7: reset high-speed USB device number 3 using xhci_hcd
Dez 02 08:31:37 user kernel: pci 0000:05:04.0: Runtime PM usage count underflow!
Dez 02 08:31:37 user kernel: xhci_hcd 0000:06:00.0: remove, state 4
Dez 02 08:31:37 user kernel: usb usb6: USB disconnect, device number 1
Dez 02 08:31:37 user kernel: xhci_hcd 0000:06:00.0: USB bus 6 deregistered
Dez 02 08:31:37 user kernel: xhci_hcd 0000:06:00.0: remove, state 4
Dez 02 08:31:37 user kernel: usb usb5: USB disconnect, device number 1
Dez 02 08:31:37 user kernel: usb 5-1: USB disconnect, device number 2
Dez 02 08:31:37 user kernel: mei_hdcp 0000:00:16.0-b638ab7e-94e2-4ea2-a552-d1c54b627f04: bound 0000:00:02.0 (ops i915_hdcp_component_ops [i915])
Dez 02 08:31:37 user kernel: OOM killer enabled.
Dez 02 08:31:37 user kernel: Restarting tasks ... 
Dez 02 08:31:37 user kernel: usb 5-3: USB disconnect, device number 3
Dez 02 08:31:37 user kernel: usb 5-4: USB disconnect, device number 4
Dez 02 08:31:37 user kernel: done.
Dez 02 08:31:37 user kernel: random: crng reseeded on system resumption
Dez 02 08:31:37 user kernel: PM: suspend exit
Dez 02 08:31:37 user kernel: xhci_hcd 0000:06:00.0: Host halt failed, -19
Dez 02 08:31:37 user kernel: xhci_hcd 0000:06:00.0: Host not accessible, reset failed.
Dez 02 08:31:37 user kernel: xhci_hcd 0000:06:00.0: USB bus 5 deregistered
Dez 02 08:31:37 user kernel: pcieport 0000:02:01.0: Runtime PM usage count underflow!
Dez 02 08:31:37 user systemd-logind[3765]: Lid opened.

The main detail I see is:
Dez 02 08:31:37 user kernel: pcieport 0000:01:00.0: Unable to change power state from D3cold to D0, device inaccessible

Running the trigger, didn’t do anything. Nothing in the log, no output.

And to my fascination, running lspci -v “woke up” the device, the log filled with connecting devices and everything works.

Just my humble view:

  1. On suspend it freezes the state.
  2. When waking up from suspend it tries to connect to the devices which were known at the frozen state while the usbc port is still suspended (maybe it doesn’t wait for usb wake up). Thus error 19 (device not found).
  3. When triggering lspci it reassigns the “virtual” (since usb) pci addresses because usb is woken up.

So I would assume you need to blacklist the usbc port for auto suspending or find a way that the usbc port will wake up before it tries to connect to the devices.

When I run this before plugging in

it will stay empty until I run lspci. Afterwards it logs a few lines and the adapter is working.

Manually starting the trigger also doesn’t print anything