DPDK patches and discussions
 help / color / mirror / Atom feed
From: Harman Kalra <hkalra@marvell.com>
To: <dev@dpdk.org>, Harman Kalra <hkalra@marvell.com>
Subject: [PATCH v2 02/11] net/octeontx: fix port close
Date: Mon, 23 May 2022 21:40:51 +0530	[thread overview]
Message-ID: <20220523161100.86280-2-hkalra@marvell.com> (raw)
In-Reply-To: <20220523161100.86280-1-hkalra@marvell.com>

Segmentation fault has been observed while closing the ethernet
port. Reason for the segfault is, eth port close also shuts down
event device while other ethernet port is still using the event
device.

Fixes: da6c687471a3 ("net/octeontx: add start and stop support")

Signed-off-by: Harman Kalra <hkalra@marvell.com>
---
 drivers/net/octeontx/octeontx_ethdev.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
index f5ea9de8ef..6469fd0a96 100644
--- a/drivers/net/octeontx/octeontx_ethdev.c
+++ b/drivers/net/octeontx/octeontx_ethdev.c
@@ -26,6 +26,11 @@
 #include "octeontx_rxtx.h"
 #include "octeontx_logs.h"
 
+/* Useful in stopping/closing event device if no of
+ * eth ports are using it.
+ */
+uint16_t evdev_refcnt;
+
 struct evdev_priv_data {
 	OFFLOAD_FLAGS; /*Sequence should not be changed */
 } __rte_cache_aligned;
@@ -491,7 +496,11 @@ octeontx_dev_close(struct rte_eth_dev *dev)
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
-	rte_event_dev_close(nic->evdev);
+	/* Stopping/closing event device once all eth ports are closed. */
+	if (__atomic_sub_fetch(&evdev_refcnt, 1, __ATOMIC_ACQUIRE) == 0) {
+		rte_event_dev_stop(nic->evdev);
+		rte_event_dev_close(nic->evdev);
+	}
 
 	octeontx_dev_flow_ctrl_fini(dev);
 
@@ -671,8 +680,6 @@ octeontx_dev_stop(struct rte_eth_dev *dev)
 
 	PMD_INIT_FUNC_TRACE();
 
-	rte_event_dev_stop(nic->evdev);
-
 	ret = octeontx_port_stop(nic);
 	if (ret < 0) {
 		octeontx_log_err("failed to req stop port %d res=%d",
@@ -1333,6 +1340,7 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
 	nic->pko_vfid = pko_vfid;
 	nic->port_id = port;
 	nic->evdev = evdev;
+	__atomic_add_fetch(&evdev_refcnt, 1, __ATOMIC_ACQUIRE);
 
 	res = octeontx_port_open(nic);
 	if (res < 0)
@@ -1582,6 +1590,7 @@ octeontx_probe(struct rte_vdev_device *dev)
 		}
 	}
 
+	__atomic_store_n(&evdev_refcnt, 0, __ATOMIC_RELEASE);
 	/*
 	 * Do 1:1 links for ports & queues. All queues would be mapped to
 	 * one port. If there are more ports than queues, then some ports
-- 
2.18.0


  reply	other threads:[~2022-05-23 16:11 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-17 17:39 [PATCH 01/12] config: add thundert83 config Harman Kalra
2022-05-17 17:39 ` [PATCH 02/12] event/octeontx: fix SSO fastpath Harman Kalra
2022-05-23 16:10   ` [PATCH v2 01/11] " Harman Kalra
2022-05-23 16:10     ` Harman Kalra [this message]
2022-05-23 16:10     ` [PATCH v2 03/11] net/octeontx: setting link attributes Harman Kalra
2022-05-23 16:10     ` [PATCH v2 04/11] net/octeontx: handle port reconfiguration Harman Kalra
2022-05-23 16:10     ` [PATCH v2 05/11] net/thunderx: implement polling of link state change Harman Kalra
2022-05-23 16:10     ` [PATCH v2 06/11] net/thunderx: reset Rx DMAC control register Harman Kalra
2022-05-23 16:10     ` [PATCH v2 07/11] net/thunderx: setting link attributes Harman Kalra
2022-05-23 16:10     ` [PATCH v2 08/11] net/octeontx: implement xstats Harman Kalra
2022-05-23 16:10     ` [PATCH v2 09/11] net/octeontx: support allmulticast Harman Kalra
2022-05-23 16:10     ` [PATCH v2 10/11] net/thunderx: device attach from secondary Harman Kalra
2022-05-23 16:11     ` [PATCH v2 11/11] net/thunderx: populate max and min MTU values Harman Kalra
2022-05-24  8:42   ` [PATCH v3 01/11] event/octeontx: fix SSO fastpath Harman Kalra
2022-05-24  8:42     ` [PATCH v3 02/11] net/octeontx: fix port close Harman Kalra
2022-05-24  8:42     ` [PATCH v3 03/11] net/octeontx: setting link attributes Harman Kalra
2022-05-24  8:42     ` [PATCH v3 04/11] net/octeontx: handle port reconfiguration Harman Kalra
2022-05-24  8:42     ` [PATCH v3 05/11] net/thunderx: implement polling of link state change Harman Kalra
2022-05-24  8:42     ` [PATCH v3 06/11] net/thunderx: reset Rx DMAC control register Harman Kalra
2022-05-24  8:42     ` [PATCH v3 07/11] net/thunderx: setting link attributes Harman Kalra
2022-05-24  8:42     ` [PATCH v3 08/11] net/octeontx: implement xstats Harman Kalra
2022-06-09 16:13       ` Jerin Jacob
2022-05-24  8:42     ` [PATCH v3 09/11] net/octeontx: support allmulticast Harman Kalra
2022-05-24  8:42     ` [PATCH v3 10/11] net/thunderx: device attach from secondary Harman Kalra
2022-05-24  8:42     ` [PATCH v3 11/11] net/thunderx: populate max and min MTU values Harman Kalra
2022-06-09 15:55       ` Jerin Jacob
2022-06-09 15:53     ` [PATCH v3 01/11] event/octeontx: fix SSO fastpath Jerin Jacob
2022-05-17 17:39 ` [PATCH 03/12] net/octeontx: fix port close Harman Kalra
2022-05-17 17:39 ` [PATCH 04/12] net/octeontx: setting link attributes Harman Kalra
2022-05-17 17:39 ` [PATCH 05/12] net/octeontx: handle port reconfiguration Harman Kalra
2022-05-17 17:39 ` [PATCH 06/12] net/thunderx: implement polling of link state change Harman Kalra
2022-05-17 17:39 ` [PATCH 07/12] net/thunderx: reset Rx DMAC control register Harman Kalra
2022-05-17 17:39 ` [PATCH 08/12] net/thunderx: setting link attributes Harman Kalra
2022-05-17 17:39 ` [PATCH 09/12] net/octeontx: implement xstats Harman Kalra
2022-05-17 17:39 ` [PATCH 10/12] net/octeontx: support allmulticast Harman Kalra
2022-05-17 17:39 ` [PATCH 11/12] net/thunderx: device attach from secondary Harman Kalra
2022-05-17 17:39 ` [PATCH 12/12] net/thunderx: populate max and min MTU values Harman Kalra
2022-05-18  6:10 ` [PATCH 01/12] config: add thundert83 config Ruifeng Wang
2022-05-23 13:34 ` [PATCH v2] config: add thunderX t83 config Harman Kalra
2022-06-01 22:02   ` Thomas Monjalon

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=20220523161100.86280-2-hkalra@marvell.com \
    --to=hkalra@marvell.com \
    --cc=dev@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;
as well as URLs for NNTP newsgroup(s).