summaryrefslogtreecommitdiff
path: root/drivers/hv
diff options
context:
space:
mode:
authorVineeth Pillai <viremana@linux.microsoft.com>2020-08-21 18:28:49 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-09-09 20:14:10 +0300
commit94fd015fe91f7f3980218ab363c045b2d80122ba (patch)
treef489fac01b18b58bce0e0e1dcc40f252a67150f0 /drivers/hv
parent6a725c83a08d41f2bc1630835712a4edc2e6caad (diff)
downloadlinux-94fd015fe91f7f3980218ab363c045b2d80122ba.tar.xz
hv_utils: drain the timesync packets on onchannelcallback
[ Upstream commit b46b4a8a57c377b72a98c7930a9f6969d2d4784e ] There could be instances where a system stall prevents the timesync packets 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> Reviewed-by: Michael Kelley <mikelley@microsoft.com> Link: https://lore.kernel.org/r/20200821152849.99517-1-viremana@linux.microsoft.com Signed-off-by: Wei Liu <wei.liu@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/hv')
-rw-r--r--drivers/hv/hv_util.c19
1 files 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)];