git: 6866177454ac - main - Revert LinuxKPI: LINUXKPI_DEBUG changes to allow drm-kmod to build

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Sat, 17 Oct 2026 09:25:29 UTC
The branch main has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=6866177454acf8fc5ac4295a0571fa791442ab52

commit 6866177454acf8fc5ac4295a0571fa791442ab52
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2026-10-17 01:38:06 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2026-10-17 09:23:23 +0000

    Revert LinuxKPI: LINUXKPI_DEBUG changes to allow drm-kmod to build
    
    It has been almost a week with an open pull-requests and a follow-up
    identified merge from master drm-kmod, as well as a patch supplied
    in a PR for the ports to fix the the current build breakage in drm-kmod
    and as a result also in nvidia-drm-* ports.
    
    The problem there is that instead of using the kmod.mk supplied
    definitions for LINUXKPI and despite using kmod.mk for the build,
    the external components have hand-rolled solutions which can get
    out of synch with src.git.
    
    This was not discovered early on given that building drm-kmod with
    LOCAL_MODULES_DIR= from git sources will not fail as the kernel
    build will have provided the new opt_linuxkpi.h file.  In addition
    drm-kmod master already had the -include for kconfig.h which the
    src tree has had since 2024.
    
    Give the pkgbase/kmod builds and users over the weekend a chance
    to produce drm-kmod packages as the number of affected poeple is
    rising.
    These changes will hopefully be brought back next week once
    drm-kmod and nvidia-drm-* ports are fixed.
    
    PR:                     299334
    Bring back after:       3+ days
    
    This reverts commit bbfd52dcbeb7b6e540220b3b24b664df6d200200.
    This reverts commit 9820afb99e6fdc471cb820f321530c52ed2c31ac.
---
 sys/compat/linuxkpi/common/include/linux/kconfig.h | 29 +---------------------
 sys/compat/linuxkpi/common/include/linux/kernel.h  |  6 ++---
 sys/compat/linuxkpi/common/include/linux/mutex.h   |  4 +--
 sys/compat/linuxkpi/common/include/linux/rwlock.h  |  2 +-
 sys/compat/linuxkpi/common/include/linux/rwsem.h   |  2 +-
 sys/compat/linuxkpi/common/include/linux/seqlock.h |  2 +-
 .../linuxkpi/common/include/linux/spinlock.h       |  8 +++---
 sys/compat/linuxkpi/common/include/linux/wait.h    |  2 +-
 .../linuxkpi/common/include/linux/ww_mutex.h       |  2 +-
 sys/compat/linuxkpi/common/src/linux_hrtimer.c     |  2 +-
 sys/compat/linuxkpi/common/src/linux_work.c        |  2 +-
 sys/conf/kmod.mk                                   |  1 -
 sys/conf/options                                   |  3 ---
 sys/conf/std.debug                                 |  1 -
 sys/conf/std.nodebug                               |  1 -
 15 files changed, 15 insertions(+), 52 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/kconfig.h b/sys/compat/linuxkpi/common/include/linux/kconfig.h
index 232bdd13656c..529d41991900 100644
--- a/sys/compat/linuxkpi/common/include/linux/kconfig.h
+++ b/sys/compat/linuxkpi/common/include/linux/kconfig.h
@@ -1,7 +1,7 @@
 /*-
  * SPDX-License-Identifier: BSD-2-Clause
  *
- * Copyright (c) 2020-2026 The FreeBSD Foundation
+ * Copyright (c) 2020 The FreeBSD Foundation
  *
  * This software was developed by Björn Zeeb under sponsorship from
  * the FreeBSD Foundation.
@@ -31,33 +31,6 @@
 #ifndef	_LINUXKPI_LINUX_KCONFIG_H_
 #define	_LINUXKPI_LINUX_KCONFIG_H_
 
-/* -------------------------------------------------------------------------- */
-#include "opt_linuxkpi.h"
-
-/*
- * LinuxKPI internals are here as this file is globally included for everything
- * compiled with LinuxKPI.
- */
-
-/*
- * Do not tell witness to ignore locks if debugging and witness are enabled.
- * This helps debugging and hopefully also long-term code quality.
- */
-#if defined(LINUXKPI_DEBUG) && defined(WITNESS)
-#define	_LKPI_MTX_NOWITNESS	(0)
-#define	_LKPI_RW_NOWITNESS	(0)
-#define	_LKPI_SX_NOWITNESS	(0)
-#define	WITNESS_ALL	/* Get better lock names. */
-#else
-#define	_LKPI_MTX_NOWITNESS	MTX_NOWITNESS
-#define	_LKPI_RW_NOWITNESS	RW_NOWITNESS
-#define	_LKPI_SX_NOWITNESS	SX_NOWITNESS
-#endif
-
-
-
-/* -------------------------------------------------------------------------- */
-
 /*
  * Checking if an option is defined would be easy if we could do CPP inside CPP.
  * The defined case whether -Dxxx or -Dxxx=1 are easy to deal with.  In either
diff --git a/sys/compat/linuxkpi/common/include/linux/kernel.h b/sys/compat/linuxkpi/common/include/linux/kernel.h
index 43aea5985ab4..3fcc6c1a925e 100644
--- a/sys/compat/linuxkpi/common/include/linux/kernel.h
+++ b/sys/compat/linuxkpi/common/include/linux/kernel.h
@@ -30,8 +30,6 @@
 #ifndef	_LINUXKPI_LINUX_KERNEL_H_
 #define	_LINUXKPI_LINUX_KERNEL_H_
 
-#include "opt_linuxkpi.h"
-
 #include <sys/types.h>
 #include <sys/systm.h>
 #include <sys/param.h>
@@ -178,9 +176,9 @@ scnprintf(char *buf, size_t size, const char *fmt, ...)
 
 /*
  * The "pr_debug()" and "pr_devel()" macros should produce zero code
- * unless LINUXKPI_DEBUG is defined:
+ * unless DEBUG is defined:
  */
