vdpa/mlx5: fix event channel setup
authorXueming Li <xuemingl@nvidia.com>
Tue, 25 Aug 2020 09:17:28 +0000 (09:17 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 18 Sep 2020 16:55:12 +0000 (18:55 +0200)
During vDPA device setup, if some error happens, event channel
release stucks at polling event channel.

Event channel fd is set to non-blocking 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: 8395927cdfaf ("vdpa/mlx5: prepare HW queues")
Cc: stable@dpdk.org
Signed-off-by: Xueming Li <xuemingl@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
drivers/vdpa/mlx5/mlx5_vdpa_event.c

index 5a2d4fb..bda547f 100644 (file)
@@ -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,