Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] package/linux-tools: fix PCI endpoint tests build with recent kernels
@ 2026-10-22 17:27 Florian Fainelli via buildroot
  2026-10-22 17:33 ` Florian Fainelli via buildroot
  2026-10-22 17:40 ` Thomas Petazzoni via buildroot
  0 siblings, 2 replies; 7+ messages in thread
From: Florian Fainelli via buildroot @ 2026-10-22 17:27 UTC (permalink / raw)
  To: buildroot
  Cc: bernd.kuhls, chrismcc, Florian Fainelli, yann.morin.1998,
	thomas.petazzoni, fontaine.fabrice, markus.mayer

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.

Add a threads dependency and update the help text to document the
binary names and installation paths. Keep the minimum kernel version
check for the legacy tools and report missing sources explicitly.

Fixes: 63e457639abb ("package/linux-tools: add support for pcitest tool")
---
 package/linux-tools/Config.in            |  9 +++++++--
 package/linux-tools/linux-tool-pci.mk.in | 22 ++++++++++++++++++----
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/package/linux-tools/Config.in b/package/linux-tools/Config.in
index b9adc25ad51d..19d54cbbe707 100644
--- a/package/linux-tools/Config.in
+++ b/package/linux-tools/Config.in
@@ -59,13 +59,18 @@ config BR2_PACKAGE_LINUX_TOOLS_MM
 
 config BR2_PACKAGE_LINUX_TOOLS_PCI
 	bool "pci"
+	depends on BR2_TOOLCHAIN_HAS_THREADS
 	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.
 
+comment "pci needs a toolchain w/ threads"
+	depends on !BR2_TOOLCHAIN_HAS_THREADS
+
 comment "perf needs a toolchain w/ dynamic library, threads"
 	depends on BR2_TOOLCHAIN_HAS_SYNC_4
 	depends on BR2_STATIC_LIBS || !BR2_TOOLCHAIN_HAS_THREADS
diff --git a/package/linux-tools/linux-tool-pci.mk.in b/package/linux-tools/linux-tool-pci.mk.in
index 17246f5d7ed2..f9acf8f041d8 100644
--- a/package/linux-tools/linux-tool-pci.mk.in
+++ b/package/linux-tools/linux-tool-pci.mk.in
@@ -6,22 +6,36 @@
 
 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 -lpthread -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 sources do not contain the PCI endpoint tests." ; \
+		echo "Expected tools/pci or tools/testing/selftests/pci_endpoint." ; \
+		exit 1 ; \
+	fi
+	$(Q)if test "$(PCI_SRCDIR)" = "$(LINUX_DIR)/tools/pci" && \
+		! grep install $(PCI_SRCDIR)/Makefile >/dev/null 2>&1 ; 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
-- 
2.53.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-10-22 19:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-22 17:27 [Buildroot] [PATCH] package/linux-tools: fix PCI endpoint tests build with recent kernels Florian Fainelli via buildroot
2026-10-22 17:33 ` Florian Fainelli via buildroot
2026-10-22 17:40 ` Thomas Petazzoni via buildroot
2026-10-22 18:02   ` Florian Fainelli via buildroot
2026-10-22 18:30     ` Thomas Petazzoni via buildroot
2026-10-22 18:35       ` Florian Fainelli via buildroot
2026-10-22 19:02         ` Thomas Petazzoni via buildroot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox