patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH 18.11] net/mlx5: fix secondary process resources release
@ 2020-12-07  4:29 Suanming Mou
  2020-12-08 10:50 ` Kevin Traynor
  0 siblings, 1 reply; 2+ messages in thread
From: Suanming Mou @ 2020-12-07  4:29 UTC (permalink / raw)
  To: viacheslavo, matan; +Cc: stable, Suanming Mou

From: Suanming Mou <suanmingm@mellanox.com>

[ upstream commit 2786b7bf9084b32dde9a346d92ab1c27f0ffc476 ]

When secondary process starts, it will allocate its own process private
data, and also does remap to UAR register of the Tx queue. Once the
secondary process exits, these resources should be released accordingly.
And the shared resources owned by primary should not be touched.

Currently, once one port in the secondary process spawn failed, all the
other spawned ports will also be released during process exits. However,
the mlx5_dev_close() function does not add the cases for secondary
process, it means call the mlx5_dev_close() function directly in
secondary process releases the resources it should not touch.

Add the case for secondary process release to its own resources in
mlx5_dev_close() function to help it quits gracefully.

Fixes: 3a8207423a0f ("net/mlx5: close all ports on remove")

Signed-off-by: Suanming Mou <suanmingm@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/mlx5.c      | 34 ++++++++++++++++++++++++++++------
 drivers/net/mlx5/mlx5_rxtx.h |  1 +
 drivers/net/mlx5/mlx5_txq.c  | 24 ++++++++++++++++++++++++
 3 files changed, 53 insertions(+), 6 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 01fff19..f3503eb 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -304,6 +304,15 @@
 	unsigned int i;
 	int ret;
 
+	if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+		/* Check if process_private released. */
+		if (!dev->process_private)
+			return;
+		mlx5_tx_uar_uninit_secondary(dev);
+		mlx5_proc_priv_uninit(dev);
+		rte_eth_dev_release_port(dev);
+		return;
+	}
 	DRV_LOG(DEBUG, "port %u closing device \"%s\"",
 		dev->data->port_id,
 		((priv->ctx != NULL) ? priv->ctx->device->name : ""));
@@ -849,26 +858,26 @@
 			DRV_LOG(ERR, "can not attach rte ethdev");
 			rte_errno = ENOMEM;
 			err = rte_errno;
-			goto error;
+			goto err_secondary;
 		}
 		eth_dev->device = dpdk_dev;
 		eth_dev->dev_ops = &mlx5_dev_sec_ops;
 		err = mlx5_proc_priv_init(eth_dev);
 		if (err) {
 			err = rte_errno;
-			goto error;
+			goto err_secondary;
 		}
 		/* Receive command fd from primary process */
 		err = mlx5_socket_connect(eth_dev);
 		if (err < 0) {
 			err = rte_errno;
-			goto error;
+			goto err_secondary;
 		}
 		/* Remap UAR for Tx queues. */
 		err = mlx5_tx_uar_init_secondary(eth_dev, err);
 		if (err) {
 			err = rte_errno;
-			goto error;
+			goto err_secondary;
 		}
 		/*
 		 * Ethdev pointer is still required as input since
@@ -879,6 +888,10 @@
 		eth_dev->tx_pkt_burst = mlx5_select_tx_function(eth_dev);
 		claim_zero(mlx5_glue->close_device(ctx));
 		return eth_dev;
+err_secondary:
+		if (eth_dev)
+			mlx5_dev_close(eth_dev);
+		return NULL;
 	}
 	/* Check port status. */
 	err = mlx5_glue->query_port(ctx, 1, &port_attr);
@@ -1499,8 +1512,17 @@ struct mlx5_dev_spawn_data {
 	for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++) {
 		port = &rte_eth_devices[port_id];
 		if (port->state != RTE_ETH_DEV_UNUSED &&
-				port->device == &pci_dev->device)
-			rte_eth_dev_close(port_id);
+				port->device == &pci_dev->device) {
+			/*
+			 * mlx5_dev_close() is not registered to secondary
+			 * process, call the close function explicitly for
+			 * secondary process.
+			 */
+			if (rte_eal_process_type() == RTE_PROC_SECONDARY)
+				mlx5_dev_close(&rte_eth_devices[port_id]);
+			else
+				rte_eth_dev_close(port_id);
+		}
 	}
 	return 0;
 }
diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h
index dc2ca5e..583985b 100644
--- a/drivers/net/mlx5/mlx5_rxtx.h
+++ b/drivers/net/mlx5/mlx5_rxtx.h
@@ -311,6 +311,7 @@ int mlx5_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
 int mlx5_txq_ibv_release(struct mlx5_txq_ibv *txq_ibv);
 int mlx5_txq_ibv_releasable(struct mlx5_txq_ibv *txq_ibv);
 int mlx5_txq_ibv_verify(struct rte_eth_dev *dev);
+void mlx5_tx_uar_uninit_secondary(struct rte_eth_dev *dev);
 struct mlx5_txq_ctrl *mlx5_txq_new(struct rte_eth_dev *dev, uint16_t idx,
 				   uint16_t desc, unsigned int socket,
 				   const struct rte_eth_txconf *conf);
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index 42ab34a..ea1e86d 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -321,6 +321,30 @@
 }
 
 /**
+ * Deinitialize Tx UAR registers for secondary process.
+ *
+ * @param dev
+ *   Pointer to Ethernet device.
+ */
+void
+mlx5_tx_uar_uninit_secondary(struct rte_eth_dev *dev)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	struct mlx5_txq_data *txq;
+	struct mlx5_txq_ctrl *txq_ctrl;
+	unsigned int i;
+
+	assert(rte_eal_process_type() == RTE_PROC_SECONDARY);
+	for (i = 0; i != priv->txqs_n; ++i) {
+		if (!(*priv->txqs)[i])
+			continue;
+		txq = (*priv->txqs)[i];
+		txq_ctrl = container_of(txq, struct mlx5_txq_ctrl, txq);
+		txq_uar_uninit_secondary(txq_ctrl);
+	}
+}
+
+/**
  * Initialize Tx UAR registers for secondary process.
  *
  * @param dev
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-stable] [PATCH 18.11] net/mlx5: fix secondary process resources release
  2020-12-07  4:29 [dpdk-stable] [PATCH 18.11] net/mlx5: fix secondary process resources release Suanming Mou
@ 2020-12-08 10:50 ` Kevin Traynor
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Traynor @ 2020-12-08 10:50 UTC (permalink / raw)
  To: Suanming Mou, viacheslavo, matan; +Cc: stable, Suanming Mou

