All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] hv_utils: drain the timesync packets on onchannelcallback
@ 2020-08-21 15:28 Vineeth Pillai
  2020-08-21 15:45 ` Michael Kelley
  2020-08-22  8:55 ` Wei Liu
  0 siblings, 2 replies; 5+ messages in thread
From: Vineeth Pillai @ 2020-08-21 15:28 UTC (permalink / raw)
  To: Haiyang Zhang, Stephen Hemminger, Wei Liu
  Cc: Vineeth Pillai, K . Y . Srinivasan, linux-hyperv, linux-kernel

There could be instances where a system stall prevents the timesync
packaets to be consumed. And this might lead to more than one packet
pending in the ring buffer. Current code empties one packet per callback
and it might be a stale one. So drain all the packets from ring buffer
on each callback.

Signed-off-by: Vineeth Pillai <viremana@linux.microsoft.com>
---

 v2:
    - s/pr_warn/pr_warn_once/
    
---
 drivers/hv/hv_util.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/hv/hv_util.c b/drivers/hv/hv_util.c
index 1f86e8d9b018..a4e8d96513c2 100644
--- a/drivers/hv/hv_util.c
+++ b/drivers/hv/hv_util.c
@@ -387,10 +387,23 @@ static void timesync_onchannelcallback(void *context)
 	struct ictimesync_ref_data *refdata;
 	u8 *time_txf_buf = util_timesynch.recv_buffer;
 
-	vmbus_recvpacket(channel, time_txf_buf,
-			 HV_HYP_PAGE_SIZE, &recvlen, &requestid);
+	/*
+	 * Drain the ring buffer and use the last packet to update
+	 * host_ts
+	 */
+	while (1) {
+		int ret = vmbus_recvpacket(channel, time_txf_buf,
+					   HV_HYP_PAGE_SIZE, &recvlen,
+					   &requestid);
+		if (ret) {
+			pr_warn_once("TimeSync IC pkt recv failed (Err: %d)\n",
+				     ret);
+			break;
+		}
+
+		if (!recvlen)
+			break;
 
-	if (recvlen > 0) {
 		icmsghdrp = (struct icmsg_hdr *)&time_txf_buf[
 				sizeof(struct vmbuspipe_hdr)];
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [PATCH v2] hv_utils: drain the timesync packets on onchannelcallback
  2020-08-21 15:28 [PATCH v2] hv_utils: drain the timesync packets on onchannelcallback Vineeth Pillai
@ 2020-08-21 15:45 ` Michael Kelley
  2020-08-22  8:55 ` Wei Liu
  1 sibling, 0 replies; 5+ messages in thread
From: Michael Kelley @ 2020-08-21 15:45 UTC (permalink / raw)
  To: Vineeth Pillai, Haiyang Zhang, Stephen Hemminger, Wei Liu
  Cc: KY Srinivasan, linux-hyperv, linux-kernel

From: viremana@linux.microsoft.com Sent: Friday, August 21, 2020 8:29 AM
> 
> There could be instances where a system stall prevents the timesync
> packaets to be consumed. And this might lead to more than one packet
> pending in the ring buffer. Current code empties one packet per callback
> and it might be a stale one. So drain all the packets from ring buffer
> on each callback.
> 
> Signed-off-by: Vineeth Pillai <viremana@linux.microsoft.com>
> ---
> 
>  v2:
>     - s/pr_warn/pr_warn_once/
> 
> ---
>  drivers/hv/hv_util.c | 19 ++++++++++++++++---
>  1 file changed, 16 insertions(+), 3 deletions(-)

Reviewed-by: Michael Kelley <mikelley@microsoft.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] hv_utils: drain the timesync packets on onchannelcallback
  2020-08-21 15:28 [PATCH v2] hv_utils: drain the timesync packets on onchannelcallback Vineeth Pillai
  2020-08-21 15:45 ` Michael Kelley
@ 2020-08-22  8:55 ` Wei Liu
  2020-08-23 12:15   ` Vineeth Pillai
  1 sibling, 1 reply; 5+ messages in thread
From: Wei Liu @ 2020-08-22  8:55 UTC (permalink / raw)
  To: Vineeth Pillai
  Cc: Haiyang Zhang, Stephen Hemminger, Wei Liu, K . Y . Srinivasan,
	linux-hyperv, linux-kernel

On Fri, Aug 21, 2020 at 03:28:49PM +0000, Vineeth Pillai wrote:
> There could be instances where a system stall prevents the timesync
> packaets to be consumed. And this might lead to more than one packet

Typo "packaet".

No need to resend. I can fix this while committing this patch.

Wei.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] hv_utils: drain the timesync packets on onchannelcallback
  2020-08-22  8:55 ` Wei Liu
@ 2020-08-23 12:15   ` Vineeth Pillai
  2020-08-24 14:51     ` Wei Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Vineeth Pillai @ 2020-08-23 12:15 UTC (permalink / raw)
  To: Wei Liu
  Cc: Haiyang Zhang, Stephen Hemminger, K . Y . Srinivasan,
	linux-hyperv, linux-kernel


> Typo "packaet".
>
> No need to resend. I can fix this while committing this patch.

Thanks Wei.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] hv_utils: drain the timesync packets on onchannelcallback
  2020-08-23 12:15   ` Vineeth Pillai
@ 2020-08-24 14:51     ` Wei Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Wei Liu @ 2020-08-24 14:51 UTC (permalink / raw)
  To: Vineeth Pillai
  Cc: Wei Liu, Haiyang Zhang, Stephen Hemminger, K . Y . Srinivasan,
	linux-hyperv, linux-kernel

On Sun, Aug 23, 2020 at 08:15:41AM -0400, Vineeth Pillai wrote:
> 
> > Typo "packaet".
> > 
> > No need to resend. I can fix this while committing this patch.
> 
> Thanks Wei.
> 
> 

Applied to hyperv-fixes. Thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-08-24 14:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-21 15:28 [PATCH v2] hv_utils: drain the timesync packets on onchannelcallback Vineeth Pillai
2020-08-21 15:45 ` Michael Kelley
2020-08-22  8:55 ` Wei Liu
2020-08-23 12:15   ` Vineeth Pillai
2020-08-24 14:51     ` Wei Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.