Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4187469pxk; Tue, 8 Sep 2020 13:00:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGUQkVRLbjzrseF10wYMIK0KwHY7lbivJ5sGe0IuFy/OzP4XEm7KUq7SLH6UHUXZKkrLgU X-Received: by 2002:aa7:d558:: with SMTP id u24mr724563edr.336.1599595241383; Tue, 08 Sep 2020 13:00:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599595241; cv=none; d=google.com; s=arc-20160816; b=XH1EzbT/KhnM8YVaYo3PtBz73K3YInHzz8QMwHbXG6Wt+jEsRDd5u5XA36g1s4y555 YeWzDGES+4+F+vqFrZXMSIg1tQ00levnnvPEZTwhsQsLKRBZqjSuR4L/kyXvnyyI+pAI Dge1VsY8dzBjLe1sqpixZ5x1Na6WabUa25/sALVLJFVa9CT5DTEyL53hiJj7rLFWCWBS R7b5ngAY1HUAsjYsF3UannxaJp9Ghlhu0QSFqsXss6jC16cuVPfgclRy4hL0zv+2Y8PQ UiEkNXuq9+ewUqdf5L7kdSGgdqoVxnlFAUF8SrO/rDT0q3dbMqfDtAVALUl78PE05uWU qu9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=k6GEBDLVEDDnc4RG29z1zCxFO3LkT6WXFDvvXsLEY1w=; b=ZKTTRHgNEqsNKOkTumiXTbwYQ49I2UFfu/LEWE5/vMNd+DIDMNu9zYxDXM9izcETCf GM3+j1FzuMj9Zj8xtBi43SIjXsbnO6i51X8KnO8QCqDl1KzaUbjHvP5/AV5DgPt1JjkF qhfwhVC3FZy2MA62yESPbe/0J4L7a/3v0WPnoOXbW2KKHo3mokzUvtw1Xck8kizohX/T TJzjM4i4RYBZCob8Zy/c/tk8kLWGDjNDRYjX79XELS6Ll1vrgs+AkI+LcsK7aAGaIx92 /k7pZIebrmeUS+856EL/knfkhOAAV6TgmnUSd+/5Z929wxIPT2j+8in8PBp7dj7UJ9gn YkFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=n9tGFOjq; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j14si71387edp.315.2020.09.08.13.00.18; Tue, 08 Sep 2020 13:00:41 -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=@kernel.org header.s=default header.b=n9tGFOjq; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732532AbgIHT5q (ORCPT + 99 others); Tue, 8 Sep 2020 15:57:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:60636 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730543AbgIHPfu (ORCPT ); Tue, 8 Sep 2020 11:35:50 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 567C3224DE; Tue, 8 Sep 2020 15:35:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599579301; bh=TNr20Rhq1tcURGtfYe8xVwLGmJ82ca1qiqhUd7CC3Ns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n9tGFOjqLZFoMIbC0oeKXmZm7bTEBU80ap4Gp2NsnjyHVvGjTt6VQYXJa4Ql5envn sit+WiSfQBkSLf25PrQlw7U5W2zJc7bTz0zNSH+pAAe0eeJIhRrmJFaMrjroFdN+dl CT0h/qDaODWFOCGCounVv3BSWV3sTeCeZwtOYUAA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vineeth Pillai , Michael Kelley , Wei Liu , Sasha Levin Subject: [PATCH 5.8 021/186] hv_utils: drain the timesync packets on onchannelcallback Date: Tue, 8 Sep 2020 17:22:43 +0200 Message-Id: <20200908152242.685692310@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200908152241.646390211@linuxfoundation.org> References: <20200908152241.646390211@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vineeth Pillai [ 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 Reviewed-by: Michael Kelley Link: https://lore.kernel.org/r/20200821152849.99517-1-viremana@linux.microsoft.com Signed-off-by: Wei Liu Signed-off-by: Sasha Levin --- 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 1f86e8d9b018d..a4e8d96513c22 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.25.1