DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ariel Otilibili <otilibil@eurecom.fr>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	Thomas Monjalon <thomas@monjalon.net>,
	David Marchand <david.marchand@redhat.com>,
	Ariel Otilibili <otilibil@eurecom.fr>,
	Ajit Khaparde <ajit.khaparde@broadcom.com>,
	Somnath Kotur <somnath.kotur@broadcom.com>
Subject: [PATCH v4 2/6] net/bnxt: remove check around pthread_mutex_init()
Date: Tue, 14 Jan 2025 08:50:29 +0100	[thread overview]
Message-ID: <20250114075033.2027286-3-otilibil@eurecom.fr> (raw)
In-Reply-To: <20250114075033.2027286-1-otilibil@eurecom.fr>

> pthread_mutex_init always returns 0. The other mutex functions
> return 0 on success and a non-zero error code on error.

Link: https://man7.org/linux/man-pages/man3/pthread_mutex_lock.3.html
Bugzilla ID: 1586
Cc: Ajit Khaparde <ajit.khaparde@broadcom.com>
Cc: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Ariel Otilibili <otilibil@eurecom.fr>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/bnxt/bnxt_ethdev.c         | 40 +++++---------------------
 drivers/net/bnxt/bnxt_txq.c            |  7 +----
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c     |  8 +-----
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c  |  6 +---
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c |  6 +---
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c   |  6 +---
 drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c   |  6 +---
 7 files changed, 13 insertions(+), 66 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index ef8a928c9170..21e9aa902c68 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -5821,31 +5821,12 @@ static int bnxt_get_config(struct bnxt *bp)
 static int
 bnxt_init_locks(struct bnxt *bp)
 {
-	int err;
+	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);
 
-	err = pthread_mutex_init(&bp->flow_lock, NULL);
-	if (err) {
-		PMD_DRV_LOG_LINE(ERR, "Unable to initialize flow_lock");
-		return err;
-	}
-
-	err = pthread_mutex_init(&bp->def_cp_lock, NULL);
-	if (err) {
-		PMD_DRV_LOG_LINE(ERR, "Unable to initialize def_cp_lock");
-		return err;
-	}
-
-	err = pthread_mutex_init(&bp->health_check_lock, NULL);
-	if (err) {
-		PMD_DRV_LOG_LINE(ERR, "Unable to initialize health_check_lock");
-		return err;
-	}
-
-	err = pthread_mutex_init(&bp->err_recovery_lock, NULL);
-	if (err)
-		PMD_DRV_LOG_LINE(ERR, "Unable to initialize err_recovery_lock");
-
-	return err;
+	return 0;
 }
 
 /* This should be called after we have queried trusted VF cap */
@@ -6746,7 +6727,7 @@ static void bnxt_free_rep_info(struct bnxt *bp)
 
 static int bnxt_init_rep_info(struct bnxt *bp)
 {
-	int i = 0, rc;
+	int i = 0;
 
 	if (bp->rep_info)
 		return 0;
@@ -6770,14 +6751,7 @@ 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;
 
-	rc = pthread_mutex_init(&bp->rep_info->vfr_start_lock, NULL);
-	if (rc) {
-		PMD_DRV_LOG_LINE(ERR, "Unable to initialize vfr_start_lock");
-		bnxt_free_rep_info(bp);
-		return rc;
-	}
-
-	return rc;
+	return pthread_mutex_init(&bp->rep_info->vfr_start_lock, NULL);
 }
 
 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 c8649359923f..3938ebc7091d 100644
--- a/drivers/net/bnxt/bnxt_txq.c
+++ b/drivers/net/bnxt/bnxt_txq.c
@@ -198,12 +198,7 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev,
 		goto err;
 	}
 
-	rc = pthread_mutex_init(&txq->txq_lock, NULL);
-	if (rc != 0) {
-		PMD_DRV_LOG_LINE(ERR, "TxQ mutex init failed!");
-		goto err;
-	}
-	return 0;
+	return pthread_mutex_init(&txq->txq_lock, NULL);
 err:
 	bnxt_tx_queue_release_op(eth_dev, queue_idx);
 	return rc;
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
index 1bfc88cf79ef..0c03ae7a8349 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
@@ -188,7 +188,6 @@ ulp_session_init(struct bnxt *bp,
 	struct rte_pci_device		*pci_dev;
 	struct rte_pci_addr		*pci_addr;
 	struct bnxt_ulp_session_state	*session;
-	int rc = 0;
 
 	if (!bp)
 		return NULL;
@@ -215,12 +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));
-			rc = pthread_mutex_init(&session->bnxt_ulp_mutex, NULL);
-			if (rc) {
-				BNXT_DRV_DBG(ERR, "mutex create failed\n");
-				pthread_mutex_unlock(&bnxt_ulp_global_mutex);
-				return NULL;
-			}
+			pthread_mutex_init(&session->bnxt_ulp_mutex, NULL);
 			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 fa7e8fe00077..4a1ccfa2a36d 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c
@@ -1472,11 +1472,7 @@ ulp_tf_init(struct bnxt *bp,
 		goto jump_to_error;
 	}
 
