Skip to contentSkip to conversation

package/linux-tools: fix PCI endpoint tests build with recent kernels

PATCH Applied Florian Fainelli via buildroot 1 participant 3 messages Oct 22 – Oct 30

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 package/linux-tools: fix PCI endpoint tests build with recent kernels

Since Linux 6.14, the PCI endpoint tests have moved from tools/pci to tools/testing/selftests/pci_endpoint. The existing build commands still use the old location, causing the build to fail with newer kernels.

Detect the selftests directory and fall back to tools/pci for older kernels. Set OUTPUT and INSTALL_PATH to build and install the selftests under /usr/lib/kselftests/pci_endpoint, and pass the required libraries explicitly.

Update the help text to document the binary names and installation paths. Check that the selected source directory contains a Makefile and report the minimum supported kernel version if it is missing.

---
 package/linux-tools/Config.in            |  5 +++--
 package/linux-tools/linux-tool-pci.mk.in | 16 ++++++++++++----
 2 files changed, 15 insertions(+), 6 deletions(-)
package/linux-tools/Config.in +3 -2
index b9adc25ad51d..1e881c3ab4f0 100644
@@ -61,8 +61,9 @@ config BR2_PACKAGE_LINUX_TOOLS_PCI
 	bool "pci"
 	select BR2_PACKAGE_LINUX_TOOLS
 	help
-	  pcitest is a tool for testing capabilities related to a
-	  PCI Endpoint (only works with specific Endpoints).
+	  Build the PCI endpoint tests (only work with specific Endpoints).
+	  Kernels before 6.14 provide pcitest in /usr/bin. Newer kernels
+	  provide pci_endpoint_test in /usr/lib/kselftests/pci_endpoint.
 
 	  These tools are available only from kernel version 4.20.
 
package/linux-tools/linux-tool-pci.mk.in +12 -4
index 17246f5d7ed2..52d7639bb102 100644
@@ -6,22 +6,30 @@
 
 LINUX_TOOLS += pci
 
-PCI_MAKE_OPTS = $(LINUX_MAKE_FLAGS) LDFLAGS="$(TARGET_LDFLAGS)"
+# Linux 6.14 moved the PCI endpoint tests into Kselftests.
+PCI_SRCDIR = $(strip $(if $(wildcard $(LINUX_DIR)/tools/testing/selftests/pci_endpoint/Makefile),\
+	$(LINUX_DIR)/tools/testing/selftests/pci_endpoint,$(LINUX_DIR)/tools/pci))
+
+PCI_MAKE_OPTS = $(LINUX_MAKE_FLAGS) \
+	OUTPUT=$(PCI_SRCDIR)/ \
+	LDFLAGS="$(TARGET_LDFLAGS)" \
+	LDLIBS="-lrt -lm"
 
 define PCI_BUILD_CMDS
-	$(Q)if ! grep install $(LINUX_DIR)/tools/pci/Makefile >/dev/null 2>&1 ; then \
+	$(Q)if test ! -f $(PCI_SRCDIR)/Makefile ; then \
 		echo "Your kernel version is too old and does not have install section in the pci tools." ; \
 		echo "At least kernel 4.20 must be used." ; \
 		exit 1 ; \
 	fi
 
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools/pci \
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(PCI_SRCDIR) \
 		$(PCI_MAKE_OPTS)
 endef
 
 define PCI_INSTALL_TARGET_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools/pci \
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(PCI_SRCDIR) \
 		$(PCI_MAKE_OPTS) \
 		DESTDIR=$(TARGET_DIR) \
+		INSTALL_PATH=$(TARGET_DIR)/usr/lib/kselftests/pci_endpoint \
 		install
 endef
Signature · 6 lines
2.53.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw
Quoted 9 lines · Florian Fainelli via buildroot

Since Linux 6.14, the PCI endpoint tests have moved from tools/pci to tools/testing/selftests/pci_endpoint. The existing build commands still use the old location, causing the build to fail with newer kernels.

Detect the selftests directory and fall back to tools/pci for older kernels. Set OUTPUT and INSTALL_PATH to build and install the selftests under /usr/lib/kselftests/pci_endpoint, and pass the required libraries explicitly.

Quoted 5 lines

