Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp338471pxa; Fri, 21 Aug 2020 08:32:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEDKj4qRREGhKARFvs62wokwDBO4tAGfTXEtPiFr8yaogoI9c1HJsKZbHsHQ/ZBERwOcxP X-Received: by 2002:a17:906:4696:: with SMTP id a22mr3433822ejr.154.1598023937453; Fri, 21 Aug 2020 08:32:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598023937; cv=none; d=google.com; s=arc-20160816; b=zpF88/JOJr8+DbiXqEQtCMr87LPcEyS6yQSwIiFKeditSKEoZbW8+caF68/ch5hCEn EuSaNgbZzt6y/j2lAe8qPKa4Ejqqnu0wehh6iYlYh6uT07I/PKIl+HO8FPEchTlhCk0H LSJocVcWHdHcbnS9nQVbgBeRlGKpkGAVUuUxjn2PhIr683lJTDs407CsrCtRRi4udvl7 e3pE0PfXHMfA+3DuXj0M3i8iYEGLHDKzujW503JwYFX/NSyeRghe+qmXQ/TGNKbRUREy 1bQJ4bh0aMbVAGw0TPjclhstdOR5h4q29xIsG4VIp0f7HZnNWroQBrV7jyTd622lUpsE KUuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=1Xx3fDRP6HUhJQ0/HwzwV1+TX9mHcQq7j3/A5j4Vz/s=; b=REDwdJgkec45cT9qCE+lvLTO3fMqizkOHPUXUdyJTjqJHlwzvu76qAD4mhBLiPKGgh vJA1+AkdD/ez/xN6XMTOwDAYgB/H/tXcnPOpjs+62xOibSZcOQ7p7Wc3YPP4ZQFxi4UC 9oguJBGXYg0JNzjQ02/8mG+7wGRjHQxZ6Mz/VZKZkRFIumiLR8NcH8GxommWyFGQ5TGR qsolX9QTifzDhs7pd1MTsiyaBBfQcIeAJKDXXA/60NwYaSMvUJcWAzOIP58IiNUm491Q 78edt1dqAacqDrWirlYQ0+bxojSxe7/GUvNNu3SuYNE1YSYGC82y+CNQA7U+9Yt/MfeM mcDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=BOLOIn2b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p18si1374602eds.144.2020.08.21.08.31.53; Fri, 21 Aug 2020 08:32:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=BOLOIn2b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728327AbgHUPaP (ORCPT + 99 others); Fri, 21 Aug 2020 11:30:15 -0400 Received: from linux.microsoft.com ([13.77.154.182]:47226 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728253AbgHUP3D (ORCPT ); Fri, 21 Aug 2020 11:29:03 -0400 Received: from testvm-timer.0wqf5yk0ngwuzjntifuk1ppqse.cx.internal.cloudapp.net (unknown [40.65.222.102]) by linux.microsoft.com (Postfix) with ESMTPSA id 7AE1320B4908; Fri, 21 Aug 2020 08:29:02 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 7AE1320B4908 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1598023743; bh=1Xx3fDRP6HUhJQ0/HwzwV1+TX9mHcQq7j3/A5j4Vz/s=; h=From:To:Cc:Subject:Date:From; b=BOLOIn2bYM+SGapuZTTujMnaSM6QFuksi5YdgkIXG/JxKQ7d4OKh2ap5o8+iMMUqd E5FvTQb4DW+TvE6MTI9Q/Gai+6/UDnKDEpXxrRZaE+Z2PCkj0agWIzPqDdnGExjZW2 M+4Emlcn9JP16t4F41OOo+vIq2TwLr4Efg/Lvz2Y= From: Vineeth Pillai To: Haiyang Zhang , Stephen Hemminger , Wei Liu Cc: Vineeth Pillai , "K . Y . Srinivasan" , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] hv_utils: drain the timesync packets on onchannelcallback Date: Fri, 21 Aug 2020 15:28:49 +0000 Message-Id: <20200821152849.99517-1-viremana@linux.microsoft.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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