diff mbox series

[meta-oe] kmscon: treat platform display controllers as primary GPUs

Message ID 20260928010600.87898-1-f_l_k@t-online.de
State Under Review
Headers show
Series [meta-oe] kmscon: treat platform display controllers as primary GPUs | expand

Commit Message

Markus Volk Sept. 28, 2026, 1:06 a.m. UTC
kmscon only counted a GPU as primary when its PCI parent had boot_vga
set, so with gpus=primary it ignored vc4 on the Raspberry Pi 4 and never
showed a terminal. Treat DRM devices without a PCI parent as primary,
except for the firmware framebuffer drivers. Tested on a Raspberry Pi 4
booting through EDK2.

AI-Generated: Uses Claude Code (Claude Opus 5.5)
Signed-off-by: Markus Volk <f_l_k@t-online.de>
---
 ...-display-controllers-as-primary-GPUs.patch | 81 +++++++++++++++++++
 .../recipes-graphics/kmscon/kmscon_10.0.1.bb  |  5 +-
 2 files changed, 85 insertions(+), 1 deletion(-)
 create mode 100644 meta-oe/recipes-graphics/kmscon/kmscon/0002-uterm_monitor-treat-platform-display-controllers-as-primary-GPUs.patch

Comments

Khem Raj Sept. 28, 2026, 2:39 a.m. UTC | #1
On Sun, Sep 27, 2026 at 6:06 PM Markus Volk via lists.openembedded.org
<f_l_k=t-online.de@lists.openembedded.org> wrote:

> kmscon only counted a GPU as primary when its PCI parent had boot_vga
> set, so with gpus=primary it ignored vc4 on the Raspberry Pi 4 and never
> showed a terminal. Treat DRM devices without a PCI parent as primary,
> except for the firmware framebuffer drivers. Tested on a Raspberry Pi 4
> booting through EDK2.
>
> AI-Generated: Uses Claude Code (Claude Opus 5.5)
> Signed-off-by: Markus Volk <f_l_k@t-online.de>
> ---
>  ...-display-controllers-as-primary-GPUs.patch | 81 +++++++++++++++++++
>  .../recipes-graphics/kmscon/kmscon_10.0.1.bb  |  5 +-
>  2 files changed, 85 insertions(+), 1 deletion(-)
>  create mode 100644
> meta-oe/recipes-graphics/kmscon/kmscon/0002-uterm_monitor-treat-platform-display-controllers-as-primary-GPUs.patch
>
> diff --git
> a/meta-oe/recipes-graphics/kmscon/kmscon/0002-uterm_monitor-treat-platform-display-controllers-as-primary-GPUs.patch
> b/meta-oe/recipes-graphics/kmscon/kmscon/0002-uterm_monitor-treat-platform-display-controllers-as-primary-GPUs.patch
> new file mode 100644
> index 0000000000..caebc23dbc
> --- /dev/null
> +++
> b/meta-oe/recipes-graphics/kmscon/kmscon/0002-uterm_monitor-treat-platform-display-controllers-as-primary-GPUs.patch
> @@ -0,0 +1,81 @@
> +From d321a1572a12d760ddade294f4e7eabe57d555d1 Mon Sep 17 00:00:00 2001
> +From: Markus Volk <f_l_k@t-online.de>
> +Date: Sat, 26 Sep 2026 10:00:57 +0200
> +Subject: [PATCH] uterm_monitor: treat platform display controllers as
> primary
> + GPUs
> +
> +A GPU only counted as primary when its PCI parent had boot_vga set.
> +SoC display controllers such as vc4 on the Raspberry Pi are platform
> +devices without a PCI parent, so with gpus=primary kmscon ignored the
> +only display in the system and never showed a terminal.
> +
> +Treat DRM devices without a PCI parent as primary, except for the
> +simpledrm, efidrm, vesadrm and ofdrm firmware framebuffers that only
> +stand in until the native driver has loaded.
> +
> +Upstream-Status: Pending
>

Whats the future plan for this patch ? it seems worthy of upstreaming.


