]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
Drivers: hv: vmbus: remove code duplication in message handling
authorVitaly Kuznetsov <vkuznets@redhat.com>
Fri, 26 Feb 2016 23:13:17 +0000 (15:13 -0800)
committerTim Gardner <tim.gardner@canonical.com>
Wed, 6 Apr 2016 09:29:04 +0000 (10:29 +0100)
BugLink: http://bugs.launchpad.net/bugs/1541585
We have 3 functions dealing with messages and they all implement
the same logic to finalize reads, move it to vmbus_signal_eom().

Suggested-by: Radim Krcmar <rkrcmar@redhat.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Reviewed-by: Radim Kr.má<rkrcmar@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 0f70b66975ce4331e9002b792d5aa6787a110181)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
drivers/hv/channel_mgmt.c
drivers/hv/hyperv_vmbus.h
drivers/hv/vmbus_drv.c

index f70e35278b94d5efc31c10681deb13a16173cc7d..73a17be1f340a31a6c0e177599a3674cdb2d7153 100644 (file)
@@ -614,15 +614,7 @@ static void vmbus_wait_for_unload(void)
                if (hdr->msgtype == CHANNELMSG_UNLOAD_RESPONSE)
                        unloaded = true;
 
-               msg->header.message_type = HVMSG_NONE;
-               /*
-                * header.message_type needs to be written before we do
-                * wrmsrl() below.
-                */
-               mb();
-
-               if (msg->header.message_flags.msg_pending)
-                       wrmsrl(HV_X64_MSR_EOM, 0);
+               vmbus_signal_eom(msg);
 
                if (unloaded)
                        break;
index e1e7634977a5ef68371694ca41cbda5d138a0919..12321b93a756b947f09b95f79dade93849794040 100644 (file)
@@ -619,6 +619,30 @@ struct vmbus_channel_message_table_entry {
 extern struct vmbus_channel_message_table_entry
        channel_message_table[CHANNELMSG_COUNT];
 
+/* Free the message slot and signal end-of-message if required */
+static inline void vmbus_signal_eom(struct hv_message *msg)
+{
+       msg->header.message_type = HVMSG_NONE;
+
+       /*
+        * Make sure the write to MessageType (ie set to
+        * HVMSG_NONE) happens before we read the
+        * MessagePending and EOMing. Otherwise, the EOMing
+        * will not deliver any more messages since there is
+        * no empty slot
+        */
+       mb();
+
+       if (msg->header.message_flags.msg_pending) {
+               /*
+                * This will cause message queue rescan to
+                * possibly deliver another msg from the
+                * hypervisor
+                */
+               wrmsrl(HV_X64_MSR_EOM, 0);
+       }
+}
+
 /* General vmbus interface */
 
 struct hv_device *vmbus_device_create(const uuid_le *type,
index 0ed587a9f31b75bd13297075ee9374eddc422d7d..64713ff47e36c73e70d429dd6650d27d3e2e1d97 100644 (file)
@@ -708,25 +708,7 @@ static void hv_process_timer_expiration(struct hv_message *msg, int cpu)
        if (dev->event_handler)
                dev->event_handler(dev);
 
-       msg->header.message_type = HVMSG_NONE;
-
-       /*
-        * Make sure the write to MessageType (ie set to
-        * HVMSG_NONE) happens before we read the
-        * MessagePending and EOMing. Otherwise, the EOMing
-        * will not deliver any more messages since there is
-        * no empty slot
-        */
-       mb();
-
-       if (msg->header.message_flags.msg_pending) {
-               /*
-                * This will cause message queue rescan to
-                * possibly deliver another msg from the
-                * hypervisor
-                */
-               wrmsrl(HV_X64_MSR_EOM, 0);
-       }
+       vmbus_signal_eom(msg);
 }
 
 void vmbus_on_msg_dpc(unsigned long data)
@@ -764,25 +746,7 @@ void vmbus_on_msg_dpc(unsigned long data)
                entry->message_handler(hdr);
 
 msg_handled:
-       msg->header.message_type = HVMSG_NONE;
-
-       /*
-        * Make sure the write to MessageType (ie set to
-        * HVMSG_NONE) happens before we read the
-        * MessagePending and EOMing. Otherwise, the EOMing
-        * will not deliver any more messages since there is
-        * no empty slot
-        */
-       mb();
-
-       if (msg->header.message_flags.msg_pending) {
-               /*
-                * This will cause message queue rescan to
-                * possibly deliver another msg from the
-                * hypervisor
-                */
-               wrmsrl(HV_X64_MSR_EOM, 0);
-       }
+       vmbus_signal_eom(msg);
 }
 
 static void vmbus_isr(void)