From: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
To: Stephen Hemminger <stephen@networkplumber.org>, dev@dpdk.org
Cc: stable@dpdk.org,
Kalesh Anakkur Purayil <kalesh-anakkur.purayil@broadcom.com>
Subject: RE: [PATCH 5/6] net/bnxt: fix mutexes for multi-process
Date: Tue, 14 Apr 2026 14:51:35 -0400 [thread overview]
Message-ID: <9032195738d97412900bf442539cbd85@mail.gmail.com> (raw)
In-Reply-To: <20260413171836.123467-6-stephen@networkplumber.org>
[-- Attachment #1: Type: text/plain, Size: 6591 bytes --]
-----Original Message-----
From: Stephen Hemminger <stephen@networkplumber.org>
Sent: Monday, April 13, 2026 1:15 PM
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>; stable@dpdk.org;
Kishore Padmanabha <kishore.padmanabha@broadcom.com>; Ajit Khaparde
<ajit.khaparde@broadcom.com>; Venkat Duvvuru
<venkatkumar.duvvuru@broadcom.com>; Kalesh AP
<kalesh-anakkur.purayil@broadcom.com>; Somnath Kotur
<somnath.kotur@broadcom.com>
Subject: [PATCH 5/6] net/bnxt: fix mutexes for multi-process
The BNXT driver supports secondary processes, as shown by the explicit
check in bnxt_dev_init(). Multiple mutexes are located in structures
allocated in shared memory (dev_private and rte_zmalloc'd structures) that
are accessible by both primary and secondary processes.
However, the mutexes are initialized without PTHREAD_PROCESS_SHARED
attribute, which means synchronization between processes is undefined
behavior.
POSIX mutexes are by default private to the process creating them.
When a mutex protects data structures in shared memory that are accessed
by multiple processes, pthread_mutexattr_setpshared() must be called with
PTHREAD_PROCESS_SHARED.
This patch adds a helper function and updates all mutex initializations in
the BNXT driver:
- flow_lock, def_cp_lock, health_check_lock, err_recovery_lock
in struct bnxt (bnxt_ethdev.c)
- vfr_start_lock in rep_info (bnxt_ethdev.c)
- txq_lock in struct bnxt_tx_queue (bnxt_txq.c)
- bnxt_ulp_mutex in session state (bnxt_ulp.c)
- flow_db_lock in cfg_data (bnxt_ulp_tf.c, bnxt_ulp_tfc.c)
Bugzilla ID: 662
Fixes: 1cb3d39a48f7 ("net/bnxt: synchronize between flow related
functions")
Fixes: 5526c8025d4d ("net/bnxt: fix race between interrupt handler and dev
config")
Fixes: b59e4be2b6a7 ("net/bnxt: fix VF representor port add")
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
---
drivers/net/bnxt/bnxt_ethdev.c | 11 ++++++-----
drivers/net/bnxt/bnxt_txq.c | 3 ++-
drivers/net/bnxt/bnxt_util.c | 13 +++++++++++++
drivers/net/bnxt/bnxt_util.h | 2 ++
drivers/net/bnxt/tf_ulp/bnxt_ulp.c | 2 +-
drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c | 2 +-
drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c | 2 +-
7 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/drivers/net/bnxt/bnxt_ethdev.c
b/drivers/net/bnxt/bnxt_ethdev.c index b677f9491d..3f55ad041d 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -5899,10 +5899,10 @@ static int bnxt_get_config(struct bnxt *bp)
static int bnxt_init_locks(struct bnxt *bp) {
- pthread_mutex_init(&bp->flow_lock, NULL);
- pthread_mutex_init(&bp->def_cp_lock, NULL);
- pthread_mutex_init(&bp->health_check_lock, NULL);
- pthread_mutex_init(&bp->err_recovery_lock, NULL);
+ bnxt_init_mutex(&bp->flow_lock);
+ bnxt_init_mutex(&bp->def_cp_lock);
+ bnxt_init_mutex(&bp->health_check_lock);
+ bnxt_init_mutex(&bp->err_recovery_lock);
return 0;
}
@@ -6920,7 +6920,8 @@ static int bnxt_init_rep_info(struct bnxt *bp)
for (i = 0; i < BNXT_MAX_CFA_CODE; i++)
bp->cfa_code_map[i] = BNXT_VF_IDX_INVALID;
- return pthread_mutex_init(&bp->rep_info->vfr_start_lock, NULL);
+ bnxt_init_mutex(&bp->rep_info->vfr_start_lock);
+ return 0;
}
static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, diff --git
a/drivers/net/bnxt/bnxt_txq.c b/drivers/net/bnxt/bnxt_txq.c index
7752f06eb7..8c834acb1d 100644
--- a/drivers/net/bnxt/bnxt_txq.c
+++ b/drivers/net/bnxt/bnxt_txq.c
@@ -204,7 +204,8 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev
*eth_dev,
goto err;
}
- return pthread_mutex_init(&txq->txq_lock, NULL);
+ bnxt_init_mutex(&txq->txq_lock);
+ return 0;
err:
bnxt_tx_queue_release_op(eth_dev, queue_idx);
return rc;
diff --git a/drivers/net/bnxt/bnxt_util.c b/drivers/net/bnxt/bnxt_util.c
index aa184496c2..c3f0a03f25 100644
--- a/drivers/net/bnxt/bnxt_util.c
+++ b/drivers/net/bnxt/bnxt_util.c
@@ -3,6 +3,7 @@
* All rights reserved.
*/
+#include <pthread.h>
#include <inttypes.h>
#include <rte_ether.h>
@@ -37,3 +38,15 @@ uint8_t hweight32(uint32_t word32)
res = res + (res >> 8);
return (res + (res >> 16)) & 0x000000FF; }
+
+/* Initialize mutex so that it can be shared between processes */ void
+bnxt_init_mutex(pthread_mutex_t *mutex) {
+ pthread_mutexattr_t attr;
+
+ pthread_mutexattr_init(&attr);
+ pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
+ pthread_mutex_init(mutex, &attr);
+ pthread_mutexattr_destroy(&attr);
+}
diff --git a/drivers/net/bnxt/bnxt_util.h b/drivers/net/bnxt/bnxt_util.h
index 416a6a2609..e1b45d1bb5 100644
--- a/drivers/net/bnxt/bnxt_util.h
+++ b/drivers/net/bnxt/bnxt_util.h
@@ -16,4 +16,6 @@
int bnxt_check_zero_bytes(const uint8_t *bytes, int len); void
bnxt_eth_hw_addr_random(uint8_t *mac_addr); uint8_t hweight32(uint32_t
word32);
+void bnxt_init_mutex(pthread_mutex_t *mutex);
+
#endif /* _BNXT_UTIL_H_ */
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
index 0c03ae7a83..c2c93859ff 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
@@ -214,7 +214,7 @@ ulp_session_init(struct bnxt *bp,
session->pci_info.domain = pci_addr->domain;
session->pci_info.bus = pci_addr->bus;
memcpy(session->dsn, bp->dsn,
sizeof(session->dsn));
- pthread_mutex_init(&session->bnxt_ulp_mutex,
NULL);
+ bnxt_init_mutex(&session->bnxt_ulp_mutex);
STAILQ_INSERT_TAIL(&bnxt_ulp_session_list,
session, next);
}
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c
b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c
index bc347de202..d87120aea3 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c
@@ -1469,7 +1469,7 @@ ulp_tf_init(struct bnxt *bp,
goto jump_to_error;
}
- pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
+ bnxt_init_mutex(&bp->ulp_ctx->cfg_data->flow_db_lock);
/* Initialize ulp dparms with values devargs passed */
rc = ulp_tf_dparms_init(bp, bp->ulp_ctx); diff --git
a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c
b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c
index ad44ec93ca..0c3d1f7dae 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c
@@ -1038,7 +1038,7 @@ ulp_tfc_init(struct bnxt *bp,
goto jump_to_error;
}
- pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
+ bnxt_init_mutex(&bp->ulp_ctx->cfg_data->flow_db_lock);
rc = ulp_tfc_dparms_init(bp, bp->ulp_ctx, ulp_dev_id);
if (rc) {
--
2.53.0
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5493 bytes --]
next prev parent reply other threads:[~2026-04-14 18:51 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-13 17:14 [PATCH 0/6] fix pthread mutexes for multi-process Stephen Hemminger
2026-04-13 17:14 ` [PATCH 1/6] ethdev: fix flow_ops_mutex " Stephen Hemminger
2026-04-13 17:14 ` [PATCH 2/6] net/failsafe: fix hotplug_mutex " Stephen Hemminger
2026-04-13 17:14 ` [PATCH 3/6] net/atlantic: fix mbox_mutex " Stephen Hemminger
2026-04-13 17:14 ` [PATCH 4/6] net/axgbe: fix mutexes " Stephen Hemminger
2026-04-13 17:14 ` [PATCH 5/6] net/bnxt: " Stephen Hemminger
2026-04-14 18:51 ` Kishore Padmanabha [this message]
2026-04-13 17:14 ` [PATCH 6/6] net/hinic: " Stephen Hemminger
2026-04-14 14:39 ` [PATCH v2 0/6] fix process shared pthread mutexes Stephen Hemminger
2026-04-14 14:39 ` [PATCH v2 1/6] ethdev: fix flow_ops_mutex for multi-process Stephen Hemminger
2026-04-14 14:39 ` [PATCH v2 2/6] net/failsafe: fix hotplug_mutex " Stephen Hemminger
2026-04-14 14:39 ` [PATCH v2 3/6] net/atlantic: fix mbox_mutex " Stephen Hemminger
2026-04-14 14:39 ` [PATCH v2 4/6] net/axgbe: fix mutexes " Stephen Hemminger
2026-04-14 14:39 ` [PATCH v2 5/6] net/bnxt: " Stephen Hemminger
2026-04-14 14:39 ` [PATCH v2 6/6] net/hinic: " Stephen Hemminger
2026-04-23 15:05 ` [PATCH v2 0/6] fix process shared pthread mutexes Stephen Hemminger
2026-04-23 17:29 ` Konstantin Ananyev
2026-05-08 16:39 ` Stephen Hemminger
2026-04-15 14:51 ` [PATCH v3 0/2] af_packet: cleanup and test Stephen Hemminger
2026-04-15 14:51 ` [PATCH v3 1/2] net/af_packet: fix indentation Stephen Hemminger
2026-04-15 14:51 ` [PATCH v3 2/2] test: add test for af_packet Stephen Hemminger
2026-04-16 17:57 ` [PATCH v4 0/2] af_packet: cleanup and test Stephen Hemminger
2026-04-16 17:57 ` [PATCH v4 1/2] net/af_packet: fix indentation Stephen Hemminger
2026-04-16 17:57 ` [PATCH v4 2/2] test: add test for af_packet Stephen Hemminger
2026-04-29 18:46 ` [PATCH v3 0/7] fix use of pthread mutex between processes Stephen Hemminger
2026-04-29 18:46 ` [PATCH v3 1/7] eal: add helper to initialize process-shared mutex Stephen Hemminger
2026-04-29 18:46 ` [PATCH v3 2/7] ethdev: fix flow_ops_mutex for multi-process Stephen Hemminger
2026-04-29 18:46 ` [PATCH v3 3/7] net/failsafe: fix hotplug_mutex " Stephen Hemminger
2026-04-29 18:46 ` [PATCH v3 4/7] net/atlantic: fix mbox_mutex " Stephen Hemminger
2026-04-29 18:46 ` [PATCH v3 5/7] net/axgbe: fix mutexes " Stephen Hemminger
2026-04-29 18:46 ` [PATCH v3 6/7] net/bnxt: " Stephen Hemminger
2026-04-29 18:46 ` [PATCH v3 7/7] net/hinic: " Stephen Hemminger
2026-04-30 17:36 ` [PATCH v3 0/7] fix use of pthread mutex between processes Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9032195738d97412900bf442539cbd85@mail.gmail.com \
--to=kishore.padmanabha@broadcom.com \
--cc=dev@dpdk.org \
--cc=kalesh-anakkur.purayil@broadcom.com \
--cc=stable@dpdk.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox