Skip to contentSkip to conversation

Drivers: hv: Fixes

PATCH In review K. Y. Srinivasan 3 participants 11 messages Dec 12, 2011

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

cover Drivers: hv: Fixes

Some fixes to the vmbus driver:

1. Fix a memory leak in a failure path.

2. Make vmbus driver unloadable.

3. Get rid of an unnecessary check in hv_init() in preparation for supporting kexec().

4. Make it possible to build the vmbus driver as part of the kernel. This patch was submitted earlier, but seems to have been lost.

Regards,

K. Y

#1 lore raw

PATCH 1/4 Drivers: hv: Fix a memory leak

There was a memory leak in a failure path in vmbus_process_offer(). Fix it.

---
 drivers/hv/channel_mgmt.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/hv/channel_mgmt.c +1 -0
index 12b85ff..b91af50 100644
@@ -287,6 +287,7 @@ static void vmbus_process_offer(struct work_struct *work)
 		spin_lock_irqsave(&vmbus_connection.channel_lock, flags);
 		list_del(&newchannel->listentry);
 		spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags);
+		kfree(newchannel->device_obj);
 
 		free_channel(newchannel);
 	} else {
Signature · 1 line
1.7.4.1
#2 lore raw

PATCH 2/4 Drivers: hv: Make the vmbus driver unloadable

It turns out that the vmbus driver can be made unloadable. Make it unloadable.

---
 drivers/hv/channel_mgmt.c |   11 +++++++++++
 drivers/hv/hv.c           |    3 +++
 drivers/hv/hyperv_vmbus.h |    1 +
 drivers/hv/vmbus_drv.c    |   11 +++++++++++
 4 files changed, 26 insertions(+), 0 deletions(-)
drivers/hv/channel_mgmt.c +11 -0
index b91af50..36484db 100644
@@ -223,6 +223,17 @@ static void vmbus_process_rescind_offer(struct work_struct *work)
 	vmbus_device_unregister(channel->device_obj);
 }
 
+void vmbus_free_channels(void)
+{
+	struct vmbus_channel *channel;
+
+	list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
+		vmbus_device_unregister(channel->device_obj);
+		kfree(channel->device_obj);
+		free_channel(channel);
+	}
+}
+
 /*
  * vmbus_process_offer - Process the offer by creating a channel/device
  * associated with this offer
drivers/hv/hv.c +3 -0
index 0fb100e..f8a77d0 100644
@@ -237,6 +237,9 @@ void hv_cleanup(void)
 {
 	union hv_x64_msr_hypercall_contents hypercall_msr;
 
+	/* Reset our OS id */
+	wrmsrl(HV_X64_MSR_GUEST_OS_ID, 0);
+
 	kfree(hv_context.signal_event_buffer);
 	hv_context.signal_event_buffer = NULL;
 	hv_context.signal_event_param = NULL;
drivers/hv/hyperv_vmbus.h +1 -0
index 0aee112..6d7d286 100644
@@ -611,6 +611,7 @@ void vmbus_device_unregister(struct hv_device *device_obj);
 
 struct vmbus_channel *relid2channel(u32 relid);
 
+void vmbus_free_channels(void);
 
 /* Connection interface */
 
drivers/hv/vmbus_drv.c +11 -0
index 0c048dd..aafee6b 100644
@@ -779,8 +779,19 @@ cleanup:
 	return ret;
 }
 
+static void __exit vmbus_exit(void)
+{
+
+	free_irq(irq, hv_acpi_dev);
+	vmbus_free_channels();
+	bus_unregister(&hv_bus);
+	hv_cleanup();
+	acpi_bus_unregister_driver(&vmbus_acpi_driver);
+}
+
 
 MODULE_LICENSE("GPL");
 MODULE_VERSION(HV_DRV_VERSION);
 
 module_init(hv_acpi_init);
+module_exit(vmbus_exit);
Signature · 1 line
1.7.4.1
#3 lore raw

PATCH 3/4 Drivers: hv: Get rid of an unnecessary check in hv.c

In reply to K. Y. Srinivasan

In preparation for eventually supporting kexec in Linux VMs on Hyper-V, get rid of an unnecessary check in hv_init().

---
 drivers/hv/hv.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
drivers/hv/hv.c +0 -5
index f8a77d0..12aa97f 100644
@@ -164,11 +164,6 @@ int hv_init(void)
 
 	max_leaf = query_hypervisor_info();
 
-	rdmsrl(HV_X64_MSR_GUEST_OS_ID, hv_context.guestid);
-
-	if (hv_context.guestid != 0)
-		goto cleanup;
-
 	/* Write our OS info */
 	wrmsrl(HV_X64_MSR_GUEST_OS_ID, HV_LINUX_GUEST_ID);
 	hv_context.guestid = HV_LINUX_GUEST_ID;
