From patchwork Wed Feb 14 14:53:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yang, Zhiyong" X-Patchwork-Id: 35175 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 9B47E1B365; Wed, 14 Feb 2018 15:53:44 +0100 (CET) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 7A9E21B360 for ; Wed, 14 Feb 2018 15:53:42 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Feb 2018 06:53:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,512,1511856000"; d="scan'208";a="17661449" Received: from unknown (HELO dpdk5.bj.intel.com) ([172.16.182.198]) by fmsmga007.fm.intel.com with ESMTP; 14 Feb 2018 06:53:40 -0800 From: Zhiyong Yang To: dev@dpdk.org, yliu@fridaylinux.org, maxime.coquelin@redhat.com, jianfeng.tan@intel.com, tiwei.bie@intel.com, zhihong.wang@intel.com Cc: dong1.wang@intel.com, Zhiyong Yang Date: Wed, 14 Feb 2018 22:53:30 +0800 Message-Id: <20180214145330.4679-5-zhiyong.yang@intel.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20180214145330.4679-1-zhiyong.yang@intel.com> References: <20180214145330.4679-1-zhiyong.yang@intel.com> Subject: [dpdk-dev] [PATCH 4/4] net/vhost: add memory checking to support client mode 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" When vhost user PMD works in client mode to connect/reconnect virtio user in server mode, new thread sometimes may run to new_device before queue_setup has been done, So have to wait until memory allocation is done. Signed-off-by: Zhiyong Yang --- drivers/net/vhost/rte_eth_vhost.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index 3aae01c39..cd67bc7c5 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -580,6 +580,15 @@ new_device(int vid) eth_dev->data->numa_node = newnode; #endif + /* The thread may run here before eth_dev->data->rx_queues or + * eth_dev->data->tx_queues have gotten valid memory, so have to + * wait until memory allocation is done. + */ + while (!eth_dev->data->rx_queues || + !eth_dev->data->tx_queues) { + ; + } + for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { vq = eth_dev->data->rx_queues[i]; if (vq == NULL)