From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by dpdk.org (Postfix) with ESMTP id 981C0187 for ; Mon, 30 Apr 2018 16:43:34 +0200 (CEST) Received: by mail-wr0-f193.google.com with SMTP id g21-v6so8286833wrb.8 for ; Mon, 30 Apr 2018 07:43:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=h8CyrSCH0kpXs6EaA8Edu2YZ+cgh4wTaXqVLaELCUao=; b=JIhnMDni5gwyC5IhNF7cS4quTNjrFbnHzTis6naIG1rsNlO7K8YqFXMHZex1DOufzc O45xfGhViIJI3KqEfD9PxBwHG3r3XS1QAM3wUPF7sTh3Je5wCkcKRDZKPhZqflLmjv8z Hre0y9ObxMkB6Bo61e+JN/vSSMwv+d1Kn92pNS2V3XI2mhEZzOOQAkdAkq++TTgWQr3j n55Y1Ws37ChHiZcMM86RORp4RjBuQq7nfI6ZPsEA84tnN4vqgSvplAck0wRGT7hoiUkR CC/tt89bAkQgfg6Qh/qit3M+UsNtH38PfKEjTczLKtT4oUrstUMbzYkcgN2Pwj4bxqxt xWTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=h8CyrSCH0kpXs6EaA8Edu2YZ+cgh4wTaXqVLaELCUao=; b=q4QR+8hSUg5tuZb5ESqDthbnxtjE1baX8dg9bi4fFiJiWX40oMjrKYnhbKUdFGsUgO 59kfenTk4j7BtoQkcyMCNHhUsBMaxCcpId8QP2CZP6lXehVRV4ILROvJtEgqkCECR0sD D5rvEKXgazz4pbXbgZd+4YOOz+zEg/0c6gHdo1BzZ9VuxHOyer0yzoUtdvca+lhKcUrW aaRjS0lDSv9a3+BST2nW+chzLh/NsxxhLwWkD2y5//IkZW9GzQIPchR/sj9IMRZeAAsD KInTEu6AEy8vJ3jYIcU9HXDzi6Mffmg/nWn5LPHsvtmiKmDNRKQhH8k6aw/eT6/OgIeC 8ylg== X-Gm-Message-State: ALQs6tCDYErO+uslBREFnigSvaRL4BsdRNJShYkm+ynyy9zUw/jCr9O6 DFRBFgb4ACWJ/W3gFFd1r9DXbIgMGRg= X-Google-Smtp-Source: AB8JxZpJ+7DZPS3yhtpoaGBhjGThmDy135VnZ1U3jfrTKB/X4hM+RvPHxJwQlqStr3kVSolpT+KKew== X-Received: by 2002:adf:8004:: with SMTP id 4-v6mr8301248wrk.274.1525099414208; Mon, 30 Apr 2018 07:43:34 -0700 (PDT) Received: from localhost ([2a00:23c5:be9a:5200:ce4c:82c0:d567:ecbb]) by smtp.gmail.com with ESMTPSA id k28-v6sm3692159wrk.46.2018.04.30.07.43.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Apr 2018 07:43:33 -0700 (PDT) From: luca.boccassi@gmail.com To: Junjie Chen Cc: Jens Freimann , Jianfeng Tan , Maxime Coquelin , dpdk stable Date: Mon, 30 Apr 2018 15:40:58 +0100 Message-Id: <20180430144223.18657-43-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180430144223.18657-1-luca.boccassi@gmail.com> References: <20180430140606.4615-80-luca.boccassi@gmail.com> <20180430144223.18657-1-luca.boccassi@gmail.com> Subject: [dpdk-stable] patch 'net/vhost: fix invalid state' has been queued to stable release 18.02.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: Mon, 30 Apr 2018 14:43:34 -0000 Hi, FYI, your patch has been queued to stable release 18.02.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 05/02/18. So please shout if anyone has objections. Thanks. Luca Boccassi --- >>From a82b4c3565f91d46942c171007a549d7ddffa927 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 11b607650..e392d719b 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, "Vhost device %d created\n", vid); @@ -651,23 +650,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]; @@ -792,11 +792,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); @@ -836,10 +832,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.14.2