diff mbox series

[meta-rockchip,v2] rknpu: gate the NPU support on a machine feature

Message ID 20261201114724.2719940-1-twoerner@gmail.com
State New
Headers show
Series [meta-rockchip,v2] rknpu: gate the NPU support on a machine feature | expand

Commit Message

Trevor Woerner Dec. 1, 2026, 11:47 a.m. UTC
ENABLE_UPSTREAM_RKNPU added the NPU kernel fragment on every rockchip
machine, so setting it for a multi-machine build made the kernel config
audit warn on all those whose NPU the driver does not support.

The RK3588(S) include now declares an "rknpu" machine feature, which
becomes a machine override under which the kernel and mesa additions
apply. The knob is then safe to set in local.conf, a board can opt out
with MACHINE_FEATURES:remove, and supporting another SoC only needs the
feature added to its include.

Cc: Quentin Schulz <quentin.schulz@cherry.de>
AI-Generated: codex/claude-opus 5.5 (xhigh)
Signed-off-by: Trevor Woerner <twoerner@gmail.com>
---
changes in v2:
- replace the rk3588s override with an "rknpu" machine feature, so
  neither the kernel nor the mesa line names an SoC; v1 was "kernel:
  only add the rocket NPU fragment on rk3588s"
- document in the README that the knob may go in local.conf
---
 README                                     | 7 +++++++
 conf/machine/include/rk3588s.inc           | 3 +++
 conf/machine/include/rockchip-defaults.inc | 2 ++
 recipes-graphics/mesa/mesa.bbappend        | 2 +-
 recipes-kernel/linux/linux-rockchip.inc    | 2 +-
 5 files changed, 14 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/README b/README
index 6d9db9b31e6e..3e4c94044235 100644
--- a/README
+++ b/README
@@ -234,6 +234,13 @@  Notes:
 
 		ENABLE_UPSTREAM_RKNPU = "1"
 
+	in the configuration (e.g. conf/local.conf). It only takes effect on
+	machines whose MACHINE_FEATURES contain "rknpu", which the RK3588(S)
+	include sets, so it is safe to set for a multi-machine build. A board
+	whose Device Tree does not declare the NPU can opt out with:
+
+		MACHINE_FEATURES:remove = "rknpu"
+
 	This requires a kernel driver (CONFIG_DRM_ACCEL_ROCKET, v6.18+) and
 	RKNN Device Tree nodes
 	(e.g. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=640366d644b1e282771a09c72be37162b6eda438).
diff --git a/conf/machine/include/rk3588s.inc b/conf/machine/include/rk3588s.inc
index 18c2fb2ecef8..a972cd61247e 100644
--- a/conf/machine/include/rk3588s.inc
+++ b/conf/machine/include/rk3588s.inc
@@ -20,3 +20,6 @@  TFA_PLATFORM = "rk3588"
 TFA_BUILD_TARGET = "bl31"
 
 ENABLE_STATELESS_VPU_GST ?= "1"
+
+# NPU supported by the upstream Rocket driver (see ENABLE_UPSTREAM_RKNPU)
+MACHINE_FEATURES += "rknpu"
diff --git a/conf/machine/include/rockchip-defaults.inc b/conf/machine/include/rockchip-defaults.inc
index 9a5cf3a4cdc7..59773ec2360c 100644
--- a/conf/machine/include/rockchip-defaults.inc
+++ b/conf/machine/include/rockchip-defaults.inc
@@ -1,6 +1,8 @@ 
 # meta-rockchip default settings
 MACHINEOVERRIDES =. "${@bb.utils.contains('ROCKCHIP_CLOSED_TPL', '1', 'closed-tpl:', '', d)}"
 MACHINEOVERRIDES =. "rockchip:"
+# 'rknpu' marks an NPU supported by the upstream Rocket driver
+MACHINEOVERRIDES .= "${@bb.utils.contains('MACHINE_FEATURES', 'rknpu', ':rknpu', '', d)}"
 
 # kernel
 # RK_KERNEL_FITIMAGE needs to be set before the next "require ..."
diff --git a/recipes-graphics/mesa/mesa.bbappend b/recipes-graphics/mesa/mesa.bbappend
index 362eced535f9..3c1134b57539 100644
--- a/recipes-graphics/mesa/mesa.bbappend
+++ b/recipes-graphics/mesa/mesa.bbappend
@@ -12,7 +12,7 @@  PACKAGECONFIG:append:rockchip = "${@bb.utils.contains('MALI_DRIVER', 'panfrost',
 
 # Enable teflon for upstream RKNPU/rocket support
 # Requires CONFIG_DRM_ACCEL_ROCKET in Linux kernel to actually work
-PACKAGECONFIG:append:rk3588s = "${@' teflon rocket' if bb.utils.to_boolean(d.getVar('ENABLE_UPSTREAM_RKNPU'), False) else ''}"
+PACKAGECONFIG:append:rknpu = "${@' teflon rocket' if bb.utils.to_boolean(d.getVar('ENABLE_UPSTREAM_RKNPU'), False) else ''}"
 
 # Mali Gen10 (Valhall, supported by Panthor) requires a firmware blob
 RRECOMMENDS:mesa-megadriver:append:rk3588s = " linux-firmware-mali-csffw-arch108"
diff --git a/recipes-kernel/linux/linux-rockchip.inc b/recipes-kernel/linux/linux-rockchip.inc
index f91492ee7968..cba82aa1c886 100644
--- a/recipes-kernel/linux/linux-rockchip.inc
+++ b/recipes-kernel/linux/linux-rockchip.inc
@@ -37,4 +37,4 @@  SRC_URI:append:nanopi-r4s = " file://realtek-r8169.cfg"
 KERNEL_FEATURES:append:rockchip = " bsp/rockchip/lttng.scc"
 KERNEL_FEATURES:append:rockchip:arm = " bsp/rockchip/remove-non-rockchip-arch-arm.scc"
 KERNEL_FEATURES:append:rockchip:aarch64 = " bsp/rockchip/remove-non-rockchip-arch-arm64.scc"
-KERNEL_FEATURES:append:rockchip = "${@' bsp/rockchip/rocket-npu.scc' if bb.utils.to_boolean(d.getVar('ENABLE_UPSTREAM_RKNPU'), False) else ''}"
+KERNEL_FEATURES:append:rknpu = "${@' bsp/rockchip/rocket-npu.scc' if bb.utils.to_boolean(d.getVar('ENABLE_UPSTREAM_RKNPU'), False) else ''}"