Skip to contentSkip to conversation

package/mesa3d: add kmsro driver

PATCH In review Sen Hastings 2 participants 3 messages Apr 28, 2022 – May 8, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/mesa3d: add kmsro driver

Howdy,

After Mesa DRI swrast support was removed on 2021.05 I realized that GPU acceleration on my RPi 4 (Raspberry pi 4)
had stopped/never actually worked. After transitioning from the deprecated Broadcom EGL library, the RPi 4 (at least) uses the VideoCore IV 3D (v3d) driver for rendering, and the VideoCore IV (vc4) driver for display output.
These are "hooked" together with the kmsro driver,
which was renamed/extended from the pl111 driver to be more generic in accomplishing this task.

https://forums.raspberrypi.com/viewtopic.php?f=67&p=1901014

http://lists.freedesktop.org/archives/mesa-dev/2019-January/214067.html

I use the RPi 4 as a specific example, but the kmsro driver is required for the task of attaching "render only" GPUs to any sort of external display controller/manager type deal.
This is pretty common AFAIK on lots of SOCs.

Mesa supports this in combination with a few drivers, including:

Lima:
https://docs.mesa3d.org/drivers/lima.html

Panfrost:
https://docs.mesa3d.org/drivers/panfrost.html#building

v3d:
https://docs.mesa3d.org/drivers/v3d.html

The current patch adds BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_KMSRO and selects it (along with BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_VC4) when BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_V3D is enabled.

Perhaps it should also be selected in conjunction with BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_LIMA, BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_PANFROST and others?

Again, technically this is not necessary if you don't want display output from your GPU.

Seeing that
BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_V3D
selects
BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_VC4

I assume the primary goal is to auto-select mesa driver options that yield functioning display output?

tldr: The kmsro driver is required to get actual display output from some "render only" GPU drivers.
If a "render only" GPU driver is selected, should the kmsro driver be selected by default?

---
 package/mesa3d/Config.in | 14 +++++++++++++-
 package/mesa3d/mesa3d.mk |  1 +
 2 files changed, 14 insertions(+), 1 deletion(-)
package/mesa3d/Config.in +10 -0
index e41da562dc..29e6b0d571 100644
@@ -151,6 +151,17 @@ config BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_IRIS
 	help
 	  Mesa driver for iris-based Intel GPUs.
 +config BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_KMSRO
+	bool "Gallium kmsro driver"
+	select BR2_PACKAGE_MESA3D_GALLIUM_DRIVER
+	help
+	  "kernel mode setting render-only" driver
+	  "bridge" driver that hooks up render only GPUs to
+	  external display controllers/engines.
+	  Required for actual display output on some systems.
+	  Must be used in conjunction with a GPU driver.
+	  Supports: Etnaviv,freedreno,lima,panfrost,v3d
+
 config BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_LIMA
 	bool "Gallium lima driver"
 	depends on (BR2_TOOLCHAIN_HAS_SYNC_4 && !BR2_RISCV_32) ||

!BR2_PACKAGE_XORG7 # libxshmfence
@@ -263,9 +274,10 @@ config BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_V3D
select BR2_PACKAGE_MESA3D_DRI3 if BR2_PACKAGE_XORG7 select BR2_PACKAGE_MESA3D_GALLIUM_DRIVER
select BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_VC4 # runtime
+ select BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_KMSRO
select BR2_PACKAGE_MESA3D_OPENGL_EGL
help
- Driver for Broadcom VC6 (rpi4) GPUs (needs vc4).
+ Driver for Broadcom VC6 (rpi4) GPUs (needs vc4 and kmsro).
It requires a kernel 4.18+ with DRM V3D support enabled:
diff --git a/package/mesa3d/mesa3d.mk b/package/mesa3d/mesa3d.mk
index 9f375edc1f..8b9787aa54 100644

package/mesa3d/mesa3d.mk +0 -0
@@ -102,6 +102,7 @@

