Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0f70b669 authored by Vitaly Kuznetsov's avatar Vitaly Kuznetsov Committed by Greg Kroah-Hartman
Browse files

Drivers: hv: vmbus: remove code duplication in message handling



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: default avatarRadim Krcmar <rkrcmar@redhat.com>
Signed-off-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
Reviewed-by: default avatarRadim <Kr.má&lt;rkrcmar@redhat.com>
Signed-off-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 75ff3a8a
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -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;
+24 −0
Original line number Diff line number Diff line
@@ -624,6 +624,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,
+2 −38
Original line number Diff line number Diff line
@@ -709,25 +709,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);
}

static void vmbus_on_msg_dpc(unsigned long data)
@@ -765,25 +747,7 @@ static 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)