diff mbox series

[1/3] refactor mesa packageconfig

Message ID 20250530172156.7199-1-twoerner@gmail.com
State New
Headers show
Series [1/3] refactor mesa packageconfig | expand

Commit Message

Trevor Woerner May 30, 2025, 5:21 p.m. UTC
Add a new variable, RK_MESA_DRIVER, to allow the user to choose which mesa
"driver" they want to use for their mesa backend. By default set it to either
"panfrost" or "lima" depending on the SoC family being used.

Signed-off-by: Trevor Woerner <twoerner@gmail.com>
---
 README                              | 5 +++++
 conf/machine/include/px30.inc       | 1 +
 conf/machine/include/rk3288.inc     | 1 +
 conf/machine/include/rk3328.inc     | 1 +
 conf/machine/include/rk3399.inc     | 1 +
 conf/machine/include/rk3566.inc     | 1 +
 conf/machine/include/rk3568.inc     | 1 +
 conf/machine/include/rk3588s.inc    | 1 +
 recipes-graphics/mesa/mesa.bbappend | 9 ++-------
 9 files changed, 14 insertions(+), 7 deletions(-)

Comments

Quentin Schulz June 2, 2025, 12:22 p.m. UTC | #1
Hi Trevor,

On 5/30/25 7:21 PM, Trevor Woerner via lists.yoctoproject.org wrote:
> Add a new variable, RK_MESA_DRIVER, to allow the user to choose which mesa
> "driver" they want to use for their mesa backend. By default set it to either
> "panfrost" or "lima" depending on the SoC family being used.
> 
> Signed-off-by: Trevor Woerner <twoerner@gmail.com>
> ---
>   README                              | 5 +++++
>   conf/machine/include/px30.inc       | 1 +
>   conf/machine/include/rk3288.inc     | 1 +
>   conf/machine/include/rk3328.inc     | 1 +
>   conf/machine/include/rk3399.inc     | 1 +
>   conf/machine/include/rk3566.inc     | 1 +
>   conf/machine/include/rk3568.inc     | 1 +
>   conf/machine/include/rk3588s.inc    | 1 +
>   recipes-graphics/mesa/mesa.bbappend | 9 ++-------
>   9 files changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/README b/README
> index 9672c6ab8d5b..97d06eaefd63 100644
> --- a/README
> +++ b/README
> @@ -159,6 +159,11 @@ Notes:
>   	compatible (see Rockchip Media Process Platform (MPP) and
>   	downstream gstreamer-rockchip plugin for those kernels).
>   
> +  mesa backend
> +	Use the variable RK_MESA_DRIVER to select which mesa backend to use
> +	for mesa. By default it is set to either "panfrost" or "lima"
> +	depending on SoC.
> +

I don't think it makes sense to make it user modifiable. You cannot pick 
which driver you want to use as lima will only work with a specific 
family and panfrost with another one, they don't intersect.

So I wouldn't actually document that at all.

>   U-Boot Environment:
>   ------------------
>   	In order to configure U-Boot to be able to store its environment into the
> diff --git a/conf/machine/include/px30.inc b/conf/machine/include/px30.inc
> index 8173cb19be2c..4918ee45d1ab 100644
> --- a/conf/machine/include/px30.inc
> +++ b/conf/machine/include/px30.inc
> @@ -21,3 +21,4 @@ UBOOT_SUFFIX ?= "itb"
>   UBOOT_ENTRYPOINT ?= "0x06000000"
>   
>   ENABLE_STATELESS_VPU_GST ?= "1"
> +RK_MESA_DRIVER ?= "panfrost"

