From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 6296AF3E for ; Sun, 22 Apr 2018 17:12:35 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id CDF3320FF8; Sun, 22 Apr 2018 11:12:34 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sun, 22 Apr 2018 11:12:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux.org; h=cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=uZ+TP2+zLhkBA0Hqf swrDcRDSVSW19Olq7a5buJ2Rb4=; b=RRe2OlQUrnv0gzn4qKZ+BqM2YPFpkJ8Ik O9Z4RjhMerIN3ZyVWX2yip4ggGkBiwzA60zXgtvhWE+cGrxcb5APloO1J8+9gUF2 2Za6QMseLI5SPw1/3UpdqmHisUkQ5qQRxx3T/80LPPEznyGJOZqCu3QClCTCu5Mg 0gdrF+J6Y4oQ3GolQmR4Zw4AFSLLAx9+ggWRMMn/jsJEkaadMQMvG5Sp0o39szkN FhyfU9Iv8w6HTrI04Z08wP3NkA3j1Ha9Lo7U3Ztb9pdrtvXsnJMEcWAaVoTgS/WW O+X+IoCuBNOCjAoWnIuv5tl/ceGDEUU5rWWOCLCFna/taTELFW7Dg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=uZ+TP2+zLhkBA0HqfswrDcRDSVSW19Olq7a5buJ2Rb4=; b=kXMSOUFv TdxqgLjtvMmGpK69KvkJWTMgymTSleSopKkDviXntRlY3nMCMtgR+gKLGUkFPEez K4yfpWu32nNQVG0ijbG3Jwk/WujWrfgIycmqfxPcp703yogW8oprSWV7DmD7ZxQm 22Ppev0NNczgLPohyLktosRuyPUuTYh0tisRGRiGGwjvZs94l126K7IoJgAsfdlF W96not0YpV6CI9CPpSRKOz3+aAHNCJn3ec+evbzDegDD5sZILRPsqCotjmWkEhzW XfT7E5f/q+UMkscPESwtrjU3NM1aIsqKJYTHDacHXoLGyLbJs9XDY8XZMWx2XCV4 xFtWmemS5pfgOg== X-ME-Sender: Received: from yuanhanliu-NB0.tencent.com (unknown [223.74.148.66]) by mail.messagingengine.com (Postfix) with ESMTPA id 24D5D10253; Sun, 22 Apr 2018 11:12:31 -0400 (EDT) From: Yuanhan Liu To: Junjie Chen Cc: Jens Freimann , Jianfeng Tan , Maxime Coquelin , dpdk stable Date: Sun, 22 Apr 2018 23:09:48 +0800 Message-Id: <20180422150949.17523-58-yliu@fridaylinux.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180422150949.17523-1-yliu@fridaylinux.org> References: <20180422150949.17523-1-yliu@fridaylinux.org> Subject: [dpdk-stable] patch 'net/vhost: fix invalid state' has been queued to LTS release 17.11.2 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Apr 2018 15:12:35 -0000 Hi, FYI, your patch has been queued to LTS release 17.11.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 04/29/18. So please shout if anyone has objections. Thanks. --yliu --- >>From a8d0841a426b59b29218bf5498eab7aaab19361a Mon Sep 17 00:00:00 2001 From: Junjie Chen Date: Wed, 11 Apr 2018 13:02:32 -0400 Subject: [PATCH] net/vhost: fix invalid state [ upstream commit e6722dee533cda3756fbc5c9ea4ddfbf30276f1b ] dev_start sets *dev_attached* after setup queues, this sets device to invalid state since no frontend is attached. Also destroy_device set *started* to zero which makes *allow_queuing* always zero until dev_start get called again. Actually, we should not determine queues existence by *dev_attached* but by queues pointers or other separated variable(s). Fixes: 30a701a53737 ("net/vhost: fix crash when creating vdev dynamically") Signed-off-by: Junjie Chen Tested-by: Jens Freimann Reviewed-by: Jianfeng Tan Reviewed-by: Maxime Coquelin --- drivers/net/vhost/rte_eth_vhost.c | 59 +++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index 2299ce877..caf9fce0a 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -528,10 +528,11 @@ update_queuing_status(struct rte_eth_dev *dev) unsigned int i; int allow_queuing = 1; - if (rte_atomic32_read(&internal->dev_attached) == 0) + if (!dev->data->rx_queues || !dev->data->tx_queues) return; - if (rte_atomic32_read(&internal->started) == 0) + if (rte_atomic32_read(&internal->started) == 0 || + rte_atomic32_read(&internal->dev_attached) == 0) allow_queuing = 0; /* Wait until rx/tx_pkt_burst stops accessing vhost device */ @@ -607,13 +608,10 @@ new_device(int vid) #endif internal->vid = vid; - if (eth_dev->data->rx_queues && eth_dev->data->tx_queues) { + if (rte_atomic32_read(&internal->started) == 1) queue_setup(eth_dev, internal); - rte_atomic32_set(&internal->dev_attached, 1); - } else { - RTE_LOG(INFO, PMD, "RX/TX queues have not setup yet\n"); - rte_atomic32_set(&internal->dev_attached, 0); - } + else + RTE_LOG(INFO, PMD, "RX/TX queues not exist yet\n"); for (i = 0; i < rte_vhost_get_vring_num(vid); i++) rte_vhost_enable_guest_notification(vid, i, 0); @@ -622,6 +620,7 @@ new_device(int vid) eth_dev->data->dev_link.link_status = ETH_LINK_UP; + rte_atomic32_set(&internal->dev_attached, 1); update_queuing_status(eth_dev); RTE_LOG(INFO, PMD, "New connection established\n"); @@ -652,23 +651,24 @@ destroy_device(int vid) eth_dev = list->eth_dev; internal = eth_dev->data->dev_private; - rte_atomic32_set(&internal->started, 0); - update_queuing_status(eth_dev); rte_atomic32_set(&internal->dev_attached, 0); + update_queuing_status(eth_dev); eth_dev->data->dev_link.link_status = ETH_LINK_DOWN; - for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { - vq = eth_dev->data->rx_queues[i]; - if (vq == NULL) - continue; - vq->vid = -1; - } - for (i = 0; i < eth_dev->data->nb_tx_queues; i++) { - vq = eth_dev->data->tx_queues[i]; - if (vq == NULL) - continue; - vq->vid = -1; + if (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) + continue; + vq->vid = -1; + } + for (i = 0; i < eth_dev->data->nb_tx_queues; i++) { + vq = eth_dev->data->tx_queues[i]; + if (!vq) + continue; + vq->vid = -1; + } } state = vring_states[eth_dev->data->port_id]; @@ -795,11 +795,7 @@ eth_dev_start(struct rte_eth_dev *eth_dev) { struct pmd_internal *internal = eth_dev->data->dev_private; - if (unlikely(rte_atomic32_read(&internal->dev_attached) == 0)) { - queue_setup(eth_dev, internal); - rte_atomic32_set(&internal->dev_attached, 1); - } - + queue_setup(eth_dev, internal); rte_atomic32_set(&internal->started, 1); update_queuing_status(eth_dev); @@ -839,10 +835,13 @@ eth_dev_close(struct rte_eth_dev *dev) pthread_mutex_unlock(&internal_list_lock); rte_free(list); - for (i = 0; i < dev->data->nb_rx_queues; i++) - rte_free(dev->data->rx_queues[i]); - for (i = 0; i < dev->data->nb_tx_queues; i++) - rte_free(dev->data->tx_queues[i]); + if (dev->data->rx_queues) + for (i = 0; i < dev->data->nb_rx_queues; i++) + rte_free(dev->data->rx_queues[i]); + + if (dev->data->tx_queues) + for (i = 0; i < dev->data->nb_tx_queues; i++) + rte_free(dev->data->tx_queues[i]); rte_free(dev->data->mac_addrs); free(internal->dev_name); -- 2.11.0