Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1057820pxk; Mon, 31 Aug 2020 08:40:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrn6FmM/3CU9OTcXzvIDJuLRRTT1+x1DHvrWJnAF52dTZZxlJte7mly3SqwahwDPk54Jlj X-Received: by 2002:a17:906:25c1:: with SMTP id n1mr1664866ejb.463.1598888445341; Mon, 31 Aug 2020 08:40:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598888445; cv=none; d=google.com; s=arc-20160816; b=gsMVBPqhrbOtMV6sobUOml6BcGWgoIGc1i4R6wSKB52pHZsvLv4dunCJQadAWUTB10 3qoI9SLK6lqryyc+X0SEGuvTVzbb0dseQD/qqEytBIGWS9RQg+EUjCPYmL7sYNpupy58 cFoBm/JzpvUXS/9ZfRHdKIhwIrl0oSer0dcOKXQMXzxOTQ1Al/hd0eGKhEOygrfNOYqK enQyNcPAdVcpFIDC5eBLcO9qxVgREl8FVvK7khUHuYdygw4TpnDNGbs4+g73NUN2rN+n 94lOjBTM5MUGnDd3R+XlncQsir0mitp/O5ELM5GeDCO4Gv/YY7wxeGmTYx9CjPMgSqeh mUtA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=k6GEBDLVEDDnc4RG29z1zCxFO3LkT6WXFDvvXsLEY1w=; b=nighP2xk9clC9UL3nY/UoAfD649MMogJ0bw6jqy7I9e61sG8CKqEb7M4K5ZteqqbkS arjkdTTG+ZI+bkFcIjphihsRG2ptQi0g0XUhZxFZga2NkCCdgXReN5v2Or1UVCVzFo9U w7lBYuJwEYPY5aukqPPl+gTXpiimMvrzF2kNxHq+P3YjLhEilXzj7L44XgwLNg6z7IXc YhP+yOFGvvE5PtD1XiURn5Dvi7pQMM1vvFgGrcOOypMx41009o3Wu7S8g4X9p9Srl2cI YYeAY0vYi6cSJU/qABGDVluhKxTcRZDJup7AlAKHH1NEydKvy+ir4LQja++KznuJ6aBL UbyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JSHVZ2JT; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id di24si2301982edb.608.2020.08.31.08.40.22; Mon, 31 Aug 2020 08:40:45 -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=JSHVZ2JT; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728597AbgHaPaW (ORCPT + 99 others); Mon, 31 Aug 2020 11:30:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:39106 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728546AbgHaPaM (ORCPT ); Mon, 31 Aug 2020 11:30:12 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A2B232151B; Mon, 31 Aug 2020 15:30:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598887810; bh=TNr20Rhq1tcURGtfYe8xVwLGmJ82ca1qiqhUd7CC3Ns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JSHVZ2JT7XZTYmLU1JNPU4/hflzH0AJ9gWCI2V33tl3mc69sssllxuegoyf9EGvKQ LlDRMt2F30hbAo4R5W7n9u3hyC1zk0py0Tw1HDHzH1BXZqjQWC1sZMiH0w+/VhdlKt pJ/jyj5OGr+o3Vxo5SQPTnBxjRktRwQuWGX6MnPs= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Vineeth Pillai , Michael Kelley , Wei Liu , Sasha Levin , linux-hyperv@vger.kernel.org Subject: [PATCH AUTOSEL 5.8 24/42] hv_utils: drain the timesync packets on onchannelcallback Date: Mon, 31 Aug 2020 11:29:16 -0400 Message-Id: <20200831152934.1023912-24-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200831152934.1023912-1-sashal@kernel.org> References: <20200831152934.1023912-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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