The Atlantic driver supports secondary processes, as shown by the
explicit check in eth_atl_dev_init(). The mbox_mutex in aq_hw_s
is located in dev_private which is in shared memory accessible
by both primary and secondary processes.
However, the mutex is 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: e9924638f5c9 ("net/atlantic: add FW mailbox guard mutex")
Cc: [email protected]
Signed-off-by: Stephen Hemminger <[email protected]>
---
drivers/net/atlantic/atl_ethdev.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/net/atlantic/atl_ethdev.c
b/drivers/net/atlantic/atl_ethdev.c
index 2925dc2478..7282f9b691 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -3,6 +3,7 @@
*/
#include <rte_string_fns.h>
+#include <pthread.h>
#include <ethdev_pci.h>
#include <rte_alarm.h>
@@ -355,6 +356,17 @@ atl_disable_intr(struct aq_hw_s *hw)
hw_atl_itr_irq_msk_clearlsw_set(hw, 0xffffffff);
}
+static void
+atl_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 int
eth_atl_dev_init(struct rte_eth_dev *eth_dev)
{
@@ -405,7 +417,7 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev)
hw->aq_nic_cfg = &adapter->hw_cfg;
- pthread_mutex_init(&hw->mbox_mutex, NULL);
+ atl_init_mutex(&hw->mbox_mutex);
/* disable interrupt */
atl_disable_intr(hw);
--
2.51.0