From patchwork Wed Feb 27 08:54:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 50536 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 30527374E; Wed, 27 Feb 2019 09:54:35 +0100 (CET) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 8F0053256; Wed, 27 Feb 2019 09:54:34 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DCA168762E; Wed, 27 Feb 2019 08:54:33 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-64.ams2.redhat.com [10.36.112.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 88E495DE62; Wed, 27 Feb 2019 08:54:30 +0000 (UTC) From: Maxime Coquelin To: tiwei.bie@intel.com, dev@dpdk.org Cc: Maxime Coquelin , stable@dpdk.org Date: Wed, 27 Feb 2019 09:54:28 +0100 Message-Id: <20190227085428.13666-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 27 Feb 2019 08:54:33 +0000 (UTC) Subject: [dpdk-dev] [PATCH] vhost: prevent disabled rings to be processed with zero-copy X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" The vhost-user spec says that once the vring is disabled, the client has to stop processing it. But it can happen when dequeue zero-copy is enabled if outstanding descriptors buffers are still being processed by an extranl NIC or another guest. The fix consists in draining the zmbufs list to ensure no more descriptors buffers are in the wild. Note that this fix is only working in the case REPLY_ACK protocol feature is enabled, which is not the case by default for now (it is only enabled when IOMMU feature is enabled in the vhost library). Fixes: b0a985d1f340 ("vhost: add dequeue zero copy") Cc: stable@dpdk.org Signed-off-by: Maxime Coquelin Reviewed-by: Tiwei Bie --- lib/librte_vhost/vhost_user.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 36c0c676d..ef947b90c 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -1336,6 +1336,10 @@ vhost_user_set_vring_enable(struct virtio_net **pdev, "set queue enable: %d to qp idx: %d\n", enable, index); + /* On disable, rings have to be stopped being processed. */ + if (!enable && dev->dequeue_zero_copy) + drain_zmbuf_list(dev->virtqueue[index]); + did = dev->vdpa_dev_id; vdpa_dev = rte_vdpa_get_device(did); if (vdpa_dev && vdpa_dev->ops->set_vring_state)