DisplayLink / evdi

Extensible Virtual Display Interface
MIT License
689 stars 179 forks source link

No devices found - 1.14.1+, kernel 6.7* #451

Open iam-TJ opened 5 months ago

iam-TJ commented 5 months ago

Edited based on realising DKMS had cached an old copy of the source so changes in /usr/src/evdi-1.14.1/ were not being built

When doing modprobe evdi initial_loglevel=6 the kernel log only shows:

kernel: evdi: [I] Initialising logging on level 6
kernel: evdi: [I] Atomic driver: yes

I added pr_info() messages to ensure evdi_init() was completing - and it is:

kernel: evdi: [I] Initialising logging on level 6
kernel: evdi: [I] Atomic driver: yes
kernel: evdi: USB support enabled
kernel: evdi: USB notify enabled
kernel: evdi: platform_driver_register() returned 0

unloading and reloading the module doesn't improve things; nor does unplugging and reconnecting the Dell D3000 USB3 hub. Kernel correctly reports the USB devices being discovered:

$ lsusb -d 17e9:
Bus 002 Device 006: ID 17e9:4318 DisplayLink Dell USB 3.0 Dock

Udev rules are triggered and userspace seems to do its part correctly, creating /dev/displaylink/by-id/usb-002-006-DisplayLink_Dell_USB_3.0_Dock_31108357 and the displaylink.service is active and DisplayLinkManager running.

SourceCode/evdi/module$ git status; git l -n 1
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean

d21a6ea 2024-01-30 09:34:41 +0100 N Crashdummy Declare DRM_UNLOCKED to improve readability

Debian 12 Bookworm, amd64, v6.7.1+debian+tj

I build upstream kernels with the Debian kernel config and a handful of my own patches (none of which would cause this!) E.g:

linux$ git l -n 10
f0b435178cbe 2024-01-31 22:42:42 +0000 N Tj debian: update latest kernel symlinks
f41f9394c736 2024-01-31 22:42:42 +0000 N Tj bluetooth: take lock before reading flags
743108d8700e 2024-01-31 22:42:42 +0000 N Tj ath: add module_param country_default for regulatory domain control
cb95c1ccd6dc 2024-01-31 22:42:42 +0000 N Tj cfg80211: suppress regdom warning when phy not ready
ffdd24fffb5d 2024-01-31 22:42:42 +0000 N Tj package: debian: make debug symbol .deb optional
7fce27ab7ef5 2024-01-31 22:42:42 +0000 N Tj firmware: report each loaded firmware file
7bbf3b67cb49 2024-01-25 15:45:31 -0800 N Greg Kroah-Hartman Linux 6.7.2

I suspect this is caused by recent kernel changes - I shall pepper the module with pr_info() to try to identify what is (not) working.

iam-TJ commented 5 months ago

Loaded module:

