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 2E18FA0524 for ; Thu, 7 Jan 2021 19:09:19 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 24697140DA1; Thu, 7 Jan 2021 19:09:19 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id DE2A8140DA1 for ; Thu, 7 Jan 2021 19:09:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610042957; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eoiy6WCpiGWrt0ra6NRe32XcXmTGYNCaD5RvwiznqkU=; b=HyyYH+KhO4VqRIJe/QN9XE0SbCKpVqfTUKWIpgj+bhVXwmfPOhyuypVX5HwKPDhc5ZWY1O ycF4WXw0NZGyZmKJIvbL02wYdpVN6eid4eYEiZBmXzKh2GasuyvdYrQIU+2qgTt84cRoQK YsVB2Qbax0zsex4N0NA6HjHASR2MQ58= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-57-QlVJDi72NPqgDl1MD7J4Yw-1; Thu, 07 Jan 2021 13:09:13 -0500 X-MC-Unique: QlVJDi72NPqgDl1MD7J4Yw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 138DF190B2A0; Thu, 7 Jan 2021 18:09:12 +0000 (UTC) Received: from [10.36.110.9] (unknown [10.36.110.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2294110013BD; Thu, 7 Jan 2021 18:09:10 +0000 (UTC) To: Matan Azrad , dev@dpdk.org Cc: stable@dpdk.org References: <1609915409-272126-1-git-send-email-matan@nvidia.com> From: Maxime Coquelin Message-ID: <746e905a-c394-44df-2c49-2afd59c05d9f@redhat.com> Date: Thu, 7 Jan 2021 19:09:09 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <1609915409-272126-1-git-send-email-matan@nvidia.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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 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? Regards, Maxime