MESA3D_GALLIUM_DRIVERS-$(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_ETNAVIV) += etnaviv
MESA3D_GALLIUM_DRIVERS-$(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_FREEDRENO)

+= freedreno
 MESA3D_GALLIUM_DRIVERS-$(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_I915)     +=

i915
MESA3D_GALLIUM_DRIVERS-$(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_IRIS) +=
iris
+MESA3D_GALLIUM_DRIVERS-$(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_KMSRO) +=
kmsro
MESA3D_GALLIUM_DRIVERS-$(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_LIMA) +=
lima
MESA3D_GALLIUM_DRIVERS-$(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_NOUVEAU) +=
nouveau
MESA3D_GALLIUM_DRIVERS-$(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_PANFROST) +=
panfrost

Signature · 6 lines
2.35.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw
Quoted 102 lines · Sen Hastings

Howdy,

After Mesa DRI swrast support was removed on 2021.05 I realized that GPU acceleration on my RPi 4 (Raspberry pi 4)
had stopped/never actually worked. After transitioning from the deprecated Broadcom EGL library, the RPi 4 (at least) uses the VideoCore IV 3D (v3d) driver for rendering, and the VideoCore IV (vc4) driver for display output.
These are "hooked" together with the kmsro driver,
which was renamed/extended from the pl111 driver to be more generic in accomplishing this task.

https://forums.raspberrypi.com/viewtopic.php?f=67&p=1901014

http://lists.freedesktop.org/archives/mesa-dev/2019-January/214067.html

I use the RPi 4 as a specific example, but the kmsro driver is required for the task of attaching "render only" GPUs to any sort of external display controller/manager type deal.
This is pretty common AFAIK on lots of SOCs.

Mesa supports this in combination with a few drivers, including:

Lima:
https://docs.mesa3d.org/drivers/lima.html

Panfrost:
https://docs.mesa3d.org/drivers/panfrost.html#building

v3d:
https://docs.mesa3d.org/drivers/v3d.html

The current patch adds BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_KMSRO and selects it (along with BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_VC4) when BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_V3D is enabled.

Perhaps it should also be selected in conjunction with BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_LIMA, BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_PANFROST and others?

Again, technically this is not necessary if you don't want display output from your GPU.

Seeing that
BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_V3D
selects
BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_VC4

I assume the primary goal is to auto-select mesa driver options that yield functioning display output?

tldr: The kmsro driver is required to get actual display output from some "render only" GPU drivers.
If a "render only" GPU driver is selected, should the kmsro driver be selected by default?

---
  package/mesa3d/Config.in | 14 +++++++++++++-
  package/mesa3d/mesa3d.mk |  1 +
  2 files changed, 14 insertions(+), 1 deletion(-)
package/mesa3d/Config.in +10 -0
index e41da562dc..29e6b0d571 100644
@@ -151,6 +151,17 @@ config BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_IRIS
  	help
  	  Mesa driver for iris-based Intel GPUs.
  +config BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_KMSRO
+	bool "Gallium kmsro driver"
+	select BR2_PACKAGE_MESA3D_GALLIUM_DRIVER
+	help
+	  "kernel mode setting render-only" driver
+	  "bridge" driver that hooks up render only GPUs to
+	  external display controllers/engines.
+	  Required for actual display output on some systems.
+	  Must be used in conjunction with a GPU driver.
+	  Supports: Etnaviv,freedreno,lima,panfrost,v3d
+
  config BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_LIMA
  	bool "Gallium lima driver"
  	depends on (BR2_TOOLCHAIN_HAS_SYNC_4 && !BR2_RISCV_32) ||

!BR2_PACKAGE_XORG7 # libxshmfence

package/mesa3d/Config.in +2 -1
@@ -263,9 +274,10 @@ config BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_V3D
  	select BR2_PACKAGE_MESA3D_DRI3 if BR2_PACKAGE_XORG7
  	select BR2_PACKAGE_MESA3D_GALLIUM_DRIVER
  	select BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_VC4 # runtime