On 07/12/2020 04:29, Suanming Mou wrote:
> From: Suanming Mou <suanmingm@mellanox.com>
> 
> [ upstream commit 2786b7bf9084b32dde9a346d92ab1c27f0ffc476 ]
> 
> When secondary process starts, it will allocate its own process private
> data, and also does remap to UAR register of the Tx queue. Once the
> secondary process exits, these resources should be released accordingly.
> And the shared resources owned by primary should not be touched.
> 
> Currently, once one port in the secondary process spawn failed, all the
> other spawned ports will also be released during process exits. However,
> the mlx5_dev_close() function does not add the cases for secondary
> process, it means call the mlx5_dev_close() function directly in
> secondary process releases the resources it should not touch.
> 
> Add the case for secondary process release to its own resources in
> mlx5_dev_close() function to help it quits gracefully.
> 
> Fixes: 3a8207423a0f ("net/mlx5: close all ports on remove")
> 
> Signed-off-by: Suanming Mou <suanmingm@mellanox.com>
> Acked-by: Matan Azrad <matan@mellanox.com>
> ---
>  drivers/net/mlx5/mlx5.c      | 34 ++++++++++++++++++++++++++++------
>  drivers/net/mlx5/mlx5_rxtx.h |  1 +
>  drivers/net/mlx5/mlx5_txq.c  | 24 ++++++++++++++++++++++++
>  3 files changed, 53 insertions(+), 6 deletions(-)

Applied, thanks.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-08 10:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-07  4:29 [dpdk-stable] [PATCH 18.11] net/mlx5: fix secondary process resources release Suanming Mou
2020-12-08 10:50 ` Kevin Traynor

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).