Last active
December 18, 2023 23:15
-
-
Save imaami/d8a75c0c5b2d20da7dc93a877ec15aed to your computer and use it in GitHub Desktop.
Correctly defer xdm.service until /dev/dri/card0 exists.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/udev/rules.d/99-xdm.rules | |
# Create a dev-dri-card0.device unit for xdm.service to wait on. | |
SUBSYSTEM=="drm", KERNEL=="card0", TAG+="systemd" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/systemd/system/xdm.service | |
[Unit] | |
Description=X-Window Display Manager | |
After=systemd-user-sessions.service | |
# Wait for DRM before starting. This only works if there's a udev rule for | |
# creating dev-dri-card0.device, otherwise "systemctl start xdm" will hang. | |
After=dev-dri-card0.device | |
BindsTo=dev-dri-card0.device | |
[Service] | |
# temporary safety check until all DMs are converted to correct | |
# display-manager.service symlink handling | |
ExecStartPre=/bin/sh -c '[ "$(cat /etc/X11/default-display-manager 2>/dev/null)" = "/usr/bin/xdm" ]' | |
ExecStart=/usr/bin/xdm -nodaemon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a fix for a problem I've recently encountered on Debian unstable. Notable symptoms are:
systemctl start xdm
, XDM will start successfully./var/log/Xorg.0.log
will contain a fatal error saying that/dev/dri/card0
was not found.The above implies that the DRM stack takes longer to initialize than what it takes my system to reach
xdm.service
during boot. I have no idea why this has only started happening recently. The cause could be some change in upstream Debian, or my config, or amdgpu changes in the kernel, or something else entirely. Ultimately the details don't matter – this sort of thing is obviously a problem if at any time, for any reason, XDM is started before the graphics stack initializes.The correct way to fix my problem is generic and universal. Simply put, the ordering between DRM init and X startup must be enforced in a non-stupid manner (the latter including things like e.g. a test-and-sleep script loop). This gist is, to my knowledge, not the worst possible hack out there.