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 07255A00C4; Sat, 29 Jan 2022 04:10:57 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C4094428B6; Sat, 29 Jan 2022 04:10:14 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id 15368428A6 for ; Sat, 29 Jan 2022 04:10:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643425813; x=1674961813; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=CYVxCE6tK347SJO9ema6bsNPo2bc/mSy5Uqe9fuByJc=; b=Hp6qmIfhL2I66LGUv9Bo0HOKo3y4N2efujT74NDDpJEXzMSVj9Rd1++u bZcFP7UNbYPPImVJR4Dw+YXRNMBwB0RqmC73p3Z4geS0E+AUaeTCE9XGi 8HDua3e1iHytg5Deq+0kOLeLM9WhgmcNh2W7AnXi5pdfZX656E8L2vJGD PpY8epndRZ36VogOC2/dZ3rynQmBxDxJHHRPNihQtZ0O6Ngm6uur5FvLy j75Y/GgKfSAEcmC3wxdquhAOeS+KvKXfbpskVQX+a9HywAx3lqk7BiYQ7 rNe20cZTweK1cA0uAsOQbSWWRKBk+yrxLxIb9lOdUaCe10n/36uYSUrFQ A==; X-IronPort-AV: E=McAfee;i="6200,9189,10241"; a="246076653" X-IronPort-AV: E=Sophos;i="5.88,325,1635231600"; d="scan'208";a="246076653" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jan 2022 19:10:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,325,1635231600"; d="scan'208";a="582047994" Received: from dpdk-dipei.sh.intel.com ([10.67.111.91]) by fmsmga008.fm.intel.com with ESMTP; 28 Jan 2022 19:10:11 -0800 From: Andy Pei To: dev@dpdk.org Cc: chenbo.xia@intel.com, maxime.coquelin@redhat.com, gang.cao@intel.com, changpeng.liu@intel.com Subject: [PATCH v3 15/15] vhost: make sure each queue callfd is configured Date: Sat, 29 Jan 2022 11:03:37 +0800 Message-Id: <1643425417-215270-16-git-send-email-andy.pei@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1643425417-215270-1-git-send-email-andy.pei@intel.com> References: <1643093258-47258-2-git-send-email-andy.pei@intel.com> <1643425417-215270-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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 --- 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