git: 0aa3e15900d3 - main - bnxt_re: Fix witness reported calltrace while unloading driver

From: Sumit Saxena <ssaxena_at_FreeBSD.org>
Date: Fri, 09 Oct 2026 10:12:46 UTC
The branch main has been updated by ssaxena:

URL: https://cgit.FreeBSD.org/src/commit/?id=0aa3e15900d31a08680e2307cbc550715d727191

commit 0aa3e15900d31a08680e2307cbc550715d727191
Author:     Sumit Saxena <sumit.saxena@broadcom.com>
AuthorDate: 2026-07-31 15:51:01 +0000
Commit:     Sumit Saxena <ssaxena@FreeBSD.org>
CommitDate: 2026-10-09 08:24:44 +0000

    bnxt_re: Fix witness reported calltrace while unloading driver
    
    bnxt_unregister_dev() called synchronize_rcu() while holding
    bp->en_ops_lock, which witness flags as a sleeping-while-locked
    violation on driver unload. Drop the lock around the RCU grace period
    and reacquire it afterward.
    
    Also gate the RoCE extended-stats hex dump in
    bnxt_qplib_qext_stat() behind bootverbose instead of printing it
    unconditionally.
    
    Reviewed by:    gallatin
    MFC after:      2 weeks
    Sponsored by:   Broadcom Inc.
    Differential Revision:  https://reviews.freebsd.org/D58611
---
 sys/dev/bnxt/bnxt_en/bnxt_ulp.c | 7 ++++++-
 sys/dev/bnxt/bnxt_re/qplib_sp.c | 4 +++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/sys/dev/bnxt/bnxt_en/bnxt_ulp.c b/sys/dev/bnxt/bnxt_en/bnxt_ulp.c
index 7f25b50bddf4..cd6df3b17d63 100644
--- a/sys/dev/bnxt/bnxt_en/bnxt_ulp.c
+++ b/sys/dev/bnxt/bnxt_en/bnxt_ulp.c
@@ -104,14 +104,19 @@ static int bnxt_unregister_dev(struct bnxt_en_dev *edev, int ulp_id)
 
 	mtx_lock(&bp->en_ops_lock);
 	RCU_INIT_POINTER(ulp->ulp_ops, NULL);
+	mtx_unlock(&bp->en_ops_lock);
 	synchronize_rcu();
+	mtx_lock(&bp->en_ops_lock);
 	ulp->max_async_event_id = 0;
 	ulp->async_events_bmap = NULL;
+	mtx_unlock(&bp->en_ops_lock);
 	while (atomic_read(&ulp->ref_count) != 0 && i < 10) {
 		msleep(100);
 		i++;
 	}
-	mtx_unlock(&bp->en_ops_lock);
+	/* Tell the caller a ULP consumer may still hold a reference into torn-down state. */
+	if (atomic_read(&ulp->ref_count) != 0)
+		return ETIMEDOUT;
 	return 0;
 }
 
diff --git a/sys/dev/bnxt/bnxt_re/qplib_sp.c b/sys/dev/bnxt/bnxt_re/qplib_sp.c
index f876573ce69f..71780211a2c1 100644
--- a/sys/dev/bnxt/bnxt_re/qplib_sp.c
+++ b/sys/dev/bnxt/bnxt_re/qplib_sp.c
@@ -1200,7 +1200,9 @@ int bnxt_qplib_qext_stat(struct bnxt_qplib_rcfw *rcfw, u32 fid,
 		goto bail;
 
 	/* dump when dyndbg is enabled */
-	print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, sb, sizeof(*sb));
+	if (bootverbose)
+		print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, sb, sizeof(*sb));
+
 	estat->tx_atomic_req = le64_to_cpu(sb->tx_atomic_req_pkts);
 	estat->tx_read_req = le64_to_cpu(sb->tx_read_req_pkts);
 	estat->tx_read_res = le64_to_cpu(sb->tx_read_res_pkts);