From nobody Mon Jun 8 20:41:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 69ACC405C40; Tue, 26 May 2026 17:13:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815625; cv=none; b=KaVlg54ZSLeoidr6npWAOeBUapBkHZe3Szz2JaAvUfPn1/HAuk3zqxDX6ifuSng2x3lorrB0XJF4CLWKepxOpOE1pQTt2acTmDvOysvKHUhhkcLNqNKzL0MXvcun5POdCB46m+ZlxOKcwkchDaWy4w6wNrI1CCm8VuBAu6nHlTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815625; c=relaxed/simple; bh=/uIxxcW/VKW7V6tqmh6Hwrv4myf2hGcVB+nmBbsM4O0=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=m35RBSP7Kfx1XMbzGHJXa5d8qvv0dUHW7IhT43nDj5iSq+t6bjIRkZ4pyQzXeb4Pf2GcUIuSa7jYeHEKjBqF3Qb7mrEVqyHZ2QTHLpiYuGZMeTG6/Uhfg0nRkuSaVycVRAmB1tmAX8uBPw+snr/eSPWvBa/BjuxGxf34S9Cxiqk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XzCPuMax; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XzCPuMax" Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id 308DD1F00A3E; Tue, 26 May 2026 17:13:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779815617; bh=C2RjMS9VQOGkJN1go0lhI1NDtbLN/H1nTVa2BdBDyCY=; h=Date:From:To:Cc:Subject:References; b=XzCPuMaxP2oFxIaAt7DXedzD5bIxlbBx7ED2ib8msOaomyI8z4WFTt+xTSXFYvexl DpA3ow5UqhjSkEwvKDhBUuj1H4vMFzDvFLyWfSk6msiow2Nu7rNop71fPeVr+oXahH qnEJ/D57j/KxJhWDOAx7SQVdqFCATBIBamxIeu7vh8rhNpA9wkL5JxR1YUBLD+qjjZ zU5yWGiCv1A9fHt+Q0RJzNKj8RSg9aJ9hqJ8cLkj6Z/aAe65jO3MYiVk++A/wGPch7 w5109BrM7Sd/pzDcES4IE6i7IKyo7GYPZs9g5ZD2UxXVDoRPjV7D0SaSFevQcLxjXj uOHOY9vOofjmQ== Date: Tue, 26 May 2026 19:13:33 +0200 Message-ID: <20260526171222.769770418@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: David Woodhouse , Miroslav Lichvar , John Stultz , Stephen Boyd , Anna-Maria Behnsen , Frederic Weisbecker , thomas.weissschuh@linutronix.de, Arthur Kiyanovski , Rodolfo Giometti , Vincent Donnefort , Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, Oliver Upton , Richard Cochran , netdev@vger.kernel.org, Takashi Iwai , Miri Korenblit , Johannes Berg , Jacob Keller , Tony Nguyen , Saeed Mahameed , Peter Hilber , "Michael S. Tsirkin" , virtualization@lists.linux.dev, linux-wireless@vger.kernel.org, linux-sound@vger.kernel.org Subject: [patch 01/24] timekeeping: Provide ktime_get_snapshot_id() References: <20260526165826.392227559@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ktime_get_snapshot() provides a snapshot of the underlying clocksource counter value and the corresponding CLOCK_MONOTONIC_RAW, CLOCK_REALTIME and CLOCK_BOOTTIME timestamps. There is no usage of CLOCK_REALTIME and CLOCK_BOOTTIME at the same time and CLOCK_BOOTTIME support was just added for the ARM64 KVM tracing mechanism, which needs CLOCK_BOOTTIME and the underlying clocksource counter value. ktime_get_snapshot() is also not suitable for usage with CLOCK_AUX, but that's a prerequisite to support PTP hardware timestamping for CLOCK_AUX steering. As a first step, rename ktime_get_snapshot() to ktime_get_snapshot_id(), which now takes a clockid argument to select the clock which needs to be captured. The result is stored in system_time_snapshot::sys, which will replace the system_time_snapshot::real/boot members once all usage sites have been converted. ktime_get_snapshot() is a simple wrapper which hands in CLOCK_REALTIME as clockid argument for the conversion period. That means CLOCK_REALTIME is now captured twice, but that redunancy is only temporary. No functional change vs. current users of ktime_get_snapshot() Signed-off-by: Thomas Gleixner Reviewed-by: David Woodhouse Reviewed-by: Jacob Keller Reviewed-by: Thomas Wei=C3=9Fschuh Tested-by: Arthur Kiyanovski Tested-by: David Woodhouse --- include/linux/timekeeping.h | 29 ++++++++++----- kernel/time/timekeeping.c | 84 +++++++++++++++++++++++++++++++++------= ----- 2 files changed, 84 insertions(+), 29 deletions(-) --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -276,24 +276,28 @@ static inline bool ktime_get_aux_ts64(cl #endif =20 /** - * struct system_time_snapshot - simultaneous raw/real time capture with - * counter value - * @cycles: Clocksource counter value to produce the system times - * @real: Realtime system time - * @boot: Boot time - * @raw: Monotonic raw system time - * @cs_id: Clocksource ID + * struct system_time_snapshot - Simultaneous time capture of CLOCK_MONOTO= NIC_RAW, + * a selected CLOCK_* and the clocksource counter value + * @cycles: Clocksource counter value to produce the system times + * @sys: The system time of the selected CLOCK ID + * @real: Realtime system time + * @boot: Boot time + * @raw: Monotonic raw system time + * @cs_id: Clocksource ID * @clock_was_set_seq: The sequence number of clock-was-set events * @cs_was_changed_seq: The sequence number of clocksource change events + * @valid: True if the snapshot is valid */ struct system_time_snapshot { u64 cycles; + ktime_t sys; ktime_t real; ktime_t boot; ktime_t raw; enum clocksource_ids cs_id; unsigned int clock_was_set_seq; u8 cs_was_changed_seq; + u8 valid; }; =20 /** @@ -341,9 +345,16 @@ extern int get_device_system_crosststamp struct system_device_crosststamp *xtstamp); =20 /* - * Simultaneously snapshot realtime and monotonic raw clocks + * Simultaneously snapshot a given clock with MONOTONIC_RAW and the underl= ying + * clocksource counter value. */ -extern void ktime_get_snapshot(struct system_time_snapshot *systime_snapsh= ot); +extern bool ktime_get_snapshot_id(struct system_time_snapshot *systime_sna= pshot, + clockid_t clock_id); + +static inline void ktime_get_snapshot(struct system_time_snapshot *systime= _snapshot) +{ + WARN_ON_ONCE(!ktime_get_snapshot_id(systime_snapshot, CLOCK_REALTIME)); +} =20 /* * Persistent clock related interfaces --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1183,43 +1183,87 @@ noinstr time64_t __ktime_get_real_second } =20 /** - * ktime_get_snapshot - snapshots the realtime/monotonic raw clocks with c= ounter - * @systime_snapshot: pointer to struct receiving the system time snapshot + * ktime_get_snapshot_id - Simultaneously snapshot a given clock ID with + * CLOCK_MONOTONIC_RAW and the underlying + * clocksource counter value. + * @systime_snapshot: Pointer to struct receiving the system time snapshot + * @clock_id: The clock ID to snapshot */ -void ktime_get_snapshot(struct system_time_snapshot *systime_snapshot) +bool ktime_get_snapshot_id(struct system_time_snapshot *systime_snapshot, = clockid_t clock_id) { - struct timekeeper *tk =3D &tk_core.timekeeper; + ktime_t base_raw, base_sys, offs_sys, *offs, offs_zero =3D 0; + u64 nsec_raw, nsec_sys, now; + struct timekeeper *tk; + struct tk_data *tkd; unsigned int seq; - ktime_t base_raw; ktime_t base_real; ktime_t base_boot; - u64 nsec_raw; - u64 nsec_real; - u64 now; =20 - WARN_ON_ONCE(timekeeping_suspended); + /* Invalidate the snapshot for all failure cases */ + systime_snapshot->valid =3D false; + + if (WARN_ON_ONCE(timekeeping_suspended)) + return false; + + switch (clock_id) { + case CLOCK_REALTIME: + tkd =3D &tk_core; + offs =3D &tk_core.timekeeper.offs_real; + break; + /* Map RAW to MONOTONIC so the loop below is trivial */ + case CLOCK_MONOTONIC_RAW: + case CLOCK_MONOTONIC: + tkd =3D &tk_core; + offs =3D &offs_zero; + break; + case CLOCK_BOOTTIME: + tkd =3D &tk_core; + offs =3D &tk_core.timekeeper.offs_boot; + break; + default: + WARN_ON_ONCE(1); + return false; + } + + tk =3D &tkd->timekeeper; =20 do { - seq =3D read_seqcount_begin(&tk_core.seq); + seq =3D read_seqcount_begin(&tkd->seq); + now =3D tk_clock_read(&tk->tkr_mono); systime_snapshot->cs_id =3D tk->tkr_mono.clock->id; systime_snapshot->cs_was_changed_seq =3D tk->cs_was_changed_seq; systime_snapshot->clock_was_set_seq =3D tk->clock_was_set_seq; - base_real =3D ktime_add(tk->tkr_mono.base, - tk_core.timekeeper.offs_real); - base_boot =3D ktime_add(tk->tkr_mono.base, - tk_core.timekeeper.offs_boot); + + base_sys =3D tk->tkr_mono.base; + offs_sys =3D *offs; base_raw =3D tk->tkr_raw.base; - nsec_real =3D timekeeping_cycles_to_ns(&tk->tkr_mono, now); - nsec_raw =3D timekeeping_cycles_to_ns(&tk->tkr_raw, now); - } while (read_seqcount_retry(&tk_core.seq, seq)); + + /* Kept around until the callers are fixed up */ + base_real =3D ktime_add(base_sys, tk_core.timekeeper.offs_real); + base_boot =3D ktime_add(base_sys, tk_core.timekeeper.offs_boot); + + nsec_sys =3D timekeeping_cycles_to_ns(&tk->tkr_mono, now); + nsec_raw =3D timekeeping_cycles_to_ns(&tk->tkr_raw, now); + } while (read_seqcount_retry(&tkd->seq, seq)); =20 systime_snapshot->cycles =3D now; - systime_snapshot->real =3D ktime_add_ns(base_real, nsec_real); - systime_snapshot->boot =3D ktime_add_ns(base_boot, nsec_real); + systime_snapshot->sys =3D ktime_add_ns(base_sys, offs_sys + nsec_sys); + systime_snapshot->real =3D ktime_add_ns(base_real, nsec_sys); + systime_snapshot->boot =3D ktime_add_ns(base_boot, nsec_sys); systime_snapshot->raw =3D ktime_add_ns(base_raw, nsec_raw); + + /* + * Special case for PTP. Just transfer the raw time into sys, + * so the call sites can consistently use snap::sys. + */ + if (clock_id =3D=3D CLOCK_MONOTONIC_RAW) + systime_snapshot->sys =3D systime_snapshot->raw; + /* Tell the consumer that this snapshot is valid */ + systime_snapshot->valid =3D true; + return true; } -EXPORT_SYMBOL_GPL(ktime_get_snapshot); +EXPORT_SYMBOL_GPL(ktime_get_snapshot_id); =20 /* Scale base by mult/div checking for overflow */ static int scale64_check_overflow(u64 mult, u64 div, u64 *base) From nobody Mon Jun 8 20:41:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 10758405C41; Tue, 26 May 2026 17:13:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815624; cv=none; b=LEQKrS8J6PxZdCWJA9lGFHFkirFpirOkFh4CNi9gHZ3zMugl0WWQz1454BMXm0OXXHsxwiHlJcbpMa3yVj5eA9mAjGXk4AE4ndoZNcc8z15Q8RSRe2vf4v4uedMFqdSTyMX58VnTTruC4JmUzLUNeRS1TTOXqqEkyg7fnulRmdM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815624; c=relaxed/simple; bh=1gJ39ZBykzUVBWyDS6VHvRoUDWgo7sKerVkC8ZiW740=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=i7Y+3DidpvBiJeIWI7sYGc6ru2QgstQ41LX8OUDhcHCevT/YymcNanjdYUPa9CwIpcK5vF4fKMu3/hT1Q0Ghpnh4CFKmtJRDC+GFuPwHwAkm999/qN3wHjuJNXVvmWvTKEqWrKB83OFTJ/FZVbx+9doLHXE4pG+pUgpl9K7xBWE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YmZbwV0J; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YmZbwV0J" Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id B20C31F00A3A; Tue, 26 May 2026 17:13:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779815621; bh=PbsJ6GKklobOZdFGQ/1Sa//V0DO21BARQCnNN3dl8uA=; h=Date:From:To:Cc:Subject:References; b=YmZbwV0Jx5+P9OBLnh6BPP6K29uNO7VDiOjP3djaK8Iq12XfIbPQUJ2XFuqbHkeUt WyclmZde0cCdGKJI0+Jp20D6gW62Ik8diU27wGA8eTNdrkgrvgeBGtfCNjdzA3Wcrg B0fV/+SCJMzLzvFQLBygK2as/tI4QC+ISwMysnUCAAHXT9g4mByv5W7uy5u9lRaSjs C9vhRoMzjdG5hfxZbAb2HQk4ycfPCgt2JdhsTKUEJ4/DOhBZd8i4Z2h1vxYyTFoSwQ v4gXkegCGDrMQjYguFpM7NgcdDcVjxMZL+JUFTK7fGaPJus8y5WGj9sWftN6vT8dNJ yXeafV0yJhihg== Date: Tue, 26 May 2026 19:13:38 +0200 Message-ID: <20260526171222.846848261@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: David Woodhouse , Miroslav Lichvar , John Stultz , Stephen Boyd , Anna-Maria Behnsen , Frederic Weisbecker , thomas.weissschuh@linutronix.de, Arthur Kiyanovski , Rodolfo Giometti , Vincent Donnefort , Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, Oliver Upton , Richard Cochran , netdev@vger.kernel.org, Takashi Iwai , Miri Korenblit , Johannes Berg , Jacob Keller , Tony Nguyen , Saeed Mahameed , Peter Hilber , "Michael S. Tsirkin" , virtualization@lists.linux.dev, linux-wireless@vger.kernel.org, linux-sound@vger.kernel.org Subject: [patch 02/24] timekeeping: Use system_time_snapshot::sys instead of ::real References: <20260526165826.392227559@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" system_time_snapshot::sys provides the same information as system_time_snapshot::real when the snapshot was taken with ktime_get_snapshot_id(CLOCK_REALTIME). Convert the history interpolation over to use 'sys' as 'real' is going away once all users are converted. As a side effect this is the first step to support CLOCK_AUX with get_device_crosstime_stamp() and the history interpolation. Signed-off-by: Thomas Gleixner Reviewed-by: David Woodhouse Reviewed-by: Jacob Keller Reviewed-by: Thomas Wei=C3=9Fschuh Tested-by: Arthur Kiyanovski Tested-by: David Woodhouse --- kernel/time/timekeeping.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1342,7 +1342,7 @@ static int adjust_historical_crosststamp (corr_raw, tk->tkr_mono.mult, tk->tkr_raw.mult); } else { corr_real =3D (u64)ktime_to_ns( - ktime_sub(ts->sys_realtime, history->real)); + ktime_sub(ts->sys_realtime, history->sys)); ret =3D scale64_check_overflow(partial_history_cycles, total_history_cycles, &corr_real); if (ret) @@ -1352,7 +1352,7 @@ static int adjust_historical_crosststamp /* Fixup monotonic raw and real time time values */ if (interp_forward) { ts->sys_monoraw =3D ktime_add_ns(history->raw, corr_raw); - ts->sys_realtime =3D ktime_add_ns(history->real, corr_real); + ts->sys_realtime =3D ktime_add_ns(history->sys, corr_real); } else { ts->sys_monoraw =3D ktime_sub_ns(ts->sys_monoraw, corr_raw); ts->sys_realtime =3D ktime_sub_ns(ts->sys_realtime, corr_real); From nobody Mon Jun 8 20:41:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 7F8CC409118; Tue, 26 May 2026 17:13:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815633; cv=none; b=X9U888iuUXrde4aHwuqEBacTzcJXsUEugSTOcFsYY69+iFGMtmGibaeKDpxyRKIWRvL945rWyOcKcbpUwtfKCCernyCWWux6EkG+D/9Z9312gzrGrTGykqtIiSi5gufun3+fVXc8vjxsXekfnNZ2SXazTm9gjUirtZd2OHQZ+ns= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815633; c=relaxed/simple; bh=Jo/Au8bQYAno4GeE3KqHD8eiAALVUwsf3qSc631Dg88=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=ZjBEMoopTvEmDPdo8fmix8jDVfNJKp9wOL1FmOJy4QIwbXcRFuATW61AmfJOpWL3cbvC19acXkJCb3z6oMWVlFfxB2dsyPWxAJ0wBgK0J0rqee8AxMf5NTlCb/nQxqWo/WiG/Imu65+9GYuX9MELsUN1ikEmmL3FzGG1jmgtgb4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gBaPgM/x; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gBaPgM/x" Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id CAD001F00A3A; Tue, 26 May 2026 17:13:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779815626; bh=X0scQND1xJm72l+yu4qfzG29LQeAoWdi/2lmLZs8YK4=; h=Date:From:To:Cc:Subject:References; b=gBaPgM/xsCiUVCAw9BPRWT13zmyadEtGDb6uVyJdpOXvhWBk2ulU534ck+xRoQ//k 9sUHIZvMsrUTuJPwaQzLyKyf1L1zY3Lo8ZxJ8SAsmKCTgb/GF9F7HZxiNCsS0Zpg/k nuU0oRAvZF6Qvj/Q+n5ulI4ai+250J3JNiqk9gnayFDcEntnuAxW2eV1zJi8SFy+nZ G0Ha02ne6Ck8Pi26tBsHGkCFMA4ybw53o2riJmtasNU+NfZ+pSqIknkIgG4R8byMwb NDmOd+QhbvSXAOBtuxGyy5RsFc93k/j4gZIgiBn2RM3VKW/510aFVqzMjHXHWgpHXN Fa0BUCoW+3qcQ== Date: Tue, 26 May 2026 19:13:43 +0200 Message-ID: <20260526171222.920736414@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: David Woodhouse , Miroslav Lichvar , John Stultz , Stephen Boyd , Anna-Maria Behnsen , Frederic Weisbecker , thomas.weissschuh@linutronix.de, Arthur Kiyanovski , Rodolfo Giometti , Vincent Donnefort , Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, Oliver Upton , Richard Cochran , netdev@vger.kernel.org, Takashi Iwai , Miri Korenblit , Johannes Berg , Jacob Keller , Tony Nguyen , Saeed Mahameed , Peter Hilber , "Michael S. Tsirkin" , virtualization@lists.linux.dev, linux-wireless@vger.kernel.org, linux-sound@vger.kernel.org Subject: [patch 03/24] pps: generators: Use ktime_get_real_ts64() instead of ktime_get_snapshot() References: <20260526165826.392227559@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There is no reason to use the more complex ktime_get_snapshot() for retrieving CLOCK_REALTIME. Just use ktime_get_real_ts64(), which avoids the extra timespec64 conversion as a bonus. No functional change intended. Signed-off-by: Thomas Gleixner Cc: Rodolfo Giometti Reviewed-by: David Woodhouse Reviewed-by: Jacob Keller Reviewed-by: Thomas Wei=C3=9Fschuh Tested-by: Arthur Kiyanovski --- drivers/pps/generators/pps_gen-dummy.c | 6 +----- drivers/pps/generators/pps_gen_tio.c | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) --- a/drivers/pps/generators/pps_gen-dummy.c +++ b/drivers/pps/generators/pps_gen-dummy.c @@ -39,11 +39,7 @@ static void pps_gen_ktimer_event(struct static int pps_gen_dummy_get_time(struct pps_gen_device *pps_gen, struct timespec64 *time) { - struct system_time_snapshot snap; - - ktime_get_snapshot(&snap); - *time =3D ktime_to_timespec64(snap.real); - + ktime_get_real_ts64(time); return 0; } =20 --- a/drivers/pps/generators/pps_gen_tio.c +++ b/drivers/pps/generators/pps_gen_tio.c @@ -189,11 +189,7 @@ static int pps_tio_gen_enable(struct pps static int pps_tio_get_time(struct pps_gen_device *pps_gen, struct timespec64 *time) { - struct system_time_snapshot snap; - - ktime_get_snapshot(&snap); - *time =3D ktime_to_timespec64(snap.real); - + ktime_get_real_ts64(time); return 0; } From nobody Mon Jun 8 20:41:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 377FD413D8F; Tue, 26 May 2026 17:13:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815636; cv=none; b=OvDkU0LOQC01acvHY8uJ/22nYGZXWJQ0mUGzfOGpFTwrHIZ02VFJJqa3pex6aStMQCMJVuT3n91YGBGWHoFFqMDMfD+Prh/iBfD3/7leb1nw1o9ujrS43def3XgNlyM4YSdUETqb+mHpqHtR2Q9hL4vwoInBnMEvY2BLR12gplc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815636; c=relaxed/simple; bh=NDw6UHaPI2dJBJJYWyMVcYdnDmDcJDE7NsRFacHuejg=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=CQ55KekC5e+/fafnOemrpkzPSxqJKxuzyHLHZMtzgB/Ee2+c2om7fhmHQJ+6AoqOpd3cbaoJs8x+TzrDyV+Kr0AQvMCyhc54jEzER+kf3xBsfEcw/seaAYbMeSSlkizdrHmspoYoCrtGbvRDVge91FihqOmLkUYPXU9pafRzX6o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=l/7TyMGC; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="l/7TyMGC" Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id CD14D1F00A3F; Tue, 26 May 2026 17:13:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779815631; bh=2J+ciIb2LyPs5xxGSmmcudFc+5BTlYYzzEvJzgHR0zk=; h=Date:From:To:Cc:Subject:References; b=l/7TyMGC5Mv6l3ZKe7c6fhs4o1pwKNEh3volJKRnmz8sUSqATPBUvLA+ZGnqe9hst vVP8HKu/Cl0PUZTGZjn2j+muR+e0Oeki3r4BWeIJ1CxqJJjBb93+8ttVfm8i80R79Y sjaRQEJ7kj0nYumOC1QMkKrb2PqakO0Hlg8ejbrehNOWoutJSq8ECnvZf+5j7jVCW4 CqTuAv37DM6DpCC8NVwrBxQyRfUGwVL5kzg/0CScRKGCfpGLh/r7DHu4nKIHM4gGSN oclVhhVS9gRq3E5suGSWD71huxZhD43uoo5rL9UCiYti5BILHylSUSXdT76eKhwf8K 9rc5+PBk5OsHA== Date: Tue, 26 May 2026 19:13:48 +0200 Message-ID: <20260526171222.995833811@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: David Woodhouse , Miroslav Lichvar , John Stultz , Stephen Boyd , Anna-Maria Behnsen , Frederic Weisbecker , thomas.weissschuh@linutronix.de, Arthur Kiyanovski , Rodolfo Giometti , Vincent Donnefort , Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, Oliver Upton , Richard Cochran , netdev@vger.kernel.org, Takashi Iwai , Miri Korenblit , Johannes Berg , Jacob Keller , Tony Nguyen , Saeed Mahameed , Peter Hilber , "Michael S. Tsirkin" , virtualization@lists.linux.dev, linux-wireless@vger.kernel.org, linux-sound@vger.kernel.org Subject: [patch 04/24] pps: Convert to ktime_get_snapshot_id() References: <20260526165826.392227559@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ktime_get_snapshot() resolves to ktime_get_snapshot_id(CLOCK_REALTIME). Make it obvious in the code and convert the readout to use the snapshot::sys field instead of snapshot::real, which is going away. Similar to the PPS generators, avoid the more expensive snapshot when CONFIG_NTP_PPS is disabled. No functional change intended. Signed-off-by: Thomas Gleixner Cc: Rodolfo Giometti Reviewed-by: David Woodhouse Reviewed-by: Jacob Keller Reviewed-by: Thomas Wei=C3=9Fschuh Tested-by: Arthur Kiyanovski --- include/linux/pps_kernel.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/include/linux/pps_kernel.h +++ b/include/linux/pps_kernel.h @@ -99,12 +99,14 @@ static inline void timespec_to_pps_ktime =20 static inline void pps_get_ts(struct pps_event_time *ts) { +#ifdef CONFIG_NTP_PPS struct system_time_snapshot snap; =20 - ktime_get_snapshot(&snap); - ts->ts_real =3D ktime_to_timespec64(snap.real); -#ifdef CONFIG_NTP_PPS + ktime_get_snapshot_id(&snap, CLOCK_REALTIME); + ts->ts_real =3D ktime_to_timespec64(snap.sys); ts->ts_raw =3D ktime_to_timespec64(snap.raw); +#else + ktime_get_real_ts64(&ts->ts_real); #endif } From nobody Mon Jun 8 20:41:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 44D0C41B360; Tue, 26 May 2026 17:13:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815639; cv=none; b=jk4lr9HZy1DwBaY/yXz9s7U5BlSRyy+Ct5b79cmCdqdIinY+CI+sQw5sT60kgz2fdds9Lcmr/bnDCCj4AipypMX3d/h8HQQb20OFlzuIuYyL34XrVs/HEImAjHPXDVd/KV+d9UFVJyG4UTAxHQczPTyvRL2gK0TEt/Z5bDueROo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815639; c=relaxed/simple; bh=+xAbAhBIS4NGDmtAAjjXvloqPhdiK33Jmo3iTUVq4nc=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=c4Lh77iIyZznHHh/GJf562Ykw6pncsXu4BjdnqDlwByaufnPgK9MdUTZuQIalTHG52tbNVHzH65XuaL+WqxZf2b3Fv00KdzCtMeY4BaZapWvCw/60dEdq3qVt6nuK0b+wjVQzGs0Y06Gnn9l1cV9k8Tv+bc3NF289p9SlonuBng= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iukdoetf; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iukdoetf" Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id E9CD71F000E9; Tue, 26 May 2026 17:13:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779815636; bh=Gcy0P/M1Djdc6nKd+KuNGUSSaq76qqVC96BEfx+Xwt0=; h=Date:From:To:Cc:Subject:References; b=iukdoetfKrX1GZsDkEFJmdiHvi94z/tMq5+r075qR0HQyvl5j6b64YcqTV4YErqCq IH6Y6XxUHAhhQM+MIGbJmv+8durUSeKgJaGYnH83leu02cUIIiT/+5iIgko//DbDTB O82eKlM9dxrMS5Sfl9NdffCXgROTcdY4ffrQ8HxjurJxeN+gWIlV7/eu1gHaib9Gv2 yfCci1ENOXJmk5fnx4tfEQTajgQUEZmYnszEQn56+UlpJij7f5WDZyi82eJrMXteQi KMlYSk/URU4OFeBo0fSqQNKCwHLlaW6kZN+dzo8Iy+ndknLq4YkBv2oPx9CONXaKqH f+z0l038h08ow== Date: Tue, 26 May 2026 19:13:53 +0200 Message-ID: <20260526171223.070087856@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: David Woodhouse , Miroslav Lichvar , John Stultz , Stephen Boyd , Anna-Maria Behnsen , Frederic Weisbecker , thomas.weissschuh@linutronix.de, Arthur Kiyanovski , Vincent Donnefort , Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, Rodolfo Giometti , Oliver Upton , Richard Cochran , netdev@vger.kernel.org, Takashi Iwai , Miri Korenblit , Johannes Berg , Jacob Keller , Tony Nguyen , Saeed Mahameed , Peter Hilber , "Michael S. Tsirkin" , virtualization@lists.linux.dev, linux-wireless@vger.kernel.org, linux-sound@vger.kernel.org Subject: [patch 05/24] KVM: arm64: Use ktime_get_snapshot_id() to retrieve CLOCK_BOOTTIME References: <20260526165826.392227559@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ktime_get_snapshot() is replaced by ktime_get_snapshot_id() which allows to request a particular CLOCK ID to be captured along with the clocksource counter. Convert the tracing mechanism over and use the new system_time_snapshot::sys field, which holds the system timestamp selected by the CLOCK ID argument. No functional change intended. Signed-off-by: Thomas Gleixner Cc: Vincent Donnefort Cc: Marc Zyngier Cc: Oliver Upton Cc: kvmarm@lists.linux.dev Acked-by: Marc Zyngier Acked-by: Vincent Donnefort Reviewed-by: David Woodhouse Reviewed-by: Jacob Keller Reviewed-by: Thomas Wei=C3=9Fschuh Tested-by: Arthur Kiyanovski --- arch/arm64/kvm/hyp_trace.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/arch/arm64/kvm/hyp_trace.c +++ b/arch/arm64/kvm/hyp_trace.c @@ -51,8 +51,8 @@ static void __hyp_clock_work(struct work =20 hyp_clock =3D container_of(dwork, struct hyp_trace_clock, work); =20 - ktime_get_snapshot(&snap); - boot =3D ktime_to_ns(snap.boot); + ktime_get_snapshot_id(&snap, CLOCK_BOOTTIME); + boot =3D ktime_to_ns(snap.sys); =20 delta_boot =3D boot - hyp_clock->boot; delta_cycles =3D snap.cycles - hyp_clock->cycles; @@ -118,9 +118,9 @@ static void hyp_trace_clock_enable(struc hyp_clock->running =3D false; } =20 - ktime_get_snapshot(&snap); + ktime_get_snapshot_id(&snap, CLOCK_BOOTTIME); =20 - hyp_clock->boot =3D ktime_to_ns(snap.boot); + hyp_clock->boot =3D ktime_to_ns(snap.sys); hyp_clock->cycles =3D snap.cycles; hyp_clock->mult =3D 0; From nobody Mon Jun 8 20:41:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 4E3A1425CF5; Tue, 26 May 2026 17:14:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815644; cv=none; b=gIykxaIUOEBZDuIq8IylTe8a8y9H7pcrza+uV3Jl3iSZX5OrEgs8hpFqrrynGAKvTlf1ymKGNxHxnoYk/sFIWIIN0p81N1qC+oMYw9ugpbtyoZYZaMs12Xh7VuHXm7+fxeziJSzSwCEduNwc4+8by9YjIOaTMV7sXGpHsuW3SpQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815644; c=relaxed/simple; bh=p1bCOvFUnRZdHK9oC4A/qYvklVkRMVW2a1tjKJ7ZXnU=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=j9sa7F2q3TJCbwgeRP3xcdhsUuPp9f4ANs/wivylPwavmXEPXlrinAKkmrEv6Oyfg9zJxLNRIQIqj5ZLE2Yzz1oggWwbxXYM7eTY5K29pelVUIHC3mVvfOKly3zHgGlTpFQ+1rGWO+0uPB1+vdz+5E+0xs+iYT0sKG/4WJNGbBM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=flRS5F69; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="flRS5F69" Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id BB5A21F00A3E; Tue, 26 May 2026 17:14:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779815641; bh=4U2mbuq0xtl7gCbi5xEqZvtSRzRMupEXV/dl04k7LQs=; h=Date:From:To:Cc:Subject:References; b=flRS5F69yAU28B6rRvNeU/k3gPOzTuv2+Nwc3ZPccKO0kXtBRESu6Tq0JqEuUZlXJ 6QofuY2O19vJqMJjhtoctyQ5wmgw2fiQAp0bkkEOiWwImF/zVrVR1ejY/YcIJriy4a ika8Yf2siWBDQ0j90LSV+l1y8w3t3sl6NkzRApMji0TY9wNuAkAtgBkFwDiIJ5nEoi KccjmbHgOplcMUBvoj+XiBKn+uz9H1Pzd0tX4dqV64VWjwh/CamYK0QjGJH+z7zwpp S6QPXJP0lph2ho6kDT8U50uwr3HKu7M24fQ5VtTIo0+17NQahXxAq9HW15HCvUANxm XPRyetaM0ZqcA== Date: Tue, 26 May 2026 19:13:58 +0200 Message-ID: <20260526171223.144327185@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: David Woodhouse , Miroslav Lichvar , John Stultz , Stephen Boyd , Anna-Maria Behnsen , Frederic Weisbecker , thomas.weissschuh@linutronix.de, Arthur Kiyanovski , Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, Rodolfo Giometti , Vincent Donnefort , Oliver Upton , Richard Cochran , netdev@vger.kernel.org, Takashi Iwai , Miri Korenblit , Johannes Berg , Jacob Keller , Tony Nguyen , Saeed Mahameed , Peter Hilber , "Michael S. Tsirkin" , virtualization@lists.linux.dev, linux-wireless@vger.kernel.org, linux-sound@vger.kernel.org Subject: [patch 06/24] KVM: arm64: Use ktime_get_snapshot_id() to snapshot CLOCK_REALTIME References: <20260526165826.392227559@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ktime_get_snapshot() is replaced by ktime_get_snapshot_id() which allows to request a particular CLOCK ID to be captured along with the clocksource counter. Convert the usage in kvm_get_ptp_time() over and use the new system_time_snapshot::sys field, which holds the system timestamp selected by the CLOCK ID argument. No functional change intended. Signed-off-by: Thomas Gleixner Cc: Marc Zyngier Cc: Oliver Upton Cc: kvmarm@lists.linux.dev Acked-by: Marc Zyngier Reviewed-by: David Woodhouse Reviewed-by: Jacob Keller Reviewed-by: Thomas Wei=C3=9Fschuh Tested-by: Arthur Kiyanovski --- arch/arm64/kvm/hypercalls.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/arch/arm64/kvm/hypercalls.c +++ b/arch/arm64/kvm/hypercalls.c @@ -28,7 +28,7 @@ static void kvm_ptp_get_time(struct kvm_ * system time and counter value must captured at the same * time to keep consistency and precision. */ - ktime_get_snapshot(&systime_snapshot); + ktime_get_snapshot_id(&systime_snapshot, CLOCK_REALTIME); =20 /* * This is only valid if the current clocksource is the @@ -61,8 +61,8 @@ static void kvm_ptp_get_time(struct kvm_ * in the future (about 292 years from 1970, and at that stage * nobody will give a damn about it). */ - val[0] =3D upper_32_bits(systime_snapshot.real); - val[1] =3D lower_32_bits(systime_snapshot.real); + val[0] =3D upper_32_bits(systime_snapshot.sys); + val[1] =3D lower_32_bits(systime_snapshot.sys); val[2] =3D upper_32_bits(cycles); val[3] =3D lower_32_bits(cycles); } From nobody Mon Jun 8 20:41:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 AB996428494; Tue, 26 May 2026 17:14:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815647; cv=none; b=c5yIJzG9olSG5UzNXz5vVzvQCU0ZylhDMzRfGZHN6/euYes7DofAL1tD7ZiJS8U2FmJactatThQ1frcmZxz/mVsnBkFnwz+UR4L/8LzqJ8TTXAoKwRB5pS68T5y/Z2sXDpZAjmtPSir8WBRHJRF65p52KjSxRLhPQSYAIp7u9OE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815647; c=relaxed/simple; bh=C/lMk2GwsVhK7xeNGjqgovxJVEbkd/ih7wBImrOm6no=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=n2MZq9o9oo54ekbfXSwEJspcKKeno+iEo4EtTvI9Ky8RoaczP0oS7Nyvip0lMZhWzX8bh0J/9SF1NKRW1bDQv4cQEtYjMjs8aIPrR4R6rIwUWbf1j+i5aOR+dGdgflrfCOXeI0nR19Zz6CL5KEtVRud+8OkF9sM2h7oBbSBb2+A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=W+jXC5EY; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="W+jXC5EY" Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id 5D0DA1F000E9; Tue, 26 May 2026 17:14:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779815646; bh=2ympzjAuthBIB8syf+QxMkzZ62mfQrNEou/VCvaS1MU=; h=Date:From:To:Cc:Subject:References; b=W+jXC5EY7w0lfHOahBCkY0aiK84bLrigeVkZqS28mZeHL4pwSOPqcyj6u14nPVAqe GRC/xUIdM+A67H6udH3kJTgfDK7P9CNeXCJo0Sxzk2NcHG/2aJCMoLE0VAtQk4ZPrz hO0CKUdsNaxx/d/kvOORBbpR6VMwJzJG54DlwhGjWplDbjcL/OklY+v8hezKTRUEe5 b1TuNSIkANh8NhVyzPYKcMSldAG9dj2Uf5D7MtAh4+fvT5e1JD73wuV8ifjcGePG7U Wr+mRcXqfynnoW0EziFCm1pS4a/kRBpVbo2A2nzQInpHtFCoccatYEtnlv8F1HLhwi b7KFZ9XWNXA8A== Date: Tue, 26 May 2026 19:14:03 +0200 Message-ID: <20260526171223.223860692@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: David Woodhouse , Miroslav Lichvar , John Stultz , Stephen Boyd , Anna-Maria Behnsen , Frederic Weisbecker , thomas.weissschuh@linutronix.de, Arthur Kiyanovski , Richard Cochran , netdev@vger.kernel.org, Rodolfo Giometti , Vincent Donnefort , Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, Oliver Upton , Takashi Iwai , Miri Korenblit , Johannes Berg , Jacob Keller , Tony Nguyen , Saeed Mahameed , Peter Hilber , "Michael S. Tsirkin" , virtualization@lists.linux.dev, linux-wireless@vger.kernel.org, linux-sound@vger.kernel.org Subject: [patch 07/24] ptp: ptp_vmclock: Convert to ktime_get_snapshot_id() References: <20260526165826.392227559@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ktime_get_snapshot() is replaced by ktime_get_snapshot_id() which allows to request a particular CLOCK ID to be captured along with the clocksource counter. Convert vmclock over and use the new system_time_snapshot::sys field, which holds the system timestamp selected by the CLOCK ID argument. No functional change intended. Signed-off-by: Thomas Gleixner Cc: Richard Cochran Cc: netdev@vger.kernel.org Reviewed-by: David Woodhouse Reviewed-by: Jacob Keller Reviewed-by: Thomas Wei=C3=9Fschuh Tested-by: Arthur Kiyanovski Tested-by: David Woodhouse --- drivers/ptp/ptp_vmclock.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/ptp/ptp_vmclock.c +++ b/drivers/ptp/ptp_vmclock.c @@ -132,7 +132,7 @@ static int vmclock_get_crosststamp(struc * will be derived from the *same* counter value. * * If the system isn't using the same counter, then the value - * from ktime_get_snapshot() will still be used as pre_ts, and + * from ktime_get_snapshot_id() will still be used as pre_ts, and * ptp_read_system_postts() is called to populate postts after * calling get_cycles(). * @@ -140,7 +140,7 @@ static int vmclock_get_crosststamp(struc * the seq_count loop. */ if (sts) { - ktime_get_snapshot(&systime_snapshot); + ktime_get_snapshot_id(&systime_snapshot, CLOCK_REALTIME); if (systime_snapshot.cs_id =3D=3D st->cs_id) { cycle =3D systime_snapshot.cycles; } else { @@ -181,7 +181,7 @@ static int vmclock_get_crosststamp(struc } =20 if (sts) { - sts->pre_ts =3D ktime_to_timespec64(systime_snapshot.real); + sts->pre_ts =3D ktime_to_timespec64(systime_snapshot.sys); if (systime_snapshot.cs_id =3D=3D st->cs_id) sts->post_ts =3D sts->pre_ts; } @@ -272,7 +272,7 @@ static int ptp_vmclock_getcrosststamp(st if (ret =3D=3D -ENODEV) { struct system_time_snapshot systime_snapshot; =20 - ktime_get_snapshot(&systime_snapshot); + ktime_get_snapshot_id(&systime_snapshot, CLOCK_REALTIME); =20 if (systime_snapshot.cs_id =3D=3D CSID_X86_TSC || systime_snapshot.cs_id =3D=3D CSID_X86_KVM_CLK) { From nobody Mon Jun 8 20:41:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 E9D98408011; Tue, 26 May 2026 17:14:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815653; cv=none; b=H7Em9Ai3O5zRVSEqJiTpv5O2HT4gPOvbaJ5CB7zjJOzz3JYIfzVDy4Neb3j1I4KTruHL+mDq01qOG+BFgSStOYU5wkL9J/02P4E7+KxRnRXXLdKGjYhT28+jphqncdRglr6z1s+OSs9jb+PcMetlGDqv6rjAKHeXWYB6GokufGc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815653; c=relaxed/simple; bh=STmBwqCS69f3H1B/WdQPyC9A5JSbEcuGaZP9yLFIjdk=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=uB0dw+Nsam4pheVEsQRvG4NCF7/wOtS81eAsV+EnDT707i3FPmqGHfBJfsDAaee4lgTA2YnMAFpSqRHfpZmRQpHsY1wpdJYxlVGCtQ1NMIplXmP9eIV01sdGXDwIbXGHVntGuqGaG1B8r0iml3v1WNty5fwIdZgfmfizl0GLJus= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eCFKYpyZ; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eCFKYpyZ" Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id 5FE351F000E9; Tue, 26 May 2026 17:14:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779815651; bh=rk/n5DCog2RqWoJ0i1Irxgkuc/EgZJSjx162WFCBbzc=; h=Date:From:To:Cc:Subject:References; b=eCFKYpyZucjpAEYv4wwh7vyYhZ3u+nHy0uIc5m+7G5LfPuCIqEKgu2exTK1BifpVz 3SJKUnDDcaWvZkztVHKcbAg4zFpeuMAhimkMMQB43Tjw/ZzM83zBsvJJYrITTQKyP2 pbbe359SHMnJPVu5Np6y9mqJi5McS1/wPtT4v4vmAvmfy4u9D47qjdAoUEF449Y5No qRgdd7PzqIDK0VdNurHYovJBEqUvPegjnTbs54kNgMje6DoDMQBbxhGPfRK9GK6Dvl ubYLQaai2lis6h36Q8G1CKgGnbwlOnQHg6V3uo4P54CzyoN2SePMUwoVoeiu/UWFTF +LlkgJ0lHhL6w== Date: Tue, 26 May 2026 19:14:08 +0200 Message-ID: <20260526171223.300914258@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: David Woodhouse , Miroslav Lichvar , John Stultz , Stephen Boyd , Anna-Maria Behnsen , Frederic Weisbecker , thomas.weissschuh@linutronix.de, Arthur Kiyanovski , Rodolfo Giometti , Vincent Donnefort , Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, Oliver Upton , Richard Cochran , netdev@vger.kernel.org, Takashi Iwai , Miri Korenblit , Johannes Berg , Jacob Keller , Tony Nguyen , Saeed Mahameed , Peter Hilber , "Michael S. Tsirkin" , virtualization@lists.linux.dev, linux-wireless@vger.kernel.org, linux-sound@vger.kernel.org Subject: [patch 08/24] timekeeping: Remove system_time_snapshot::real/boot References: <20260526165826.392227559@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" All users are converted over to ktime_get_snapshot_id() and system_time_snapshot::sys. Remove the leftovers. Signed-off-by: Thomas Gleixner Reviewed-by: David Woodhouse Reviewed-by: Jacob Keller Reviewed-by: Thomas Wei=C3=9Fschuh Tested-by: Arthur Kiyanovski Tested-by: David Woodhouse --- include/linux/timekeeping.h | 4 ---- kernel/time/timekeeping.c | 8 -------- 2 files changed, 12 deletions(-) --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -280,8 +280,6 @@ static inline bool ktime_get_aux_ts64(cl * a selected CLOCK_* and the clocksource counter value * @cycles: Clocksource counter value to produce the system times * @sys: The system time of the selected CLOCK ID - * @real: Realtime system time - * @boot: Boot time * @raw: Monotonic raw system time * @cs_id: Clocksource ID * @clock_was_set_seq: The sequence number of clock-was-set events @@ -291,8 +289,6 @@ static inline bool ktime_get_aux_ts64(cl struct system_time_snapshot { u64 cycles; ktime_t sys; - ktime_t real; - ktime_t boot; ktime_t raw; enum clocksource_ids cs_id; unsigned int clock_was_set_seq; --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1196,8 +1196,6 @@ bool ktime_get_snapshot_id(struct system struct timekeeper *tk; struct tk_data *tkd; unsigned int seq; - ktime_t base_real; - ktime_t base_boot; =20 /* Invalidate the snapshot for all failure cases */ systime_snapshot->valid =3D false; @@ -1239,18 +1237,12 @@ bool ktime_get_snapshot_id(struct system offs_sys =3D *offs; base_raw =3D tk->tkr_raw.base; =20 - /* Kept around until the callers are fixed up */ - base_real =3D ktime_add(base_sys, tk_core.timekeeper.offs_real); - base_boot =3D ktime_add(base_sys, tk_core.timekeeper.offs_boot); - nsec_sys =3D timekeeping_cycles_to_ns(&tk->tkr_mono, now); nsec_raw =3D timekeeping_cycles_to_ns(&tk->tkr_raw, now); } while (read_seqcount_retry(&tkd->seq, seq)); =20 systime_snapshot->cycles =3D now; systime_snapshot->sys =3D ktime_add_ns(base_sys, offs_sys + nsec_sys); - systime_snapshot->real =3D ktime_add_ns(base_real, nsec_sys); - systime_snapshot->boot =3D ktime_add_ns(base_boot, nsec_sys); systime_snapshot->raw =3D ktime_add_ns(base_raw, nsec_raw); =20 /* From nobody Mon Jun 8 20:41:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 91F2D4048A7; Tue, 26 May 2026 17:14:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815657; cv=none; b=a9wZCAlZmwPO4H6zIYQnSO1JnCsfmY83kVtCvxtfKjs4TvmxEhTHwYMVNt9l03pDX8ajOkifSvcmirqbc2t3/9AfuJwLc4L87GU9ufqrd0vD73WU+ZhSDRMCs1DUKzYR1dFUpFvKipAWyOYgf7rkTDot3xBSwCehwo+0wFHHrSI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815657; c=relaxed/simple; bh=NARuUrkHmNevlyIPFQFIlrHQGoHA/MiQ41mOIukkYr0=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=ciTaaTQDq44LuLx4TkHAKgXlgmhtRkr0p+oebKoWQt1NWVZO21RHYifv5Ezy/s7DxPJBLvF+R2+01Ol+D/OvuZZpv2X6hkCZbjLk5sMRtgJw1J2Hke8Cl3mTIkLzGMrSSrigTkHlR62pcHzAc5uOmZ3FesmyuxeVePKbBC7wzL4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jrc2F73Z; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jrc2F73Z" Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id 685011F000E9; Tue, 26 May 2026 17:14:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779815656; bh=Zuslkw/wyLuc6P6SYlU885Bs4PDs+BVXU769LA34MfA=; h=Date:From:To:Cc:Subject:References; b=jrc2F73Zqf+wrR8aePRalmTTp1CxIywOZfK7+g19mZb6cP/i9FMMelBgNfiV0WioR wSBUZwhGtNXmlyg2ywnHYoOUzbECrYAgoF8anRf6IDr+cdD3tv+lxOXEkcMkkU3TXL zsLYsSdlAJUzxlUhu6WcBYc93NhqoNxGqPJJLIi7L8G5qAq6t9nrzfSntyVNhD/M2f matYf0ZaYZf+xVuh6dom0b3Wxu6ESPiQIRWsmYzmRC2g7/5qgAvNeDUjWwod5xeqWb aoDyzVBk9jzWigFzvAC+1saO6Q+gH4XRHaGgUytnmWo5mcOubBx/Yt/gvHCYRbyPTJ 9dZkIsvJZgl6A== Date: Tue, 26 May 2026 19:14:13 +0200 Message-ID: <20260526171223.374814973@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: David Woodhouse , Miroslav Lichvar , John Stultz , Stephen Boyd , Anna-Maria Behnsen , Frederic Weisbecker , thomas.weissschuh@linutronix.de, Arthur Kiyanovski , Rodolfo Giometti , Vincent Donnefort , Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, Oliver Upton , Richard Cochran , netdev@vger.kernel.org, Takashi Iwai , Miri Korenblit , Johannes Berg , Jacob Keller , Tony Nguyen , Saeed Mahameed , Peter Hilber , "Michael S. Tsirkin" , virtualization@lists.linux.dev, linux-wireless@vger.kernel.org, linux-sound@vger.kernel.org Subject: [patch 09/24] timekeeping: Add CLOCK_AUX support for ktime_get_snapshot_id() References: <20260526165826.392227559@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now that all users are converted it's possible to enable snapshotting of CLOCK_AUX time. The underlying clocksource is the same as for all other CLOCK variants. Signed-off-by: Thomas Gleixner Reviewed-by: David Woodhouse Reviewed-by: Jacob Keller Reviewed-by: Thomas Wei=C3=9Fschuh Tested-by: Arthur Kiyanovski --- kernel/time/timekeeping.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -67,6 +67,7 @@ static inline bool tk_is_aux(const struc { return tk->id >=3D TIMEKEEPER_AUX_FIRST && tk->id <=3D TIMEKEEPER_AUX_LAS= T; } +static inline struct tk_data *aux_get_tk_data(clockid_t id); #else static inline bool tk_get_aux_ts64(unsigned int tkid, struct timespec64 *t= s) { @@ -77,6 +78,10 @@ static inline bool tk_is_aux(const struc { return false; } +static inline struct tk_data *aux_get_tk_data(clockid_t id) +{ + return NULL; +} #endif =20 static inline void tk_update_aux_offs(struct timekeeper *tk, ktime_t offs) @@ -1218,6 +1223,12 @@ bool ktime_get_snapshot_id(struct system tkd =3D &tk_core; offs =3D &tk_core.timekeeper.offs_boot; break; + case CLOCK_AUX ... CLOCK_AUX_LAST: + tkd =3D aux_get_tk_data(clock_id); + if (!tkd) + return false; + offs =3D &tkd->timekeeper.offs_aux; + break; default: WARN_ON_ONCE(1); return false; @@ -1228,6 +1239,10 @@ bool ktime_get_snapshot_id(struct system do { seq =3D read_seqcount_begin(&tkd->seq); =20 + /* Aux clocks can be invalid */ + if (!tk->clock_valid) + return false; + now =3D tk_clock_read(&tk->tkr_mono); systime_snapshot->cs_id =3D tk->tkr_mono.clock->id; systime_snapshot->cs_was_changed_seq =3D tk->cs_was_changed_seq; From nobody Mon Jun 8 20:41:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 9E6F54014AA; Tue, 26 May 2026 17:14:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815662; cv=none; b=jYIhfFlyR9akjz5CH3ersmvAUsUo0Ut+TjU/VOSAbLTQaxGtmE0naIS+aIDH8tI6Opamn/VkfeILHe/7bkddjqfdJbjnQUkA+DqonRmCvTSSBZ6Pwof2D8k6aFttM/UGxtmgXZvn8h9NP1BT9FoLzW9QqpKuxTQ7RQQrJvj0/GI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815662; c=relaxed/simple; bh=dWNNq8fiVdN+WDn5GaHOJN6Ksagnh/2Qvk/I2pZv9Mo=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=jl1ZPB8C4esoYtlgcqvffbkfeFzZANg6zSBSxp2nZ19a1Q64pGsgwtXxIxE8fu7WzDolNO966DiOwhLKVfKO/ZJoEWK6e8rInd+0+EwAAyTedeEtO8kOlKQUUN8uRDzyH4W45HGWn3M9iHaiT9PsTqekYC7TW/FOvppRioD0mMk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KNQ8Fpi9; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KNQ8Fpi9" Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id 6C7D81F000E9; Tue, 26 May 2026 17:14:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779815661; bh=2Gq19z55uKjR3IXd+Mf/0eopO8jyNxR32nvzywhnfzI=; h=Date:From:To:Cc:Subject:References; b=KNQ8Fpi9iZlj3+1Cud0AjFzYzrb4qE+FuB+PtNH7FF1OlfYdHD+MTKwjSnqwDpfiG 1aP66+EKqeHTWGg3aBmH6GGysrfHyMbErmvGGpOHjeThjx+1GmwArVVMtH94mh3Fv6 DMckC587PN3NKElqHVViXVXVSzeFFCmBABt2//r2GeEaA+jWnvntM34t+FvLYgpT0+ G3XsPvZ/OmX7ebup8xGR7ONWQS2ha94Z20gNU4bbE9kV9vz7EBudIzebz8Dw8+/wDa xJe6NpVHvzzc4mmjSEhF/qXwzt0Q1/E5iLSItZI6ghRpt3V3nwlH+iGNA7wcR3mUxE 8D/Iag8nJH8Wg== Date: Tue, 26 May 2026 19:14:18 +0200 Message-ID: <20260526171223.448889379@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: David Woodhouse , Miroslav Lichvar , John Stultz , Stephen Boyd , Anna-Maria Behnsen , Frederic Weisbecker , thomas.weissschuh@linutronix.de, Arthur Kiyanovski , Rodolfo Giometti , Vincent Donnefort , Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, Oliver Upton , Richard Cochran , netdev@vger.kernel.org, Takashi Iwai , Miri Korenblit , Johannes Berg , Jacob Keller , Tony Nguyen , Saeed Mahameed , Peter Hilber , "Michael S. Tsirkin" , virtualization@lists.linux.dev, linux-wireless@vger.kernel.org, linux-sound@vger.kernel.org Subject: [patch 10/24] timekeeping: Add system_counterval_t to struct system_device_crosststamp References: <20260526165826.392227559@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" An upcoming extension to the PTP IOCTL requires to return the system counter value and the clocksource ID to user space. get_device_system_crosststamp()= has this information already. Extend struct system_device_crosststamp with a system_counterval_t member and fill in the data. Signed-off-by: Thomas Gleixner Reviewed-by: David Woodhouse Reviewed-by: Jacob Keller Tested-by: Arthur Kiyanovski Tested-by: David Woodhouse --- include/linux/timekeeping.h | 28 ++++++++++++++------------ kernel/time/timekeeping.c | 46 ++++++++++++++++++++-------------------= ----- 2 files changed, 36 insertions(+), 38 deletions(-) --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -297,19 +297,6 @@ struct system_time_snapshot { }; =20 /** - * struct system_device_crosststamp - system/device cross-timestamp - * (synchronized capture) - * @device: Device time - * @sys_realtime: Realtime simultaneous with device time - * @sys_monoraw: Monotonic raw simultaneous with device time - */ -struct system_device_crosststamp { - ktime_t device; - ktime_t sys_realtime; - ktime_t sys_monoraw; -}; - -/** * struct system_counterval_t - system counter value with the ID of the * corresponding clocksource * @cycles: System counter value @@ -325,6 +312,21 @@ struct system_counterval_t { bool use_nsecs; }; =20 +/** + * struct system_device_crosststamp - system/device cross-timestamp + * (synchronized capture) + * @device: Device time + * @sys_counter: Clocksource counter value simultaneous with device time + * @sys_realtime: Realtime simultaneous with device time + * @sys_monoraw: Monotonic raw simultaneous with device time + */ +struct system_device_crosststamp { + ktime_t device; + struct system_counterval_t sys_counter; + ktime_t sys_realtime; + ktime_t sys_monoraw; +}; + extern bool ktime_real_to_base_clock(ktime_t treal, enum clocksource_ids base_id, u64 *cycles); extern bool timekeeping_clocksource_has_base(enum clocksource_ids id); --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1419,6 +1419,8 @@ static bool convert_base_to_cs(struct sy return false; =20 scv->cycles +=3D base->offset; + /* Set the clocksource ID as scv::cycles is now clocksource based */ + scv->cs_id =3D cs->id; return true; } =20 @@ -1486,11 +1488,11 @@ EXPORT_SYMBOL_GPL(ktime_real_to_base_clo =20 /** * get_device_system_crosststamp - Synchronously capture system/device tim= estamp - * @get_time_fn: Callback to get simultaneous device time and - * system counter from the device driver + * @get_time_fn: Callback to get simultaneous device time and system count= er + * from the device driver * @ctx: Context passed to get_time_fn() - * @history_begin: Historical reference point used to interpolate system - * time when counter provided by the driver is before the current interval + * @history_begin: Historical reference point used to interpolate system t= ime when + * the counter value provided by the driver is before the current interv= al * @xtstamp: Receives simultaneously captured system and device time * * Reads a timestamp from a device and correlates it to system time @@ -1503,14 +1505,12 @@ int get_device_system_crosststamp(int (* struct system_time_snapshot *history_begin, struct system_device_crosststamp *xtstamp) { - struct system_counterval_t system_counterval =3D {}; + u64 syscnt_cycles, cycles, now, interval_start; struct timekeeper *tk =3D &tk_core.timekeeper; - u64 cycles, now, interval_start; - unsigned int clock_was_set_seq =3D 0; + unsigned int seq, clock_was_set_seq =3D 0; ktime_t base_real, base_raw; u64 nsec_real, nsec_raw; u8 cs_was_changed_seq; - unsigned int seq; bool do_interp; int ret; =20 @@ -1520,19 +1520,20 @@ int get_device_system_crosststamp(int (* * Try to synchronously capture device time and a system * counter value calling back into the device driver */ - ret =3D get_time_fn(&xtstamp->device, &system_counterval, ctx); + ret =3D get_time_fn(&xtstamp->device, &xtstamp->sys_counter, ctx); if (ret) return ret; =20 /* * Verify that the clocksource ID associated with the captured * system counter value is the same as for the currently - * installed timekeeper clocksource + * installed timekeeper clocksource and convert to it. */ - if (system_counterval.cs_id =3D=3D CSID_GENERIC || - !convert_base_to_cs(&system_counterval)) + if (xtstamp->sys_counter.cs_id =3D=3D CSID_GENERIC || + !convert_base_to_cs(&xtstamp->sys_counter)) return -ENODEV; - cycles =3D system_counterval.cycles; + + cycles =3D syscnt_cycles =3D xtstamp->sys_counter.cycles; =20 /* * Check whether the system counter value provided by the @@ -1574,24 +1575,19 @@ int get_device_system_crosststamp(int (* * clocksource change */ if (!history_begin || - !timestamp_in_interval(history_begin->cycles, - cycles, system_counterval.cycles) || + !timestamp_in_interval(history_begin->cycles, cycles, syscnt_cycles)= || history_begin->cs_was_changed_seq !=3D cs_was_changed_seq) return -EINVAL; - partial_history_cycles =3D cycles - system_counterval.cycles; + + partial_history_cycles =3D cycles - syscnt_cycles; total_history_cycles =3D cycles - history_begin->cycles; - discontinuity =3D - history_begin->clock_was_set_seq !=3D clock_was_set_seq; + discontinuity =3D history_begin->clock_was_set_seq !=3D clock_was_set_se= q; =20 - ret =3D adjust_historical_crosststamp(history_begin, - partial_history_cycles, - total_history_cycles, - discontinuity, xtstamp); - if (ret) - return ret; + ret =3D adjust_historical_crosststamp(history_begin, partial_history_cyc= les, + total_history_cycles, discontinuity, xtstamp); } =20 - return 0; + return ret; } EXPORT_SYMBOL_GPL(get_device_system_crosststamp); From nobody Mon Jun 8 20:41:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 B912E406267; Tue, 26 May 2026 17:14:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815667; cv=none; b=Won36r136W01883+pfyyMAfEO900cwG8THLT/OHnORJG4Rj3lo6lH0uy5whTX1H/NK6g3A6BXfHwWnr9WkIaAg+Xt3xFyfAl7u6P5i0v77iSIqQ10BqSDaO5Jhymn1jg8waLZFLXxbNwdCcvUJegtWfnhViuBQkpbFXYGl5ql/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815667; c=relaxed/simple; bh=UnUe9MHT86IThOANvTClBCvas7NQoNn77t2q9Prf/ik=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=Ox4u1ee+3M0d54r8oGC15jOGLtb0P1K1rOB+jWqtpJuSsM2U1lZRp2uIcyfOo1E0zvXmgJJBUB9dVdLmud0tPGJV9s+/qSadaxHZks0BbQDQEyMfpcMKHljpBHc1Xh0V30Pr1Y56I8hezRS9z0rMDmyXy9cO8MoL3wyWgDxHV7U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SH3Q+0BX; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SH3Q+0BX" Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id 87A6A1F000E9; Tue, 26 May 2026 17:14:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779815666; bh=o35TybNtvElFbKMNcpkUkArI5s3Bfjkcl70NZOwwDvM=; h=Date:From:To:Cc:Subject:References; b=SH3Q+0BXJ/kvGPA1mD6EzHR1nyZZl/R6Lcn8Jizr3YR4dnpZtwuTWq4uzVL47/rLL 5brlYKUILwdaMFvaIBkIGOAhu5mlxr1v7lX/Yom1ehEaqJNk+x9W/xn/R/VAyFhhGn L9s/v0D8C1TJhu5qfx3V6NntM2jGXTQFL1qh/RkfS8dgYiPBniuO9OaEfRT31Wy9l6 mEd7ipCj9oZnHgxGyzqorQveNcjeYoYrk4HW6BVVDBtjpN5Qe74mc0y6YKFpf5zsEI UKq/FnrIwIYK6ve9lAW05B5w7K1fWPlMyRnXUw7dsGS6kDddj0rPs2aXDS8pj71XhF aA19BE44qWk+w== Date: Tue, 26 May 2026 19:14:23 +0200 Message-ID: <20260526171223.522578743@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: David Woodhouse , Miroslav Lichvar , John Stultz , Stephen Boyd , Anna-Maria Behnsen , Frederic Weisbecker , thomas.weissschuh@linutronix.de, Arthur Kiyanovski , Richard Cochran , Takashi Iwai , netdev@vger.kernel.org, Rodolfo Giometti , Vincent Donnefort , Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, Oliver Upton , Miri Korenblit , Johannes Berg , Jacob Keller , Tony Nguyen , Saeed Mahameed , Peter Hilber , "Michael S. Tsirkin" , virtualization@lists.linux.dev, linux-wireless@vger.kernel.org, linux-sound@vger.kernel.org Subject: [patch 11/24] timekeeping: Add CLOCK ID to system_device_crosststamp References: <20260526165826.392227559@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The normal capture for system/device cross timestamps is CLOCK_REALTIME, but that's meaningless for AUX clocks. Add a clock_id field to struct system_device_crosststamp and initialize it with CLOCK_REALTIME at the two places which prepare for cross timestamps. After the related code has been cleaned up, the core code will honor the clock_id field when calculating the system time from the system counter snapshot. No functional change. Signed-off-by: Thomas Gleixner Cc: Richard Cochran Cc: Takashi Iwai Cc: netdev@vger.kernel.org Reviewed-by: David Woodhouse Reviewed-by: Jacob Keller Tested-by: Arthur Kiyanovski Tested-by: David Woodhouse --- drivers/ptp/ptp_chardev.c | 2 +- include/linux/timekeeping.h | 2 ++ sound/hda/common/controller.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) --- a/drivers/ptp/ptp_chardev.c +++ b/drivers/ptp/ptp_chardev.c @@ -317,8 +317,8 @@ typedef int (*ptp_crosststamp_fn)(struct static long ptp_sys_offset_precise(struct ptp_clock *ptp, void __user *arg, ptp_crosststamp_fn crosststamp_fn) { + struct system_device_crosststamp xtstamp =3D { .clock_id =3D CLOCK_REALTI= ME }; struct ptp_sys_offset_precise precise_offset; - struct system_device_crosststamp xtstamp; struct timespec64 ts; int err; =20 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -315,12 +315,14 @@ struct system_counterval_t { /** * struct system_device_crosststamp - system/device cross-timestamp * (synchronized capture) + * @clock_id: System time Clock ID to capture * @device: Device time * @sys_counter: Clocksource counter value simultaneous with device time * @sys_realtime: Realtime simultaneous with device time * @sys_monoraw: Monotonic raw simultaneous with device time */ struct system_device_crosststamp { + clockid_t clock_id; ktime_t device; struct system_counterval_t sys_counter; ktime_t sys_realtime; --- a/sound/hda/common/controller.c +++ b/sound/hda/common/controller.c @@ -489,9 +489,9 @@ static int azx_get_time_info(struct snd_ struct snd_pcm_audio_tstamp_config *audio_tstamp_config, struct snd_pcm_audio_tstamp_report *audio_tstamp_report) { + struct system_device_crosststamp xtstamp =3D { .clock_id =3D CLOCK_REALTI= ME }; struct azx_dev *azx_dev =3D get_azx_dev(substream); struct snd_pcm_runtime *runtime =3D substream->runtime; - struct system_device_crosststamp xtstamp; int ret; u64 nsec; From nobody Mon Jun 8 20:41:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 AC62640802D; Tue, 26 May 2026 17:14:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815672; cv=none; b=QQZ1yn0mFgQzf3dFyd427QZG/+UG+p09Hp1xLNnsfIdPVwxYUzhm7Kd7lbaik47qd54Klkyk35bviy6hJoWm9ELfbOjgsPKpEY4Es1+x/J/wbwJxWcM/GdmObSkzOixWTVTkbymAnfAk0vI7HjiQ6gA9tlcOCXn0JKxWx3fOhaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815672; c=relaxed/simple; bh=pVBKZTTjKnVYIsgkX1sP0itgWIRCCaZAzYFdMftMFDk=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=H/EeNNWF+DjicyNFZ0saSW0Mrr8wGKtjlJdrwDhlVrX/cdUwzKdffyIPn7pGhWjveQuvCgqS0qF5en+y+AUOxn56T/OKHFESZmwrkMzr8RihXj9xMjgttdu+56rGWhKySeZ+DrAD5qHMYLUjGrF8zHckWGD4IvhSuvaiXiP7vps= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q/RUX++h; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Q/RUX++h" Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id 8B78C1F000E9; Tue, 26 May 2026 17:14:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779815671; bh=01BvEX50d1bs98mqnVQxb7uaA9htZEJOC8eRW013CR8=; h=Date:From:To:Cc:Subject:References; b=Q/RUX++hykS+Vi5lfam5+d5XGwkcNEueC7yv3oT4tUtXasYUycjVPh7zYBZdF8ZSw uHl08C4ag3dpFszduUg6293PaZEG35rYC2ezuacZ8QlhNACaFvKfx2NWzuQ6GuHB1A hW9ZpM+i22CIanaBxHH0MyGa0xaaVKxHzxnXpZxsJDfsAFGRykLejd86k5mprL66zY WDjrE2GCF1DgZniWN/wvd2FTEZxqkBFmB6s7b8tAcfhqiSRB3M0aZdgIr0J+f1KuAD W5xYdv/konHf7LzLU09NHSl6AX1b5Wod2p1b0hDrUiEXONgAqtIBQDJRVgrKoRmJ7x 5OKFrkLEoQDuw== Date: Tue, 26 May 2026 19:14:28 +0200 Message-ID: <20260526171223.596169122@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: David Woodhouse , Miroslav Lichvar , John Stultz , Stephen Boyd , Anna-Maria Behnsen , Frederic Weisbecker , thomas.weissschuh@linutronix.de, Arthur Kiyanovski , Miri Korenblit , Johannes Berg , Rodolfo Giometti , Vincent Donnefort , Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, Oliver Upton , Richard Cochran , netdev@vger.kernel.org, Takashi Iwai , Jacob Keller , Tony Nguyen , Saeed Mahameed , Peter Hilber , "Michael S. Tsirkin" , virtualization@lists.linux.dev, linux-wireless@vger.kernel.org, linux-sound@vger.kernel.org Subject: [patch 12/24] wifi: iwlwifi: Adopt PTP cross timestamps to core changes References: <20260526165826.392227559@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" iwlwifi only supports CLOCK_REALTIME timestamps and provides an incomplete result without system counter values etc. It also zeros struct system_device_crosststamp, which is already zeroed in the core and initialized with the clock ID. Remove the zeroing and reject any request for a clock ID other than REALTIM= E. Signed-off-by: Thomas Gleixner Cc: Miri Korenblit Cc: Johannes Berg Reviewed-by: David Woodhouse Reviewed-by: Jacob Keller Tested-by: Arthur Kiyanovski --- drivers/net/wireless/intel/iwlwifi/mld/ptp.c | 3 ++- drivers/net/wireless/intel/iwlwifi/mvm/ptp.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) --- a/drivers/net/wireless/intel/iwlwifi/mld/ptp.c +++ b/drivers/net/wireless/intel/iwlwifi/mld/ptp.c @@ -250,7 +250,8 @@ iwl_mld_phc_get_crosstimestamp(struct pt /* System (wall) time */ ktime_t sys_time; =20 - memset(xtstamp, 0, sizeof(struct system_device_crosststamp)); + if (xtstamp->clock_id !=3D CLOCK_REALTIME) + return -ENOTSUPP; =20 ret =3D iwl_mld_get_crosstimestamp_fw(mld, &gp2, &sys_time); if (ret) { --- a/drivers/net/wireless/intel/iwlwifi/mvm/ptp.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/ptp.c @@ -160,13 +160,14 @@ iwl_mvm_phc_get_crosstimestamp(struct pt /* System (wall) time */ ktime_t sys_time; =20 - memset(xtstamp, 0, sizeof(struct system_device_crosststamp)); - if (!mvm->ptp_data.ptp_clock) { IWL_ERR(mvm, "No PHC clock registered\n"); return -ENODEV; } =20 + if (xtstamp->clock_id !=3D CLOCK_REALTIME) + return -ENOTSUPP; + mutex_lock(&mvm->mutex); if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_SYNCED_TIME)) { ret =3D iwl_mvm_get_crosstimestamp_fw(mvm, &gp2, &sys_time); From nobody Mon Jun 8 20:41:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 3FD4238C42F; Tue, 26 May 2026 17:14:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815677; cv=none; b=fOh4PX/tVslmuPXNu1hSDcoaGfUo/xRp9QcSq+fc0fPaiC8Pd6VhVu+dlfSIBpcEwecpKbCEXCXMHDSxYfQoEWjpPd5LVxwblZmXnjXSCbNt0LodNduuOjKn46IrLzI+FJTiPrJN/kp1HpTlsInLZOR02zpMkK7A+rYqva8jCus= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815677; c=relaxed/simple; bh=DArheUVO61XUzBgNB85AXjNmnIHLUI6Q0bxHpApsjVk=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=der1Ax1U2X87uSCpp6KZL4GPHVpElzc6Rc2o+kcxBYFvHKECD/brwceTBeO3TLxYQ2e3Ka6iCZdtlZ5p5o2B8r7Qo2JwKgv2HO3hBdMBvZKmajqTM8zpQXtblWlu8AfrOY/jIbavhwBJ8MNrlGriCDGGkAh0Av7bojgarsIOMuo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gh61Pf2b; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gh61Pf2b" Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id 45BC01F00A3A; Tue, 26 May 2026 17:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779815676; bh=tIfdsxtLHEHKv/HG7wFZVqMYMQjPHg6WbV6XiYCEtAA=; h=Date:From:To:Cc:Subject:References; b=gh61Pf2bwkkQRe4nF/oglZC6S3bL38FPLNua214+hjlq7CLs3e+8TQ1kVFMIMGbWp cDFlwvHmqEJ5YgC6SsOIsg+0ONZvyC7a1yZdPj0vCwmWJKpSfYu8wuaEk0Xa4R66AI yT919lxYqGEh2p6izz2Q6StZgUlljlLBfvWbPgIRLHgsLrnFq9Lhogi5p/721sfYBF WdMq2SsGbt7YFS5iVzhR5088g8zXNn3ecoN1tjcZEHVmwUn+ILdBXtxxlHTOEttoHN DDPdy6vQzBUcak7rWUxxkLSDuIDrSps7DUK/yhzv07lyBXob07ZWx9HNjSP6qHXtpK grztSygWBlwtQ== Date: Tue, 26 May 2026 19:14:33 +0200 Message-ID: <20260526171223.670955218@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: David Woodhouse , Miroslav Lichvar , John Stultz , Stephen Boyd , Anna-Maria Behnsen , Frederic Weisbecker , thomas.weissschuh@linutronix.de, Arthur Kiyanovski , Jacob Keller , Rodolfo Giometti , Vincent Donnefort , Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, Oliver Upton , Richard Cochran , netdev@vger.kernel.org, Takashi Iwai , Miri Korenblit , Johannes Berg , Tony Nguyen , Saeed Mahameed , Peter Hilber , "Michael S. Tsirkin" , virtualization@lists.linux.dev, linux-wireless@vger.kernel.org, linux-sound@vger.kernel.org Subject: [patch 13/24] ice/ptp: Use provided clock ID for history snapshot References: <20260526165826.392227559@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The PTP core indicates in system_device_crosststamp::clock_id the clock ID for which then system time stamp should be taken. That allows to utilize hardware timestamps with e.g. AUX clocks. Save the provided clock ID and use it in ice_capture_crosststamp() for taking the history snapshot. No functional change. Signed-off-by: Thomas Gleixner Cc: Jacob Keller Acked-by: Jacob Keller Reviewed-by: David Woodhouse Reviewed-by: Jacob Keller Tested-by: Arthur Kiyanovski --- drivers/net/ethernet/intel/ice/ice_ptp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -2065,11 +2065,13 @@ static const struct ice_crosststamp_cfg /** * struct ice_crosststamp_ctx - Device cross timestamp context * @snapshot: snapshot of system clocks for historic interpolation + * @snapshot_clock_id: System clock ID for @snapshot * @pf: pointer to the PF private structure * @cfg: pointer to hardware configuration for cross timestamp */ struct ice_crosststamp_ctx { struct system_time_snapshot snapshot; + clockid_t snapshot_clock_id; struct ice_pf *pf; const struct ice_crosststamp_cfg *cfg; }; @@ -2115,7 +2117,7 @@ static int ice_capture_crosststamp(ktime } =20 /* Snapshot system time for historic interpolation */ - ktime_get_snapshot(&ctx->snapshot); + ktime_get_snapshot_id(&ctx->snapshot, ctx->snapshot_clock_id); =20 /* Program cmd to master timer */ ice_ptp_src_cmd(hw, ICE_PTP_READ_TIME); @@ -2176,6 +2178,7 @@ static int ice_ptp_getcrosststamp(struct { struct ice_pf *pf =3D ptp_info_to_pf(info); struct ice_crosststamp_ctx ctx =3D { + .snapshot_clock_id =3D cts->clock_id, .pf =3D pf, }; From nobody Mon Jun 8 20:41:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 578A338C42F; Tue, 26 May 2026 17:14:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815682; cv=none; b=YSjXG2YMWnUU6PfXa7SNrq6YHTSwoKoWzi8b5HB6xCV5BwSZM2Ah9+ROTK/oLbz1RffB6S4WkT3VXiKUzVnUTcSBVGhr3ZG7jJc5nlyrPMipmdBM452bvOWaTU8Osr+NOluv4kgyILNXQjvtu3wvqUEqcdDwayMoc4RuLgOTypw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815682; c=relaxed/simple; bh=FMGiUIWW29SL0cXr9CKSy7VJv5vDZCiZTj4ZKb2FdvQ=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=RS6gP1RmF96rtPP/ykk0YuM/2WphnOjebY5pswFJP8LcPblzdiao18dq4j6GOtUFybDWeL/+p5rdmxgRAN5+IoBDhWNkq7vzI5kN7hleK4ByelGGcDKLHZJLTO45jDuIblTtlX9sEgTr5y90zlJDrwa00LK8UyIvif4YMuSjjUg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JVagiMvh; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JVagiMvh" Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id 4A0861F000E9; Tue, 26 May 2026 17:14:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779815681; bh=R0VKXSe8JW8k5VwE7MkMVpULu2pZ+xlu5Y3DpfUjVmo=; h=Date:From:To:Cc:Subject:References; b=JVagiMvhbmqyJMx9X+aTaV+UDZZvwgWYIrS+aNgU2okDyiRIvRvbFwz/A29WTxXS8 51r1Q1MIsLtqJQrlTjMBT49ltU+58Q0N4q877Fv2BGYN9x445JKtjA7c2do/7EeG2+ TaruBcMC5dzJrtT+otenMpWyTM3hE6yxlGWZkq2pIW1+1iUkU0Qvt+v2sYFuUbUfUV NIV905YFJB86dXqFnuJxK39b8EQ2knTmu0hqMojX10drt1XUyieb8jsVsU6lkRTBBm LtMs0ZDHSYln9h16lwj6xJA+iKtE9+hfHS1MiqAdOnrSnVDgT/imOMh0wC8Kg59MIZ qQNWppVCV66cA== Date: Tue, 26 May 2026 19:14:37 +0200 Message-ID: <20260526171223.745281238@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: David Woodhouse , Miroslav Lichvar , John Stultz , Stephen Boyd , Anna-Maria Behnsen , Frederic Weisbecker , thomas.weissschuh@linutronix.de, Arthur Kiyanovski , Tony Nguyen , Rodolfo Giometti , Vincent Donnefort , Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, Oliver Upton , Richard Cochran , netdev@vger.kernel.org, Takashi Iwai , Miri Korenblit , Johannes Berg , Jacob Keller , Saeed Mahameed , Peter Hilber , "Michael S. Tsirkin" , virtualization@lists.linux.dev, linux-wireless@vger.kernel.org, linux-sound@vger.kernel.org Subject: [patch 14/24] igc: Use provided clock ID for history snapshot References: <20260526165826.392227559@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The PTP core indicates in system_device_crosststamp::clock_id the clock ID for which the system time stamp should be taken. That allows to utilize hardware timestamps with e.g. AUX clocks. Save the provided clock ID and use it in igc_phc_get_syncdevicetime() for taking the history snapshot. No functional change. Signed-off-by: Thomas Gleixner Cc: Tony Nguyen Acked-by: Jacob Keller Reviewed-by: David Woodhouse Reviewed-by: Jacob Keller Tested-by: Arthur Kiyanovski --- drivers/net/ethernet/intel/igc/igc.h | 1 + drivers/net/ethernet/intel/igc/igc_ptp.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) --- a/drivers/net/ethernet/intel/igc/igc.h +++ b/drivers/net/ethernet/intel/igc/igc.h @@ -326,6 +326,7 @@ struct igc_adapter { struct timespec64 prev_ptp_time; /* Pre-reset PTP clock */ ktime_t ptp_reset_start; /* Reset time in clock mono */ struct system_time_snapshot snapshot; + clockid_t snapshot_clock_id; struct mutex ptm_lock; /* Only allow one PTM transaction at a time */ =20 char fw_version[32]; --- a/drivers/net/ethernet/intel/igc/igc_ptp.c +++ b/drivers/net/ethernet/intel/igc/igc_ptp.c @@ -1049,7 +1049,7 @@ static int igc_phc_get_syncdevicetime(kt */ do { /* Get a snapshot of system clocks to use as historic value. */ - ktime_get_snapshot(&adapter->snapshot); + ktime_get_snapshot_id(&adapter->snapshot, adapter->snapshot_clock_id); =20 igc_ptm_trigger(hw); =20 @@ -1103,6 +1103,8 @@ static int igc_ptp_getcrosststamp(struct /* This blocks until any in progress PTM transactions complete */ mutex_lock(&adapter->ptm_lock); =20 + adapter->snapshot_clock_id =3D cts->clock_id; + ret =3D get_device_system_crosststamp(igc_phc_get_syncdevicetime, adapter, &adapter->snapshot, cts); mutex_unlock(&adapter->ptm_lock); From nobody Mon Jun 8 20:41:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 535D8403E99; Tue, 26 May 2026 17:14:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815687; cv=none; b=qeQTjGPTCrIEzE0siYs7GFFyFaY5WMGrMj7KY3rQw1G2FHOFPulY0KBC5rnRrLOADGeac6Im9W8Bk5oZ2JWEDP6IkxOHas/YL28WYJ5E8VC8s46HCeNpaqNkgrpS0E8b6dEwZ1VkLzl9kC1Q0+KVFW7+w/A3G8tRA9WNuZ20PQs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815687; c=relaxed/simple; bh=eqDmv2UxJrRVlr6eig+h4vADLMNuDousFQxN6Zd4qtI=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=n1kCtIy/BoL7wGh2iLMdSjf31jWnl4UIw6geHDIde7HhkW8ynC7FuGC4eCcJNblKg6VPJc1oQPSzxzvWlQTB0V7b4upVslYn1p2BV1OP/ELfAPuk6G84U/A+ljQpeqaIyNs8mHEH4z5ITMHmE8B/B6O1AUxLZjZaG4VNhO02lzw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cILTQson; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cILTQson" Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id 1B2411F000E9; Tue, 26 May 2026 17:14:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779815686; bh=cBO+dX735CksKtXJ1HJ6TXwHjNQmqyoR/p2tV7cxXb0=; h=Date:From:To:Cc:Subject:References; b=cILTQsonW++0qS7x+cFj3PEdFUuahq/pXsnEuKC8tyzniFVBXJd5h8Ig+wX52U8nw gvjeABRhU4sekjYYnLQT9DOEehvX5hcUhBx5B0E41+Zd2Z/FwXGbjiB5GPOCcBEFrm EGyNzpdo6ZS3w3lEShtw8oaNynpYrJLZnNlBGexShIj5GrhT7qzy84w5ReeffvpeMt 6qwlJJVOwtf8GkuyB0WyjKN7lHEfi5wyIE0Z8XsKLlqqq+rlP8pt/NdLpmHeWOGVqN TXuSzUw1zK+ZvcOTSlzyDDXes/VBxBcl3zCCVCRQbEy+JQ8Df3/e4xGFlXzdDqyUJL vg0GpsVpO/enw== Date: Tue, 26 May 2026 19:14:42 +0200 Message-ID: <20260526171223.826096151@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: David Woodhouse , Miroslav Lichvar , John Stultz , Stephen Boyd , Anna-Maria Behnsen , Frederic Weisbecker , thomas.weissschuh@linutronix.de, Arthur Kiyanovski , Saeed Mahameed , Rodolfo Giometti , Vincent Donnefort , Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, Oliver Upton , Richard Cochran , netdev@vger.kernel.org, Takashi Iwai , Miri Korenblit , Johannes Berg , Jacob Keller , Tony Nguyen , Peter Hilber , "Michael S. Tsirkin" , virtualization@lists.linux.dev, linux-wireless@vger.kernel.org, linux-sound@vger.kernel.org Subject: [patch 15/24] net/mlx5: Use provided clock ID for history snapshot References: <20260526165826.392227559@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The PTP core indicates in system_device_crosststamp::clock_id the clock ID for which the system time stamp should be taken. That allows to utilize hardware timestamps with e.g. AUX clocks. Use ktime_get_snapshot_id() and hand the provided clock ID in. No functional change. Signed-off-by: Thomas Gleixner Cc: Saeed Mahameed Reviewed-by: David Woodhouse Reviewed-by: Jacob Keller Tested-by: Arthur Kiyanovski --- drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c @@ -340,7 +340,7 @@ static int mlx5_ptp_getcrosststamp(struc goto unlock; } =20 - ktime_get_snapshot(&history_begin); + ktime_get_snapshot_id(&history_begin, cts->clock_id); =20 err =3D get_device_system_crosststamp(mlx5_mtctr_syncdevicetime, mdev, &history_begin, cts); @@ -366,7 +366,7 @@ static int mlx5_ptp_getcrosscycles(struc goto unlock; } =20 - ktime_get_snapshot(&history_begin); + ktime_get_snapshot_id(&history_begin, cts->clock_id); =20 err =3D get_device_system_crosststamp(mlx5_mtctr_syncdevicecyclestime, mdev, &history_begin, cts); From nobody Mon Jun 8 20:41:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 1A15A403E99; Tue, 26 May 2026 17:14:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815692; cv=none; b=leRuXjcTM88QClggEVx3mcrGFelppFXN8tru5UnnIukmtoxOyk4APgGNAsfva62Ib8WcsCJnCQj/MWDyXos9K97cA/wF9rwxq0094tCeaMpWoPwYP/OxFQZAspgGK0UEzNft0bTRRLTu4sq9oYNjW4u9Q8mku8hY9VQGv7QwfX0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815692; c=relaxed/simple; bh=Y8IXzMUomtrlwK38Q7O+Uaj3T9uEUrs8xtbBKTUcZUk=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=bL9RMPZrVOdOLwqu3vlgTeDV7UkUwU6OSKLFDOzllqheStVaaCeruCAcfrLDgYnn33EfBWBEfz+LzYqUH+pE1disrEdpHAnbUJl8ve53EmGV6kKkwrRp+RHujQq3+9bBtuGAeOXwFfParbZCs5G0S9IHj7lAQwKd9T3qsK+c4ic= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gkDfevTY; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gkDfevTY" Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id 1F0FC1F000E9; Tue, 26 May 2026 17:14:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779815691; bh=51tug6a6FaLaxd2I+xCk3mWFTQm5O63L+L59ZG+fII0=; h=Date:From:To:Cc:Subject:References; b=gkDfevTY41dsIoa9JxJ2MLOX8gXyCV3hS3Ud9hg+NxybSAIIJRaaUXs45noG50E7f IzjbiWKMlvzkFZB2pXRDon0qCbSM0FYd2d1GP7aner0ZQ7wr60YlQw9NOyyxPMn4Q5 +M7NMep/nG+YO7NH04T4LmsQRwI2ixuhMo29LcyrEjkc480aGZkezQ2P9ieElq4Oa2 TCOs/Sz9nqziL+8EZh359uUSyUkKYO6EO08u7SwXmFAG+zTnmInTJD9fGDX47S+lUv CI8juvZtxqAYEgg+EnAhcY60uosYehO1USDSt8/iamAW9+aKECAn6wqt4bVFIiGl35 5uqolx94e+NWg== Date: Tue, 26 May 2026 19:14:47 +0200 Message-ID: <20260526171223.901103717@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: David Woodhouse , Miroslav Lichvar , John Stultz , Stephen Boyd , Anna-Maria Behnsen , Frederic Weisbecker , thomas.weissschuh@linutronix.de, Arthur Kiyanovski , Peter Hilber , "Michael S. Tsirkin" , virtualization@lists.linux.dev, Rodolfo Giometti , Vincent Donnefort , Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, Oliver Upton , Richard Cochran , netdev@vger.kernel.org, Takashi Iwai , Miri Korenblit , Johannes Berg , Jacob Keller , Tony Nguyen , Saeed Mahameed , linux-wireless@vger.kernel.org, linux-sound@vger.kernel.org Subject: [patch 16/24] virtio_rtc: Use provided clock ID for history snapshot References: <20260526165826.392227559@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The PTP core indicates in system_device_crosststamp::clock_id the clock ID for which the system time stamp should be taken. That allows to utilize hardware timestamps with e.g. AUX clocks. Use ktime_get_snapshot_id() and hand the provided clock ID in. No functional change. Signed-off-by: Thomas Gleixner Cc: Peter Hilber Cc: "Michael S. Tsirkin" Cc: virtualization@lists.linux.dev Reviewed-by: David Woodhouse Reviewed-by: Jacob Keller Tested-by: Arthur Kiyanovski --- drivers/virtio/virtio_rtc_ptp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/virtio/virtio_rtc_ptp.c +++ b/drivers/virtio/virtio_rtc_ptp.c @@ -139,7 +139,7 @@ static int viortc_ptp_getcrosststamp(str if (ret) return ret; =20 - ktime_get_snapshot(&history_begin); + ktime_get_snapshot_id(&history_begin, xtstamp->clock_id); if (history_begin.cs_id !=3D cs_id) return -EOPNOTSUPP; From nobody Mon Jun 8 20:41:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 704113BB117; Tue, 26 May 2026 17:14:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815697; cv=none; b=rxM8t4MXMzWbE/UxzlW/BdHA1INVWep7Shwe8oT0No9I/ROdr9Tt32iryXFloGYZlHy19sNpq6HOH9HgfoQMR/seKCZGzTyvcTPUwYkZPmhXLLT3JpImbOfKzB1i4uXyLZ5e748lRxgVZr9Zk4TsKiBsbc9/H7CR2DwbYkb3VIo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815697; c=relaxed/simple; bh=SK/3JKLXcdAd0YA9Id3+ZKQgFkUKWMlumDPX4kWtLcU=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=JCrO35mhWKknXwpY1yvrh5xDskX3PkXTYprj3GahMhvtkhagJ2okfGEJJUvp0lDvdSU26wwlOd4gdqaNCKNyp7qEUj1znyiM+n7VahzLJgY+2z8Uz/oPhg21NFihhx+zqjArkXlqwlc/VT68VcsjhMc29S3hMn6rubi36axQrWc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BQY+aGWC; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BQY+aGWC" Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id 234611F000E9; Tue, 26 May 2026 17:14:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779815696; bh=VlSkpOxaAvhGprMh41yHQUf26c+3JClC3KsUbd0ubDw=; h=Date:From:To:Cc:Subject:References; b=BQY+aGWCDcmMJKzgY+cWui4K1C2HgXKdKaImj5UTEZpsSPFJSzfMmHDq29Xpv2CPo z2lYBNm+P6naa+5EslAF6iwutkvHVBb4yTZC62mAdofF/i1BZyO0g+hr4ZBgJbUit7 pQYbuFbo0mUjuEsg9mh8oFqcVTEYa/4R0mDcE6SiPiXkSRLp2rNmrb7wik9HmwOeyY /lfYfPrUQyMw4nDbIm18XS8UQ/D6rizQK/Tn/LUt7E/1G7YgB8CsWb5xPJi1fL3HuX Cvc6eCFK83cJzh6dAGZfmZEHAO+YtY581OhrWQW5SnHrOjVcJom8QdeVWlKylolDCg DEplBp341GV6g== Date: Tue, 26 May 2026 19:14:52 +0200 Message-ID: <20260526171223.974925389@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: David Woodhouse , Miroslav Lichvar , John Stultz , Stephen Boyd , Anna-Maria Behnsen , Frederic Weisbecker , thomas.weissschuh@linutronix.de, Arthur Kiyanovski , Rodolfo Giometti , Vincent Donnefort , Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, Oliver Upton , Richard Cochran , netdev@vger.kernel.org, Takashi Iwai , Miri Korenblit , Johannes Berg , Jacob Keller , Tony Nguyen , Saeed Mahameed , Peter Hilber , "Michael S. Tsirkin" , virtualization@lists.linux.dev, linux-wireless@vger.kernel.org, linux-sound@vger.kernel.org Subject: [patch 17/24] timekeeping: Remove ktime_get_snapshot() References: <20260526165826.392227559@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" All users have been converted to ktime_get_snapshot_id(). Signed-off-by: Thomas Gleixner Reviewed-by: David Woodhouse Reviewed-by: Jacob Keller Reviewed-by: Thomas Wei=C3=9Fschuh Tested-by: Arthur Kiyanovski Tested-by: David Woodhouse --- include/linux/timekeeping.h | 5 ----- 1 file changed, 5 deletions(-) --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -351,11 +351,6 @@ extern int get_device_system_crosststamp extern bool ktime_get_snapshot_id(struct system_time_snapshot *systime_sna= pshot, clockid_t clock_id); =20 -static inline void ktime_get_snapshot(struct system_time_snapshot *systime= _snapshot) -{ - WARN_ON_ONCE(!ktime_get_snapshot_id(systime_snapshot, CLOCK_REALTIME)); -} - /* * Persistent clock related interfaces */ From nobody Mon Jun 8 20:41:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 42364405C42; Tue, 26 May 2026 17:15:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815702; cv=none; b=CSV09QS43jk/3Beo4W7wQsQAePCkfuBim+vqsaKXuNTeHpYf/3WwiY45kq4SkDMqRFuX9qi3HBUfCtSXYOOnwQFs6sTNE/rLh1GVO05niucjNVX8kmvF6cV0UPPQVACAQ18zy4sKRvOa39PJK6BbGSPJuIXZKVr1WMlxEIqGkdI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815702; c=relaxed/simple; bh=bD3utuSlPbamA3zVTxSyHKHRssUo/JN3sskelxj+RSE=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=gZrTHkRvFOrV64AO7J7xVzxnmdszfiZKRSv/gkv73fWxqzo6mjBXrK+Yq/d+OHpCFrzp/+IAggtiW7BZ10o15cf4JixBLXVu5/exo2B9/wi0KPf2g/KUIyC0fM6/Ei14CZU70X97x7lJg+UeW1uRHE1F2Re+e/5lxBmrsrDPT6Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=U2dpfaY1; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="U2dpfaY1" Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id 2A60F1F000E9; Tue, 26 May 2026 17:15:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779815700; bh=ZeQbVv4L9ncUMhYIkWghiHddA02uEqT5ryfrdMmIfNg=; h=Date:From:To:Cc:Subject:References; b=U2dpfaY1c3HKcRij+DP8P5i92p8GHzGJN4DMM101e8td7r4veeN1SiWE3pP0MkXG5 j+06nXyT3fruI+59zAzuV4TtXgnsCoNf9PSGVuE045MeY/m5qPzTFWf4tgPFgWI+lO iWMJW1w/iP+Y0lh7lnbQniFb+zptAabQshAq7KLAd1ZwZSO6xA1zuKfribGZSNSVaQ QrRAO8yiSo72uhKoPecwO9gjHxGSwcUebFHr4H8ZmXbCxedE0EsQ4fK6GBj0Ryrhx2 IGEPwmLOMCEqsn8mm23U0D/9dnJJozQuoR0Pqm9wrFgFeX5mIZvwGP4jUbom57AmUd MCaN6UJxW4ZvA== Date: Tue, 26 May 2026 19:14:57 +0200 Message-ID: <20260526171224.050496338@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: David Woodhouse , Miroslav Lichvar , John Stultz , Stephen Boyd , Anna-Maria Behnsen , Frederic Weisbecker , thomas.weissschuh@linutronix.de, Arthur Kiyanovski , Rodolfo Giometti , Vincent Donnefort , Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, Oliver Upton , Richard Cochran , netdev@vger.kernel.org, Takashi Iwai , Miri Korenblit , Johannes Berg , Jacob Keller , Tony Nguyen , Saeed Mahameed , Peter Hilber , "Michael S. Tsirkin" , virtualization@lists.linux.dev, linux-wireless@vger.kernel.org, linux-sound@vger.kernel.org Subject: [patch 18/24] timekeeping: Prepare for cross timestamps on arbitrary clock IDs References: <20260526165826.392227559@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" PTP device system crosstime stamps support only CLOCK_REALTIME, which is meaningless for AUX clocks. The PTP core hands in the clock ID already, so prepare the core code to honor it. - Add a new sys_systime field to struct system_device_crosststamp which aliases the sys_realtime field. Once all users are converted sys_realtime can be removed. - Prepare get_device_system_crosststamp() and the related code for it by switching to sys_systime and providing the initial changes to utilize different time keepers. No functional change intended. Signed-off-by: Thomas Gleixner Reviewed-by: David Woodhouse Reviewed-by: Jacob Keller Reviewed-by: Thomas Wei=C3=9Fschuh Tested-by: Arthur Kiyanovski Tested-by: David Woodhouse --- include/linux/timekeeping.h | 7 ++++- kernel/time/timekeeping.c | 60 +++++++++++++++++++++++++--------------= ----- 2 files changed, 41 insertions(+), 26 deletions(-) --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -319,13 +319,18 @@ struct system_counterval_t { * @device: Device time * @sys_counter: Clocksource counter value simultaneous with device time * @sys_realtime: Realtime simultaneous with device time + * @sys_systime: System time for @clock_id * @sys_monoraw: Monotonic raw simultaneous with device time */ struct system_device_crosststamp { clockid_t clock_id; ktime_t device; struct system_counterval_t sys_counter; - ktime_t sys_realtime; + union { + /* realtime goes away once all users are converted */ + ktime_t sys_realtime; + ktime_t sys_systime; + }; ktime_t sys_monoraw; }; =20 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1313,7 +1313,7 @@ static int adjust_historical_crosststamp struct system_device_crosststamp *ts) { struct timekeeper *tk =3D &tk_core.timekeeper; - u64 corr_raw, corr_real; + u64 corr_raw, corr_sys; bool interp_forward; int ret; =20 @@ -1330,8 +1330,7 @@ static int adjust_historical_crosststamp * Scale the monotonic raw time delta by: * partial_history_cycles / total_history_cycles */ - corr_raw =3D (u64)ktime_to_ns( - ktime_sub(ts->sys_monoraw, history->raw)); + corr_raw =3D (u64)ktime_to_ns(ktime_sub(ts->sys_monoraw, history->raw)); ret =3D scale64_check_overflow(partial_history_cycles, total_history_cycles, &corr_raw); if (ret) @@ -1339,30 +1338,29 @@ static int adjust_historical_crosststamp =20 /* * If there is a discontinuity in the history, scale monotonic raw - * correction by: - * mult(real)/mult(raw) yielding the realtime correction - * Otherwise, calculate the realtime correction similar to monotonic - * raw calculation + * correction by: + * mult(sys)/mult(raw) yielding the system time correction + * + * Otherwise, calculate the system time correction similar to monotonic + * raw calculation */ if (discontinuity) { - corr_real =3D mul_u64_u32_div - (corr_raw, tk->tkr_mono.mult, tk->tkr_raw.mult); + corr_sys =3D mul_u64_u32_div(corr_raw, tk->tkr_mono.mult, tk->tkr_raw.mu= lt); } else { - corr_real =3D (u64)ktime_to_ns( - ktime_sub(ts->sys_realtime, history->sys)); - ret =3D scale64_check_overflow(partial_history_cycles, - total_history_cycles, &corr_real); + corr_sys =3D (u64)ktime_to_ns(ktime_sub(ts->sys_systime, history->sys)); + ret =3D scale64_check_overflow(partial_history_cycles, total_history_cyc= les, + &corr_sys); if (ret) return ret; } =20 - /* Fixup monotonic raw and real time time values */ + /* Fixup monotonic raw and system time time values */ if (interp_forward) { ts->sys_monoraw =3D ktime_add_ns(history->raw, corr_raw); - ts->sys_realtime =3D ktime_add_ns(history->sys, corr_real); + ts->sys_systime =3D ktime_add_ns(history->sys, corr_sys); } else { ts->sys_monoraw =3D ktime_sub_ns(ts->sys_monoraw, corr_raw); - ts->sys_realtime =3D ktime_sub_ns(ts->sys_realtime, corr_real); + ts->sys_systime =3D ktime_sub_ns(ts->sys_systime, corr_sys); } =20 return 0; @@ -1506,16 +1504,29 @@ int get_device_system_crosststamp(int (* struct system_device_crosststamp *xtstamp) { u64 syscnt_cycles, cycles, now, interval_start; - struct timekeeper *tk =3D &tk_core.timekeeper; unsigned int seq, clock_was_set_seq =3D 0; - ktime_t base_real, base_raw; - u64 nsec_real, nsec_raw; + ktime_t base_sys, base_raw, *offs; + u64 nsec_sys, nsec_raw; u8 cs_was_changed_seq; bool do_interp; + struct timekeeper *tk; + struct tk_data *tkd; int ret; =20 + switch (xtstamp->clock_id) { + case CLOCK_REALTIME: + tkd =3D &tk_core; + offs =3D &tk_core.timekeeper.offs_real; + break; + default: + WARN_ON_ONCE(1); + return false; + } + + tk =3D &tkd->timekeeper; + do { - seq =3D read_seqcount_begin(&tk_core.seq); + seq =3D read_seqcount_begin(&tkd->seq); /* * Try to synchronously capture device time and a system * counter value calling back into the device driver @@ -1550,15 +1561,14 @@ int get_device_system_crosststamp(int (* do_interp =3D false; } =20 - base_real =3D ktime_add(tk->tkr_mono.base, - tk_core.timekeeper.offs_real); + base_sys =3D ktime_add(tk->tkr_mono.base, *offs); base_raw =3D tk->tkr_raw.base; =20 - nsec_real =3D timekeeping_cycles_to_ns(&tk->tkr_mono, cycles); + nsec_sys =3D timekeeping_cycles_to_ns(&tk->tkr_mono, cycles); nsec_raw =3D timekeeping_cycles_to_ns(&tk->tkr_raw, cycles); - } while (read_seqcount_retry(&tk_core.seq, seq)); + } while (read_seqcount_retry(&tkd->seq, seq)); =20 - xtstamp->sys_realtime =3D ktime_add_ns(base_real, nsec_real); + xtstamp->sys_systime =3D ktime_add_ns(base_sys, nsec_sys); xtstamp->sys_monoraw =3D ktime_add_ns(base_raw, nsec_raw); =20 /* From nobody Mon Jun 8 20:41:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 0B8724418F2; Tue, 26 May 2026 17:15:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815707; cv=none; b=Vmde5F9rKyv1ZAqVfhf3+dN/oybU/uqExgbuF+vOTzTojrDofrxsQ0eobushOT2lOGG/qJV2hf8kEeewCT2hagVaErSUB6UkJKFLoEnjlUwBlbUJ0tETTwwyjytW6ssQIScqwaCtrZ8rJiq+HAITTXYm0QZPmv4eZuOYr3SvOSw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815707; c=relaxed/simple; bh=YURwA6+s+6fPB1LThEMXPoxgu0rZtCRJgZo7bvbyX5Q=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=luko1SWdhCvfMdxmnXeuQ8XL0rHv7UxQJ+tq/EOn5QeZREv0Yu8RRdh2CaqidkZXlIesbgLtUKFrDbjIAeHqndsgyiqT5lhWZKtpq0VpKifozZH049oeppKcXYBwRuTQ+X1sgz1O+FvpurFGy3vjzWlACmzSqmuIDdqlv+UrLOs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TZ1ZSVWx; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TZ1ZSVWx" Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id BD3191F000E9; Tue, 26 May 2026 17:15:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779815705; bh=yhwQYYAvyeyOA5BotIUCq0FAeRMIiVuWdgIXT7OQn38=; h=Date:From:To:Cc:Subject:References; b=TZ1ZSVWxd5rpQdtcvNYSLXO8N8FXmdBxLJjwZ7feXk4eNnRuqggL5tt5OvRNlonDK BmmcHnBRD2zfpr3eV0FtXgDhb6hExzYQqskQM+Pqc2efvKMSCyE5RZ8/q1ivpmGD5e 54pr+wUkSJmulgQfOuBhjOniIRISgbTL4NskICtdla3IWp/ZGz7qm3zeIJ1MHBuM9C YEzeXtVyI6bkwXIeXrTh7eGAkw+j5dFzVDYgqID/J9TbVzzgXxDhMEEhgdEaRfruA2 eX1IBv8duQYkk2LgpPZtrZnZpwkI2jO33k6Cz0jROkok3ip3S8Tvty+Lbi24Q2EdAL R5lPOicf5vIJw== Date: Tue, 26 May 2026 19:15:02 +0200 Message-ID: <20260526171224.124442963@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: David Woodhouse , Miroslav Lichvar , John Stultz , Stephen Boyd , Anna-Maria Behnsen , Frederic Weisbecker , thomas.weissschuh@linutronix.de, Arthur Kiyanovski , Richard Cochran , Rodolfo Giometti , Vincent Donnefort , Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, Oliver Upton , netdev@vger.kernel.org, Takashi Iwai , Miri Korenblit , Johannes Berg , Jacob Keller , Tony Nguyen , Saeed Mahameed , Peter Hilber , "Michael S. Tsirkin" , virtualization@lists.linux.dev, linux-wireless@vger.kernel.org, linux-sound@vger.kernel.org Subject: [patch 19/24] ptp: Use system_device_crosststamp::sys_systime References: <20260526165826.392227559@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" .. to prepare for cross timestamps with variable clock IDs. No functional change. Signed-off-by: Thomas Gleixner Cc: Richard Cochran Reviewed-by: David Woodhouse Reviewed-by: Jacob Keller Tested-by: Arthur Kiyanovski Tested-by: David Woodhouse --- drivers/ptp/ptp_chardev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/ptp/ptp_chardev.c +++ b/drivers/ptp/ptp_chardev.c @@ -333,7 +333,7 @@ static long ptp_sys_offset_precise(struc ts =3D ktime_to_timespec64(xtstamp.device); precise_offset.device.sec =3D ts.tv_sec; precise_offset.device.nsec =3D ts.tv_nsec; - ts =3D ktime_to_timespec64(xtstamp.sys_realtime); + ts =3D ktime_to_timespec64(xtstamp.sys_systime); precise_offset.sys_realtime.sec =3D ts.tv_sec; precise_offset.sys_realtime.nsec =3D ts.tv_nsec; ts =3D ktime_to_timespec64(xtstamp.sys_monoraw); From nobody Mon Jun 8 20:41:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 BC4B44418F2; Tue, 26 May 2026 17:15:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815711; cv=none; b=kufLZPo+7V5mOGAepJ/YNyn2VprjJ7YGzNZaKAiRDc0vm91b1rfZbBIKrn6Wd73NeUEhuyrYQON7kPmL7ALbN21dV7zAm7bg+1HGzSi6+7IwLnBZYW6CAymn/an73OigcWknysE4W8vP7b60kXCL2dVBfUh7nAcsUrzpNGlWO9E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815711; c=relaxed/simple; bh=qh5z+Kg4oYjCDXalalq6sHc/U8ocIHbVTF4h/qc9+B8=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=DgYLMI8yRgC+u/pq1JZZIiPB7s0bcTRBP2f+iA90AQGQ8Tknn0/kw93KNTmvFK/d3D7DMOGaZ+XVJpfU2NnADsBEwEZeohiWRHvQgEiatFDLUrrTu0IBtpOLCjcxWRd49/ZUZ+QKdD6kes+azsb2qlo1N1nUDEHTfVgjrOJtonY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=j2+QOl03; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="j2+QOl03" Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id C0E941F000E9; Tue, 26 May 2026 17:15:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779815710; bh=bsO9xMrbXYOi+1ANV8/URAy8a3Pmb8c0uBje1sYfZ9g=; h=Date:From:To:Cc:Subject:References; b=j2+QOl03ERWXbt5Z+hlyvh94yVW+Ys+40SNeWcbnagjaX3tIYaNkHsLmkAtWrFX8a f+0Lxxsf3D5OCJxQ6Q3OQUpUUMyO7HC/qeAP/ztG4yE6Lxa42y36SA76uFQud5Moje z5SJdNwnh1PgVHwZE1M+DwN+3hUYBiUmav0R+NL8nXEkPKkLM4wP2KklGWRFzv6DDK zfKiGksrg9sjbNWfUI7lXhe2Cas5loIDkfoEbwxsDGvRIPC8PZq6MXqRNoMZAl72ku Bc1F1/rzk2xfeRmp5aDw5FzqgOJW/bVG8M9OkVOygGT8a7YCz+j9kXyvh/p0DIZ8Ih go6415IeZ8nmQ== Date: Tue, 26 May 2026 19:15:07 +0200 Message-ID: <20260526171224.198945692@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: David Woodhouse , Miroslav Lichvar , John Stultz , Stephen Boyd , Anna-Maria Behnsen , Frederic Weisbecker , thomas.weissschuh@linutronix.de, Arthur Kiyanovski , Miri Korenblit , Johannes Berg , linux-wireless@vger.kernel.org, Rodolfo Giometti , Vincent Donnefort , Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, Oliver Upton , Richard Cochran , netdev@vger.kernel.org, Takashi Iwai , Jacob Keller , Tony Nguyen , Saeed Mahameed , Peter Hilber , "Michael S. Tsirkin" , virtualization@lists.linux.dev, linux-sound@vger.kernel.org Subject: [patch 20/24] wifi: iwlwifi: Use system_device_crosststamp::sys_systime References: <20260526165826.392227559@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" sys_systime is an alias for sys_realtime. The latter will be removed so switch the code over to the new naming scheme. No functional change. Signed-off-by: Thomas Gleixner Cc: Miri Korenblit Cc: Johannes Berg Cc: linux-wireless@vger.kernel.org Reviewed-by: David Woodhouse Reviewed-by: Jacob Keller Tested-by: Arthur Kiyanovski --- drivers/net/wireless/intel/iwlwifi/mld/ptp.c | 2 +- drivers/net/wireless/intel/iwlwifi/mvm/ptp.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) --- a/drivers/net/wireless/intel/iwlwifi/mld/ptp.c +++ b/drivers/net/wireless/intel/iwlwifi/mld/ptp.c @@ -271,7 +271,7 @@ iwl_mld_phc_get_crosstimestamp(struct pt =20 /* System monotonic raw time is not used */ xtstamp->device =3D ns_to_ktime(gp2_ns); - xtstamp->sys_realtime =3D sys_time; + xtstamp->sys_systime =3D sys_time; =20 return ret; } --- a/drivers/net/wireless/intel/iwlwifi/mvm/ptp.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/ptp.c @@ -185,7 +185,7 @@ iwl_mvm_phc_get_crosstimestamp(struct pt =20 /* System monotonic raw time is not used */ xtstamp->device =3D (ktime_t)gp2_ns; - xtstamp->sys_realtime =3D sys_time; + xtstamp->sys_systime =3D sys_time; =20 out: mutex_unlock(&mvm->mutex); From nobody Mon Jun 8 20:41:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 F37B530C630; Tue, 26 May 2026 17:15:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815717; cv=none; b=P3p2B/rUTBTEV559VmazwXVbDCZaZ03WCWxmgO5ACgegxUs2HxfQR2C47yLu1eo8IFF3giwRzhO16DFmCaG5t49552QwHdGNkwbnmad6538RJzFvSisC2v5HSeHLVexmQuiUte4o0ceGKJIp1BSA/Td3WplWg2KMyITSj5C+dMY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815717; c=relaxed/simple; bh=NOmBkTqbakyfOUVdORZfgwK+dXAs70959cFjhBJn8Es=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=rEnLM7B/UmoZJazmtMqpkmbf79JV+Dg81eDmnuWYxWcRWjDY71y/CoGWNvi9sSIQ/AsnfiYA2dDpfWbAJF9s25GEC0KJNhSD7s+nxzWHD+YRhgzDPj7+e7yb0yg471YBfc2317oeKm7PrHWdt1RZV4NMQbLDxNcKZ85CDH9HRZo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Miztqc4y; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Miztqc4y" Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id C47501F000E9; Tue, 26 May 2026 17:15:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779815715; bh=ftZ/BVwDkJqs6UrSYS/Zjek1XjF16mMX5AsHng25tho=; h=Date:From:To:Cc:Subject:References; b=Miztqc4yA2odP+0Ywcb6TJNSHpIaC1UgP4Dnq/+LkmpKFbz1JyOqzJtj9VOEcFpDc dtL7Cd7FL1tB79uWD2M5WC3P7pqo2s6JU3B/G9zdBY/lLJSGIepfH7CgZ+RQ2x5FZT KD5Se1dVl6mm+ZrBQNF/zU186aHgoBn6refteqmY7x1wQKbuHVfzqkzLRo8lywa98V uoq5QMNbfbKaSH7IauNzEL8oKZQqRJBJHtSwKPmf/MSBWnFMEuIJJCXg13N4xjbP8C VqYwd7Jx/F/tX0UGMesw4b2tTYcLe3PcbU1eMffjr3rIwXCKVEo41XdycA87IaysSe UReqqA0Wzb+UA== Date: Tue, 26 May 2026 19:15:12 +0200 Message-ID: <20260526171224.274187786@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: David Woodhouse , Miroslav Lichvar , John Stultz , Stephen Boyd , Anna-Maria Behnsen , Frederic Weisbecker , thomas.weissschuh@linutronix.de, Arthur Kiyanovski , Takashi Iwai , linux-sound@vger.kernel.org, Rodolfo Giometti , Vincent Donnefort , Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, Oliver Upton , Richard Cochran , netdev@vger.kernel.org, Miri Korenblit , Johannes Berg , Jacob Keller , Tony Nguyen , Saeed Mahameed , Peter Hilber , "Michael S. Tsirkin" , virtualization@lists.linux.dev, linux-wireless@vger.kernel.org Subject: [patch 21/24] ALSA: hda/common: Use system_device_crosststamp::sys_systime References: <20260526165826.392227559@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" sys_systime is an alias for sys_realtime. The latter will be removed so switch the code over to the new naming scheme. No functional change. Signed-off-by: Thomas Gleixner Cc: Takashi Iwai Cc: linux-sound@vger.kernel.org Reviewed-by: David Woodhouse Reviewed-by: Jacob Keller Tested-by: Arthur Kiyanovski --- sound/hda/common/controller.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/sound/hda/common/controller.c +++ b/sound/hda/common/controller.c @@ -525,7 +525,7 @@ static int azx_get_time_info(struct snd_ break; =20 default: - *system_ts =3D ktime_to_timespec64(xtstamp.sys_realtime); + *system_ts =3D ktime_to_timespec64(xtstamp.sys_systime); break; =20 } From nobody Mon Jun 8 20:41:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 EA420405C51; Tue, 26 May 2026 17:15:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815722; cv=none; b=fUp1DAV4SFcfckrCpYCS7C5Oh1S1o6QFjq9bqis+pNOrvNIxlhrwrg5IYJmB/CyHY1eZG0nEJiRiUDzdu2hKyCc7qoU3AijDmoT0EV1lmnvyDAPzgdxZ/6GLUjfKfpf75eAClL0bwWkjbmayGbSFV+IWu+BzoEWqqjgafBDxanE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815722; c=relaxed/simple; bh=taA3JhJ8LfR540IvF/KyclmLykmRPPkG2o8PM3ZOnT0=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=IBleQwZ2eL06uIg89lsmC7arA2EIHCdKzgYPEFHGj7GT7HT8C7vpVfmAsyXLDYManmnkZPR7WxqEGMqlt9QNxq2DMCkMOYs13XXdPIWFlUQuI/9Dy4nzFpW04pJG/wY7pjGX0X5oWIbSARnvO0oddUA6lS6o1tUqgRG8i5IIl0U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mJ9txE58; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mJ9txE58" Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id B18251F000E9; Tue, 26 May 2026 17:15:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779815720; bh=iP9+Ejq+468GjDeS30IX6KFuH3pNpoH1TK3AxvpH6jM=; h=Date:From:To:Cc:Subject:References; b=mJ9txE58645sQz4WH7pcRhejpZWtR9+rOPLzP0JoT85ne5BnRR3eoGxgqeuO3sXvm EDc64YGg1uTPw64JEPsVEU/b0dm7bVYiFTnD5hKg8/FVmMxA1ScVOaLF0PhpzwUb5k uhplXMkSmgbQHiK5PBnr1dcuFNlqkToeEut6YWN/aSkUqlVNM00Sbl3WNlBTldhqY2 MGZPhvQKA/s6B0w3VRRX87UD4VEiMcJe2sWsfB1gXznCB+F+EUlGDhtihWuk9QUL85 9ENqoFtbpNE1NpBSkPuMTHrYCHzxJdmm4U0cyui2DB26SCFwqza711Wm1FkFMnJ1f1 Qk8tMpgtfmbeQ== Date: Tue, 26 May 2026 19:15:17 +0200 Message-ID: <20260526171224.347997043@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: David Woodhouse , Miroslav Lichvar , John Stultz , Stephen Boyd , Anna-Maria Behnsen , Frederic Weisbecker , thomas.weissschuh@linutronix.de, Arthur Kiyanovski , Rodolfo Giometti , Vincent Donnefort , Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, Oliver Upton , Richard Cochran , netdev@vger.kernel.org, Takashi Iwai , Miri Korenblit , Johannes Berg , Jacob Keller , Tony Nguyen , Saeed Mahameed , Peter Hilber , "Michael S. Tsirkin" , virtualization@lists.linux.dev, linux-wireless@vger.kernel.org, linux-sound@vger.kernel.org Subject: [patch 22/24] timekeeping: Remove system_device_crosststamp::sys_realtime References: <20260526165826.392227559@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" All users are converted to sys_systime. Signed-off-by: Thomas Gleixner Reviewed-by: David Woodhouse Reviewed-by: Jacob Keller Reviewed-by: Thomas Wei=C3=9Fschuh Tested-by: Arthur Kiyanovski Tested-by: David Woodhouse --- include/linux/timekeeping.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -318,7 +318,6 @@ struct system_counterval_t { * @clock_id: System time Clock ID to capture * @device: Device time * @sys_counter: Clocksource counter value simultaneous with device time - * @sys_realtime: Realtime simultaneous with device time * @sys_systime: System time for @clock_id * @sys_monoraw: Monotonic raw simultaneous with device time */ @@ -326,11 +325,7 @@ struct system_device_crosststamp { clockid_t clock_id; ktime_t device; struct system_counterval_t sys_counter; - union { - /* realtime goes away once all users are converted */ - ktime_t sys_realtime; - ktime_t sys_systime; - }; + ktime_t sys_systime; ktime_t sys_monoraw; }; From nobody Mon Jun 8 20:41:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 DE3D8413D63; Tue, 26 May 2026 17:15:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815726; cv=none; b=hAcF2MU8+ygupJD61omFQQf9W2G4t6oObCnl6pZGgKuQ8da3latCxWZzuICbY3TC0OeHxEa+tqxXVP+CiF1/uuqf8OnTJEgE1NzGenhUTeE7m89JoMC9qnz7Lv5Wds5N6qwFm1FRaemhdvrRpT0ZGWIBh5gHh0FKKLtNApNBqr0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815726; c=relaxed/simple; bh=UPQTtjMr5+Q62rEYqCbl500+U2deKAK7t7gFD28njww=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=Dc7SmDqLC18mBRy0l/ct4fEktl+DQbtDKNj5wqSMSYickc6HTbtkak/rl5EmoF27vBQ/Jotn2/ydm2Ip2ttacuKEZb81TIVORtjaE/vfI33/FRmlkk8UrJZcdLkAbWQYnGijIFEG2ilOZ7m9cYeKFvC9VW2OhR9zMNB6I/WbIUc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hz5rNADp; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hz5rNADp" Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id 9E10A1F000E9; Tue, 26 May 2026 17:15:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779815725; bh=kHti9+sqVBZGq/j203ISTyL+B5Np9OokbIRFwk8d52M=; h=Date:From:To:Cc:Subject:References; b=hz5rNADprN6ALUeIESOs1EAHI+3FrqImMNfrKx8bHnTUUhymIz6kZ19jV9U59OEKJ +oQD6+HT2X3ZFUTkTaGu8AhNw2XmcPBg0Soma/+16SPZb2sNVLr2z3EFSZif/Ph24c eocOJhkBMV6pZ/Y3pRsmMYgO8Hk2+qiuC6j445ZmpdGiytf/kblpU1IzFCNjdyZF39 ZMyIdYvz4t+473edPLKykgFkAUlE/CLzT/fbPmf56abgPb1I+5x9lhJk4SWBgTVGVO LMXqW91ZCsRmm99cZPhes8CX4bm4dBXg/NzSUpCVRTui+5VNo9rYI/L5tCxaWg0cFo v8VlRWgnTi4AQ== Date: Tue, 26 May 2026 19:15:22 +0200 Message-ID: <20260526171224.423155175@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: David Woodhouse , Miroslav Lichvar , John Stultz , Stephen Boyd , Anna-Maria Behnsen , Frederic Weisbecker , thomas.weissschuh@linutronix.de, Arthur Kiyanovski , Rodolfo Giometti , Vincent Donnefort , Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, Oliver Upton , Richard Cochran , netdev@vger.kernel.org, Takashi Iwai , Miri Korenblit , Johannes Berg , Jacob Keller , Tony Nguyen , Saeed Mahameed , Peter Hilber , "Michael S. Tsirkin" , virtualization@lists.linux.dev, linux-wireless@vger.kernel.org, linux-sound@vger.kernel.org Subject: [patch 23/24] timekeeping: Add support for AUX clock cross timestamping References: <20260526165826.392227559@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now that all prerequisites are in place add the final support for AUX clocks in get_device_system_crosststamp(), which enables the PTP layer to support hardware cross timestamps with a new IOTCL. Signed-off-by: Thomas Gleixner Reviewed-by: David Woodhouse Reviewed-by: Jacob Keller Reviewed-by: Thomas Wei=C3=9Fschuh Tested-by: Arthur Kiyanovski --- kernel/time/timekeeping.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1518,6 +1518,12 @@ int get_device_system_crosststamp(int (* tkd =3D &tk_core; offs =3D &tk_core.timekeeper.offs_real; break; + case CLOCK_AUX ... CLOCK_AUX_LAST: + tkd =3D aux_get_tk_data(xtstamp->clock_id); + if (!tkd) + return false; + offs =3D &tkd->timekeeper.offs_aux; + break; default: WARN_ON_ONCE(1); return false; From nobody Mon Jun 8 20:41:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 DC99D41C2FB; Tue, 26 May 2026 17:15:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815732; cv=none; b=rW1i0n9iGhwgNiqOrhn6CPtjyuwjgXKzZGRnQ0gl+ftxt4VfisWMvV9SmPbQ6FEffN1a9WltDgfkPV+qwCFMPym6/IU/w9+PXzfxOu/+q8zxnmj6t2NNzl2ogSkoXif5FU1pDD8GqCqBM1FaFft+eTa9BPPUoWtLf/ZxjqGY0Cs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779815732; c=relaxed/simple; bh=x+DEaPvKv7TQz/Zz8vDRySswulFxfroGrLWhxyBmfJM=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=ZAk6jwz9Q9OLmX3838kFRJhgC1TDpHpJOG8rOJp+fk64zsMgI86LBfKSYYlsEDcKvyEkBilfpizf19BysWfM2G+fFyluOTkQMfHIwSXBf8npwf7aEbLF3Oz29NpEdEP8RSjfWnMNCDz/WZ+l3zJf/vqG7FDSu0M4K78odAKL2ck= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ixngS4Sn; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ixngS4Sn" Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id A379E1F000E9; Tue, 26 May 2026 17:15:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779815730; bh=a4FYRpF1UYnCO8X4b7Ms8Ubqb9G1rX4iNVRYaeabgIQ=; h=Date:From:To:Cc:Subject:References; b=ixngS4SnkGLyqGeipEEwuirzm/HHZxpkH7kvwDyAyEK24rrwJT/ZQ101v2Cx4uWVn JgGTIBZ5UNi2TzcfUlL9RV/Fmon0QpUgY5LCPlPxe0EFOITmBrBDrfZOUwMBlKqcPh Qtx9WenveUCT9y9lpoQMVFRE5WRX02W6gtVRBQBOCQdxY50L15drAfLSX5puBpeeCf A+SuRtbTKPyWL3ur4a/SISfMATT1S9BwY2xZM9y/LU2qrzGExLZ05B08iEO58KdJHG gb3dwQX8Az1X5YalJgJXToi9tu7Gq4cWGAd3OmdRzY4rEuVGAWjQqSF3eUsWnJrf6i Jcs6AoAq3kAZg== Date: Tue, 26 May 2026 19:15:27 +0200 Message-ID: <20260526171224.499777655@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: David Woodhouse , Miroslav Lichvar , John Stultz , Stephen Boyd , Anna-Maria Behnsen , Frederic Weisbecker , thomas.weissschuh@linutronix.de, Arthur Kiyanovski , Rodolfo Giometti , Vincent Donnefort , Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, Oliver Upton , Richard Cochran , netdev@vger.kernel.org, Takashi Iwai , Miri Korenblit , Johannes Berg , Jacob Keller , Tony Nguyen , Saeed Mahameed , Peter Hilber , "Michael S. Tsirkin" , virtualization@lists.linux.dev, linux-wireless@vger.kernel.org, linux-sound@vger.kernel.org Subject: [patch 24/24] ptp: Switch to ktime_get_snapshot_id() for pre/post timestamps References: <20260526165826.392227559@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" To prepare for a new PTP IOCTL, which exposes the raw counter value along with the requested system time snapshot, switch the pre/post time stamp sampling over to use ktime_get_snapshot_id() and fix up all usage sites. No functional change intended. The ptp_vmclock conversion was simplified by David Woodhouse. Signed-off-by: Thomas Gleixner Acked-by: Vadim Fedorenko Reviewed-by: David Woodhouse Reviewed-by: Jacob Keller Tested-by: Arthur Kiyanovski Tested-by: David Woodhouse --- drivers/net/dsa/sja1105/sja1105_main.c | 8 ++++---- drivers/ptp/ptp_chardev.c | 14 +++++++++----- drivers/ptp/ptp_ocp.c | 11 ++++------- drivers/ptp/ptp_vmclock.c | 23 +++++++---------------- include/linux/ptp_clock_kernel.h | 15 ++++++++------- 5 files changed, 32 insertions(+), 39 deletions(-) --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -2310,10 +2310,10 @@ int sja1105_static_config_reload(struct goto out; } =20 - t1 =3D timespec64_to_ns(&ptp_sts_before.pre_ts); - t2 =3D timespec64_to_ns(&ptp_sts_before.post_ts); - t3 =3D timespec64_to_ns(&ptp_sts_after.pre_ts); - t4 =3D timespec64_to_ns(&ptp_sts_after.post_ts); + t1 =3D ktime_to_ns(ptp_sts_before.pre_sts.sys); + t2 =3D ktime_to_ns(ptp_sts_before.post_sts.sys); + t3 =3D ktime_to_ns(ptp_sts_after.pre_sts.sys); + t4 =3D ktime_to_ns(ptp_sts_after.post_sts.sys); /* Mid point, corresponds to pre-reset PTPCLKVAL */ t12 =3D t1 + (t2 - t1) / 2; /* Mid point, corresponds to post-reset PTPCLKVAL, aka 0 */ --- a/drivers/ptp/ptp_chardev.c +++ b/drivers/ptp/ptp_chardev.c @@ -386,15 +386,19 @@ static long ptp_sys_offset_extended(stru return err; =20 /* Filter out disabled or unavailable clocks */ - if (sts.pre_ts.tv_sec < 0 || sts.post_ts.tv_sec < 0) + if (!sts.pre_sts.valid || !sts.post_sts.valid) return -EINVAL; =20 - extoff->ts[i][0].sec =3D sts.pre_ts.tv_sec; - extoff->ts[i][0].nsec =3D sts.pre_ts.tv_nsec; extoff->ts[i][1].sec =3D ts.tv_sec; extoff->ts[i][1].nsec =3D ts.tv_nsec; - extoff->ts[i][2].sec =3D sts.post_ts.tv_sec; - extoff->ts[i][2].nsec =3D sts.post_ts.tv_nsec; + + ts =3D ktime_to_timespec64(sts.pre_sts.sys); + extoff->ts[i][0].sec =3D ts.tv_sec; + extoff->ts[i][0].nsec =3D ts.tv_nsec; + + ts =3D ktime_to_timespec64(sts.post_sts.sys); + extoff->ts[i][2].sec =3D ts.tv_sec; + extoff->ts[i][2].nsec =3D ts.tv_nsec; } =20 return copy_to_user(arg, extoff, sizeof(*extoff)) ? -EFAULT : 0; --- a/drivers/ptp/ptp_ocp.c +++ b/drivers/ptp/ptp_ocp.c @@ -1491,11 +1491,8 @@ static int } ptp_read_system_postts(sts); =20 - if (sts && bp->ts_window_adjust) { - s64 ns =3D timespec64_to_ns(&sts->post_ts); - - sts->post_ts =3D ns_to_timespec64(ns - bp->ts_window_adjust); - } + if (sts && bp->ts_window_adjust) + sts->post_ts.sys -=3D bp->ts_window_adjust; =20 time_ns =3D ioread32(&bp->reg->time_ns); time_sec =3D ioread32(&bp->reg->time_sec); @@ -4595,8 +4592,8 @@ ptp_ocp_summary_show(struct seq_file *s, struct timespec64 sys_ts; s64 pre_ns, post_ns, ns; =20 - pre_ns =3D timespec64_to_ns(&sts.pre_ts); - post_ns =3D timespec64_to_ns(&sts.post_ts); + pre_ns =3D ktime_to_ns(sts.pre_sts.sys); + post_ns =3D ktime_to_ns(sts.post_sts.sys); ns =3D (pre_ns + post_ns) / 2; ns +=3D (s64)bp->utc_tai_offset * NSEC_PER_SEC; sys_ts =3D ns_to_timespec64(ns); --- a/drivers/ptp/ptp_vmclock.c +++ b/drivers/ptp/ptp_vmclock.c @@ -101,7 +101,6 @@ static int vmclock_get_crosststamp(struc struct timespec64 *tspec) { ktime_t deadline =3D ktime_add(ktime_get(), VMCLOCK_MAX_WAIT); - struct system_time_snapshot systime_snapshot; uint64_t cycle, delta, seq, frac_sec; =20 #ifdef CONFIG_X86 @@ -132,17 +131,15 @@ static int vmclock_get_crosststamp(struc * will be derived from the *same* counter value. * * If the system isn't using the same counter, then the value - * from ktime_get_snapshot_id() will still be used as pre_ts, and - * ptp_read_system_postts() is called to populate postts after - * calling get_cycles(). - * - * The conversion to timespec64 happens further down, outside - * the seq_count loop. + * from ptp_read_system_prets() will still be used as pre_ts, + * and ptp_read_system_postts() is called to populate postts + * after calling get_cycles(). */ if (sts) { - ktime_get_snapshot_id(&systime_snapshot, CLOCK_REALTIME); - if (systime_snapshot.cs_id =3D=3D st->cs_id) { - cycle =3D systime_snapshot.cycles; + ptp_read_system_prets(sts); + 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 { cycle =3D get_cycles(); ptp_read_system_postts(sts); @@ -180,12 +177,6 @@ static int vmclock_get_crosststamp(struc system_counter->cs_id =3D st->cs_id; } =20 - if (sts) { - sts->pre_ts =3D ktime_to_timespec64(systime_snapshot.sys); - if (systime_snapshot.cs_id =3D=3D st->cs_id) - sts->post_ts =3D sts->pre_ts; - } - return 0; } =20 --- a/include/linux/ptp_clock_kernel.h +++ b/include/linux/ptp_clock_kernel.h @@ -12,6 +12,7 @@ #include #include #include +#include #include =20 #define PTP_CLOCK_NAME_LEN 32 @@ -45,13 +46,13 @@ struct system_device_crosststamp; =20 /** * struct ptp_system_timestamp - system time corresponding to a PHC timest= amp - * @pre_ts: system timestamp before capturing PHC - * @post_ts: system timestamp after capturing PHC - * @clockid: clock-base used for capturing the system timestamps + * @pre_sts: system time snapshot before capturing PHC + * @post_sts: system time snapshot after capturing PHC + * @clockid: clock-base used for capturing the system timestamps */ struct ptp_system_timestamp { - struct timespec64 pre_ts; - struct timespec64 post_ts; + struct system_time_snapshot pre_sts; + struct system_time_snapshot post_sts; clockid_t clockid; }; =20 @@ -510,13 +511,13 @@ static inline ktime_t ptp_convert_timest static inline void ptp_read_system_prets(struct ptp_system_timestamp *sts) { if (sts) - ktime_get_clock_ts64(sts->clockid, &sts->pre_ts); + ktime_get_snapshot_id(&sts->pre_sts, sts->clockid); } =20 static inline void ptp_read_system_postts(struct ptp_system_timestamp *sts) { if (sts) - ktime_get_clock_ts64(sts->clockid, &sts->post_ts); + ktime_get_snapshot_id(&sts->post_sts, sts->clockid); } =20 #endif