-	rc = pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
-	if (rc) {
-		BNXT_DRV_DBG(ERR, "Unable to initialize flow db lock\n");
-		goto jump_to_error;
-	}
+	pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
 
 	/* 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 6d7ec0ffec79..508c194d0490 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c
@@ -993,11 +993,7 @@ ulp_tfc_init(struct bnxt *bp,
 		goto jump_to_error;
 	}
 
-	rc = pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
-	if (rc) {
-		BNXT_DRV_DBG(ERR, "Unable to initialize flow db lock\n");
-		goto jump_to_error;
-	}
+	pthread_mutex_init(&bp->ulp_ctx->cfg_data->flow_db_lock, NULL);
 
 	rc = ulp_tfc_dparms_init(bp, bp->ulp_ctx, ulp_dev_id);
 	if (rc) {
diff --git a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
index 67489b76f390..f9d069f4e17e 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
@@ -129,11 +129,7 @@ ulp_fc_mgr_init(struct bnxt_ulp_context *ctxt)
 	ulp_fc_info->fc_ops = fc_ops;
 	ulp_fc_info->flags = flags;
 
-	rc = pthread_mutex_init(&ulp_fc_info->fc_lock, NULL);
-	if (rc) {
-		BNXT_DRV_DBG(ERR, "Failed to initialize fc mutex\n");
-		goto error;
-	}
+	pthread_mutex_init(&ulp_fc_info->fc_lock, NULL);
 
 	/* Add the FC info tbl to the ulp context. */
 	bnxt_ulp_cntxt_ptr2_fc_info_set(ctxt, ulp_fc_info);
diff --git a/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c
index 3c75a6b43721..7b7c10d3602e 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c
@@ -412,11 +412,7 @@ ulp_ha_mgr_init(struct bnxt_ulp_context *ulp_ctx)
 	/* Add the HA info tbl to the ulp context. */
 	bnxt_ulp_cntxt_ptr2_ha_info_set(ulp_ctx, ha_info);
 
-	rc = pthread_mutex_init(&ha_info->ha_lock, NULL);
-	if (rc) {
-		PMD_DRV_LOG_LINE(ERR, "Failed to initialize ha mutex");
-		goto cleanup;
-	}
+	pthread_mutex_init(&ha_info->ha_lock, NULL);
 	rc = ulp_ha_mgr_timer_start(ulp_ctx->cfg_data);
 	if (rc) {
 		PMD_DRV_LOG_LINE(ERR, "Unable to start timer CB");
-- 
2.30.2


  parent reply	other threads:[~2025-01-14  7:50 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-12 18:58 [PATCH 0/6] " Ariel Otilibili
2025-01-12 18:58 ` [PATCH 1/6] raw/ifpga: " Ariel Otilibili
2025-01-12 18:58 ` [PATCH 2/6] net/bnxt: " Ariel Otilibili
2025-01-12 18:58 ` [PATCH 3/6] common/cnxk: " Ariel Otilibili
2025-01-12 18:58 ` [PATCH 4/6] net/failsafe: " Ariel Otilibili
2025-01-12 18:58 ` [PATCH 5/6] net/hinic: " Ariel Otilibili
2025-01-12 18:58 ` [PATCH 6/6] lib/vhost: " Ariel Otilibili
2025-01-12 19:30 ` [PATCH v2 0/6] " Ariel Otilibili
2025-01-12 19:30   ` [PATCH v2 1/6] raw/ifpga: " Ariel Otilibili
2025-01-12 19:30   ` [PATCH v2 2/6] net/bnxt: " Ariel Otilibili
2025-01-12 19:30   ` [PATCH v2 3/6] common/cnxk: " Ariel Otilibili
2025-01-12 19:30   ` [PATCH v2 4/6] net/failsafe: " Ariel Otilibili
2025-01-12 19:30   ` [PATCH v2 5/6] net/hinic: " Ariel Otilibili
2025-01-12 19:30   ` [PATCH v2 6/6] lib/vhost: " Ariel Otilibili
2025-01-12 20:20 ` [PATCH v3 0/6] " Ariel Otilibili
2025-01-12 20:20   ` [PATCH v3 1/6] raw/ifpga: " Ariel Otilibili
2025-01-12 20:20   ` [PATCH v3 2/6] net/bnxt: " Ariel Otilibili
2025-01-12 20:20   ` [PATCH v3 3/6] common/cnxk: " Ariel Otilibili
2025-01-12 20:20   ` [PATCH v3 4/6] net/failsafe: " Ariel Otilibili
2025-01-13 19:10     ` Stephen Hemminger
2025-01-12 20:20   ` [PATCH v3 5/6] net/hinic: " Ariel Otilibili
2025-01-13 19:09     ` Stephen Hemminger
2025-01-12 20:20   ` [PATCH v3 6/6] lib/vhost: " Ariel Otilibili
2025-01-13 19:11   ` [PATCH v3 0/6] " Stephen Hemminger
2025-01-14  8:22     ` Ariel Otilibili-Anieli
2025-01-13 17:19 ` [PATCH 0/1] eal/linux: Remove unused values Ariel Otilibili
2025-01-13 17:19   ` [PATCH 1/1] " Ariel Otilibili
2025-01-14  7:50 ` [PATCH v4 0/6] remove check around pthread_mutex_init() Ariel Otilibili
2025-01-14  7:50   ` [PATCH v4 1/6] raw/ifpga: " Ariel Otilibili
2025-01-14  7:50   ` Ariel Otilibili [this message]
2025-01-14  7:50   ` [PATCH v4 3/6] common/cnxk: " Ariel Otilibili
2025-01-14  7:50   ` [PATCH v4 4/6] net/failsafe: " Ariel Otilibili
2025-01-14  7:50   ` [PATCH v4 5/6] net/hinic: " Ariel Otilibili
2025-01-14  7:50   ` [PATCH v4 6/6] lib/vhost: " Ariel Otilibili
2025-01-14  8:48     ` Maxime Coquelin
2025-01-14 11:03       ` Ariel Otilibili-Anieli

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=20250114075033.2027286-3-otilibil@eurecom.fr \
    --to=otilibil@eurecom.fr \
    --cc=ajit.khaparde@broadcom.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=somnath.kotur@broadcom.com \
    --cc=stephen@networkplumber.org \
    --cc=thomas@monjalon.net \
    /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;
as well as URLs for NNTP newsgroup(s).