Skip to contentSkip to conversation

hv_utils: drain the timesync packets on onchannelcallback

PATCH Applied Vineeth Pillai 3 participants 5 messages Aug 21, 2020 – Aug 24, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 hv_utils: drain the timesync packets on onchannelcallback

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.

---

v2:
- s/pr_warn/pr_warn_once/

---
 drivers/hv/hv_util.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/hv/hv_util.c +16 -3
index 1f86e8d9b018..a4e8d96513c2 100644
@@ -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)];
 
Signature · 1 line
2.17.1
Reviewed-by on v2 1/1
#1 lore raw

From: [email protected] Sent: Friday, August 21, 2020 8:29 AM

Quoted 8 lines

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.

Quoted 8 lines

---

v2:
- s/pr_warn/pr_warn_once/

---
 drivers/hv/hv_util.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
maintainer
#2 lore raw
In reply to Vineeth Pillai
Quoted 2 lines · Vineeth Pillai

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.

#3 lore raw
Quoted 4 lines

Typo "packaet".

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

Thanks Wei.

maintainer Applied
#4 lore raw
Quoted 8 lines · Vineeth Pillai
Quoted 4 lines

Typo "packaet".

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

Thanks Wei.

Applied to hyperv-fixes. Thanks.