Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2556668lqp; Mon, 25 Mar 2024 02:29:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWBvUbiB7CIklyTLln6gOYSRr45QHYPRpMGKbBlFfImgUFZ0ooVaNqJEyGkSTSPN9nAAg5xM173q7DDNSILRivhQIceePRgez+XjoOoZw== X-Google-Smtp-Source: AGHT+IFk12HnQFzKMOiMSWikoCVaRWJpulp3fomw9s/ftNi0H868ykXkha1LtepzqrSg/SClgIUM X-Received: by 2002:a05:620a:2955:b0:78a:5d01:deaf with SMTP id n21-20020a05620a295500b0078a5d01deafmr369562qkp.16.1711358999054; Mon, 25 Mar 2024 02:29:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711358999; cv=pass; d=google.com; s=arc-20160816; b=qPpL68DnB7SLpQJPjL9jeNkxmwETsZuwXR8SNXSpsnSsXWQCsgeBCnyQbWRsP8KhSs z4InLDSFQCmaFCcdhmaOOyqumoUIEhigtjUlMOaMt3pbGfSz2N8JGxsKf3WMZiXMK3gO AX+I7p+4PQhoQJkEvk+U7oiT8upHo6cfGTu7wbP5Ia+YzSf3amJu9WF6mM9OVHITWyay HsFwgV8Z5LbduYer2bCK9YfPWAo5cHWqGhK6YroPIlSH8OUPa0MeffJmcnQvVVk1WK6p aLpLNQtZEH9ajnNcs2jr36Q7pYoK22hWpUVdZHSEpvTgf0zZivvsBK9ZYIzg+Qq3Xslb I81Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=S97rACBEUwqDXf2ISV88D4ZftMVe/s1vWc8OIURs4Pc=; fh=Kup36vPmDrRX/ZED4HiLo7D05zuBWldEjkgKP/N/E5c=; b=QmqoR5n8M3ola1Kbq7fb8fH8pQD8Eem9TysIzJAxkCmRxLr7vvA6XW534QILZFJwCE YbgjamMj58zvXPXjXnzV8hFDnyXjcFR1pM0P4VATbGZ9i4iO9AaQHur6R6D15dsjvYox A2CDCZ4cdj0RiSJvNR0ARpVdk2F6sbb5jYLoyn/33Mie3I4t9ImJPsVye2uh/wl+VZWY gRHxqI7GoG1DUaS+bHugFhb2zxTab2pUluLoSkygn7ukJi8/8wQyZvgxjiVg+5w86i25 Dsiu41g4/OC6T/ODLoViXo4DC48axABU+XvlaVy2z40IMmKYCYrhWTr/hcbShs+E3mqL XF4Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iIj4OWZB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115831-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115831-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id z24-20020a05620a261800b0078a46d1adebsi4872449qko.623.2024.03.25.02.29.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 02:29:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115831-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iIj4OWZB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115831-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115831-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C2CBD1C315CC for ; Mon, 25 Mar 2024 09:29:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9797416E861; Mon, 25 Mar 2024 03:01:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iIj4OWZB" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 957DF145B0D; Sun, 24 Mar 2024 23:13:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322006; cv=none; b=eoGvcv9RFnoqeyHGlt3hjlZcyEMMkcq6J4tLR7BQmXFD53O3Cy9DK/3OZSgRnS+wTf1QvLPzswO2K2F8U/fGoJSle7krLXN+/MNphWlyJxOii5ty6kYwKkaXSCO7VCGE98tvXfAsT71lytA0sX11+aQyQogeZI1/wSE3NqY0UoY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322006; c=relaxed/simple; bh=KxKDHMnXXNeIqJdD5tAEXkK5ykdmBQbtB7cCktcMVQ0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mCAJJkL2gfY+15n0zbT6ZiJzG4rCpbLOHD1mO3AM0e2Fg/nUE33cLqTDEZbVyQBNW6cnGxge+B4h6wU12IV+ws3479B2BBBDGIJCxw8fntmMcJhpOdHZ8uQJk1M+W3fby4vuI7Ah1jOKyXmkUdH/sjHFpCGpMqc2sFBLAyek4kk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iIj4OWZB; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC595C433C7; Sun, 24 Mar 2024 23:13:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711322006; bh=KxKDHMnXXNeIqJdD5tAEXkK5ykdmBQbtB7cCktcMVQ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iIj4OWZBxieTM80F2Zm5w8JKY7B/LgNAR2MhtVOxJAtEaNKrg+aQaJu8T+uK1eb54 59AOg6adVgaMWSu0742B5gNgCkfBMnun+o9ilMPpGyoPeTJKosVXknxyVn/IdiNAWh Cf8QBYqRW7JxadNSK93ZAQ5dS32wAI8I637fjx/lehFC/YfGMdzsl1bkCSlGt1splN G3/95F7JC1AjNVa4IfqVsl0uKTlUUIh+FuQAfD2ttTOIPPka27MoG8ytsxsZ1HGzHU GLyelucmXa2LffD9y7q5otChPc4eW+VlBZ+JTY8LLywUdQsKRZcJFUnFwVz6bRwv+k +hPvHx8Fa6NvA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Peter Hilber , Thomas Gleixner , John Stultz , Sasha Levin Subject: [PATCH 6.1 078/451] timekeeping: Fix cross-timestamp interpolation on counter wrap Date: Sun, 24 Mar 2024 19:05:54 -0400 Message-ID: <20240324231207.1351418-79-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324231207.1351418-1-sashal@kernel.org> References: <20240324231207.1351418-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Peter Hilber [ Upstream commit 84dccadd3e2a3f1a373826ad71e5ced5e76b0c00 ] cycle_between() decides whether get_device_system_crosststamp() will interpolate for older counter readings. cycle_between() yields wrong results for a counter wrap-around where after < before < test, and for the case after < test < before. Fix the comparison logic. Fixes: 2c756feb18d9 ("time: Add history to cross timestamp interface supporting slower devices") Signed-off-by: Peter Hilber Signed-off-by: Thomas Gleixner Acked-by: John Stultz Link: https://lore.kernel.org/r/20231218073849.35294-2-peter.hilber@opensynergy.com Signed-off-by: Sasha Levin --- kernel/time/timekeeping.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 221c8c404973a..c168931c78e01 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1186,7 +1186,7 @@ static bool cycle_between(u64 before, u64 test, u64 after) { if (test > before && test < after) return true; - if (test < before && before > after) + if (before > after && (test > before || test < after)) return true; return false; } -- 2.43.0