From nobody Mon Jun 8 05:26:22 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 EFB3D37F007; Fri, 5 Jun 2026 12:30:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780662620; cv=none; b=F4ryyo9vZw5z1k+Lc1kIFSs+OLHf5vbZ6X1WkdYgucjqbQ85tFWTyrCHFyNexCs/NBPsELdrXjfOR4skylKVooa61rIsThkAiE3QN/7cebNX36z1dTTD1093ngK8dl+Fa+kCupwNosym4iR60fYxpN2eaqDH2PMMya+0c6DFcZA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780662620; c=relaxed/simple; bh=VtmAe5qB9O7IUFpovzEVE4F89E7FN5g3IH1iKC0hPRY=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=Tcy4Ej6Eq87XKkb+ms1TyTh8H6uapLZpYtYCafv6AfRRsPCtCw9JL+hMLM1Ry6t933DOqk6djWCJh0sAAdqD2KH7bL7BcGP2l9pPsMstUWwudh0IrxEga6OubcComxvPJkWq0KuhbOLhMlT/dAZc0Mp08P/h7bi/AeWnljnBm3M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=fktmzDYP; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=V8XYgdIF; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="fktmzDYP"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="V8XYgdIF" Date: Fri, 05 Jun 2026 12:30:12 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1780662614; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fvKYc+F1GvMPp5j1phchT2G6i9bgoDCsPQv4h0gbJmw=; b=fktmzDYP1HdT43szJ9/cu26+Bn8PgjOa7PvZ5ruxIwVYj4MgS8Iv+pii05cADu7UE/vo0f 9w6XnqJ6A7+XdWxhT4+fVf2lRSnCKHDMMeQH3DD8s/TQGaogQkgMubb/QqxP1ydRRRYnrN 4BSAneL2ihdSEPhgUyFkrHCpi95d8Y3TVL+T6lrwvtBrkhlJT4e3olcPI0SUeCb/MATRhB dZyn0VlMSjRV3cKLFRYb9qNEPMz3kYIEAkJKTCAdH+7f+/8tjnZI/80aBJd11jkg9YkJ53 YaIMWN276X6QVBZDAr3tzIfCkw0JwiW3SOCqQLEZ/mpC+1kP7v0OJ9P7fJG9BQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1780662614; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fvKYc+F1GvMPp5j1phchT2G6i9bgoDCsPQv4h0gbJmw=; b=V8XYgdIFrr/Be1L+gWx/4m09WoXYosB0PADRXUj37lq3XpggHYWu+n0I9fR5cU1BCqcPNP 3lxn+PLcKb2aTtBg== From: "tip-bot2 for David Woodhouse" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/ptp] ptp: vmclock: Use hw_cycles from snapshot for precise TSC pairing Cc: David Woodhouse , Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260604095755.64849-4-dwmw2@infradead.org> References: <20260604095755.64849-4-dwmw2@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178066261275.710.18406344039913628007.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the timers/ptp branch of tip: Commit-ID: bc484a5096732cd858771cccd3164ec985bdc03d Gitweb: https://git.kernel.org/tip/bc484a5096732cd858771cccd3164ec98= 5bdc03d Author: David Woodhouse AuthorDate: Thu, 04 Jun 2026 10:35:18 +01:00 Committer: Thomas Gleixner CommitterDate: Fri, 05 Jun 2026 14:25:03 +02:00 ptp: vmclock: Use hw_cycles from snapshot for precise TSC pairing When the system clocksource is kvmclock or Hyper-V (not the TSC directly), vmclock_get_crosststamp() falls through to a separate get_cycles() call, losing the atomic pairing between the system time snapshot and the TSC reading. Now that ktime_get_snapshot_id() populates hw_cycles with the underlying TSC value for derived clocksources, use it when available. This gives a perfect (system_time, tsc) pairing for the device time calculation. The SUPPORT_KVMCLOCK wrapper is still needed to convert the TSC into kvmclock nanoseconds for system_counter->cycles, because otherwise get_device_system_crosststamp() can't interpret the result against the system clock. Signed-off-by: David Woodhouse Signed-off-by: Thomas Gleixner Assisted-by: Kiro:claude-opus-4.6-1m Link: https://patch.msgid.link/20260604095755.64849-4-dwmw2@infradead.org --- drivers/ptp/ptp_vmclock.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/ptp/ptp_vmclock.c b/drivers/ptp/ptp_vmclock.c index d6a5a53..eebdcd5 100644 --- a/drivers/ptp/ptp_vmclock.c +++ b/drivers/ptp/ptp_vmclock.c @@ -140,6 +140,10 @@ static int vmclock_get_crosststamp(struct vmclock_stat= e *st, if (sts->pre_sts.cs_id =3D=3D st->cs_id) { cycle =3D sts->pre_sts.cycles; sts->post_sts =3D sts->pre_sts; + } else if (sts->pre_sts.hw_csid =3D=3D st->cs_id && + sts->pre_sts.hw_cycles) { + cycle =3D sts->pre_sts.hw_cycles; + sts->post_sts =3D sts->pre_sts; } else { cycle =3D get_cycles(); ptp_read_system_postts(sts);