From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 1F82EA04A7;
	Tue, 25 Jan 2022 10:44:00 +0100 (CET)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id D1517428F0;
	Tue, 25 Jan 2022 10:43:19 +0100 (CET)
Received: from mga18.intel.com (mga18.intel.com [134.134.136.126])
 by mails.dpdk.org (Postfix) with ESMTP id EEDC2428FF
 for <dev@dpdk.org>; Tue, 25 Jan 2022 10:43:17 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
 d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
 t=1643103798; x=1674639798;
 h=from:to:cc:subject:date:message-id:in-reply-to: references;
 bh=CYVxCE6tK347SJO9ema6bsNPo2bc/mSy5Uqe9fuByJc=;
 b=Q67Fb8I61pq0zkPQAzBcRyUMG/MlV/FOH/AUS8io3ju9fPwNxZsJxzzL
 gwX0JQyudtVAvSZL8yTU47GO8xcIpmHguc8GaCbr4wgOVsYh+doqA9kp5
 yw+zeL7uyM8bni7IaWcGF6I+4GBRAJRq/g9T8Rrz3Pt8Jh1RMF14I2ED9
 WiSFMP49pNVcjtleNJUHP3L5GbODVAamZpXEX13W2UbQQE1It06mKW6JU
 FfzmbPMReEzFkjsRExX2eWcnI3VPCgLmpbeaX1Yln1mUiaQLPgCQVUmxG
 EZsUEQCmo+00bjbLJ3Vc5/xeCHE+IYF7I80gE+fVy4ErX6SY7PXxD5FEN g==;
X-IronPort-AV: E=McAfee;i="6200,9189,10237"; a="229840493"
X-IronPort-AV: E=Sophos;i="5.88,314,1635231600"; d="scan'208";a="229840493"
Received: from orsmga008.jf.intel.com ([10.7.209.65])
 by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 25 Jan 2022 01:43:17 -0800
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.88,314,1635231600"; d="scan'208";a="534656915"
Received: from dpdk-dipei.sh.intel.com ([10.67.111.91])
 by orsmga008.jf.intel.com with ESMTP; 25 Jan 2022 01:43:15 -0800
From: Andy Pei <andy.pei@intel.com>
To: dev@dpdk.org
Cc: chenbo.xia@intel.com, maxime.coquelin@redhat.com, gang.cao@intel.com,
 changpeng.liu@intel.com
Subject: [PATCH v2 15/15] vhost: make sure each queue callfd is configured
Date: Tue, 25 Jan 2022 17:37:17 +0800
Message-Id: <1643103437-118618-16-git-send-email-andy.pei@intel.com>
X-Mailer: git-send-email 1.8.3.1
In-Reply-To: <1643103437-118618-1-git-send-email-andy.pei@intel.com>
References: <1643093258-47258-2-git-send-email-andy.pei@intel.com>
 <1643103437-118618-1-git-send-email-andy.pei@intel.com>
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

During the vhost data path building process, qemu will create
a call fd at first, and create another call fd in the end.
The final call fd will be used to relay notify.
In the original code, after kick fd is set, dev_conf will
set the first call fd. Even though the actual call fd will set,
the data path will not work correctly.

Signed-off-by: Andy Pei <andy.pei@intel.com>
---
 lib/vhost/vhost_user.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
index 5eb1dd6..b25b25f 100644
--- a/lib/vhost/vhost_user.c
+++ b/lib/vhost/vhost_user.c
@@ -3137,12 +3137,26 @@ typedef int (*vhost_message_handler_t)(struct virtio_net **pdev,
 	if (!vdpa_dev)
 		goto out;
 
+	if (request != VHOST_USER_SET_VRING_CALL)
+		goto out;
+
 	if (!(dev->flags & VIRTIO_DEV_VDPA_CONFIGURED)) {
 		if (vdpa_dev->ops->dev_conf(dev->vid))
 			VHOST_LOG_CONFIG(ERR,
 					 "Failed to configure vDPA device\n");
 		else
 			dev->flags |= VIRTIO_DEV_VDPA_CONFIGURED;
+	} else {
+		/* when VIRTIO_DEV_VDPA_CONFIGURED already configured
+		 * close the device and config the device again,
+		 * make sure the call fd of each queue is configured correctly.
+		 */
+		if (vdpa_dev->ops->dev_close(dev->vid))
+			VHOST_LOG_CONFIG(ERR,
+					 "Failed to close vDPA device\n");
+		if (vdpa_dev->ops->dev_conf(dev->vid))
+			VHOST_LOG_CONFIG(ERR,
+					 "Failed to re-config vDPA device\n");
 	}
 
 out:
-- 
1.8.3.1