Drivers: hv: Make the vmbus driver unloadable
authorK. Y. Srinivasan <kys@microsoft.com>
Mon, 12 Dec 2011 17:29:17 +0000 (09:29 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 12 Dec 2011 22:26:50 +0000 (14:26 -0800)
It turns out that the vmbus driver can be made unloadable. Make it
unloadable.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/hv/channel_mgmt.c
drivers/hv/hv.c
drivers/hv/hyperv_vmbus.h
drivers/hv/vmbus_drv.c

index b91af50875e9ae4292009bc91e28dd265837aa83..36484db36baf01709846cd4224589a8863e9ab72 100644 (file)
@@ -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
index 0fb100ed91a36a79910b0d7fec72c51ca1aa4264..f8a77d01a5165cc0fb8b4bd80a7793bec4eda2c4 100644 (file)
@@ -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;
index 0aee1122734c45df8a5b98732b52d3695dade69a..6d7d286d54407789de589b9de83e07b85fc2c0ef 100644 (file)
@@ -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 */
 
index 40956d1c6608c80bbe1e51069a3ac201e4310dd5..c3875f72b5bfd0fe2d8cda46e425dd84554f6680 100644 (file)
@@ -795,8 +795,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);
 
 subsys_initcall(hv_acpi_init);
+module_exit(vmbus_exit);