> +
> +AI-Generated: Uses Claude Code (Claude Opus 5.5)
> +---
> + src/uterm_monitor.c | 26 +++++++++++++++++++++++---
> + 1 file changed, 23 insertions(+), 3 deletions(-)
> +
> +diff --git a/src/uterm_monitor.c b/src/uterm_monitor.c
> +index d89bfa1..3ecf40b 100644
> +--- a/src/uterm_monitor.c
> ++++ b/src/uterm_monitor.c
> +@@ -234,10 +234,15 @@ out_close:
> +       return flags;
> + }
> +
> +-static bool is_drm_primary(struct uterm_monitor *mon, struct udev_device
> *dev, const char *node)
> ++static char *get_drm_name(int fd);
> ++
> ++static bool is_drm_primary(struct uterm_monitor *mon, struct udev_device
> *dev, const char *node,
> ++                         int fd)
> + {
> +       struct udev_device *pci;
> +       const char *id;
> ++      char *name;
> ++      bool res;
> +
> +       pci = udev_device_get_parent_with_subsystem_devtype(dev, "pci",
> NULL);
> +       if (pci) {
> +@@ -246,9 +251,24 @@ static bool is_drm_primary(struct uterm_monitor
> *mon, struct udev_device *dev, c
> +                       log_debug("DRM device %s is primary PCI GPU",
> node);
> +                       return true;
> +               }
> ++              return false;
> +       }
> +
> +-      return false;
> ++      /*
> ++       * SoC display controllers are platform devices without a boot_vga
> ++       * attribute. Treat them as primary, except for the generic
> firmware
> ++       * framebuffer drivers that only stand in until the real driver
> loads.
> ++       */
> ++      name = get_drm_name(fd);
> ++      if (!name)
> ++              return false;
> ++
> ++      res = strcmp(name, "simpledrm") && strcmp(name, "efidrm") &&
> strcmp(name, "vesadrm") &&
> ++            strcmp(name, "ofdrm");
> ++      if (res)
> ++              log_debug("DRM device %s is primary platform GPU (%s)",
> node, name);
> ++      free(name);
> ++      return res;
> + }
> +
> + /*
> +@@ -334,7 +354,7 @@ static unsigned int get_drm_flags(struct
> uterm_monitor *mon, struct udev_device
> +               return flags;
> +       }
> +
> +-      if (is_drm_primary(mon, dev, node))
> ++      if (is_drm_primary(mon, dev, node, fd))
> +               flags |= UTERM_MONITOR_PRIMARY;
> +       if (is_drm_usb(mon, node, fd))
> +               flags |= UTERM_MONITOR_AUX;
> +--
> +2.55.0
> +
> diff --git a/meta-oe/recipes-graphics/kmscon/kmscon_10.0.1.bb
> b/meta-oe/recipes-graphics/kmscon/kmscon_10.0.1.bb
> index c5cfd527d5..0336649551 100644
> --- a/meta-oe/recipes-graphics/kmscon/kmscon_10.0.1.bb
> +++ b/meta-oe/recipes-graphics/kmscon/kmscon_10.0.1.bb
> @@ -23,7 +23,10 @@ DEPENDS = "\
>  SRC_URI = "git://
> github.com/kmscon/kmscon;protocol=https;branch=main;tag=v${PV}
> <http://github.com/kmscon/kmscon;protocol=https;branch=main;tag=v$%7BPV%7D>
> "
>  SRCREV = "c9d0e23336c6bb7645a1f5f48a4a82f1d5a589d9"
>
> -SRC_URI +=
> "file://0001-terminal-open-the-pty-only-once-a-display-is-attached.patch"
> +SRC_URI += " \
> +
> file://0001-terminal-open-the-pty-only-once-a-display-is-attached.patch \
> +
> file://0002-uterm_monitor-treat-platform-display-controllers-as-primary-GPUs.patch
> \
> +"
>
>  inherit meson pkgconfig systemd
>
> --
> 2.55.0
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#130419):
> https://lists.openembedded.org/g/openembedded-devel/message/130419
> Mute This Topic: https://lists.openembedded.org/mt/121464722/1997914
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [
> raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
diff mbox series

Patch

diff --git a/meta-oe/recipes-graphics/kmscon/kmscon/0002-uterm_monitor-treat-platform-display-controllers-as-primary-GPUs.patch b/meta-oe/recipes-graphics/kmscon/kmscon/0002-uterm_monitor-treat-platform-display-controllers-as-primary-GPUs.patch
new file mode 100644
index 0000000000..caebc23dbc
--- /dev/null
+++ b/meta-oe/recipes-graphics/kmscon/kmscon/0002-uterm_monitor-treat-platform-display-controllers-as-primary-GPUs.patch
@@ -0,0 +1,81 @@ 
+From d321a1572a12d760ddade294f4e7eabe57d555d1 Mon Sep 17 00:00:00 2001
+From: Markus Volk <f_l_k@t-online.de>
+Date: Sat, 26 Sep 2026 10:00:57 +0200
+Subject: [PATCH] uterm_monitor: treat platform display controllers as primary
+ GPUs
+
+A GPU only counted as primary when its PCI parent had boot_vga set.
+SoC display controllers such as vc4 on the Raspberry Pi are platform
+devices without a PCI parent, so with gpus=primary kmscon ignored the
+only display in the system and never showed a terminal.
+
+Treat DRM devices without a PCI parent as primary, except for the
+simpledrm, efidrm, vesadrm and ofdrm firmware framebuffers that only
+stand in until the native driver has loaded.
+
+Upstream-Status: Pending
+
+AI-Generated: Uses Claude Code (Claude Opus 5.5)
+---
+ src/uterm_monitor.c | 26 +++++++++++++++++++++++---
+ 1 file changed, 23 insertions(+), 3 deletions(-)
+
+diff --git a/src/uterm_monitor.c b/src/uterm_monitor.c
+index d89bfa1..3ecf40b 100644
+--- a/src/uterm_monitor.c
++++ b/src/uterm_monitor.c
+@@ -234,10 +234,15 @@ out_close:
+ 	return flags;
+ }
+ 
+-static bool is_drm_primary(struct uterm_monitor *mon, struct udev_device *dev, const char *node)
++static char *get_drm_name(int fd);
++
++static bool is_drm_primary(struct uterm_monitor *mon, struct udev_device *dev, const char *node,
++			   int fd)
+ {
+ 	struct udev_device *pci;
+ 	const char *id;
++	char *name;
++	bool res;
+ 
+ 	pci = udev_device_get_parent_with_subsystem_devtype(dev, "pci", NULL);
+ 	if (pci) {
+@@ -246,9 +251,24 @@ static bool is_drm_primary(struct uterm_monitor *mon, struct udev_device *dev, c
+ 			log_debug("DRM device %s is primary PCI GPU", node);
+ 			return true;
+ 		}
++		return false;
+ 	}
+ 
+-	return false;
++	/*
++	 * SoC display controllers are platform devices without a boot_vga
++	 * attribute. Treat them as primary, except for the generic firmware
++	 * framebuffer drivers that only stand in until the real driver loads.
++	 */
++	name = get_drm_name(fd);
++	if (!name)
++		return false;
++
++	res = strcmp(name, "simpledrm") && strcmp(name, "efidrm") && strcmp(name, "vesadrm") &&
++	      strcmp(name, "ofdrm");
++	if (res)
++		log_debug("DRM device %s is primary platform GPU (%s)", node, name);
++	free(name);
++	return res;
+ }
+ 
+ /*
+@@ -334,7 +354,7 @@ static unsigned int get_drm_flags(struct uterm_monitor *mon, struct udev_device
+ 		return flags;
+ 	}
+ 
+-	if (is_drm_primary(mon, dev, node))
++	if (is_drm_primary(mon, dev, node, fd))
+ 		flags |= UTERM_MONITOR_PRIMARY;
+ 	if (is_drm_usb(mon, node, fd))
+ 		flags |= UTERM_MONITOR_AUX;
+-- 
+2.55.0
+
diff --git a/meta-oe/recipes-graphics/kmscon/kmscon_10.0.1.bb b/meta-oe/recipes-graphics/kmscon/kmscon_10.0.1.bb
index c5cfd527d5..0336649551 100644
--- a/meta-oe/recipes-graphics/kmscon/kmscon_10.0.1.bb
+++ b/meta-oe/recipes-graphics/kmscon/kmscon_10.0.1.bb
@@ -23,7 +23,10 @@  DEPENDS = "\
 SRC_URI = "git://github.com/kmscon/kmscon;protocol=https;branch=main;tag=v${PV}"
 SRCREV = "c9d0e23336c6bb7645a1f5f48a4a82f1d5a589d9"
 
-SRC_URI += "file://0001-terminal-open-the-pty-only-once-a-display-is-attached.patch"
+SRC_URI += " \
+    file://0001-terminal-open-the-pty-only-once-a-display-is-attached.patch \
+    file://0002-uterm_monitor-treat-platform-display-controllers-as-primary-GPUs.patch \
+"
 
 inherit meson pkgconfig systemd