linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: kys@exchange.microsoft.com
To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
	devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com,
	vkuznets@redhat.com, jasowang@redhat.com,
	leann.ogasawara@canonical.com, sthemmin@microsoft.com
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Subject: [PATCH V2 14/14] Drivers: hv: vmbus: On the read path cleanup the logic to interrupt the host
Date: Tue,  1 Nov 2016 13:07:34 -0700	[thread overview]
Message-ID: <1478030854-5970-14-git-send-email-kys@exchange.microsoft.com> (raw)
In-Reply-To: <1478030854-5970-1-git-send-email-kys@exchange.microsoft.com>

From: K. Y. Srinivasan <kys@microsoft.com>

Signal the host when we determine the host is to be signaled -
on th read path. The currrent code determines the need to signal in the
ringbuffer code and actually issues the signal elsewhere. This can result
in the host viewing this interrupt as spurious since the host may also
poll the channel. Make the necessary adjustments.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 drivers/hv/channel.c      |   11 ++---------
 drivers/hv/hyperv_vmbus.h |    4 ++--
 drivers/hv/ring_buffer.c  |    7 ++++---
 include/linux/hyperv.h    |   12 ++++++------
 4 files changed, 14 insertions(+), 20 deletions(-)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 8a8148f..5fb4c6d 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -879,16 +879,9 @@ int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel,
 		   u32 bufferlen, u32 *buffer_actual_len, u64 *requestid,
 		   bool raw)
 {
-	int ret;
-	bool signal = false;
-
-	ret = hv_ringbuffer_read(&channel->inbound, buffer, bufferlen,
-				 buffer_actual_len, requestid, &signal, raw);
+	return hv_ringbuffer_read(channel, buffer, bufferlen,
+				  buffer_actual_len, requestid, raw);
 
-	if (signal)
-		vmbus_setevent(channel);
-
-	return ret;
 }
 
 int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer,
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 2d42ebe..0675b39 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -532,9 +532,9 @@ int hv_ringbuffer_write(struct vmbus_channel *channel,
 		    u32 kv_count, bool lock,
 		    bool kick_q);
 
-int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info,
+int hv_ringbuffer_read(struct vmbus_channel *channel,
 		       void *buffer, u32 buflen, u32 *buffer_actual_len,
-		       u64 *requestid, bool *signal, bool raw);
+		       u64 *requestid, bool raw);
 
 void hv_ringbuffer_get_debuginfo(struct hv_ring_buffer_info *ring_info,
 			    struct hv_ring_buffer_debug_info *debug_info);
diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index 4af7130..cd49cb1 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -353,9 +353,9 @@ int hv_ringbuffer_write(struct vmbus_channel *channel,
 	return 0;
 }
 
-int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info,
+int hv_ringbuffer_read(struct vmbus_channel *channel,
 		       void *buffer, u32 buflen, u32 *buffer_actual_len,
-		       u64 *requestid, bool *signal, bool raw)
+		       u64 *requestid, bool raw)
 {
 	u32 bytes_avail_toread;
 	u32 next_read_location = 0;
@@ -364,6 +364,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info,
 	u32 offset;
 	u32 packetlen;
 	int ret = 0;
+	struct hv_ring_buffer_info *inring_info = &channel->inbound;
 
 	if (buflen <= 0)
 		return -EINVAL;
@@ -421,7 +422,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info,
 	/* Update the read index */
 	hv_set_next_read_location(inring_info, next_read_location);
 
-	*signal = hv_need_to_signal_on_read(inring_info);
+	hv_signal_on_read(channel);
 
 	return ret;
 }
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 8cf78ed..fdb0a87 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -1487,10 +1487,11 @@ int vmbus_send_tl_connect_request(const uuid_le *shv_guest_servie_id,
  *    there is room for the producer to send the pending packet.
  */
 
-static inline  bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi)
+static inline  void hv_signal_on_read(struct vmbus_channel *channel)
 {
 	u32 cur_write_sz;
 	u32 pending_sz;
+	struct hv_ring_buffer_info *rbi = &channel->inbound;
 
 	/*
 	 * Issue a full memory barrier before making the signaling decision.
@@ -1508,14 +1509,14 @@ static inline  bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi)
 	pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz);
 	/* If the other end is not blocked on write don't bother. */
 	if (pending_sz == 0)
-		return false;
+		return;
 
 	cur_write_sz = hv_get_bytes_to_write(rbi);
 
 	if (cur_write_sz >= pending_sz)
-		return true;
+		vmbus_setevent(channel);
 
-	return false;
+	return;
 }
 
 /*
@@ -1587,8 +1588,7 @@ static inline void commit_rd_index(struct vmbus_channel *channel)
 	virt_rmb();
 	ring_info->ring_buffer->read_index = ring_info->priv_read_index;
 
-	if (hv_need_to_signal_on_read(ring_info))
-		vmbus_set_event(channel);
+	hv_signal_on_read(channel);
 }
 
 
-- 
1.7.4.1

      parent reply	other threads:[~2016-11-01 18:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-01 20:06 [PATCH V2 00/14] Drivers: hv: Some miscellaneous fixes and enhancements kys
2016-11-01 20:07 ` [PATCH V2 01/14] Drivers: hv: ring_buffer: count on wrap around mappings in get_next_pkt_raw() (v2) kys
2016-11-01 20:07   ` [PATCH V2 02/14] Drivers: hv: utils: reduce HV_UTIL_NEGO_TIMEOUT timeout kys
2016-11-01 20:07   ` [PATCH V2 03/14] Drivers: hv: utils: Fix the mapping between host version and protocol to use kys
2016-11-01 20:07   ` [PATCH V2 04/14] Drivers: hv: balloon: Disable hot add when CONFIG_MEMORY_HOTPLUG is not set kys
2016-11-01 20:07   ` [PATCH V2 05/14] Drivers: hv: balloon: Add logging for dynamic memory operations kys
2016-11-01 20:07   ` [PATCH V2 06/14] Drivers: hv: vss: Improve log messages kys
2016-11-01 20:07   ` [PATCH V2 07/14] Drivers: hv: vss: Operation timeouts should match host expectation kys
2016-11-01 20:07   ` [PATCH V2 08/14] Drivers: hv: balloon: Fix info request to show max page count kys
2016-11-10 19:09     ` Dan Carpenter
2016-11-10 19:38       ` Alex Ng (LIS)
2016-11-01 20:07   ` [PATCH V2 09/14] tools: hv: remove unnecessary link flag kys
2016-11-01 20:07   ` [PATCH V2 10/14] tools: hv: fix a compile warning in snprintf kys
2016-11-01 20:07   ` [PATCH V2 11/14] tools: hv: remove unnecessary header files and netlink related code kys
2016-11-01 20:07   ` [PATCH V2 12/14] Drivers: hv: vmbus: Base host signaling strictly on the ring state kys
2016-11-01 20:07   ` [PATCH V2 13/14] Drivers: hv: vmbus: On write cleanup the logic to interrupt the host kys
2016-11-01 20:07   ` kys [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1478030854-5970-14-git-send-email-kys@exchange.microsoft.com \
    --to=kys@exchange.microsoft.com \
    --cc=apw@canonical.com \
    --cc=devel@linuxdriverproject.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jasowang@redhat.com \
    --cc=kys@microsoft.com \
    --cc=leann.ogasawara@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olaf@aepfle.de \
    --cc=sthemmin@microsoft.com \
    --cc=vkuznets@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).