Skip to contentSkip to conversation

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

PATCH In review Dexuan Cui 3 participants 9 messages Feb 2, 2015 – Feb 3, 2015 2 messages not in the archive Hyper-V/Azure core and drivers

lore
Share & tools
lore

Dexuan Cui

author maintainer
#0 lore raw

PATCH v2 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 variables, 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().

---

v2:
This is a RESEND.
I just added Vitaly's Reviewed-by.

 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
#1 lore raw
Quoted 2 lines · Dexuan Cui

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

A questions is why we do this for util only? Can callbacks of other devices be called before vmbus_open() returns?

Quoted 21 lines

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

---

v2:
This is a RESEND.
I just added Vitaly's Reviewed-by.

 drivers/hv/hv_util.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/hv/hv_util.c +0 -0
index 3b9c9ef..c5be773 100644
@@ -340,12 +340,8 @@ static int util_probe(struct hv_device *dev,
 

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

Quoted 10 lines
drivers/hv/hv_util.c +1 -5
 	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);
+

This seems unnecessary.

Quoted 20 lines
drivers/hv/hv_util.c +0 -0
 	/*
 	 * Based on the host; initialize the framework and
drivers/hv/hv_util.c +5 -0
 	 * 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
author maintainer
#2 lore raw
Quoted 11 lines

-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Monday, February 2, 2015 17:36 PM
To: Dexuan Cui
Cc: [email protected]; [email protected]; driverdev- [email protected]; [email protected]; [email protected]; KY Srinivasan; [email protected]; Haiyang Zhang
Subject: Re: [PATCH v2 1/3] hv: hv_util: move vmbus_open() to a later place

Quoted 8 lines
Quoted 4 lines · Dexuan Cui

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

A questions is why we do this for util only? Can callbacks of other devices be called before vmbus_open() returns?

The variables are used in vmbus_prep_negotiate_resp(), which is only for the util devices.

I think the other devices should already handle the similar issue properly. If this is not the case, we need to fix them too.

Quoted 25 lines
Quoted 25 lines

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

---

v2:
This is a RESEND.
I just added Vitaly's Reviewed-by.

 drivers/hv/hv_util.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/hv/hv_util.c +0 -0
index 3b9c9ef..c5be773 100644
@@ -340,12 +340,8 @@ static int util_probe(struct hv_device *dev,
 
 	set_channel_read_state(dev->channel, false);
 
Quoted 10 lines

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

Quoted 8 lines
drivers/hv/hv_util.c +1 -5
-	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);
+

This seems unnecessary.

Yeah, it's an empty line, splitting the line and the below comment. I'm Ok to not have it.

Quoted 15 lines
Quoted 15 lines
drivers/hv/hv_util.c +0 -0
 	/*
 	 * Based on the host; initialize the framework and
drivers/hv/hv_util.c +5 -0
 	 * 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;
 
Quoted 4 lines
Quoted 4 lines

error:
--
1.9.1

-- Dexuan ���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

#3 lore raw
Quoted 20 lines · Dexuan Cui
Quoted 20 lines

-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Monday, February 2, 2015 17:36 PM
To: Dexuan Cui
Cc: [email protected]; [email protected];
driverdev-
[email protected]; [email protected]; [email protected]; KY Srinivasan; [email protected]; Haiyang Zhang
Subject: Re: [PATCH v2 1/3] hv: hv_util: move vmbus_open() to a
later place

Quoted 4 lines · Dexuan Cui

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

Quoted 7 lines
Quoted 2 lines

A questions is why we do this for util only? Can callbacks of other devices be called before vmbus_open() returns?

The variables are used in vmbus_prep_negotiate_resp(), which is only for the util devices.

I think the other devices should already handle the similar issue properly. If this is not the case, we need to fix them too.

Better to check all the others, e.g in balloon_probe(), it call hv_set_drvdata() after vmbus_open() and dose several datas setups in the middle. If balloon_onchannelcallback() could be called before hv_set_drvdata(), the code looks wrong.

Thanks

#4 lore raw
Quoted 38 lines

-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Monday, February 2, 2015 7:09 PM
To: Dexuan Cui
Cc: [email protected]; [email protected]; driverdev- [email protected]; [email protected]; [email protected]; KY Srinivasan; [email protected]; Haiyang Zhang
Subject: RE: [PATCH v2 1/3] hv: hv_util: move vmbus_open() to a later place

Quoted 24 lines · Dexuan Cui
Quoted 13 lines

-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Monday, February 2, 2015 17:36 PM
To: Dexuan Cui
Cc: [email protected]; [email protected];
driverdev-
[email protected]; [email protected]; [email protected]; KY
Srinivasan; [email protected]; Haiyang Zhang
Subject: Re: [PATCH v2 1/3] hv: hv_util: move vmbus_open() to a
later place

Quoted 8 lines
Quoted 2 lines · Dexuan Cui

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

the > srv->util_cb.

A questions is why we do this for util only? Can callbacks of other
devices be called before vmbus_open() returns?

The variables are used in vmbus_prep_negotiate_resp(), which is only for the util devices.

Quoted 8 lines
Quoted 3 lines

I think the other devices should already handle the similar issue properly.
If this is not the case, we need to fix them too.

Better to check all the others, e.g in balloon_probe(), it call hv_set_drvdata() after vmbus_open() and dose several datas setups in the middle. If balloon_onchannelcallback() could be called before hv_set_drvdata(), the code looks wrong.

Jason,

For all other device types, the guest initiates the communication with the host and potentially negotiates appropriate (supported) version with the host. For the services packaged in the util driver, the flow is a little different - the host pushes the version information into the guest. So, the fix Dexuan made is only needed in the util driver.

Regards,

K. Y

Quoted 4 lines

Thanks

���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

A message that is not in the archive (sent off-list or not yet received): BY2PR0301MB071153EA9F73C9855A4B4119A03D0@BY2PR0301MB0711.namprd03.prod.out look.com

#6 lore raw
Quoted 59 lines · KY Srinivasan
Quoted 51 lines

-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Monday, February 2, 2015 7:09 PM
To: Dexuan Cui
Cc: [email protected]; [email protected];
driverdev-
[email protected]; [email protected]; [email protected]; KY Srinivasan; [email protected]; Haiyang Zhang
Subject: RE: [PATCH v2 1/3] hv: hv_util: move vmbus_open() to a
later place

Quoted 7 lines · Dexuan Cui
Quoted 7 lines

-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Monday, February 2, 2015 17:36 PM
To: Dexuan Cui
Cc: [email protected]; [email protected];
driverdev-
[email protected]; [email protected];

[email protected]; KY

Quoted 7 lines
Quoted 7 lines

Srinivasan; [email protected]; Haiyang Zhang
Subject: Re: [PATCH v2 1/3] hv: hv_util: move vmbus_open() to a
later place

On Mon, Feb 2, 2015 at 12:35 PM, Dexuan Cui

<[email protected]>

Quoted 2 lines
Quoted 2 lines
Quoted 1 line · wrote:

Before the line vmbus_open() returns, srv->util_cb can be

already

Quoted 1 line
Quoted 1 line
Quoted 1 line

running > and the variables, like util_fw_version, are needed

by

Quoted 3 lines
Quoted 3 lines

the > srv->util_cb.

A questions is why we do this for util only? Can callbacks of

other

Quoted 2 lines
Quoted 1 line

devices be called before vmbus_open() returns?

The variables are used in vmbus_prep_negotiate_resp(), which is

only

Quoted 5 lines

for the util devices.

I think the other devices should already handle the similar issue properly.
If this is not the case, we need to fix them too.

Quoted 5 lines

Better to check all the others, e.g in balloon_probe(), it call hv_set_drvdata() after vmbus_open() and dose several datas setups
in the
middle. If balloon_onchannelcallback() could be called before hv_set_drvdata(), the code looks wrong.

Jason,

Quoted 8 lines

For all other device types, the guest initiates the communication with the host and potentially negotiates appropriate (supported) version with the host. For the services packaged in the util driver, the flow is a little different - the host pushes the version information into the guest. So, the fix Dexuan made is only needed in the util driver.

Regards,

K. Y

Thanks, so you mean for other device, it won't get any interrupt before guest negotiate the version with host?

Quoted 6 lines
Quoted 5 lines

Thanks

#7 lore raw
Quoted 67 lines

-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Monday, February 2, 2015 7:38 PM
To: KY Srinivasan
Cc: Dexuan Cui; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Haiyang Zhang
Subject: RE: [PATCH v2 1/3] hv: hv_util: move vmbus_open() to a later place

Quoted 52 lines · KY Srinivasan
Quoted 35 lines

-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Monday, February 2, 2015 7:09 PM
To: Dexuan Cui
Cc: [email protected]; [email protected];
driverdev-
[email protected]; [email protected]; [email protected]; KY
Srinivasan; [email protected]; Haiyang Zhang
Subject: RE: [PATCH v2 1/3] hv: hv_util: move vmbus_open() to a
later place

Quoted 2 lines · Dexuan Cui
Quoted 2 lines

-----Original Message-----
From: Jason Wang [mailto:[email protected]] >> Sent: Monday,

February 2, 2015 17:36 PM >> To: Dexuan Cui >> Cc:
[email protected]; [email protected]; >> driverdev- >> [email protected]; [email protected]; [email protected]; KY >> Srinivasan; [email protected]; Haiyang Zhang >> Subject: Re: [PATCH v2 1/3] hv: hv_util: move vmbus_open() to a >> later place >> >> >> >> On Mon, Feb 2, 2015 at 12:35

Quoted 1 line · Dexuan Cui
Quoted 1 line
Quoted 1 line

Before the line vmbus_open() returns, srv->util_cb can be

already >> > running > and the variables, like util_fw_version, are needed by >> the > srv->util_cb.

Quoted 2 lines
Quoted 2 lines

A questions is why we do this for util only? Can callbacks of

other >> devices be called before vmbus_open() returns?

Quoted 1 line

The variables are used in vmbus_prep_negotiate_resp(), which is

only > for the util devices.

Quoted 1 line
Quoted 8 lines
Quoted 3 lines

I think the other devices should already handle the similar issue properly.
If this is not the case, we need to fix them too.

Better to check all the others, e.g in balloon_probe(), it call hv_set_drvdata() after vmbus_open() and dose several datas setups in
the middle. If balloon_onchannelcallback() could be called before hv_set_drvdata(), the code looks wrong.

Jason,

For all other device types, the guest initiates the communication with the host and potentially negotiates appropriate (supported) version with the host. For the services packaged in the util driver, the flow is a little different - the host pushes the version information into the guest. So, the fix Dexuan made is only needed in the util driver.

Quoted 6 lines
Quoted 3 lines

Regards,

K. Y

Thanks, so you mean for other device, it won't get any interrupt before guest negotiate the version with host?

Yes, the guest initiates the version negotiation. Are you seeing something different?

K. Y

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

Thanks

���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

A message that is not in the archive (sent off-list or not yet received): BY2PR0301MB07113EC0C4277FA01AE66B9DA03D0@BY2PR0301MB0711.namprd03.prod.out look.com

#9 lore raw
Quoted 89 lines · KY Srinivasan
Quoted 89 lines

-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Monday, February 2, 2015 7:38 PM
To: KY Srinivasan
Cc: Dexuan Cui; [email protected];
[email protected];
[email protected]; [email protected]; [email protected]; [email protected]; Haiyang Zhang
Subject: RE: [PATCH v2 1/3] hv: hv_util: move vmbus_open() to a
later place

Quoted 9 lines · KY Srinivasan
Quoted 9 lines

-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Monday, February 2, 2015 7:09 PM
To: Dexuan Cui
Cc: [email protected]; [email protected];
driverdev-
[email protected]; [email protected];

[email protected]; KY

Quoted 10 lines
Quoted 10 lines

Srinivasan; [email protected]; Haiyang Zhang
Subject: RE: [PATCH v2 1/3] hv: hv_util: move vmbus_open() to a
later place

Quoted 2 lines · Dexuan Cui
Quoted 2 lines

-----Original Message-----
From: Jason Wang [mailto:[email protected]] >> Sent:

Monday,

Quoted 4 lines
Quoted 4 lines

February 2, 2015 17:36 PM >> To: Dexuan Cui >> Cc:
[email protected]; [email protected]; >> driverdev- >> [email protected]; [email protected]; [email protected]; KY >> Srinivasan; [email protected];

Haiyang

Quoted 1 line
Quoted 1 line

Zhang >> Subject: Re: [PATCH v2 1/3] hv: hv_util: move

vmbus_open()

Quoted 1 line
Quoted 1 line

to a >> later place >> >> >> >> On Mon, Feb 2, 2015 at

12:35

Quoted 3 lines
Quoted 3 lines
Quoted 1 line · Dexuan Cui
Quoted 1 line
Quoted 1 line

Before the line vmbus_open() returns, srv->util_cb can be

already >> > running > and the variables, like

util_fw_version, are

Quoted 3 lines
Quoted 3 lines

needed by >> the > srv->util_cb.

Quoted 2 lines
Quoted 2 lines

A questions is why we do this for util only? Can callbacks

of

Quoted 2 lines
Quoted 2 lines

other >> devices be called before vmbus_open() returns?

Quoted 1 line

The variables are used in vmbus_prep_negotiate_resp(), which

is

Quoted 3 lines
Quoted 3 lines

only > for the util devices.

Quoted 2 lines

I think the other devices should already handle the similar

issue

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

properly.
If this is not the case, we need to fix them too.

Better to check all the others, e.g in balloon_probe(), it call hv_set_drvdata() after vmbus_open() and dose several datas

setups in

Quoted 1 line
Quoted 1 line

the middle. If balloon_onchannelcallback() could be called

before

Quoted 5 lines
Quoted 1 line

hv_set_drvdata(), the code looks wrong.

Jason,

For all other device types, the guest initiates the communication

with

Quoted 1 line

the host and potentially negotiates appropriate (supported)

version

Quoted 1 line

with the host. For the services packaged in the util driver, the

flow

Quoted 1 line

is a little different - the host pushes the version information

into

Quoted 1 line

the guest. So, the fix Dexuan made is only needed in the util

driver.

Quoted 4 lines

Regards,

K. Y

Quoted 7 lines
Quoted 3 lines

Thanks, so you mean for other device, it won't get any interrupt
before guest
negotiate the version with host?

Yes, the guest initiates the version negotiation. Are you seeing something different?

K. Y

No, thanks.

Reviewed-by on v2 1/3
#10 lore raw
In reply to Dexuan Cui
Quoted 48 lines · Dexuan Cui

Before the line vmbus_open() returns, srv->util_cb can be already running and the variables, 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().

---

v2:
This is a RESEND.
I just added Vitaly's Reviewed-by.

 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
drivers/hv/hv_util.c +5 -0
 	 * 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;
 
Quoted 3 lines

error:

Signature · 1 line
1.9.1