$ grep -s . /sys/devices/evdi/*
/sys/devices/evdi/count:0
/sys/devices/evdi/loglevel:6
/sys/devices/evdi/version:1.14.1
iam-TJ commented 5 months ago

Using an fprobe attached to evdi_platform_device_probe() there is no event reported when connecting the Dell D3000 hub; so it may be the issue is higher up the chain.

/sys/kernel/tracing# echo "f evdi_platform_device_probe" >> dynamic_events
/sys/kernel/tracing# echo 1 >  events/fprobes/enable
/sys/kernel/tracing# cat trace
# tracer: nop
#
# entries-in-buffer/entries-written: 0/0   #P:4
#
#                                _-----=> irqs-off/BH-disabled
#                               / _----=> need-resched
#                              | / _---=> hardirq/softirq
#                              || / _--=> preempt-depth
#                              ||| / _-=> migrate-disable
#                              |||| /     delay
#           TASK-PID     CPU#  |||||  TIMESTAMP  FUNCTION
#              | |         |   |||||     |         |

kernel log:

/sys/kernel/tracing# journalctl --dmesg --since "10 minutes ago" | awk '{$1 = $2 =$3 = $4 = $5 = ""; print}'
     usb 2-2.2: USB disconnect, device number 3
     usb 2-2.2.3: USB disconnect, device number 4
     cdc_ncm 2-2.2.3:1.5 enx00249b0c6dd1: unregister 'cdc_ncm' usb-0000:00:14.0-2.2.3, CDC NCM (SEND ZLP)
     usb 1-2.2: USB disconnect, device number 7
     usb 1-2.2.4: USB disconnect, device number 9
     usb 2-2.2: new SuperSpeed USB device number 5 using xhci_hcd
     usb 2-2.2: New USB device found, idVendor=05e3, idProduct=0612, bcdDevice=44.01
     usb 2-2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
     usb 2-2.2: Product: USB3.0 Hub
     usb 2-2.2: Manufacturer: GenesysLogic
     hub 2-2.2:1.0: USB hub found
     hub 2-2.2:1.0: 4 ports detected
     usb 1-2.2: new high-speed USB device number 11 using xhci_hcd
     usb 1-2.2: new high-speed USB device number 12 using xhci_hcd
     usb 1-2-port2: attempt power cycle
     usb 2-2.2.3: new SuperSpeed USB device number 6 using xhci_hcd
     usb 2-2.2.3: New USB device found, idVendor=17e9, idProduct=4318, bcdDevice=31.02
     usb 2-2.2.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
     usb 2-2.2.3: Product: Dell USB 3.0 Dock
     usb 2-2.2.3: Manufacturer: DisplayLink
     usb 2-2.2.3: SerialNumber: 31108357
     usb 2-2.2.3: Warning! Unlikely big volume range (=511), cval->res is probably wrong.
     usb 2-2.2.3: [15] FU [Dell USB Audio Playback Volume] ch = 6, val = -8176/0/16
     usb 2-2.2.3: Warning! Unlikely big volume range (=767), cval->res is probably wrong.
     usb 2-2.2.3: [12] FU [Mic Capture Volume] ch = 2, val = -4592/7680/16
     cdc_ncm 2-2.2.3:1.5: MAC-Address: 00:24:9b:0c:6d:d1
     cdc_ncm 2-2.2.3:1.5: setting rx_max = 16384
     cdc_ncm 2-2.2.3:1.5: setting tx_max = 16384
     cdc_ncm 2-2.2.3:1.5 eth0: register 'cdc_ncm' at usb-0000:00:14.0-2.2.3, CDC NCM (SEND ZLP), 00:24:9b:0c:6d:d1
     cdc_ncm 2-2.2.3:1.5: setting rx_max = 64511
     cdc_ncm 2-2.2.3:1.5: setting tx_max = 64511
     cdc_ncm 2-2.2.3:1.5 enx00249b0c6dd1: renamed from eth0
     usb 1-2.2: new high-speed USB device number 13 using xhci_hcd
     usb 1-2.2: New USB device found, idVendor=05e3, idProduct=0610, bcdDevice=44.01
     usb 1-2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
     usb 1-2.2: Product: USB2.0 Hub
     usb 1-2.2: Manufacturer: GenesysLogic
     hub 1-2.2:1.0: USB hub found
     hub 1-2.2:1.0: 4 ports detected
     usb 1-2.2.4: new high-speed USB device number 14 using xhci_hcd
     usb 1-2.2.4: New USB device found, idVendor=05e3, idProduct=0610, bcdDevice=32.98
     usb 1-2.2.4: New USB device strings: Mfr=0, Product=1, SerialNumber=0
     usb 1-2.2.4: Product: USB2.0 Hub
     hub 1-2.2.4:1.0: USB hub found
     hub 1-2.2.4:1.0: 4 ports detected
iam-TJ commented 5 months ago

Adding another fprobe for the USB notifier also does not report any events:

/sys/kernel/tracing# cat dynamic_events 
f:fprobes/evdi_platform_device_probe__entry evdi_platform_device_probe
f:fprobes/evdi_platform_drv_usb__entry evdi_platform_drv_usb

/sys/kernel/tracing# grep . events/fprobes/*/enable
events/fprobes/evdi_platform_device_probe__entry/enable:1
events/fprobes/evdi_platform_drv_usb__entry/enable:1
iam-TJ commented 5 months ago

After studying dkms_install.sh I realised device/output discovery is not automatic as would be expected! One has to either manually add devices (echo 1 > /sys/devices/evdi/add) or use the module load option initial_device_count=

I've added PR Issue #453 "module: add README with instructions on usage" to address this.

Although outputs now show up the host still has the same problem as others have reported; the physical devices are not discovered.

iam-TJ commented 5 months ago

Update with system config now evdi module is now reporting (but failing to detect CRTCs). There is one DVI monitor connected to the Dell D3000.

