From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id C2D5AA04AC;
	Mon, 24 Aug 2020 09:34:28 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id F4023100C;
	Mon, 24 Aug 2020 09:34:27 +0200 (CEST)
Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130])
 by dpdk.org (Postfix) with ESMTP id 67BBB1C0B4
 for <dev@dpdk.org>; Thu, 20 Aug 2020 15:15:27 +0200 (CEST)
From: Xueming Li <xuemingl@mellanox.com>
To: Matan Azrad <matan@nvidia.com>,
 Viacheslav Ovsiienko <viacheslavo@nvidia.com>
Cc: dev@dpdk.org, Asaf Penso <asafp@nvidia.com>,
 Xueming Li <xuemingl@nvidia.com>
Date: Thu, 20 Aug 2020 13:15:08 +0000
Message-Id: <1597929308-26025-1-git-send-email-xuemingl@mellanox.com>
X-Mailer: git-send-email 1.8.3.1
X-Mailman-Approved-At: Mon, 24 Aug 2020 09:34:27 +0200
Subject: [dpdk-dev] [PATCH] vdpa/mlx5: fix event channel setup
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

During vdap device setup, if some error happens, event channel release
stuck at polling event channel.

Event channel fd is set to nonblocking in cqe setup, so if any error
happens before this function and after event channel created, the
pooling before releasing resources will stuck.

This patch moves event channel to non-blocking mode right after
creation.

Fixes: 8395927cdf ("vdpa/mlx5: prepare HW queues")
Cc: matan@nvidia.com

Signed-off-by: Xueming Li <xuemingl@nvidia.com>
---
 drivers/vdpa/mlx5/mlx5_vdpa_event.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_event.c b/drivers/vdpa/mlx5/mlx5_vdpa_event.c
index 5a2d4fb1ec..bda547ffe0 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa_event.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa_event.c
@@ -51,6 +51,8 @@ mlx5_vdpa_event_qp_global_release(struct mlx5_vdpa_priv *priv)
 static int
 mlx5_vdpa_event_qp_global_prepare(struct mlx5_vdpa_priv *priv)
 {
+	int flags, ret;
+
 	if (priv->eventc)
 		return 0;
 	if (mlx5_glue->devx_query_eqn(priv->ctx, 0, &priv->eqn)) {
@@ -66,6 +68,12 @@ mlx5_vdpa_event_qp_global_prepare(struct mlx5_vdpa_priv *priv)
 			rte_errno);
 		goto error;
 	}
+	flags = fcntl(priv->eventc->fd, F_GETFL);
+	ret = fcntl(priv->eventc->fd, F_SETFL, flags | O_NONBLOCK);
+	if (ret) {
+		DRV_LOG(ERR, "Failed to change event channel FD.");
+		goto error;
+	}
 	priv->uar = mlx5_glue->devx_alloc_uar(priv->ctx, 0);
 	if (!priv->uar) {
 		rte_errno = errno;
@@ -376,7 +384,6 @@ mlx5_vdpa_interrupt_handler(void *cb_arg)
 int
 mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv)
 {
-	int flags;
 	int ret;
 
 	if (!priv->eventc)
@@ -393,12 +400,6 @@ mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv)
 			return -1;
 		}
 	}
-	flags = fcntl(priv->eventc->fd, F_GETFL);
-	ret = fcntl(priv->eventc->fd, F_SETFL, flags | O_NONBLOCK);
-	if (ret) {
-		DRV_LOG(ERR, "Failed to change event channel FD.");
-		goto error;
-	}
 	priv->intr_handle.fd = priv->eventc->fd;
 	priv->intr_handle.type = RTE_INTR_HANDLE_EXT;
 	if (rte_intr_callback_register(&priv->intr_handle,
-- 
2.17.1