Skip to contentSkip to conversation

hv: hv_util: move vmbus_open() to a later place

PATCH Superseded Dexuan Cui 2 participants 3 messages Jan 29, 2015 – Jan 30, 2015 Hyper-V/Azure core and drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Dexuan Cui

author maintainer
#0 lore raw

PATCH 1/3 hv: hv_util: move vmbus_open() to a later place

Before the line vmbus_open() returns, srv->util_cb can be already running and the variablies, like util_fw_version, are needed by the srv->util_cb.

So we have to make sure the variables are initialized before the vmbus_open().

CC "K. Y. Srinivasan" <[email protected]>
---
 drivers/hv/hv_util.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/hv/hv_util.c +6 -5
index 3b9c9ef..c5be773 100644
@@ -340,12 +340,8 @@ static int util_probe(struct hv_device *dev,
 
 	set_channel_read_state(dev->channel, false);
 
-	ret = vmbus_open(dev->channel, 4 * PAGE_SIZE, 4 * PAGE_SIZE, NULL, 0,
-			srv->util_cb, dev->channel);
-	if (ret)
-		goto error;
-
 	hv_set_drvdata(dev, srv);
+
 	/*
 	 * Based on the host; initialize the framework and
 	 * service version numbers we will negotiate.
@@ -365,6 +361,11 @@ static int util_probe(struct hv_device *dev,
 		hb_srv_version = HB_VERSION;
 	}
 
+	ret = vmbus_open(dev->channel, 4 * PAGE_SIZE, 4 * PAGE_SIZE, NULL, 0,
+			srv->util_cb, dev->channel);
+	if (ret)
+		goto error;
+
 	return 0;
 
 error:
Signature · 1 line
1.9.1
Reviewed-by on v1 1/3
#1 lore raw
Quoted 7 lines · Dexuan Cui

Before the line vmbus_open() returns, srv->util_cb can be already running and the variablies, like util_fw_version, are needed by the srv->util_cb.

So we have to make sure the variables are initialized before the vmbus_open().

CC "K. Y. Srinivasan" <[email protected]>

It is not said in the description but moving hv_set_drvdata() before vmbus_open() make sense in case probe and remove can collide (can they?).

Quoted 34 lines
---
 drivers/hv/hv_util.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/hv/hv_util.c +6 -5
index 3b9c9ef..c5be773 100644
@@ -340,12 +340,8 @@ static int util_probe(struct hv_device *dev,
 
 	set_channel_read_state(dev->channel, false);
 
-	ret = vmbus_open(dev->channel, 4 * PAGE_SIZE, 4 * PAGE_SIZE, NULL, 0,
-			srv->util_cb, dev->channel);
-	if (ret)
-		goto error;
-
 	hv_set_drvdata(dev, srv);
+
 	/*
 	 * Based on the host; initialize the framework and
 	 * service version numbers we will negotiate.
@@ -365,6 +361,11 @@ static int util_probe(struct hv_device *dev,
 		hb_srv_version = HB_VERSION;
 	}
 
+	ret = vmbus_open(dev->channel, 4 * PAGE_SIZE, 4 * PAGE_SIZE, NULL, 0,
+			srv->util_cb, dev->channel);
+	if (ret)
+		goto error;
+
 	return 0;
 
 error:
Signature · 1 line
  Vitaly
author maintainer
#2 lore raw
Quoted 14 lines

-----Original Message-----
From: Vitaly Kuznetsov [mailto:[email protected]]
Sent: Thursday, January 29, 2015 21:13 PM
To: Dexuan Cui
Cc: [email protected]; [email protected]; driverdev- [email protected]; [email protected]; [email protected]; [email protected]; KY Srinivasan; Haiyang Zhang
Subject: Re: [PATCH 1/3] hv: hv_util: move vmbus_open() to a later place

Quoted 3 lines · Dexuan Cui

Before the line vmbus_open() returns, srv->util_cb can be already running and the variablies, like util_fw_version, are needed by the srv->util_cb.

Quoted 8 lines
Quoted 4 lines

So we have to make sure the variables are initialized before the vmbus_open().

CC "K. Y. Srinivasan" <[email protected]>

It is not said in the description but moving hv_set_drvdata() before vmbus_open() make sense in case probe and remove can collide (can they?).

I'm not so sure. In normal usages, the collision should be unlikely. Anyway, the patch makes things better. :-)

Quoted 2 lines

Thanks for the review!

Thanks,
-- Dexuan

Quoted 37 lines
Quoted 24 lines
---
 drivers/hv/hv_util.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/hv/hv_util.c +1 -5
index 3b9c9ef..c5be773 100644
@@ -340,12 +340,8 @@ static int util_probe(struct hv_device *dev,
 
 	set_channel_read_state(dev->channel, false);
 
-	ret = vmbus_open(dev->channel, 4 * PAGE_SIZE, 4 * PAGE_SIZE, NULL, 0,
-			srv->util_cb, dev->channel);
-	if (ret)
-		goto error;
-
 	hv_set_drvdata(dev, srv);
+
 	/*
 	 * Based on the host; initialize the framework and
 	 * service version numbers we will negotiate.
@@ -365,6 +361,11 @@ static int util_probe(struct hv_device *dev,
 		hb_srv_version = HB_VERSION;

drivers/hv/hv_util.c static int util_probe(struct hv_device *dev, · line 371

Quoted 10 lines
drivers/hv/hv_util.c +5 -0
 	}
 
+	ret = vmbus_open(dev->channel, 4 * PAGE_SIZE, 4 * PAGE_SIZE, NULL, 0,
+			srv->util_cb, dev->channel);
+	if (ret)
+		goto error;
+
 	return 0;
 
 error:

--
Vitaly