From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 499A141D3E; Thu, 2 Mar 2023 11:42:13 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 361A140E2D; Thu, 2 Mar 2023 11:42:13 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id B4E1640E09 for ; Thu, 2 Mar 2023 11:42:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677753731; 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=nR/G2quCcmDWxYB/SgKO8lZYFMHqJW8eRXEF8osxEPg=; b=YN4DaoV1h9Qb2IOrfOi0LrPWR1cldBEKTKRkYjAOwZjcxAQnBTiN6RrqPW410/EvJjH7H1 WsLr00zROeNNlpod7JQCnAm7b+pGOj2lUPYzPqCjLXCLrWf0FthgVZr/bmahBTn7f2u+t2 6/7tgUZQs4lXfU0je7JPe7m6AIPV178= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-570-85_8cF0AMDSeu6s6crVyiQ-1; Thu, 02 Mar 2023 05:42:07 -0500 X-MC-Unique: 85_8cF0AMDSeu6s6crVyiQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AC4392806041; Thu, 2 Mar 2023 10:42:06 +0000 (UTC) Received: from [10.39.208.28] (unknown [10.39.208.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BF9DAC16027; Thu, 2 Mar 2023 10:42:04 +0000 (UTC) Message-ID: Date: Thu, 2 Mar 2023 11:42:02 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH] vhost: fix vring enable with VDPA To: David Marchand , dev@dpdk.org Cc: ssimma@nvidia.com, yajunw@nvidia.com, Chenbo Xia , =?UTF-8?Q?Morten_Br=c3=b8rup?= References: <20230302094808.1519310-1-david.marchand@redhat.com> From: Maxime Coquelin In-Reply-To: <20230302094808.1519310-1-david.marchand@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 On 3/2/23 10:48, David Marchand wrote: > For VDPA devices, vq are not locked once the device has been configured. > But we need to hold the vq lock to check if vhost async is enabled. > > Combining VDPA and vhost async does not seem to make much sense, so > prevent this combination, and only assert the lock is taken when VDPA is > not configured on this vq. > > Bugzilla ID: 1169 > Fixes: 4b02c2673757 ("vhost: annotate async accesses") > > Signed-off-by: David Marchand > --- > lib/vhost/vhost.c | 4 ++-- > lib/vhost/vhost_user.c | 8 ++++---- > 2 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c > index c36dc06a0a..6b73c03224 100644 > --- a/lib/vhost/vhost.c > +++ b/lib/vhost/vhost.c > @@ -1754,7 +1754,7 @@ rte_vhost_async_channel_register(int vid, uint16_t queue_id) > > vq = dev->virtqueue[queue_id]; > > - if (unlikely(vq == NULL || !dev->async_copy)) > + if (unlikely(vq == NULL || !dev->async_copy || dev->vdpa_dev)) > return -1; > > rte_spinlock_lock(&vq->access_lock); > @@ -1778,7 +1778,7 @@ rte_vhost_async_channel_register_thread_unsafe(int vid, uint16_t queue_id) > > vq = dev->virtqueue[queue_id]; > > - if (unlikely(vq == NULL || !dev->async_copy)) > + if (unlikely(vq == NULL || !dev->async_copy || dev->vdpa_dev)) > return -1; > > vq_assert_lock(dev, vq); > diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c > index d702d082dd..daf3458985 100644 > --- a/lib/vhost/vhost_user.c > +++ b/lib/vhost/vhost_user.c > @@ -2177,10 +2177,10 @@ vhost_user_set_vring_enable(struct virtio_net **pdev, > enable, index); > > vq = dev->virtqueue[index]; > - /* vhost_user_lock_all_queue_pairs locked all qps */ > - vq_assert_lock(dev, vq); > - if (enable && vq->async) { > - if (vq->async->pkts_inflight_n) { > + if (!(dev->flags & VIRTIO_DEV_VDPA_CONFIGURED)) { > + /* vhost_user_lock_all_queue_pairs locked all qps */ > + vq_assert_lock(dev, vq); > + if (enable && vq->async && vq->async->pkts_inflight_n) { > VHOST_LOG_CONFIG(dev->ifname, ERR, > "failed to enable vring. Inflight packets must be completed first\n"); > return RTE_VHOST_MSG_RESULT_ERR; Reviewed-by: Maxime Coquelin Thanks, Maxime