I would also make it = instead of ?= as there's no reason to override 
it? (and you could anyway if you wanted from a confi machine file 
including this SoC .inc file.

> diff --git a/conf/machine/include/rk3288.inc b/conf/machine/include/rk3288.inc
> index 06fda69a3eb7..0fccae7896aa 100644
> --- a/conf/machine/include/rk3288.inc
> +++ b/conf/machine/include/rk3288.inc
> @@ -16,3 +16,4 @@ KERNEL_IMAGETYPE ?= "zImage"
>   UBOOT_SUFFIX ?= "bin"
>   
>   ENABLE_STATELESS_VPU_GST ?= "1"
> +RK_MESA_DRIVER ?= "panfrost"
> diff --git a/conf/machine/include/rk3328.inc b/conf/machine/include/rk3328.inc
> index e6f810dcd2ca..cdc2e2df2703 100644
> --- a/conf/machine/include/rk3328.inc
> +++ b/conf/machine/include/rk3328.inc
> @@ -22,3 +22,4 @@ UBOOT_SUFFIX ?= "itb"
>   UBOOT_ENTRYPOINT ?= "0x06000000"
>   
>   ENABLE_STATELESS_VPU_GST ?= "1"
> +RK_MESA_DRIVER ?= "lima"
> diff --git a/conf/machine/include/rk3399.inc b/conf/machine/include/rk3399.inc
> index cd1be49064ed..06326946f1e3 100644
> --- a/conf/machine/include/rk3399.inc
> +++ b/conf/machine/include/rk3399.inc
> @@ -22,3 +22,4 @@ UBOOT_SUFFIX ?= "itb"
>   UBOOT_ENTRYPOINT ?= "0x06000000"
>   
>   ENABLE_STATELESS_VPU_GST ?= "1"
> +RK_MESA_DRIVER ?= "panfrost"
> diff --git a/conf/machine/include/rk3566.inc b/conf/machine/include/rk3566.inc
> index 6386ec7eb51c..4d84bf8a11a2 100644
> --- a/conf/machine/include/rk3566.inc
> +++ b/conf/machine/include/rk3566.inc
> @@ -24,3 +24,4 @@ TFA_PLATFORM = "rk3568"
>   TFA_BUILD_TARGET = "bl31"
>   
>   ENABLE_STATELESS_VPU_GST ?= "1"
> +RK_MESA_DRIVER ?= "panfrost"
> diff --git a/conf/machine/include/rk3568.inc b/conf/machine/include/rk3568.inc
> index bcf9dd8b0f44..dedda3b8f47e 100644
> --- a/conf/machine/include/rk3568.inc
> +++ b/conf/machine/include/rk3568.inc
> @@ -24,3 +24,4 @@ TFA_PLATFORM = "rk3568"
>   TFA_BUILD_TARGET = "bl31"
>   
>   ENABLE_STATELESS_VPU_GST ?= "1"
> +RK_MESA_DRIVER ?= "panfrost"
> diff --git a/conf/machine/include/rk3588s.inc b/conf/machine/include/rk3588s.inc
> index 6ec344abae5b..5a085ab29ebc 100644
> --- a/conf/machine/include/rk3588s.inc
> +++ b/conf/machine/include/rk3588s.inc
> @@ -23,3 +23,4 @@ TFA_PLATFORM = "rk3588"
>   TFA_BUILD_TARGET = "bl31"
>   
>   ENABLE_STATELESS_VPU_GST ?= "1"
> +RK_MESA_DRIVER ?= "panfrost"
> diff --git a/recipes-graphics/mesa/mesa.bbappend b/recipes-graphics/mesa/mesa.bbappend
> index f22280754a14..9e9bf9afc4a0 100644
> --- a/recipes-graphics/mesa/mesa.bbappend
> +++ b/recipes-graphics/mesa/mesa.bbappend
> @@ -1,9 +1,4 @@
> -PACKAGECONFIG:append:rk3288 = " panfrost"
> -PACKAGECONFIG:append:rk3328 = " lima"
> -PACKAGECONFIG:append:rk3399 = " panfrost"
> -PACKAGECONFIG:append:rk3566 = " panfrost"
> -PACKAGECONFIG:append:rk3568 = " panfrost"
> -PACKAGECONFIG:append:rk3588s = " panfrost"
> -PACKAGECONFIG:append:px30 = " panfrost"
> +PACKAGECONFIG:append:rockchip = " ${@bb.utils.contains('RK_MESA_DRIVER', 'panfrost', 'panfrost', '', d)}"
> +PACKAGECONFIG:append:rockchip = " ${@bb.utils.contains('RK_MESA_DRIVER', 'lima', 'lima', '', d)}"
>   

This is fine though :)