# lsusb -s 2:4
Bus 002 Device 004: ID 17e9:4318 DisplayLink Dell USB 3.0 Dock
# lsusb -tv
...
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
    ID 1d6b:0003 Linux Foundation 3.0 root hub
    |__ Port 2: Dev 2, If 0, Class=Hub, Driver=hub/2p, 5000M
        ID 05e3:0616 Genesys Logic, Inc. hub
        |__ Port 2: Dev 3, If 0, Class=Hub, Driver=hub/4p, 5000M
            ID 05e3:0612 Genesys Logic, Inc. Hub
            |__ Port 3: Dev 4, If 0, Class=Vendor Specific Class, Driver=, 5000M
                ID 17e9:4318 DisplayLink 
            |__ Port 3: Dev 4, If 1, Class=Application Specific Interface, Driver=, 5000M
                ID 17e9:4318 DisplayLink 
            |__ Port 3: Dev 4, If 2, Class=Audio, Driver=snd-usb-audio, 5000M
                ID 17e9:4318 DisplayLink 
            |__ Port 3: Dev 4, If 3, Class=Audio, Driver=snd-usb-audio, 5000M
                ID 17e9:4318 DisplayLink 
            |__ Port 3: Dev 4, If 4, Class=Audio, Driver=snd-usb-audio, 5000M
                ID 17e9:4318 DisplayLink 
            |__ Port 3: Dev 4, If 5, Class=Communications, Driver=cdc_ncm, 5000M
                ID 17e9:4318 DisplayLink 
            |__ Port 3: Dev 4, If 6, Class=CDC Data, Driver=cdc_ncm, 5000M
                ID 17e9:4318 DisplayLink

Summary of the kernel log (full log is attached):

# journalctl --dmesg --since 11:58  | grep -E 'Initial|Cannot|Connector' | awk '{$1=$2=$3=$4=$5=""; print}'
     evdi: [I] Initialising logging on level 6
     evdi: [V] evdi_detect:134 (card1) Connector state: disconnected
     evdi evdi.0: [drm] Cannot find any crtc or sizes
     [drm] Initialized evdi 1.14.2 20240131 for evdi.0 on minor 1
     evdi: [V] evdi_detect:134 (card2) Connector state: disconnected
     evdi evdi.1: [drm] Cannot find any crtc or sizes
     [drm] Initialized evdi 1.14.2 20240131 for evdi.1 on minor 2
     evdi: [V] evdi_detect:134 (card3) Connector state: disconnected
     evdi evdi.2: [drm] Cannot find any crtc or sizes
     [drm] Initialized evdi 1.14.2 20240131 for evdi.2 on minor 3
     evdi: [V] evdi_detect:134 (card4) Connector state: disconnected
     evdi evdi.3: [drm] Cannot find any crtc or sizes
     [drm] Initialized evdi 1.14.2 20240131 for evdi.3 on minor 4
     evdi: [V] evdi_detect:134 (card3) Connector state: disconnected

kernel.log

iam-TJ commented 5 months ago

I added logging to udev.sh so it has set -x and writes stdout/stderr to /var/log/displaylink-udev.log; on connecting the USB hub it reports:

+ [ add = add ]
+ [ 4 -ge 3 ]
+ main add /dev /devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2.2/2-2.2.3/2-2.2.3:1.0 usb-002-006-DisplayLink_Dell_USB_3.0_Dock_31108357 /dev/bus/usb/002/006
+ action=add
+ root=/dev
+ devpath=/devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2.2/2-2.2.3/2-2.2.3:1.0
+ devnode=/dev/bus/usb/002/006
+ [ add = add ]
+ device_id=usb-002-006-DisplayLink_Dell_USB_3.0_Dock_31108357
+ create_displaylink_symlink /dev usb-002-006-DisplayLink_Dell_USB_3.0_Dock_31108357 /dev/bus/usb/002/006
+ root=/dev
+ device_id=usb-002-006-DisplayLink_Dell_USB_3.0_Dock_31108357
+ devnode=/dev/bus/usb/002/006
+ mkdir -p /dev/displaylink/by-id
+ ln -sf /dev/bus/usb/002/006 /dev/displaylink/by-id/usb-002-006-DisplayLink_Dell_USB_3.0_Dock_31108357
+ start_displaylink
+ get_displaylink_dev_count
+ grep 17e9
+ cat /sys/bus/usb/devices/1-2.2.4/idVendor /sys/bus/usb/devices/1-2.2/idVendor /sys/bus/usb/devices/1-2/idVendor /sys/bus/usb/devices/1-4/idVendor /sys/bus/usb/devices/1-5/idVendor /sys/bus/usb/devices/1-6/idVendor /sys/bus/usb/devices/1-7/idVendor /sys/bus/usb/devices/2-2.2.3/idVendor /sys/bus/usb/devices/2-2.2/idVendor /sys/bus/usb/devices/2-2/idVendor /sys/bus/usb/devices/3-1/idVendor /sys/bus/usb/devices/usb1/idVendor /sys/bus/usb/devices/usb2/idVendor /sys/bus/usb/devices/usb3/idVendor
+ wc -l
+ [ 1 != 0 ]
+ start_service
+ systemctl start --no-block displaylink
+ disable_u1_u2 /devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2.2/2-2.2.3/2-2.2.3:1.0
+ echo 0
+ return 0

