ewagner12 / all-ways-egpu

Configure eGPU as primary under Linux Wayland desktops
MIT License
169 stars 11 forks source link

Method 2 detects the eGPU but method 3 does not #24

Open Smeeto13 opened 4 weeks ago

Smeeto13 commented 4 weeks ago

I tried changing the service file so method 3 runs after method 2 in order to verify and the GPU is still not detected by method 3

Method 2 auto switch at startup service
○ all-ways-egpu-boot-vga.service - Configure eGPU as primary using boot_vga under Wayland desktops
     Loaded: loaded (/etc/systemd/system/all-ways-egpu-boot-vga.service; enabled; preset: disabled)
     Active: inactive (dead) since Mon 2024-06-03 20:34:44 BST; 32s ago
    Process: 771 ExecStart=all-ways-egpu set-boot-vga egpu (code=exited, status=0/SUCCESS)
   Main PID: 771 (code=exited, status=0/SUCCESS)
        CPU: 55ms

Jun 03 20:34:43 Dell-Latitude-7330 systemd[1]: Starting Configure eGPU as primary using boot_vga under Wayland desktops...
Jun 03 20:34:43 Dell-Latitude-7330 all-ways-egpu[771]: No eGPU detected, retry 1
Jun 03 20:34:44 Dell-Latitude-7330 all-ways-egpu[771]: No eGPU detected, retry 2
Jun 03 20:34:44 Dell-Latitude-7330 all-ways-egpu[939]: /sys/bus/pci/devices/0000:00:02.0
Jun 03 20:34:44 Dell-Latitude-7330 all-ways-egpu[943]: /sys/bus/pci/devices/0000:3e:00.0
Jun 03 20:34:44 Dell-Latitude-7330 all-ways-egpu[771]: Bind mounts set. Restart Display Manager for changes to take effect.
Jun 03 20:34:44 Dell-Latitude-7330 systemd[1]: all-ways-egpu-boot-vga.service: Deactivated successfully.
Jun 03 20:34:44 Dell-Latitude-7330 systemd[1]: Finished Configure eGPU as primary using boot_vga under Wayland desktops.
Method 3 auto switch at startup service
○ all-ways-egpu-set-compositor.service - Configure eGPU as primary using compositor variables under Wayland desktops
     Loaded: loaded (/etc/systemd/system/all-ways-egpu-set-compositor.service; enabled; preset: disabled)
     Active: inactive (dead) since Mon 2024-06-03 20:34:46 BST; 30s ago
    Process: 947 ExecStart=all-ways-egpu set-compositor-primary egpu (code=exited, status=0/SUCCESS)
   Main PID: 947 (code=exited, status=0/SUCCESS)
        CPU: 129ms

Jun 03 20:34:44 Dell-Latitude-7330 systemd[1]: Starting Configure eGPU as primary using compositor variables under Wayland desktops...
Jun 03 20:34:44 Dell-Latitude-7330 all-ways-egpu[947]: No eGPU detected, retry 1
Jun 03 20:34:45 Dell-Latitude-7330 all-ways-egpu[947]: No eGPU detected, retry 2
Jun 03 20:34:45 Dell-Latitude-7330 all-ways-egpu[947]: No eGPU detected, retry 3
Jun 03 20:34:46 Dell-Latitude-7330 all-ways-egpu[947]: No eGPU detected after 3 retries. Check eGPU connection or increase number in /usr/share/all-ways-egpu/max-retry to give more time
Jun 03 20:34:46 Dell-Latitude-7330 all-ways-egpu[947]: No card set as primary
Jun 03 20:34:46 Dell-Latitude-7330 systemd[1]: all-ways-egpu-set-compositor.service: Deactivated successfully.
Jun 03 20:34:46 Dell-Latitude-7330 systemd[1]: Finished Configure eGPU as primary using compositor variables under Wayland desktops.
ewagner12 commented 4 weeks ago

It looks to me like it's a race between how fast (or slow) the eGPU is initialized and how fast the script runs before it gives up. Could you try increasing the number in /usr/share/all-ways-egpu/max-retry to something like 4 and see if that fixes it for you?

Smeeto13 commented 4 weeks ago

I tried it with /usr/share/all-ways-egpu/max-retry set to 5 and no luck, also I modified the service file to make method 3 run after method 2 to make sure the eGPU is definitely initialized at that point

ewagner12 commented 4 weeks ago

@Smeeto13 Ok, could you post the output of the command ls /dev/dri with and without the eGPU attached?

Smeeto13 commented 4 weeks ago

The systemd service functions as expected if started manually after the laptop has booted, Without the eGPU connected I get:

drwxr-xr-x  2 root root         80 Jun  4 12:02 by-path
crw-rw----+ 1 root video  226,   1 Jun  4 12:02 card1
crw-rw-rw-  1 root render 226, 128 Jun  4 12:02 renderD128

When the card is connected I get:

drwxr-xr-x  2 root root        120 Jun  4 12:09 by-path
crw-rw----+ 1 root video  226,   0 Jun  4 12:09 card0
crw-rw----+ 1 root video  226,   1 Jun  4 12:02 card1
crw-rw-rw-  1 root render 226, 128 Jun  4 12:02 renderD128
crw-rw-rw-  1 root render 226, 129 Jun  4 12:09 renderD129
ewagner12 commented 4 weeks ago

Ok good to know it works if started after the laptop is booted. Method 3 depends on udev being up and initialized. On my system (Fedora 40) this happens early in the boot process, but maybe on your system it happens later? You could try changing the all-ways-egpu-set-compositor.service file to add: After=systemd-udevd.service Otherwise if that doesn't do it I'm not sure what else could be done in the script to fix this.

Smeeto13 commented 3 weeks ago

I've tried that to no success, I'm assuming it is something to do with how the eGPU enclosure is connected on my new laptop as it uses USB4 with iommu security and my old laptop running the same setup software wise used thunderbolt 3 and secure user device authentication