Signature · 1 line
1.7.4.1
#4 lore raw

PATCH 4/4 Drivers: hv: Support building the vmbus driver as part of the kernel

In reply to K. Y. Srinivasan

Support building the vmbus driver as part of the kernel.

---
 drivers/hv/vmbus_drv.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/hv/vmbus_drv.c +1 -1
index aafee6b..1d3d809 100644
@@ -793,5 +793,5 @@ static void __exit vmbus_exit(void)
 MODULE_LICENSE("GPL");
 MODULE_VERSION(HV_DRV_VERSION);
 
-module_init(hv_acpi_init);
+subsys_initcall(hv_acpi_init);
 module_exit(vmbus_exit);
Signature · 1 line
1.7.4.1
#6 lore raw

RE: [PATCH 4/4] Drivers: hv: Support building the vmbus driver as part of the kernel

Quoted 12 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Monday, December 12, 2011 5:27 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Haiyang Zhang
Subject: Re: [PATCH 4/4] Drivers: hv: Support building the vmbus driver as part of the kernel

Quoted 7 lines
Quoted 4 lines · K. Y. Srinivasan

Support building the vmbus driver as part of the kernel.

This was already applied to my tree, I don't know why you missed it...

Thanks Greg. I pulled down your tree yesterday (staging.git) and checked out the staging-next branch and did not find the fix needed to build this driver as part of the kernel. I will check again.

Thanks,

K. Y

#7 lore raw

Re: [PATCH 4/4] Drivers: hv: Support building the vmbus driver as part of the kernel

Quoted 15 lines · KY Srinivasan
Quoted 15 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Monday, December 12, 2011 5:27 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Haiyang Zhang
Subject: Re: [PATCH 4/4] Drivers: hv: Support building the vmbus driver as part of the kernel

Quoted 2 lines · K. Y. Srinivasan

Support building the vmbus driver as part of the kernel.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

This was already applied to my tree, I don't know why you missed it...

Thanks Greg. I pulled down your tree yesterday (staging.git) and checked out the staging-next branch and did not find the fix needed to build this driver as part of the kernel. I will check again.

That is because I'm not applying these patches to the staging.git tree, as the commit messages you get show...

#8 lore raw

RE: [PATCH 4/4] Drivers: hv: Support building the vmbus driver as part of the kernel

Quoted 32 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Monday, December 12, 2011 6:49 PM
To: KY Srinivasan
Cc: Greg KH; [email protected]; [email protected]; [email protected]; [email protected]; Haiyang Zhang
Subject: Re: [PATCH 4/4] Drivers: hv: Support building the vmbus driver as part of the kernel

Quoted 8 lines · KY Srinivasan
Quoted 8 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Monday, December 12, 2011 5:27 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected];

[email protected];

Quoted 2 lines
Quoted 2 lines

Haiyang Zhang
Subject: Re: [PATCH 4/4] Drivers: hv: Support building the vmbus driver as

part of

Quoted 8 lines
Quoted 8 lines

the kernel

Quoted 4 lines · K. Y. Srinivasan

Support building the vmbus driver as part of the kernel.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

This was already applied to my tree, I don't know why you missed it...

Thanks Greg. I pulled down your tree yesterday (staging.git) and checked out the staging-next branch and did not find the fix needed to build this driver as part of the kernel. I will check again.

That is because I'm not applying these patches to the staging.git tree, as the commit messages you get show...

Oops! Thanks Greg.

Regards,

K. Y

#9 lore raw
In reply to K. Y. Srinivasan
Quoted 4 lines · K. Y. Srinivasan

Some fixes to the vmbus driver:

1. Fix a memory leak in a failure path.

Quoted 8 lines

2. Make vmbus driver unloadable.

3. Get rid of an unnecessary check in hv_init() in preparation for supporting kexec().

4. Make it possible to build the vmbus driver as part of the kernel. This patch was submitted earlier, but seems to have been lost.

No, it was not lost, it was applied to my driver-core-next tree a while ago. Because of this, I had to hand-edit patch 2 above and skip patch 4 here.

greg k-h

#10 lore raw
Quoted 20 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Monday, December 12, 2011 5:28 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 0000/0004] Drivers: hv: Fixes

Quoted 9 lines · K. Y. Srinivasan

Some fixes to the vmbus driver:

1. Fix a memory leak in a failure path.

2. Make vmbus driver unloadable.

3. Get rid of an unnecessary check in hv_init() in preparation for supporting kexec().

Quoted 7 lines
Quoted 3 lines

4. Make it possible to build the vmbus driver as part of the kernel. This patch was submitted earlier, but seems to have been lost.

No, it was not lost, it was applied to my driver-core-next tree a while ago. Because of this, I had to hand-edit patch 2 above and skip patch 4 here.

Thanks Greg. I will check to see why I got some stale bits yesterday.

Regards,

K. Y