Update the help text to document the binary names and installation paths. Check that the selected source directory contains a Makefile and report the minimum supported kernel version if it is missing.

Applied to master after adjusting two minor things:

- Wrapped the Config.in help, some lines were a bit too long and were causing a "make check-package" warning.

- Adding a Fixes: tag, not pointing to the commit introducing the issue because as discussed there isn't any, but instead pointing to an autobuilder failure that your patch is fixing.

Thanks a lot!

Thomas Petazzoni

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw
In reply to Florian Fainelli via buildroot

In reply of:

Quoted 9 lines

Since Linux 6.14, the PCI endpoint tests have moved from tools/pci to tools/testing/selftests/pci_endpoint. The existing build commands still use the old location, causing the build to fail with newer kernels.

Detect the selftests directory and fall back to tools/pci for older kernels. Set OUTPUT and INSTALL_PATH to build and install the selftests under /usr/lib/kselftests/pci_endpoint, and pass the required libraries explicitly.

Quoted 5 lines

Update the help text to document the binary names and installation paths. Check that the selected source directory contains a Makefile and report the minimum supported kernel version if it is missing.

Applied to 2026.08.x. Thanks

Quoted 50 lines
---
 package/linux-tools/Config.in            |  5 +++--
 package/linux-tools/linux-tool-pci.mk.in | 16 ++++++++++++----
 2 files changed, 15 insertions(+), 6 deletions(-)
package/linux-tools/Config.in +3 -2
index b9adc25ad51d..1e881c3ab4f0 100644
@@ -61,8 +61,9 @@ config BR2_PACKAGE_LINUX_TOOLS_PCI
 	bool "pci"
 	select BR2_PACKAGE_LINUX_TOOLS
 	help
-	  pcitest is a tool for testing capabilities related to a
-	  PCI Endpoint (only works with specific Endpoints).
+	  Build the PCI endpoint tests (only work with specific Endpoints).
+	  Kernels before 6.14 provide pcitest in /usr/bin. Newer kernels
+	  provide pci_endpoint_test in /usr/lib/kselftests/pci_endpoint.
 
 	  These tools are available only from kernel version 4.20.
 
package/linux-tools/linux-tool-pci.mk.in +10 -3
index 17246f5d7ed2..52d7639bb102 100644
@@ -6,22 +6,30 @@
 
 LINUX_TOOLS += pci
 
-PCI_MAKE_OPTS = $(LINUX_MAKE_FLAGS) LDFLAGS="$(TARGET_LDFLAGS)"
+# Linux 6.14 moved the PCI endpoint tests into Kselftests.
+PCI_SRCDIR = $(strip $(if $(wildcard $(LINUX_DIR)/tools/testing/selftests/pci_endpoint/Makefile),\
+	$(LINUX_DIR)/tools/testing/selftests/pci_endpoint,$(LINUX_DIR)/tools/pci))
+
+PCI_MAKE_OPTS = $(LINUX_MAKE_FLAGS) \
+	OUTPUT=$(PCI_SRCDIR)/ \
+	LDFLAGS="$(TARGET_LDFLAGS)" \
+	LDLIBS="-lrt -lm"
 
 define PCI_BUILD_CMDS
-	$(Q)if ! grep install $(LINUX_DIR)/tools/pci/Makefile >/dev/null 2>&1 ; then \
+	$(Q)if test ! -f $(PCI_SRCDIR)/Makefile ; then \
 		echo "Your kernel version is too old and does not have install section in the pci tools." ; \
 		echo "At least kernel 4.20 must be used." ; \
 		exit 1 ; \
 	fi
 
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools/pci \
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(PCI_SRCDIR) \
 		$(PCI_MAKE_OPTS)

package/linux-tools/linux-tool-pci.mk.in line 35

Quoted 10 lines
package/linux-tools/linux-tool-pci.mk.in +2 -1
 endef
 
 define PCI_INSTALL_TARGET_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools/pci \
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(PCI_SRCDIR) \
 		$(PCI_MAKE_OPTS) \
 		DESTDIR=$(TARGET_DIR) \
+		INSTALL_PATH=$(TARGET_DIR)/usr/lib/kselftests/pci_endpoint \
 		install
 endef

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