-#ifdef LINUXKPI_DEBUG
+#ifdef DEBUG
 extern int linuxkpi_debug;
 #define pr_debug(fmt, ...)					\
 	do {							\
diff --git a/sys/compat/linuxkpi/common/include/linux/mutex.h b/sys/compat/linuxkpi/common/include/linux/mutex.h
index 8008cb574552..64d76491a76f 100644
--- a/sys/compat/linuxkpi/common/include/linux/mutex.h
+++ b/sys/compat/linuxkpi/common/include/linux/mutex.h
@@ -109,10 +109,10 @@ mutex_trylock_recursive(struct mutex *lock)
 }
 
 #define	mutex_init(_m) \
-	linux_mutex_init(_m, mutex_name(#_m), _LKPI_SX_NOWITNESS)
+	linux_mutex_init(_m, mutex_name(#_m), SX_NOWITNESS)
 
 #define	__mutex_init(_m, _n, _l) \
-	linux_mutex_init(_m, _n, _LKPI_SX_NOWITNESS)
+	linux_mutex_init(_m, _n, SX_NOWITNESS)
 
 #define	mutex_init_witness(_m) \
 	linux_mutex_init(_m, mutex_name(#_m), SX_DUPOK)
diff --git a/sys/compat/linuxkpi/common/include/linux/rwlock.h b/sys/compat/linuxkpi/common/include/linux/rwlock.h
index 1a75831d3750..3030ec89ff1e 100644
--- a/sys/compat/linuxkpi/common/include/linux/rwlock.h
+++ b/sys/compat/linuxkpi/common/include/linux/rwlock.h
@@ -52,6 +52,6 @@ typedef struct rwlock rwlock_t;
     do { read_unlock(lock); } while (0)
 #define	write_unlock_irqrestore(lock, flags)				\
     do { write_unlock(lock); } while (0)
-#define	rwlock_init(_l)	rw_init_flags(_l, "lnxrw", _LKPI_RW_NOWITNESS | RW_NEW)
+#define	rwlock_init(_l)	rw_init_flags(_l, "lnxrw", RW_NOWITNESS | RW_NEW)
 
 #endif	/* _LINUXKPI_LINUX_RWLOCK_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/rwsem.h b/sys/compat/linuxkpi/common/include/linux/rwsem.h
index 2fed94f0a81a..43688ab93796 100644
--- a/sys/compat/linuxkpi/common/include/linux/rwsem.h
+++ b/sys/compat/linuxkpi/common/include/linux/rwsem.h
@@ -77,7 +77,7 @@ linux_init_rwsem(struct rw_semaphore *rw, const char *name)
 {
 
 	memset(rw, 0, sizeof(*rw));
-	sx_init_flags(&rw->sx, name, _LKPI_SX_NOWITNESS);
+	sx_init_flags(&rw->sx, name, SX_NOWITNESS);
 }
 
 extern int linux_down_read_killable(struct rw_semaphore *);
diff --git a/sys/compat/linuxkpi/common/include/linux/seqlock.h b/sys/compat/linuxkpi/common/include/linux/seqlock.h
index be2fe5f3daed..554fdfd6e202 100644
--- a/sys/compat/linuxkpi/common/include/linux/seqlock.h
+++ b/sys/compat/linuxkpi/common/include/linux/seqlock.h
@@ -119,7 +119,7 @@ seqlock_init(struct seqlock *seqlock)
 	 * seqlock has been freed. There is no seqlock destructor exists so we
 	 * can't expect automatic mtx_destroy() execution before free().
 	 */
-	mtx_init(&seqlock->seql_lock, "seqlock", NULL, MTX_DEF | _LKPI_MTX_NOWITNESS);
+	mtx_init(&seqlock->seql_lock, "seqlock", NULL, MTX_DEF|MTX_NOWITNESS);
 	seqcount_init(&seqlock->seql_count);
 }
 
diff --git a/sys/compat/linuxkpi/common/include/linux/spinlock.h b/sys/compat/linuxkpi/common/include/linux/spinlock.h
index 258322ea8ce7..a786cbab5e13 100644
--- a/sys/compat/linuxkpi/common/include/linux/spinlock.h
+++ b/sys/compat/linuxkpi/common/include/linux/spinlock.h
@@ -29,8 +29,6 @@
 #ifndef	_LINUXKPI_LINUX_SPINLOCK_H_
 #define	_LINUXKPI_LINUX_SPINLOCK_H_
 
-#include "opt_linuxkpi.h"
-
 #include <asm/atomic.h>
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -132,7 +130,7 @@ typedef struct mtx spinlock_t;
 	spin_unlock(_l);				\
 } while (0)
 
-#if defined(LINUXKPI_DEBUG) && defined(WITNESS)
+#ifdef WITNESS_ALL
 /* NOTE: the maximum WITNESS name is 64 chars */
 #define	__spin_lock_name(name, file, line)		\
 	(((const char *){file ":" #line "-" name}) +	\
@@ -144,7 +142,7 @@ typedef struct mtx spinlock_t;
 #define	spin_lock_name(name)		_spin_lock_name(name, __FILE__, __LINE__)
 
 #define	spin_lock_init(lock)	mtx_init(lock, spin_lock_name("lnxspin"), \
-				  NULL, MTX_DEF | _LKPI_MTX_NOWITNESS | MTX_NEW)
+				  NULL, MTX_DEF | MTX_NOWITNESS | MTX_NEW)
 
 #define	spin_lock_destroy(_l)	mtx_destroy(_l)
 
@@ -192,7 +190,7 @@ typedef struct raw_spinlock {
 
 #define	raw_spin_lock_init(rlock) \
 	mtx_init(&(rlock)->lock, spin_lock_name("lnxspin_raw"), \
-	    NULL, MTX_DEF | _LKPI_MTX_NOWITNESS | MTX_NEW)
+	    NULL, MTX_DEF | MTX_NOWITNESS | MTX_NEW)
 
 #define	raw_spin_lock(rl)	spin_lock(&(rl)->lock)
 #define	raw_spin_trylock(rl)	spin_trylock(&(rl)->lock)
diff --git a/sys/compat/linuxkpi/common/include/linux/wait.h b/sys/compat/linuxkpi/common/include/linux/wait.h
index 5d98ccfa7af8..698a1056b713 100644
--- a/sys/compat/linuxkpi/common/include/linux/wait.h
+++ b/sys/compat/linuxkpi/common/include/linux/wait.h
@@ -115,7 +115,7 @@ long linux_wait_woken(wait_queue_t *wq, unsigned state, long timeout);
 
 #define	init_waitqueue_head(wqh) do {					\
 	mtx_init(&(wqh)->lock, spin_lock_name("wqhead"),		\
-	    NULL, MTX_DEF | MTX_NEW | _LKPI_MTX_NOWITNESS);		\
+	    NULL, MTX_DEF | MTX_NEW | MTX_NOWITNESS);			\
 	INIT_LIST_HEAD(&(wqh)->task_list);				\
 } while (0)
 
diff --git a/sys/compat/linuxkpi/common/include/linux/ww_mutex.h b/sys/compat/linuxkpi/common/include/linux/ww_mutex.h
index eff838ab214a..9219755bb78e 100644
--- a/sys/compat/linuxkpi/common/include/linux/ww_mutex.h
+++ b/sys/compat/linuxkpi/common/include/linux/ww_mutex.h
@@ -132,7 +132,7 @@ ww_acquire_init(struct ww_acquire_ctx *ctx, struct ww_class *ww_class)
 static inline void
 ww_mutex_init(struct ww_mutex *lock, struct ww_class *ww_class)
 {
-	linux_mutex_init(&lock->base, ww_class->mutex_name, _LKPI_SX_NOWITNESS);
+	linux_mutex_init(&lock->base, ww_class->mutex_name, SX_NOWITNESS);
 	cv_init(&lock->condvar, "lkpi-ww");
 }
 
diff --git a/sys/compat/linuxkpi/common/src/linux_hrtimer.c b/sys/compat/linuxkpi/common/src/linux_hrtimer.c
index 58c55fed5d1a..bbd99dec2d83 100644
--- a/sys/compat/linuxkpi/common/src/linux_hrtimer.c
+++ b/sys/compat/linuxkpi/common/src/linux_hrtimer.c
@@ -101,7 +101,7 @@ linux_hrtimer_init(struct hrtimer *hrtimer)
 
 	memset(hrtimer, 0, sizeof(*hrtimer));
 	mtx_init(&hrtimer->mtx, "hrtimer", NULL,
-	    MTX_DEF | MTX_RECURSE | _LKPI_MTX_NOWITNESS);
+	    MTX_DEF | MTX_RECURSE | MTX_NOWITNESS);
 	callout_init_mtx(&hrtimer->callout, &hrtimer->mtx, 0);
 }
 
diff --git a/sys/compat/linuxkpi/common/src/linux_work.c b/sys/compat/linuxkpi/common/src/linux_work.c
index ef2891b1f249..bf4c82767621 100644
--- a/sys/compat/linuxkpi/common/src/linux_work.c
+++ b/sys/compat/linuxkpi/common/src/linux_work.c
@@ -706,7 +706,7 @@ linux_init_delayed_work(struct delayed_work *dwork, work_func_t func)
 	dwork->work.func = func;
 	TASK_INIT(&dwork->work.work_task, 0, linux_delayed_work_fn, dwork);
 	mtx_init(&dwork->timer.mtx, spin_lock_name("lkpi-dwork"), NULL,
-	    MTX_DEF | _LKPI_MTX_NOWITNESS);
+	    MTX_DEF | MTX_NOWITNESS);
 	callout_init_mtx(&dwork->timer.callout, &dwork->timer.mtx, 0);
 }
 
diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk
index c2081be0da5a..c35116dfcaa8 100644
--- a/sys/conf/kmod.mk
+++ b/sys/conf/kmod.mk
@@ -103,7 +103,6 @@ LINUXKPI_GENSRCS+= \
 	pci_iov_if.h \
 	pcib_if.h \
 	vnode_if.h \
-	opt_linuxkpi.h \
 	opt_stack.h
 
 .if ${MK_USB} != "no"
diff --git a/sys/conf/options b/sys/conf/options
index d14fe964949e..c9d72fdfdbb3 100644
--- a/sys/conf/options
+++ b/sys/conf/options
@@ -908,9 +908,6 @@ TDMA_TXRATE_QUARTER_DEFAULT	opt_tdma.h
 TDMA_TXRATE_11NA_DEFAULT	opt_tdma.h
 TDMA_TXRATE_11NG_DEFAULT	opt_tdma.h
 
-# LinuxKPI
-LINUXKPI_DEBUG		opt_linuxkpi.h
-
 # VideoMode
 PICKMODE_DEBUG			opt_videomode.h
 
diff --git a/sys/conf/std.debug b/sys/conf/std.debug
index 4ec89de4b407..0149779b3e5c 100644
--- a/sys/conf/std.debug
+++ b/sys/conf/std.debug
@@ -17,4 +17,3 @@ options 	VERBOSE_SYSINIT=0	# Support debug.verbose_sysinit, off by default
 options		ALT_BREAK_TO_DEBUGGER	# Enter debugger on keyboard escape sequence
 options		KDTRACE_MIB_SDT		# Add SDT probes to network counters
 options 	TCP_HPTS_KTEST		# Add KTEST support for HPTS
-options		LINUXKPI_DEBUG		# Add LinuxKPI pr_debug/pr_devel support
diff --git a/sys/conf/std.nodebug b/sys/conf/std.nodebug
index ac5d27cedd36..f8c908cc9936 100644
--- a/sys/conf/std.nodebug
+++ b/sys/conf/std.nodebug
@@ -17,7 +17,6 @@ nooptions	MALLOC_DEBUG_MAXZONES
 nooptions	QUEUE_MACRO_DEBUG_TRASH
 nooptions	KDTRACE_MIB_SDT
 nooptions	TCP_HPTS_KTEST
-nooptions	LINUXKPI_DEBUG
 
 # Net80211 debugging
 nooptions	IEEE80211_DEBUG