From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (xvm-189-124.dc0.ghst.net [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 41A5BA0524 for ; Fri, 8 Jan 2021 09:48:46 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 15E7C140E95; Fri, 8 Jan 2021 09:48:46 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mails.dpdk.org (Postfix) with ESMTP id 15B3D140E95 for ; Fri, 8 Jan 2021 09:48:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610095724; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=tMtow1GLVZINDCiLyeibp7ypSxPj6bRemRlxabOAsD8=; b=Hw1CtiSxfxXtq/LkeE7TfcPOwhu1lHKSpsCVZYXdFh+G2B0vK3ItW/nW79rPBp6ZNR20im B+sUCOHMRurfaPqNadL3G+Ay/D71nRPTrLvbfkY9NW7TnmPyyKHBytWDLMOVSIvdbitiGl Tq9t3YnGO95HlfXOtVxLODAlWWEhXmo= Received: from mail-vk1-f197.google.com (mail-vk1-f197.google.com [209.85.221.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-18-KBV4ez30M-ioJxwRQFP2Eg-1; Fri, 08 Jan 2021 03:48:43 -0500 X-MC-Unique: KBV4ez30M-ioJxwRQFP2Eg-1 Received: by mail-vk1-f197.google.com with SMTP id 84so5194156vkx.1 for ; Fri, 08 Jan 2021 00:48:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tMtow1GLVZINDCiLyeibp7ypSxPj6bRemRlxabOAsD8=; b=s5GTomGSy7ooNjp1licAaManwM9afqelA9i6iI9xNKnnmkvAX3BUvtGKdtcC+vP2RU G1ZlmBurSrc6SJY1hzcAdL8XIb6NMVRBH7BOLIgZhWXH/Va3KYY+L0LU5VxaVqqIyxk4 PhxxULts1dLaSQvU3Y3dV5+ffqRyPSp9/vCtIpiX2MAHKZ1TAvKZd6+HT9SU/LYlNRNc QIHI9q42V6X74g5VMnJg63K46QpBnzuqwYgdpNNjVnmCX4L5UC6w5LB5J3WZE9fdZu1p kpxXWtctyGFxOCIcaKknJ61kxYRzp2D1tOYd1uVxp4GqSjPcK/thV9iCxUrfNoYMHgXF r62w== X-Gm-Message-State: AOAM5307kYYLUCPBEgQuI/7Pct9IdZm8EOzpDHDCT9oaI8NsAE4VoWr7 zz+svhtsQAHP/VQRnD4sob7c/yKED7G3z2nE+mod5fRDnw9QYx9WALRllpzHH+gLPsgoWIyk/Uq 26Gax5NmsKAvrzlkduKZiRfU= X-Received: by 2002:a1f:9e83:: with SMTP id h125mr5072156vke.18.1610095722786; Fri, 08 Jan 2021 00:48:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6fGMKjv/WZX+4c/eyhDhkiRAx/QqRmwlEQc9Wda3ILHpgVOs7ok4zKOt3xXcpXLucoN2fb9zDOCRrQDs4xPE= X-Received: by 2002:a1f:9e83:: with SMTP id h125mr5072149vke.18.1610095722599; Fri, 08 Jan 2021 00:48:42 -0800 (PST) MIME-Version: 1.0 References: <1609915409-272126-1-git-send-email-matan@nvidia.com> <746e905a-c394-44df-2c49-2afd59c05d9f@redhat.com> In-Reply-To: <746e905a-c394-44df-2c49-2afd59c05d9f@redhat.com> From: David Marchand Date: Fri, 8 Jan 2021 09:48:31 +0100 Message-ID: To: Maxime Coquelin , Matan Azrad Cc: dev , dpdk stable Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-stable] [PATCH] vdpa/mlx5: fix configuration mutex cleanup X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" On Thu, Jan 7, 2021 at 7:09 PM Maxime Coquelin wrote: > On 1/6/21 7:43 AM, Matan Azrad wrote: > > 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 > > --- > > 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; > > } > > > > I wonder if it would be possible and cleaner to disable cancellation on > the thread while the mutex is held? +1 -- David Marchand