Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2361791lqp; Sun, 24 Mar 2024 15:47:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXyZS5sbsdbii/jBukvfhIfC5FKBaayttFFAIAhCtVTQMqKAUfqkMoIh92xeEXNU2cEA3WHCacNm3XhkeHSo4xXRH+L1pKdbNF1cvGjBA== X-Google-Smtp-Source: AGHT+IFQYb+R+rBnc48pLeTODVa9KSo/LJBoJOdoZjmt0GH2+GkI/OqxaIa1zUmUvCGeFprRmrR/ X-Received: by 2002:a17:902:c3cd:b0:1e0:54:87d9 with SMTP id j13-20020a170902c3cd00b001e0005487d9mr5847906plj.18.1711320431857; Sun, 24 Mar 2024 15:47:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711320431; cv=pass; d=google.com; s=arc-20160816; b=e63j5qsSdKA805LomWQ+FE4KwRfi993sVdprbTwf7zinwWln/Rwq7c6PoRzXHOWGlU gHatUtK2UkYnVLJ6QQ1WY4Pbxw5SbygxZcrOaT7hggcmlm1FxVbDOlEHnlYRJNVrxnkv WkPXenHoaWmZvJo3Fy4bpEvqBkmGW2slbx3XR4Q5k+NeBAi6JhE0v3aJTpClx6++yPYs NyZVLCrDerBo2HHiEQ3zzgpuicN1LxLQp9R09NDhCZHDTSj0f/bPJPHcXDJDi1T6kDtW vIzZURjpCcdTwqSNySX1LcA4c+iQ29pTqdRBI3Jad8Io1AQL6dyZIFKmlg6BPnbgHCmQ ebJQ== 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=fFhG/d8OO7wetEcHcV61150P4W9P9MWYQ3NBmARbLtc=; fh=Kup36vPmDrRX/ZED4HiLo7D05zuBWldEjkgKP/N/E5c=; b=Zl/uySHwdyKhq5WkGDCpSWWb2U5IcPRkpDLSTOizAT5UPZXA1sAYod/BFsdcknL7Ih YGDtlEcPToIDSDngd30OSWtDCmWfPvDHy9hmqBC/9DIEf7Ml/c8btSTqhLmeYSoY1uWR CIUgFhjwcEjjMfzfvNvGBFgQH3EDFrMk6wC/Xz5yeM/W57A8YK5jxXEf2O50akNeYrEi I6CoCpXZd1bv5DapNwz7EVa8LO4+2MOpZrVeQ7bTn7iKdc6B7ro/pIzKFJnyRPRhAeth KU8zF+Y4hpr5HyMIqFD+Md/wNr+mVq8/mRblFaNQb0TMllTiFQe7argrYfpw/rogzU8D 7C/w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=edZeNxu4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112936-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112936-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id nn1-20020a17090b38c100b0029c6f8dd5casi6686823pjb.185.2024.03.24.15.47.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 15:47:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112936-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=edZeNxu4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112936-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112936-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7A12B281434 for ; Sun, 24 Mar 2024 22:47:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ED219763F3; Sun, 24 Mar 2024 22:35:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="edZeNxu4" 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 07A3B76047; Sun, 24 Mar 2024 22:35:48 +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=1711319749; cv=none; b=BBOPJqP+qSiBUHRdKWrrzRb5fbPmW6ezT9dIPf+Xarjm5UfbS9edNQcnDmO5kpQKfDgeNoJJw5KKAWz8Ky279B8L7cahQk1YaDL1Xh3BooBR6BsKux2kHc1bMkQbkmS3uJRShkBmKzcWjUwuDaTr3+PlMJzefk3gs+fJNOFkVaM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711319749; c=relaxed/simple; bh=23eHHuh/DV2k7PZWl6XBVkeG9jJGgENpTKhIC6FWxGs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OXbTpexkdCUVb+p9NXYjFZfKzZNnSLqSfUMHvECJAD56X/lpIkU53MLZ4EbUmP2gpYeEqwhclNHCrOmhrwyZ9TVw8kr+uOBU0qJVLdLcJteQ2nDSbEoIKbUpkJAn3Hj2GbnEvQdRtpOuJOl2y/bX1aaCQ5ZtCBBDhpuOFT3p1JM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=edZeNxu4; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFDABC433A6; Sun, 24 Mar 2024 22:35:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711319748; bh=23eHHuh/DV2k7PZWl6XBVkeG9jJGgENpTKhIC6FWxGs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=edZeNxu4CtDTK4WDuqSmv4BXYpV61gz1g+gImkcOAEYZWMFflOnOgHq9r+g7cq4aA FV/PRrQc3gQ/fWhY9hoi7ce9BfvJU5BLbUBPVY1EjY69dQLi138BfMH8gdoBqZzuz4 PfwXdxsTCujl/jAlIoWniO2qniyr3vVl0LGI6SGHxeTUe1Vuz61IvLPb/ekANbhSf/ Xrc357bhJw/HrJGkpA7DXa9EK06tF8wxujJXQmgeTmpCxKMA4Ogk4UtDz7jbhp3grH 2M/hFYxM5rotqzJYpSKyJU8jkY1mzKGLNEF8Bbgxm0QzjJmasDiu03vkPa4snTc1aB CuQN8JB973TtA== 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.8 049/715] timekeeping: Fix cross-timestamp interpolation on counter wrap Date: Sun, 24 Mar 2024 18:23:48 -0400 Message-ID: <20240324223455.1342824-50-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-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 266d02809dbb1..8f35455b62509 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