patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Suanming Mou <suanmingm@mellanox.com>
To: Matan Azrad <matan@mellanox.com>,
	Shahaf Shuler <shahafs@mellanox.com>,
	Viacheslav Ovsiienko <viacheslavo@mellanox.com>
Cc: dev@dpdk.org, rasland@mellanox.com, stable@dpdk.org
Subject: [dpdk-stable] [PATCH] net/mlx5: fix counter query fail during port closing
Date: Fri, 15 May 2020 16:56:43 +0800	[thread overview]
Message-ID: <1589533003-322710-1-git-send-email-suanmingm@mellanox.com> (raw)

Currently, the DevX counter query works asynchronously with Devx
interrupt handler return the query result. When port closes, the
interrupt handler will be uninstalled and the Devx comp obj will
also be destroyed. Meanwhile the query is still not cancelled.
In this case, counter query may use the invalid Devx comp which
has been destroyed, and query failure with invalid FD will be
reported.

Move the query alarm cancel before Devx interrupt uninstall to
avoid query failure with invalid FD issue.

Fixes: f15db67df09c ("net/mlx5: accelerate DV flow counter query")
Cc: stable@dpdk.org

Signed-off-by: Suanming Mou <suanmingm@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
---
Please apply the patch after the patch below:
https://patches.dpdk.org/patch/70310/
---
 drivers/net/mlx5/mlx5.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index be16841..579da76 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -506,15 +506,7 @@ struct mlx5_flow_id_pool *
 	struct mlx5_counter_stats_mem_mng *mng;
 	int i;
 	int j;
-	int retries = 1024;
 
-	rte_errno = 0;
-	while (--retries) {
-		rte_eal_alarm_cancel(mlx5_flow_query_alarm, sh);
-		if (rte_errno != EINPROGRESS)
-			break;
-		rte_pause();
-	}
 	for (i = 0; i < MLX5_CCONT_TYPE_MAX; ++i) {
 		struct mlx5_flow_counter_pool *pool;
 		uint32_t batch = !!(i > 1);
@@ -1427,6 +1419,23 @@ struct mlx5_flow_id_pool *
 		dev->data->port_id,
 		((priv->sh && priv->sh->ctx) ?
 		priv->sh->ctx->device->name : ""));
+	/*
+	 * The devx->comp is going to be destroyed in
+	 * mlx5_dev_interrupt_handler_devx_uninstall(), stop the asynchronous
+	 * counter query in advanced in case the devx->comp destroyed during
+	 * query causes invalid fd used.
+	 */
+	if (priv->sh) {
+		int retries = 1024;
+
+		rte_errno = 0;
+		while (--retries) {
+			rte_eal_alarm_cancel(mlx5_flow_query_alarm, priv->sh);
+			if (rte_errno != EINPROGRESS)
+				break;
+			rte_pause();
+		}
+	}
 	/* In case mlx5_dev_stop() has not been called. */
 	mlx5_dev_interrupt_handler_uninstall(dev);
 	mlx5_dev_interrupt_handler_devx_uninstall(dev);
-- 
1.8.3.1


             reply	other threads:[~2020-05-15  8:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-15  8:56 Suanming Mou [this message]
2020-05-28  9:22 ` [dpdk-stable] [PATCH v2] net/mlx5: fix interrupt installation timing Suanming Mou
2020-05-31 14:04   ` Raslan Darawsheh

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=1589533003-322710-1-git-send-email-suanmingm@mellanox.com \
    --to=suanmingm@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=matan@mellanox.com \
    --cc=rasland@mellanox.com \
    --cc=shahafs@mellanox.com \
    --cc=stable@dpdk.org \
    --cc=viacheslavo@mellanox.com \
    /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).