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 1074B41D3D; Thu, 2 Mar 2023 10:48:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0099F41153; Thu, 2 Mar 2023 10:48:15 +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 5079E40DFB for ; Thu, 2 Mar 2023 10:48:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677750493; 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; bh=9YJoO+ZeWEGh0rZ83BrLX5arVddAz3j/gNb7hs1HnGI=; b=Vkrd0gwmxa7lECBHiEtIfJqre+MrL17TTN3GuGhAPAdn+oMbmZyin3Bc4sJkrhtlQGquZP 9KUV+imyj0GLnFsIipE5oL5ayMy4ajVteyoKMDIniK5NcSm4AWx2zdd0p1gIkr9M09SLxI Tq6v9tvY3XD9rOydDna1Z5J2wq8Z2WA= 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-600-782V7yxSNH2AiReUYXzu5A-1; Thu, 02 Mar 2023 04:48:12 -0500 X-MC-Unique: 782V7yxSNH2AiReUYXzu5A-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 491831C05AEA; Thu, 2 Mar 2023 09:48:12 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.39.192.123]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E6372026D4B; Thu, 2 Mar 2023 09:48:10 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: ssimma@nvidia.com, yajunw@nvidia.com, Maxime Coquelin , Chenbo Xia , =?UTF-8?q?Morten=20Br=C3=B8rup?= Subject: [PATCH] vhost: fix vring enable with VDPA Date: Thu, 2 Mar 2023 10:48:08 +0100 Message-Id: <20230302094808.1519310-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 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; -- 2.39.2