I'm wondering if we shouldn't simply make panfrost the default for all 
SoCs and only override it to lima for older SoCs (and I believe some 
have some Imagination GPUs too (like the RK3368?)). I guess for GPU-less 
systems we would need to unset the variable. Not sure what's best here :)

Cheers,
Quentin
Quentin Schulz June 2, 2025, 12:39 p.m. UTC | #2
Hi Trevor,


Missing [meta-rockchip] in the subject :)

On 5/30/25 7:21 PM, Trevor Woerner via lists.yoctoproject.org wrote:
> Add a new variable, RK_MESA_DRIVER, to allow the user to choose which mesa
> "driver" they want to use for their mesa backend. By default set it to either
> "panfrost" or "lima" depending on the SoC family being used.
> 
> Signed-off-by: Trevor Woerner <twoerner@gmail.com>
> ---
>   README                              | 5 +++++
>   conf/machine/include/px30.inc       | 1 +
>   conf/machine/include/rk3288.inc     | 1 +
>   conf/machine/include/rk3328.inc     | 1 +
>   conf/machine/include/rk3399.inc     | 1 +
>   conf/machine/include/rk3566.inc     | 1 +
>   conf/machine/include/rk3568.inc     | 1 +
>   conf/machine/include/rk3588s.inc    | 1 +
>   recipes-graphics/mesa/mesa.bbappend | 9 ++-------
>   9 files changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/README b/README
> index 9672c6ab8d5b..97d06eaefd63 100644
> --- a/README
> +++ b/README
> @@ -159,6 +159,11 @@ Notes:
>   	compatible (see Rockchip Media Process Platform (MPP) and
>   	downstream gstreamer-rockchip plugin for those kernels).
>   
> +  mesa backend
> +	Use the variable RK_MESA_DRIVER to select which mesa backend to use
> +	for mesa. By default it is set to either "panfrost" or "lima"
> +	depending on SoC.
> +
>   U-Boot Environment:
>   ------------------
>   	In order to configure U-Boot to be able to store its environment into the
> diff --git a/conf/machine/include/px30.inc b/conf/machine/include/px30.inc
> index 8173cb19be2c..4918ee45d1ab 100644
> --- a/conf/machine/include/px30.inc
> +++ b/conf/machine/include/px30.inc
> @@ -21,3 +21,4 @@ UBOOT_SUFFIX ?= "itb"
>   UBOOT_ENTRYPOINT ?= "0x06000000"
>   
>   ENABLE_STATELESS_VPU_GST ?= "1"
> +RK_MESA_DRIVER ?= "panfrost"
> diff --git a/conf/machine/include/rk3288.inc b/conf/machine/include/rk3288.inc
> index 06fda69a3eb7..0fccae7896aa 100644
> --- a/conf/machine/include/rk3288.inc
> +++ b/conf/machine/include/rk3288.inc
> @@ -16,3 +16,4 @@ KERNEL_IMAGETYPE ?= "zImage"
>   UBOOT_SUFFIX ?= "bin"
>   
>   ENABLE_STATELESS_VPU_GST ?= "1"
> +RK_MESA_DRIVER ?= "panfrost"
> diff --git a/conf/machine/include/rk3328.inc b/conf/machine/include/rk3328.inc
> index e6f810dcd2ca..cdc2e2df2703 100644
> --- a/conf/machine/include/rk3328.inc
> +++ b/conf/machine/include/rk3328.inc
> @@ -22,3 +22,4 @@ UBOOT_SUFFIX ?= "itb"
>   UBOOT_ENTRYPOINT ?= "0x06000000"
>   
>   ENABLE_STATELESS_VPU_GST ?= "1"
> +RK_MESA_DRIVER ?= "lima"
> diff --git a/conf/machine/include/rk3399.inc b/conf/machine/include/rk3399.inc
> index cd1be49064ed..06326946f1e3 100644
> --- a/conf/machine/include/rk3399.inc
> +++ b/conf/machine/include/rk3399.inc
> @@ -22,3 +22,4 @@ UBOOT_SUFFIX ?= "itb"
>   UBOOT_ENTRYPOINT ?= "0x06000000"
>   
>   ENABLE_STATELESS_VPU_GST ?= "1"
> +RK_MESA_DRIVER ?= "panfrost"
> diff --git a/conf/machine/include/rk3566.inc b/conf/machine/include/rk3566.inc
> index 6386ec7eb51c..4d84bf8a11a2 100644
> --- a/conf/machine/include/rk3566.inc
> +++ b/conf/machine/include/rk3566.inc
> @@ -24,3 +24,4 @@ TFA_PLATFORM = "rk3568"
>   TFA_BUILD_TARGET = "bl31"
>   
>   ENABLE_STATELESS_VPU_GST ?= "1"
> +RK_MESA_DRIVER ?= "panfrost"
> diff --git a/conf/machine/include/rk3568.inc b/conf/machine/include/rk3568.inc
> index bcf9dd8b0f44..dedda3b8f47e 100644
> --- a/conf/machine/include/rk3568.inc
> +++ b/conf/machine/include/rk3568.inc
> @@ -24,3 +24,4 @@ TFA_PLATFORM = "rk3568"
>   TFA_BUILD_TARGET = "bl31"
>   
>   ENABLE_STATELESS_VPU_GST ?= "1"
> +RK_MESA_DRIVER ?= "panfrost"
> diff --git a/conf/machine/include/rk3588s.inc b/conf/machine/include/rk3588s.inc
> index 6ec344abae5b..5a085ab29ebc 100644
> --- a/conf/machine/include/rk3588s.inc
> +++ b/conf/machine/include/rk3588s.inc
> @@ -23,3 +23,4 @@ TFA_PLATFORM = "rk3588"
>   TFA_BUILD_TARGET = "bl31"
>   
>   ENABLE_STATELESS_VPU_GST ?= "1"
> +RK_MESA_DRIVER ?= "panfrost"
> diff --git a/recipes-graphics/mesa/mesa.bbappend b/recipes-graphics/mesa/mesa.bbappend
> index f22280754a14..9e9bf9afc4a0 100644
> --- a/recipes-graphics/mesa/mesa.bbappend
> +++ b/recipes-graphics/mesa/mesa.bbappend
> @@ -1,9 +1,4 @@
> -PACKAGECONFIG:append:rk3288 = " panfrost"
> -PACKAGECONFIG:append:rk3328 = " lima"
> -PACKAGECONFIG:append:rk3399 = " panfrost"
> -PACKAGECONFIG:append:rk3566 = " panfrost"
> -PACKAGECONFIG:append:rk3568 = " panfrost"
> -PACKAGECONFIG:append:rk3588s = " panfrost"

