Skip to content

LordOS — a free, fast and secure GNU/Linux distribution based on Debian, with its own desktop environment: display server and Wayland compositor in C, a React UI engine on QuickJS, and private native apps.

Pi 5 on HDMI: wait longer for the display driver (wait-kms 30 s plus modprobe vc4, lord-sessiond up to 30 s more) instead of giving up

Federico Pereira4d17d2d4ac0c
diff --git a/docs/RASPBERRY.md b/docs/RASPBERRY.md
index 37364a3..6a1a3a4 100644
--- a/docs/RASPBERRY.md
+++ b/docs/RASPBERRY.md
@@ -584,7 +584,7 @@ The order of `card0` and `card1` depends on which driver loads first.
`card1`.
- `LORD_CARD=/dev/dri/cardN` pins it, and lord-server's `--card` still works.
- **`lordos.service.d/rpi.conf`** waits up to 10 s for a connector to appear in `/sys/class/drm`
- (`wait-kms`). If lord-sessiond starts before vc4 is loaded, without this it would only see v3d.
+ (`wait-kms`, up to 30 s, and it asks for `vc4` with `modprobe`; lord-sessiond then waits up to 30 s more for a card with KMS before showing the "no display" text). If lord-sessiond starts before vc4 is loaded, without this it would only see v3d.
- **GBM and EGL** are created on the display card (vc4), as always. Mesa recognizes it (kmsro) and
renders with v3d. Scanout buffers are created on vc4 and v3d imports them. lord-server doesn't need
to know anything about this.
diff --git a/server/src/remote/monitor.c b/server/src/remote/monitor.c
index 0920c47..0bb77d4 100644
--- a/server/src/remote/monitor.c
+++ b/server/src/remote/monitor.c
@@ -15,6 +15,7 @@
#include "../drmcard.h"
#include <errno.h>
+#include <time.h>
#include <fcntl.h>
#include <linux/input.h>
#include <linux/kd.h>
@@ -54,8 +55,18 @@ static int useful(int fd) {
}
int sd_mon_open(void) {
- if (drm_pick_card(card, sizeof card)) sd_log("no card with KMS; trying %s", card);
- else sd_log("display: %s", card);
+ /* On ARM boards the display driver can show up well after boot (on a Raspberry Pi 5's first
+ * boot vc4 may come after lordos.service has started): wait up to 30 s for a card with KMS
+ * before giving up, instead of falling back to the text console for good. */
+ int tries = 0;
+ while (drm_pick_card(card, sizeof card) && tries < 150) {
+ if (!tries) sd_log("no card with KMS yet; waiting up to 30 s");
+ struct timespec ts = { 0, 200000000 };
+ nanosleep(&ts, NULL);
+ tries++;
+ }
+ if (tries >= 150) sd_log("no card with KMS after 30 s; trying %s", card);
+ else sd_log("display: %s%s", card, tries ? " (after waiting)" : "");
int fd = open(CARD, O_RDWR | O_CLOEXEC);
if (fd < 0) { sd_log("no monitor (%s: %s)", CARD, strerror(errno)); return -1; }
close(fd);
diff --git a/tools/rpi/rootfs/usr/lib/lordos/rpi/wait-kms b/tools/rpi/rootfs/usr/lib/lordos/rpi/wait-kms
index f66bf1c..b377a34 100755
--- a/tools/rpi/rootfs/usr/lib/lordos/rpi/wait-kms
+++ b/tools/rpi/rootfs/usr/lib/lordos/rpi/wait-kms
@@ -1,13 +1,15 @@
#!/bin/sh
-# wait-kms — waits (up to 10 s) for some DRM card to have a connector (vc4 on the Raspberry Pi).
+# wait-kms — waits (up to 30 s) for some DRM card to have a connector (vc4 on the Raspberry Pi).
# With no monitor no connector is connected, but the connector still exists: it is enough for it to appear.
+# If udev hasn't loaded the display driver yet, ask for it (a no-op when it's built in or loaded).
+modprobe -q vc4 2>/dev/null || true
i=0
-while [ $i -lt 100 ]; do
+while [ $i -lt 300 ]; do
for c in /sys/class/drm/card*-*; do
[ -e "$c/status" ] && exit 0
done
sleep 0.1
i=$((i + 1))
done
-echo "wait-kms: no card with connectors after 10 s" >&2
+echo "wait-kms: no card with connectors after 30 s (lord-sessiond keeps waiting another 30 s)" >&2
exit 0