From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <tomaszx.kulasek@intel.com>
Received: from mga05.intel.com (mga05.intel.com [192.55.52.43])
 by dpdk.org (Postfix) with ESMTP id 34F2E1B840;
 Fri,  9 Feb 2018 18:36:09 +0100 (CET)
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from fmsmga001.fm.intel.com ([10.253.24.23])
 by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 09 Feb 2018 09:36:09 -0800
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.46,483,1511856000"; d="scan'208";a="29532142"
Received: from unknown (HELO Sent) ([10.103.103.74])
 by fmsmga001.fm.intel.com with SMTP; 09 Feb 2018 09:36:06 -0800
Received: by Sent (sSMTP sendmail emulation); Fri, 09 Feb 2018 18:35:02 +0100
From: Tomasz Kulasek <tomaszx.kulasek@intel.com>
To: yliu@fridaylinux.org
Cc: dev@dpdk.org, yuanhan.liu@linux.intel.com, stable@dpdk.org,
 Changpeng Liu <changpeng.liu@intel.com>
Date: Fri,  9 Feb 2018 18:34:55 +0100
Message-Id: <20180209173455.14116-1-tomaszx.kulasek@intel.com>
X-Mailer: git-send-email 2.12.3
Subject: [dpdk-dev] [PATCH] vhost: fix wait for valid descriptor
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Fri, 09 Feb 2018 17:36:10 -0000

For each virt queue's kickfd and callfd, there are 2 invalid
status: VIRTIO_UNINITIALIZED_EVENTFD and VIRTIO_INVALID_EVENTFD.
Don't set the virt queue to ready status until got the valid
descriptor.

This is safe for polling mode drivers in Guest OS, the backend
vhost process will not post notification to interrupt vector for
PMD mode in guest, but the interrupt vector still valid.

Fixes: e049ca6d10e0 ("vhost-user: prepare multiple queue setup")
Cc: yuanhan.liu@linux.intel.com
Cc: stable@dpdk.org

Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
---
 lib/librte_vhost/vhost_user.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 65ee33919..4508f697b 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -766,7 +766,9 @@ vq_is_ready(struct vhost_virtqueue *vq)
 {
 	return vq && vq->desc && vq->avail && vq->used &&
 	       vq->kickfd != VIRTIO_UNINITIALIZED_EVENTFD &&
-	       vq->callfd != VIRTIO_UNINITIALIZED_EVENTFD;
+	       vq->callfd != VIRTIO_UNINITIALIZED_EVENTFD &&
+	       vq->kickfd != VIRTIO_INVALID_EVENTFD &&
+	       vq->callfd != VIRTIO_INVALID_EVENTFD;
 }
 
 static int
-- 
2.14.1