+	select BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_KMSRO
  	select BR2_PACKAGE_MESA3D_OPENGL_EGL
  	help
-	  Driver for Broadcom VC6 (rpi4) GPUs (needs vc4).
+	  Driver for Broadcom VC6 (rpi4) GPUs (needs vc4 and kmsro).
   	  It requires a kernel 4.18+ with DRM V3D support enabled:
  diff --git a/package/mesa3d/mesa3d.mk b/package/mesa3d/mesa3d.mk

index 9f375edc1f..8b9787aa54 100644

package/mesa3d/mesa3d.mk +0 -0
@@ -102,6 +102,7 @@

MESA3D_GALLIUM_DRIVERS-$(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_ETNAVIV) += etnaviv
MESA3D_GALLIUM_DRIVERS-$(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_FREEDRENO)

Quoted 7 lines
+= freedreno
  MESA3D_GALLIUM_DRIVERS-$(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_I915)     +=

i915
MESA3D_GALLIUM_DRIVERS-$(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_IRIS) +=
iris
+MESA3D_GALLIUM_DRIVERS-$(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_KMSRO) +=
kmsro

I was about to apply this (after fixing the horribly whitespace destruction),
but then I noticed that mesa3d actually doesn't have kmsro as a gallium driver option. Instead, it is set automatically:

with_gallium_kmsro = with_gallium_v3d or with_gallium_vc4 or with_gallium_etnaviv or with_gallium_panfrost or with_gallium_lima or with_gallium_freedreno

This has been the case since mesa3d was bumped to 21.1.0 in commit
d51736f47296e3681cdb610765c73424272d42db. This was not part of 2021.05; however, at the time, the BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_KMSRO still existed and it was automatically selected by vc4, panfrost, and others.

So I don't understand why this patch is needed. Does it really have an effect
for you? Can you explain how it works?

Regards,
Arnout

Quoted 6 lines

MESA3D_GALLIUM_DRIVERS-$(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_LIMA) +=
lima
MESA3D_GALLIUM_DRIVERS-$(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_NOUVEAU) +=
nouveau
MESA3D_GALLIUM_DRIVERS-$(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_PANFROST) +=
panfrost

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#2 lore raw

Sorry about the whitespace awfulness, I *thought* I could get thunderbird to behave, oh well. I have finally properly configured git-send email to deal with outlook, sorry to wear out your spacebar :p.

Tried kmscube with an OOTB and my current 5.16 ubuntu kernel and sure enough it works. Tried it again with my old 5.4 ubuntu kernel and it demands a swrast driver, and once provided with one is still broken.

You are correct, this patch is unnecessary. Something *somewhere* else seems to be broken.

Quoted 126 lines · Arnout Vandecappelle
Quoted 101 lines · Sen Hastings

Howdy,

After Mesa DRI swrast support was removed on 2021.05 I realized that GPU acceleration on my RPi 4 (Raspberry pi 4)
had stopped/never actually worked. After transitioning from the deprecated Broadcom EGL library, the RPi 4 (at least) uses the VideoCore IV 3D (v3d) driver for rendering, and the VideoCore IV (vc4) driver for display output.
These are "hooked" together with the kmsro driver,
which was renamed/extended from the pl111 driver to be more generic in accomplishing this task.

https://forums.raspberrypi.com/viewtopic.php?f=67&p=1901014

http://lists.freedesktop.org/archives/mesa-dev/2019-January/214067.html

I use the RPi 4 as a specific example, but the kmsro driver is required for the task of attaching "render only" GPUs to any sort of external display controller/manager type deal.
This is pretty common AFAIK on lots of SOCs.

Mesa supports this in combination with a few drivers, including:

Lima:
https://docs.mesa3d.org/drivers/lima.html

Panfrost:
https://docs.mesa3d.org/drivers/panfrost.html#building

v3d:
https://docs.mesa3d.org/drivers/v3d.html

The current patch adds BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_KMSRO and selects it (along with BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_VC4) when BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_V3D is enabled.

