From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
stable@dpdk.org, Selwin Sebastian <selwin.sebastian@amd.com>,
Ravi Kumar <ravi1.kumar@amd.com>
Subject: [RFC 4/6] net/axgbe: fix mutexes for multi-process
Date: Thu, 29 Jan 2026 21:17:35 -0800 [thread overview]
Message-ID: <20260130052142.251649-5-stephen@networkplumber.org> (raw)
In-Reply-To: <20260130052142.251649-1-stephen@networkplumber.org>
The AXGBE driver supports secondary processes, as shown by the
explicit check in eth_axgbe_dev_init(). The xpcs_mutex, i2c_mutex,
an_mutex, and phy_mutex in axgbe_port are located in dev_private
which is in shared memory 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.
Bugzilla ID: 662
Fixes: 572890ef6625 ("net/axgbe: add structs for MAC init and reset")
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/axgbe/axgbe_ethdev.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c
index cf3b0d9ef5..0fedac72ab 100644
--- a/drivers/net/axgbe/axgbe_ethdev.c
+++ b/drivers/net/axgbe/axgbe_ethdev.c
@@ -193,6 +193,17 @@ static const struct axgbe_xstats axgbe_xstats_strings[] = {
#define AMD_PCI_AXGBE_DEVICE_V2A 0x1458
#define AMD_PCI_AXGBE_DEVICE_V2B 0x1459
+static void
+axgbe_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);
+}
+
static const struct rte_pci_id pci_id_axgbe_map[] = {
{RTE_PCI_DEVICE(AMD_PCI_VENDOR_ID, AMD_PCI_AXGBE_DEVICE_V2A)},
{RTE_PCI_DEVICE(AMD_PCI_VENDOR_ID, AMD_PCI_AXGBE_DEVICE_V2B)},
@@ -2403,10 +2414,10 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)
pdata->tx_desc_count = AXGBE_MAX_RING_DESC;
pdata->rx_desc_count = AXGBE_MAX_RING_DESC;
- pthread_mutex_init(&pdata->xpcs_mutex, NULL);
- pthread_mutex_init(&pdata->i2c_mutex, NULL);
- pthread_mutex_init(&pdata->an_mutex, NULL);
- pthread_mutex_init(&pdata->phy_mutex, NULL);
+ axgbe_init_mutex(&pdata->xpcs_mutex);
+ axgbe_init_mutex(&pdata->i2c_mutex);
+ axgbe_init_mutex(&pdata->an_mutex);
+ axgbe_init_mutex(&pdata->phy_mutex);
ret = pdata->phy_if.phy_init(pdata);
if (ret) {
--
2.51.0
next prev parent reply other threads:[~2026-01-30 5:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-30 5:17 [RFC 0/6] Fix pthread mutexes for multi-process support Stephen Hemminger
2026-01-30 5:17 ` [RFC 1/6] ethdev: fix flow_ops_mutex for multi-process Stephen Hemminger
2026-01-30 5:17 ` [RFC 2/6] net/failsafe: fix hotplug_mutex " Stephen Hemminger
2026-01-30 5:17 ` [RFC 3/6] net/atlantic: fix mbox_mutex " Stephen Hemminger
2026-01-30 5:17 ` Stephen Hemminger [this message]
2026-01-30 5:17 ` [RFC 5/6] net/bnxt: fix mutexes " Stephen Hemminger
2026-01-30 5:17 ` [RFC 6/6] net/hinic: " 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=20260130052142.251649-5-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=ravi1.kumar@amd.com \
--cc=selwin.sebastian@amd.com \
--cc=stable@dpdk.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