From patchwork Wed Jan 6 06:43:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Azrad X-Patchwork-Id: 86019 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (xvm-189-124.dc0.ghst.net [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D4F0AA09FF; Wed, 6 Jan 2021 07:43:53 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 68BE51608AA; Wed, 6 Jan 2021 07:43:53 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id 3FE6B16089F for ; Wed, 6 Jan 2021 07:43:52 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from matan@nvidia.com) with SMTP; 6 Jan 2021 08:43:50 +0200 Received: from pegasus25.mtr.labs.mlnx. (pegasus25.mtr.labs.mlnx [10.210.16.10]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 1066hoau030655; Wed, 6 Jan 2021 08:43:50 +0200 From: Matan Azrad To: dev@dpdk.org Cc: Maxime Coquelin , stable@dpdk.org Date: Wed, 6 Jan 2021 06:43:29 +0000 Message-Id: <1609915409-272126-1-git-send-email-matan@nvidia.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] vdpa/mlx5: fix configuration mutex cleanup X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" When the vDPA device is closed, the driver polling thread is canceled. The polling thread locks the configuration mutex while it polls the CQs. When the cancellation happens, it may terminate the thread inside the critical section what remains the configuration mutex locked. After device close, the driver may be configured again, in this case, for example, when the first queue state is updated, the driver tries to lock the mutex again and deadlock appears. Initialize the mutex after the polling thread cancellation. Fixes: 99abbd62c272 ("vdpa/mlx5: fix queue update synchronization") Cc: stable@dpdk.org Signed-off-by: Matan Azrad Acked-by: Xueming Li Acked-by: Maxime Coquelin --- drivers/vdpa/mlx5/mlx5_vdpa.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c index b64f364..0b2f1ab 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa.c @@ -295,6 +295,8 @@ } priv->configured = 0; priv->vid = 0; + /* The mutex may stay locked after event thread cancel - initiate it. */ + pthread_mutex_init(&priv->vq_config_lock, NULL); DRV_LOG(INFO, "vDPA device %d was closed.", vid); return ret; }