It seems like this is based on my Panthor patch series but it isn't 
explicitly listed in the dependency of this patch series? I'm fine if 
you want to take over my patch series, but I guess it'd make sense to 
have the patches (even reworked/squashed/fixed up) as part of this patch 
series now?

Cheers,
Quentin
diff mbox series

Patch

diff --git a/README b/README
index 9672c6ab8d5b..97d06eaefd63 100644
--- a/README
+++ b/README
@@ -159,6 +159,11 @@  Notes:
 	compatible (see Rockchip Media Process Platform (MPP) and
 	downstream gstreamer-rockchip plugin for those kernels).
 
+  mesa backend
+	Use the variable RK_MESA_DRIVER to select which mesa backend to use
+	for mesa. By default it is set to either "panfrost" or "lima"
+	depending on SoC.
+
 U-Boot Environment:
 ------------------
 	In order to configure U-Boot to be able to store its environment into the
diff --git a/conf/machine/include/px30.inc b/conf/machine/include/px30.inc
index 8173cb19be2c..4918ee45d1ab 100644
--- a/conf/machine/include/px30.inc
+++ b/conf/machine/include/px30.inc
@@ -21,3 +21,4 @@  UBOOT_SUFFIX ?= "itb"
 UBOOT_ENTRYPOINT ?= "0x06000000"
 
 ENABLE_STATELESS_VPU_GST ?= "1"
+RK_MESA_DRIVER ?= "panfrost"
diff --git a/conf/machine/include/rk3288.inc b/conf/machine/include/rk3288.inc
index 06fda69a3eb7..0fccae7896aa 100644
--- a/conf/machine/include/rk3288.inc
+++ b/conf/machine/include/rk3288.inc
@@ -16,3 +16,4 @@  KERNEL_IMAGETYPE ?= "zImage"
 UBOOT_SUFFIX ?= "bin"
 
 ENABLE_STATELESS_VPU_GST ?= "1"