Perhaps it should also be selected in conjunction with BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_LIMA, BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_PANFROST and others?

Again, technically this is not necessary if you don't want display output from your GPU.

Seeing that
BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_V3D
selects
BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_VC4

I assume the primary goal is to auto-select mesa driver options that yield functioning display output?

tldr: The kmsro driver is required to get actual display output from some "render only" GPU drivers.
If a "render only" GPU driver is selected, should the kmsro driver be selected by default?

---
  package/mesa3d/Config.in | 14 +++++++++++++-
  package/mesa3d/mesa3d.mk |  1 +

  2 files changed, 14 insertions(+), 1 deletion(-)
package/mesa3d/Config.in +0 -0
index e41da562dc..29e6b0d571 100644
@@ -151,6 +151,17 @@ config BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_IRIS

      help
        Mesa driver for iris-based Intel GPUs. +config BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_KMSRO
+    bool "Gallium kmsro driver"
+    select BR2_PACKAGE_MESA3D_GALLIUM_DRIVER
+    help
+      "kernel mode setting render-only" driver
+      "bridge" driver that hooks up render only GPUs to +      external display controllers/engines.
+      Required for actual display output on some systems. +      Must be used in conjunction with a GPU driver. +      Supports: Etnaviv,freedreno,lima,panfrost,v3d +
  config BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_LIMA
      bool "Gallium lima driver"
      depends on (BR2_TOOLCHAIN_HAS_SYNC_4 && !BR2_RISCV_32) || !BR2_PACKAGE_XORG7 # libxshmfence

package/mesa3d/Config.in +0 -0
@@ -263,9 +274,10 @@ config BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_V3D

      select BR2_PACKAGE_MESA3D_DRI3 if BR2_PACKAGE_XORG7 select BR2_PACKAGE_MESA3D_GALLIUM_DRIVER
      select BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_VC4 # runtime +    select BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_KMSRO select BR2_PACKAGE_MESA3D_OPENGL_EGL
      help
-      Driver for Broadcom VC6 (rpi4) GPUs (needs vc4). +      Driver for Broadcom VC6 (rpi4) GPUs (needs vc4 and kmsro). It requires a kernel 4.18+ with DRM V3D support enabled:
  diff --git a/package/mesa3d/mesa3d.mk b/package/mesa3d/mesa3d.mk index 9f375edc1f..8b9787aa54 100644

package/mesa3d/mesa3d.mk +0 -0
@@ -102,6 +102,7 @@

MESA3D_GALLIUM_DRIVERS-$(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_ETNAVIV)  += etnaviv

Quoted 8 lines

  MESA3D_GALLIUM_DRIVERS-$(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_FREEDRENO) += freedreno MESA3D_GALLIUM_DRIVERS-$(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_I915)     += i915 MESA3D_GALLIUM_DRIVERS-$(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_IRIS)     += iris +MESA3D_GALLIUM_DRIVERS-$(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_KMSRO)    += kmsro

 I was about to apply this (after fixing the horribly whitespace destruction), but then I noticed that mesa3d actually doesn't have kmsro as a gallium driver option. Instead, it is set automatically:

with_gallium_kmsro = with_gallium_v3d or with_gallium_vc4 or with_gallium_etnaviv or with_gallium_panfrost or with_gallium_lima or with_gallium_freedreno

 This has been the case since mesa3d was bumped to 21.1.0 in commit d51736f47296e3681cdb610765c73424272d42db. This was not part of 2021.05; however, at the time, the BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_KMSRO still existed and it was automatically selected by vc4, panfrost, and others.

Quoted 14 lines

 So I don't understand why this patch is needed. Does it really have an effect for you? Can you explain how it works?

 Regards,
 Arnout

Quoted 6 lines

  MESA3D_GALLIUM_DRIVERS-$(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_LIMA)     += lima MESA3D_GALLIUM_DRIVERS-$(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_NOUVEAU)  += nouveau MESA3D_GALLIUM_DRIVERS-$(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_PANFROST) += panfrost

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot