Skip to contentSkip to conversation

vdpa/mlx5: fix event channel setup

PATCH New Xueming Li 3 participants 6 messages Aug 20, 2020 – Sep 18, 2020

Subsystems (2)
lore
Share & tools
lore

Xueming Li

author
#0 lore raw

PATCH 1/1 vdpa/mlx5: fix event channel setup

From: Xueming Li <[email protected]>

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")
---
 drivers/vdpa/mlx5/mlx5_vdpa_event.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/vdpa/mlx5/mlx5_vdpa_event.c +8 -7
index 5a2d4fb1ec..bda547ffe0 100644
@@ -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,
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/1 vdpa/mlx5: fix event channel setup

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")
---
 drivers/vdpa/mlx5/mlx5_vdpa_event.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/vdpa/mlx5/mlx5_vdpa_event.c +8 -7
index 5a2d4fb1ec..bda547ffe0 100644
@@ -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,
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#2 lore raw

From: Xueming Li <[email protected]>

Quoted 7 lines

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.

Quoted 6 lines

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

Fixes 8395927cdf ("vdpa/mlx5: prepare HW queues")
Reviewed-by on v1 1/1
#3 lore raw
In reply to Xueming Li
Quoted 1 line · Xueming Li

During vdap device setup, if some error happens, event channel release

s/vdap/vDPA/

Quoted 3 lines

stuck at polling event channel.

Event channel fd is set to nonblocking in cqe setup, so if any error

non-blocking

Quoted 52 lines

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")
---
 drivers/vdpa/mlx5/mlx5_vdpa_event.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/vdpa/mlx5/mlx5_vdpa_event.c +8 -1
index 5a2d4fb1ec..bda547ffe0 100644
@@ -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;
 		}

drivers/vdpa/mlx5/mlx5_vdpa_event.c mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv) · line 405

Quoted 10 lines
drivers/vdpa/mlx5/mlx5_vdpa_event.c +0 -6
 	}
-	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,

Looks good to me, I'll fix the typos while applying.

Thanks,
Maxime

#4 lore raw
Quoted 72 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Friday, September 18, 2020 5:42 PM
To: Xueming(Steven) Li <[email protected]>; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>
Cc: [email protected]; Asaf Penso <[email protected]>
Subject: Re: [dpdk-dev] [v1] vdpa/mlx5: fix event channel setup

Quoted 1 line · Xueming Li

During vdap device setup, if some error happens, event channel release

s/vdap/vDPA/

Quoted 3 lines

stuck at polling event channel.

Event channel fd is set to nonblocking in cqe setup, so if any error

non-blocking

Quoted 22 lines

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")
---
 drivers/vdpa/mlx5/mlx5_vdpa_event.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/vdpa/mlx5/mlx5_vdpa_event.c +0 -0
index 5a2d4fb1ec..bda547ffe0 100644
@@ -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) {

drivers/vdpa/mlx5/mlx5_vdpa_event.c mlx5_vdpa_event_qp_global_release(struct mlx5_vdpa_priv *priv)

Quoted 6 lines
drivers/vdpa/mlx5/mlx5_vdpa_event.c +3 -0
+	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)

drivers/vdpa/mlx5/mlx5_vdpa_event.c mlx5_vdpa_cqe_event_setup(struct

Quoted 19 lines
drivers/vdpa/mlx5/mlx5_vdpa_event.c +6 -1
 			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)

Quoted 16 lines

drivers/vdpa/mlx5/mlx5_vdpa_event.c mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv) · line 405

Quoted 13 lines
drivers/vdpa/mlx5/mlx5_vdpa_event.c +0 -6
 			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,

Looks good to me, I'll fix the typos while applying.

Appreciate!

Quoted 4 lines

Thanks,
Maxime

#5 lore raw
In reply to Xueming Li
Quoted 10 lines · Xueming Li

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.

Quoted 7 lines
Fixes 8395927cdf ("vdpa/mlx5: prepare HW queues")
---
 drivers/vdpa/mlx5/mlx5_vdpa_event.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

Applied to dpdk-next-virtio/master.

Thanks,
Maxime