From patchwork Fri May 15 08:56:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suanming Mou X-Patchwork-Id: 70311 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B7403A00C3; Fri, 15 May 2020 10:56:50 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EA96F1DAA4; Fri, 15 May 2020 10:56:49 +0200 (CEST) Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130]) by dpdk.org (Postfix) with ESMTP id E86F51DAA1; Fri, 15 May 2020 10:56:47 +0200 (CEST) From: Suanming Mou To: Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko Cc: dev@dpdk.org, rasland@mellanox.com, stable@dpdk.org Date: Fri, 15 May 2020 16:56:43 +0800 Message-Id: <1589533003-322710-1-git-send-email-suanmingm@mellanox.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] net/mlx5: fix counter query fail during port closing X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 Acked-by: Viacheslav Ovsiienko --- 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);