+RK_MESA_DRIVER ?= "panfrost"
diff --git a/conf/machine/include/rk3328.inc b/conf/machine/include/rk3328.inc
index e6f810dcd2ca..cdc2e2df2703 100644
--- a/conf/machine/include/rk3328.inc
+++ b/conf/machine/include/rk3328.inc
@@ -22,3 +22,4 @@  UBOOT_SUFFIX ?= "itb"
 UBOOT_ENTRYPOINT ?= "0x06000000"
 
 ENABLE_STATELESS_VPU_GST ?= "1"
+RK_MESA_DRIVER ?= "lima"
diff --git a/conf/machine/include/rk3399.inc b/conf/machine/include/rk3399.inc
index cd1be49064ed..06326946f1e3 100644
--- a/conf/machine/include/rk3399.inc
+++ b/conf/machine/include/rk3399.inc
@@ -22,3 +22,4 @@  UBOOT_SUFFIX ?= "itb"
 UBOOT_ENTRYPOINT ?= "0x06000000"
 
 ENABLE_STATELESS_VPU_GST ?= "1"
+RK_MESA_DRIVER ?= "panfrost"
diff --git a/conf/machine/include/rk3566.inc b/conf/machine/include/rk3566.inc
index 6386ec7eb51c..4d84bf8a11a2 100644
--- a/conf/machine/include/rk3566.inc
+++ b/conf/machine/include/rk3566.inc
@@ -24,3 +24,4 @@  TFA_PLATFORM = "rk3568"
 TFA_BUILD_TARGET = "bl31"
 
 ENABLE_STATELESS_VPU_GST ?= "1"
+RK_MESA_DRIVER ?= "panfrost"
diff --git a/conf/machine/include/rk3568.inc b/conf/machine/include/rk3568.inc
index bcf9dd8b0f44..dedda3b8f47e 100644
--- a/conf/machine/include/rk3568.inc
+++ b/conf/machine/include/rk3568.inc
@@ -24,3 +24,4 @@  TFA_PLATFORM = "rk3568"
 TFA_BUILD_TARGET = "bl31"
 
 ENABLE_STATELESS_VPU_GST ?= "1"
+RK_MESA_DRIVER ?= "panfrost"
diff --git a/conf/machine/include/rk3588s.inc b/conf/machine/include/rk3588s.inc
index 6ec344abae5b..5a085ab29ebc 100644
--- a/conf/machine/include/rk3588s.inc
+++ b/conf/machine/include/rk3588s.inc
@@ -23,3 +23,4 @@  TFA_PLATFORM = "rk3588"
 TFA_BUILD_TARGET = "bl31"
 
 ENABLE_STATELESS_VPU_GST ?= "1"
+RK_MESA_DRIVER ?= "panfrost"
diff --git a/recipes-graphics/mesa/mesa.bbappend b/recipes-graphics/mesa/mesa.bbappend
index f22280754a14..9e9bf9afc4a0 100644
--- a/recipes-graphics/mesa/mesa.bbappend
+++ b/recipes-graphics/mesa/mesa.bbappend
@@ -1,9 +1,4 @@ 
-PACKAGECONFIG:append:rk3288 = " panfrost"
-PACKAGECONFIG:append:rk3328 = " lima"
-PACKAGECONFIG:append:rk3399 = " panfrost"
-PACKAGECONFIG:append:rk3566 = " panfrost"
-PACKAGECONFIG:append:rk3568 = " panfrost"
-PACKAGECONFIG:append:rk3588s = " panfrost"
-PACKAGECONFIG:append:px30 = " panfrost"
+PACKAGECONFIG:append:rockchip = " ${@bb.utils.contains('RK_MESA_DRIVER', 'panfrost', 'panfrost', '', d)}"
+PACKAGECONFIG:append:rockchip = " ${@bb.utils.contains('RK_MESA_DRIVER', 'lima', 'lima', '', d)}"
 
 RRECOMMENDS:mesa-megadriver:append:rk3588s = " linux-firmware-mali-csffw-arch108"