Skip to contentSkip to conversation

Drivers: hv: vmbus: Some miscellaneous bug fixes and cleanup

PATCH RESEND In review K. Y. Srinivasan 2 participants 11 messages Feb 3, 2015 – Feb 4, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Drivers: hv: vmbus: Some miscellaneous bug fixes and cleanup

This is a resend of the patches from Dexuan and Nicholas

Dexuan Cui (3):
hv: hv_util: move vmbus_open() to a later place
hv: vmbus_post_msg: retry the hypercall on some transient errors
hv: vmbus_open(): reset the channel state on ENOMEM

Nicholas Mc Guire (3):
hv: channel: match var type to return type of wait_for_completion
hv: channel_mgmt: match var type to return type of
wait_for_completion
hv: hv_balloon: match var type to return type of wait_for_completion

 arch/x86/include/uapi/asm/hyperv.h |    2 ++
 drivers/hv/channel.c               |   11 +++++++----
 drivers/hv/channel_mgmt.c          |    3 ++-
 drivers/hv/connection.c            |   11 +++++++++--
 drivers/hv/hv_balloon.c            |    3 ++-
 drivers/hv/hv_util.c               |   11 ++++++-----
 6 files changed, 28 insertions(+), 13 deletions(-)
Signature · 1 line
1.7.4.1
#1 lore raw

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

From: Dexuan Cui <[mailto:[email protected]]>

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().

---
 drivers/hv/hv_util.c |   11 ++++++-----
 1 files 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.7.4.1
#2 lore raw

PATCH RESEND 2/6 hv: vmbus_post_msg: retry the hypercall on some transient errors

From: Dexuan Cui <[mailto:[email protected]]>

I got HV_STATUS_INVALID_CONNECTION_ID on Hyper-V 2008 R2 when keeping running "rmmod hv_netvsc; modprobe hv_netvsc; rmmod hv_utils; modprobe hv_utils" in a Linux guest. Looks the host has some kind of throttling mechanism if some kinds of hypercalls are sent too frequently.
Without the patch, the driver can occasionally fail to load.

Also let's retry HV_STATUS_INSUFFICIENT_MEMORY, though we didn't get it before.

Removed 'case -ENOMEM', since the hypervisor doesn't return this.

---
 arch/x86/include/uapi/asm/hyperv.h |    2 ++
 drivers/hv/connection.c            |   11 +++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)
arch/x86/include/uapi/asm/hyperv.h +2 -0
index 90c458e..ce6068d 100644
@@ -225,6 +225,8 @@
 #define HV_STATUS_INVALID_HYPERCALL_CODE	2
 #define HV_STATUS_INVALID_HYPERCALL_INPUT	3
 #define HV_STATUS_INVALID_ALIGNMENT		4
+#define HV_STATUS_INSUFFICIENT_MEMORY		11
+#define HV_STATUS_INVALID_CONNECTION_ID		18
 #define HV_STATUS_INSUFFICIENT_BUFFERS		19
 
 typedef struct _HV_REFERENCE_TSC_PAGE {
drivers/hv/connection.c +9 -2
index c4acd1c..af2388f 100644
@@ -440,9 +440,16 @@ int vmbus_post_msg(void *buffer, size_t buflen)
 		ret = hv_post_message(conn_id, 1, buffer, buflen);
 
 		switch (ret) {
+		case HV_STATUS_INVALID_CONNECTION_ID:
+			/*
+			 * We could get this if we send messages too
+			 * frequently.
+			 */
+			ret = -EAGAIN;
+			break;
+		case HV_STATUS_INSUFFICIENT_MEMORY:
 		case HV_STATUS_INSUFFICIENT_BUFFERS:
 			ret = -ENOMEM;
-		case -ENOMEM:
 			break;
 		case HV_STATUS_SUCCESS:
 			return ret;
@@ -452,7 +459,7 @@ int vmbus_post_msg(void *buffer, size_t buflen)
 		}
 
 		retries++;
-		msleep(100);
+		msleep(1000);
 	}
 	return ret;
 }
Signature · 1 line
1.7.4.1
#3 lore raw

PATCH RESEND 3/6 hv: vmbus_open(): reset the channel state on ENOMEM

In reply to K. Y. Srinivasan

From: Dexuan Cui <[mailto:[email protected]]>

Without this patch, the state is put to CHANNEL_OPENING_STATE, and when the driver is loaded next time, vmbus_open() will fail immediately due to newchannel->state != CHANNEL_OPEN_STATE.

---
 drivers/hv/channel.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
drivers/hv/channel.c +5 -3
index 2978f5e..26dcf26 100644
@@ -89,9 +89,10 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 	out = (void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO,
 		get_order(send_ringbuffer_size + recv_ringbuffer_size));
 
-	if (!out)
-		return -ENOMEM;
-
+	if (!out) {
+		err = -ENOMEM;
+		goto error0;
+	}
 
 	in = (void *)((unsigned long)out + send_ringbuffer_size);
 
@@ -199,6 +200,7 @@ error0:
 	free_pages((unsigned long)out,
 		get_order(send_ringbuffer_size + recv_ringbuffer_size));
 	kfree(open_info);
+	newchannel->state = CHANNEL_OPEN_STATE;
 	return err;
 }
 EXPORT_SYMBOL_GPL(vmbus_open);
Signature · 1 line
1.7.4.1
#4 lore raw