displaylink.service is running after this so it seems to be working correctly.

iam-TJ commented 5 months ago

In order to determine what the userspace daemon DisplayLinkManager is doing I added logging into every function of libevdi.so to try and track its use. It is extremely unhelpful that the log output of DisplayLinkManager is encrypted. To that end I didn't let libevdi use the internal logging function; instead I have:

diff --git a/library/evdi_lib.c b/library/evdi_lib.c
index 483cf2b..33c8c5d 100644
--- a/library/evdi_lib.c
+++ b/library/evdi_lib.c
@@ -32,7 +32,7 @@
 #define EVDI_MODULE_COMPATIBILITY_VERSION_MINOR 9
 #define EVDI_MODULE_COMPATIBILITY_VERSION_PATCH 0

-#define evdi_log(...) do {                                             \
+/* #define evdi_log(...) do {                                          \
        if (g_evdi_logging.function) {                                  \
                g_evdi_logging.function(g_evdi_logging.user_data,       \
                                        __VA_ARGS__);                   \
@@ -41,6 +41,8 @@
                printf("\n");                                           \
        }                                                               \
 } while (0)
+*/
+#define evdi_log(...) do { printf("[libevdi] " __VA_ARGS__); printf("\n"); } while (0)

 struct evdi_logging g_evdi_logging = {
        .function = NULL,
@@ -65,7 +67,7 @@ static evdi_handle card_usage[EVDI_USAGE_LEN];
 static int drm_ioctl(int fd, unsigned long request, void *arg)
 {
        int ret;
-
+       evdi_log("drm_ioctl()\n");
...

When connecting the DL hub the displaylink.service log only contains a couple of messages from libevdi that makes me wonder if the problems being experienced are due to an incompatible userspace?

systemd[1]: Starting DisplayLink Manager Service...
systemd[1]: Started DisplayLink Manager Service.
DisplayLinkManager[297911]: GFYFEKZlPOOleEFNXqYmG7953hBLErVY3zvTX7HRDTdjkwev3DZzy0qtwSrjD2ngBgsWoIEMeWGT1N8YM5IYE0XFRcnBUFLQwiN150wDLDgYJV4MPB/CsXedW2NA729ZM168k>
DisplayLinkManager[297911]: BqD9UFAOlJDd0O4djYSqLNIJJERkjBTnsgGbTuRrAmmR2ihQ0rrZRMUbz6Jo9ewSF+5FHLJwHigte4jhXpxiWtHS+Y38HYHXW08Z705TMgtlZ821pXAqR29gpnqRE1+BZZ36a>
DisplayLinkManager[297911]: 7y/O+IEmP+pPjBuAo7/fPBJEwj28nbqSx3EaofyyNs/E1gMGZbPGglCWkyK2JmiPTo9uuEOLylZVF0JD3/mDelnfV4Vd2ulSuvJuIW+0j53FX00VjFnay6PEqs3OfMxmGLO6Y>
DisplayLinkManager[297911]: IoCGv+8dCCT8tC9Tsx2PJeiE7SvXpMDwviVPLykNQt9muuiwMBPbjT0ork6bdNymtfLPP+ur9WpXMnmqp/97OHjyi90Yq9zQ9EfmXuOgCnBBcnaSD5yEZa9ybOrwLIv3
DisplayLinkManager[297911]: boJJE1LL4M/wOZf8U67olQp3KFxzxq8zpUR4Q5T/Fl/j+YhKG0ARbasz9iy6TJqakFHgUwxWdSWz9+f/HjNquyLC+KCm61OawbYVC6xtvr6DlEx2aIAwHoNcTFmnLozX5B67r>
DisplayLinkManager[297911]: [libevdi] evdi_set_logging()
DisplayLinkManager[297911]: [libevdi] evdi_get_lib_version()
...
retpolanne commented 4 months ago

I think I'm having the same issue as you (although I haven't done any fiddling with the logs),

Whenever I connect or disconnect a display from my docking station, I don't see any messages on dmesg or anything related to evdi. I have evdi and displayport installed on Arch, the daemon is working and evdi is listed on dkms.

Also, nothing shows up when I strace the process when disconnecting the display.