DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/2] vhost: reference count fix for nb_started_ports
@ 2016-12-28 21:10 Charles (Chas) Williams
  2016-12-28 21:10 ` [dpdk-dev] [PATCH 2/2] vhost: start vhost servers once Charles (Chas) Williams
  2016-12-29  8:51 ` [dpdk-dev] [PATCH 1/2] vhost: reference count fix for nb_started_ports Yuanhan Liu
  0 siblings, 2 replies; 9+ messages in thread
From: Charles (Chas) Williams @ 2016-12-28 21:10 UTC (permalink / raw)
  To: dev; +Cc: mtetsuyah, yuanhan.liu, Wen Chiu

From: Wen Chiu <wchiu@brocade.com>

Only increment and decrement nb_started_ports on the first and last
device start and stop.  Otherwise, nb_started_ports can become negative
if a device is stopped multiple times.

Fixes: ee584e9710b9 ("vhost: add driver on top of the library")

Signed-off-by: Wen Chiu <wchiu@brocade.com>
Reviewed-by: Chas Williams <ciwillia@brocade.com>
---
 drivers/net/vhost/rte_eth_vhost.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index 60b0f51..ba559ff 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -782,11 +782,11 @@ eth_dev_start(struct rte_eth_dev *dev)
 						internal->flags);
 		if (ret)
 			return ret;
-	}
 
-	/* We need only one message handling thread */
-	if (rte_atomic16_add_return(&nb_started_ports, 1) == 1)
-		ret = vhost_driver_session_start();
+		/* We need only one message handling thread */
+		if (rte_atomic16_add_return(&nb_started_ports, 1) == 1)
+			ret = vhost_driver_session_start();
+	}
 
 	return ret;
 }
@@ -796,11 +796,12 @@ eth_dev_stop(struct rte_eth_dev *dev)
 {
 	struct pmd_internal *internal = dev->data->dev_private;
 
-	if (rte_atomic16_cmpset(&internal->once, 1, 0))
+	if (rte_atomic16_cmpset(&internal->once, 1, 0)) {
 		rte_vhost_driver_unregister(internal->iface_name);
 
-	if (rte_atomic16_sub_return(&nb_started_ports, 1) == 0)
-		vhost_driver_session_stop();
+		if (rte_atomic16_sub_return(&nb_started_ports, 1) == 0)
+			vhost_driver_session_stop();
+	}
 }
 
 static int
-- 
2.1.4

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-01-03  8:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-28 21:10 [dpdk-dev] [PATCH 1/2] vhost: reference count fix for nb_started_ports Charles (Chas) Williams
2016-12-28 21:10 ` [dpdk-dev] [PATCH 2/2] vhost: start vhost servers once Charles (Chas) Williams
2016-12-29  8:52   ` Yuanhan Liu
2016-12-29 15:58     ` Charles (Chas) Williams
2016-12-30  3:15       ` Yuanhan Liu
2016-12-30 21:26         ` Charles (Chas) Williams
2017-01-03  8:16           ` Yuanhan Liu
2016-12-29  8:51 ` [dpdk-dev] [PATCH 1/2] vhost: reference count fix for nb_started_ports Yuanhan Liu
2016-12-29 15:49   ` Charles (Chas) Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).