PATCH RESEND 4/6 hv: channel: match var type to return type of wait_for_completion

In reply to K. Y. Srinivasan

From: Nicholas Mc Guire <[email protected]>

return type of wait_for_completion_timeout is unsigned long not int, this patch changes the type of t from int to unsigned long.

---
 drivers/hv/channel.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/hv/channel.c +2 -1
index 26dcf26..f687995 100644
@@ -71,7 +71,8 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 	struct vmbus_channel_msginfo *open_info = NULL;
 	void *in, *out;
 	unsigned long flags;
-	int ret, t, err = 0;
+	int ret, err = 0;
+	unsigned long t;
 
 	spin_lock_irqsave(&newchannel->lock, flags);
 	if (newchannel->state == CHANNEL_OPEN_STATE) {
Signature · 1 line
1.7.4.1
#5 lore raw

PATCH RESEND 5/6 hv: channel_mgmt: match var type to return type of wait_for_completion

In reply to K. Y. Srinivasan

From: Nicholas Mc Guire <[email protected]>

return type of wait_for_completion_timeout is unsigned long not int, this patch changes the type of t from int to unsigned long.

---
 drivers/hv/channel_mgmt.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/hv/channel_mgmt.c +2 -1
index 36bacc7..6be93f0 100644
@@ -789,7 +789,8 @@ int vmbus_request_offers(void)
 {
 	struct vmbus_channel_message_header *msg;
 	struct vmbus_channel_msginfo *msginfo;
-	int ret, t;
+	int ret;
+	unsigned long t;
 
 	msginfo = kmalloc(sizeof(*msginfo) +
 			  sizeof(struct vmbus_channel_message_header),
Signature · 1 line
1.7.4.1
#6 lore raw

PATCH RESEND 6/6 hv: hv_balloon: match var type to return type of wait_for_completion

In reply to K. Y. Srinivasan

From: Nicholas Mc Guire <[email protected]>

return type of wait_for_completion_timeout is unsigned long not int, this patch changes the type of t from int to unsigned long.

---
 drivers/hv/hv_balloon.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/hv/hv_balloon.c +2 -1
index ff16938..965c37a 100644
@@ -1414,7 +1414,8 @@ static void balloon_onchannelcallback(void *context)
 static int balloon_probe(struct hv_device *dev,
 			const struct hv_vmbus_device_id *dev_id)
 {
-	int ret, t;
+	int ret;
+	unsigned long t;
 	struct dm_version_request version_req;
 	struct dm_capabilities cap_msg;
 
Signature · 1 line
1.7.4.1
#7 lore raw
In reply to K. Y. Srinivasan
Quoted 1 line · K. Y. Srinivasan

This is a resend of the patches from Dexuan and Nicholas

What do you mean by "resend"? Did you send them to be before? I can't see them in my inbox anywhere.

confused,

greg k-h

#8 lore raw
Quoted 11 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Tuesday, February 3, 2015 3:45 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH RESEND 0/6] Drivers: hv: vmbus: Some miscellaneous bug fixes and cleanup

Quoted 7 lines
Quoted 1 line · K. Y. Srinivasan

This is a resend of the patches from Dexuan and Nicholas

What do you mean by "resend"? Did you send them to be before? I can't see them in my inbox anywhere.

confused,

Greg,

You had asked me to resend patches after reviewing them and making sure they applied cleanly. These patches were posted on LKML earlier; I resent them.

K. Y

Quoted 2 lines

greg k-h

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

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Tuesday, February 3, 2015 3:45 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH RESEND 0/6] Drivers: hv: vmbus: Some miscellaneous bug fixes and cleanup

Quoted 1 line · K. Y. Srinivasan

This is a resend of the patches from Dexuan and Nicholas

What do you mean by "resend"? Did you send them to be before? I can't see them in my inbox anywhere.

Quoted 6 lines
Quoted 1 line

confused,

Greg,

You had asked me to resend patches after reviewing them and making sure they applied cleanly. These patches were posted on LKML earlier; I resent them.

But I didn't know that, as you hadn't sent them to me before.

Please collect all hyperv patches and send them to me in batches like other subsystem maintainers do, it makes it easier for me as I'm obviously easy to get confused here...

thanks,

greg k-h

#10 lore raw
Quoted 35 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Tuesday, February 3, 2015 4:01 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH RESEND 0/6] Drivers: hv: vmbus: Some miscellaneous bug fixes and cleanup

Quoted 17 lines · KY Srinivasan
Quoted 17 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Tuesday, February 3, 2015 3:45 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH RESEND 0/6] Drivers: hv: vmbus: Some miscellaneous bug fixes and cleanup

Quoted 1 line · K. Y. Srinivasan

This is a resend of the patches from Dexuan and Nicholas

What do you mean by "resend"? Did you send them to be before? I can't see them in my inbox anywhere.

Quoted 6 lines
Quoted 1 line

confused,

Greg,

You had asked me to resend patches after reviewing them and making sure they applied cleanly. These patches were posted on LKML earlier; I

Quoted 7 lines

resent them.

But I didn't know that, as you hadn't sent them to me before.

Please collect all hyperv patches and send them to me in batches like other subsystem maintainers do, it makes it easier for me as I'm obviously easy to get confused here...

Will do.

K. Y

Quoted 4 lines

thanks,

greg k-h