]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
Drivers: hv: vmbus: Implement the protocol for tearing down vmbus state
authorK. Y. Srinivasan <kys@microsoft.com>
Thu, 23 Apr 2015 04:31:32 +0000 (21:31 -0700)
committerChuck Anderson <chuck.anderson@oracle.com>
Fri, 26 Feb 2016 02:28:42 +0000 (18:28 -0800)
Implement the protocol for tearing down the monitor state established with
the host.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Tested-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 2db84eff127e3f4b3635edc589cd6a56db8755a3)

Orabug: 21886720
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
drivers/hv/channel_mgmt.c
drivers/hv/connection.c
drivers/hv/hyperv_vmbus.h
drivers/hv/vmbus_drv.c
include/linux/hyperv.h

index 0eeb1b3bc0484ce75572b0f6326ca0857cb73268..0075f00ce04ff067dee91e377d91a18a19a993fa 100644 (file)
@@ -416,6 +416,30 @@ static void init_vp_index(struct vmbus_channel *channel, const uuid_le *type_gui
        channel->target_vp = hv_context.vp_index[cur_cpu];
 }
 
+/*
+ * vmbus_unload_response - Handler for the unload response.
+ */
+static void vmbus_unload_response(struct vmbus_channel_message_header *hdr)
+{
+       /*
+        * This is a global event; just wakeup the waiting thread.
+        * Once we successfully unload, we can cleanup the monitor state.
+        */
+       complete(&vmbus_connection.unload_event);
+}
+
+void vmbus_initiate_unload(void)
+{
+       struct vmbus_channel_message_header hdr;
+
+       init_completion(&vmbus_connection.unload_event);
+       memset(&hdr, 0, sizeof(struct vmbus_channel_message_header));
+       hdr.msgtype = CHANNELMSG_UNLOAD;
+       vmbus_post_msg(&hdr, sizeof(struct vmbus_channel_message_header));
+
+       wait_for_completion(&vmbus_connection.unload_event);
+}
+
 /*
  * vmbus_onoffer - Handler for channel offers from vmbus in parent partition.
  *
@@ -712,6 +736,7 @@ struct vmbus_channel_message_table_entry
        {CHANNELMSG_INITIATE_CONTACT,           0, NULL},
        {CHANNELMSG_VERSION_RESPONSE,           1, vmbus_onversion_response},
        {CHANNELMSG_UNLOAD,                     0, NULL},
+       {CHANNELMSG_UNLOAD_RESPONSE,            1, vmbus_unload_response},
 };
 
 /*
index b27220a425f4a44b6b1143f39017998f1b77533a..acd50e9d666ae96a56f003af725e32b36a6e333d 100644 (file)
@@ -227,6 +227,11 @@ cleanup:
 
 void vmbus_disconnect(void)
 {
+       /*
+        * First send the unload request to the host.
+        */
+       vmbus_initiate_unload();
+
        if (vmbus_connection.work_queue) {
                drain_workqueue(vmbus_connection.work_queue);
                destroy_workqueue(vmbus_connection.work_queue);
index 2f30456d90a5dbb5ad7c0a99c7926fbf6554b1e0..9a6c1fc03269ae08c0b5833fcf6d104aeb9cb88f 100644 (file)
@@ -647,6 +647,7 @@ struct vmbus_connection {
 
        atomic_t next_gpadl_handle;
 
+       struct completion  unload_event;
        /*
         * Represents channel interrupts. Each bit position represents a
         * channel.  When a channel sends an interrupt via VMBUS, it finds its
@@ -741,6 +742,7 @@ void hv_vss_onchannelcallback(void *);
 int hv_fcopy_init(struct hv_util_service *);
 void hv_fcopy_deinit(void);
 void hv_fcopy_onchannelcallback(void *);
+void vmbus_initiate_unload(void);
 
 static inline void hv_poll_channel(struct vmbus_channel *channel,
                                   void (*cb)(void *))
index c85235e9f245b6d210384673168bef12c6f9f0de..ebe4d338fd7799f46935dd6f78fd592f6accf578 100644 (file)
@@ -1096,6 +1096,7 @@ static void __exit vmbus_exit(void)
 
        vmbus_connection.conn_state = DISCONNECTED;
        hv_synic_clockevents_cleanup();
+       vmbus_disconnect();
        hv_remove_vmbus_irq();
        vmbus_free_channels();
        bus_unregister(&hv_bus);
@@ -1104,7 +1105,6 @@ static void __exit vmbus_exit(void)
                smp_call_function_single(cpu, hv_synic_cleanup, NULL, 1);
        acpi_bus_unregister_driver(&vmbus_acpi_driver);
        hv_cpu_hotplug_quirk(false);
-       vmbus_disconnect();
 }
 
 
index e29ccddc6300ec571bcb96f6ee669593568860e9..ea934864293d969463b8ff53dae6ea8d6164aa04 100644 (file)
@@ -389,6 +389,7 @@ enum vmbus_channel_message_type {
        CHANNELMSG_INITIATE_CONTACT             = 14,
        CHANNELMSG_VERSION_RESPONSE             = 15,
        CHANNELMSG_UNLOAD                       = 16,
+       CHANNELMSG_UNLOAD_RESPONSE              = 17,
        CHANNELMSG_COUNT
 };