From nobody Wed Oct 8 08:19:18 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4961C28FAB5; Mon, 30 Jun 2025 15:05:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751295928; cv=none; b=EkofyPZrXKvo63fH4LqUMEDEi8oNLzwAYHOgpMIBQ4kL12lSi2RUdBCoWOm6cCYb2ok9FfqFcrQ1jlqa1xKf7eLfjh/z0rJE23hQB12aoKhnt/liMxHuF63jB+XJIoeK2josi8WCAWY5oP9ATEsz2BfFD0+l7wBXvE2qx/ny1bQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751295928; c=relaxed/simple; bh=VmwRtV4EDyoOJYMR9KncFFZ3QRzcR7AFXzCkOpnGsuw=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=EOVC7g7BZ+rIEzyDNaS1zuuM9jEZF43Ujrjvi03c5MylVUc1CQECEA1vZcyRhyPIkTEQFp+F8LtwWgOy+rbRC/3TizWUpGtl0Nu/q1rS036OMuBERuf29jISZzcuPPmAHJmykiSfcqnPbEHMINoIRfN9Ylo5KnRE95pNnfwupmw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Zl2KckBO; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=uoAu+pIR; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Zl2KckBO"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="uoAu+pIR" Date: Mon, 30 Jun 2025 15:05:23 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1751295924; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZsQWHYvdlvP7PY0Rcpt+MHy7s5iAeznkfeJ3TxbK5oI=; b=Zl2KckBOu1oM5jx54Zdj0Y+LwUnO1eZa2xK8YF8lDZVtdmiMg3fNn4GJOwQyhHulZHcQKO 1ogHpJZoYdtTgiaKwie61/o646RdzGOEqR28SjD18F9kmHxto5h+wt12hTPf/XPGppkNrL KI1u4vSIhK8LI638Eegtmx6kiIvvEGsE5w9SeZeGFQLc0jnM9TWJW0MJNdPIx1dLAjlere mztCMi+zEuS+dlbUEVOywFOjOyOEQA1lx+dxPzxb03DS3juOo2RmHn34jSOgIPlrcRQiul sYBfMzxmqYkpmgzLGjBlBI1tlzB9P8KHgd97bviFvl0ei3QaM8Fx5HbN9lBPvg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1751295924; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZsQWHYvdlvP7PY0Rcpt+MHy7s5iAeznkfeJ3TxbK5oI=; b=uoAu+pIRWwrC6WWRDlKcR+ROcL7+XtgNr9pXtWSg2J925Tj3R2uB1LpV1kE6F2ERvleP+Y v7RWxZDyLAhBQaCQ== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/ptp] timekeeping: Provide time setter for auxiliary clocks Cc: Thomas Gleixner , John Stultz , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20250625183757.995688714@linutronix.de> References: <20250625183757.995688714@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <175129592353.406.12059259254019900229.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the timers/ptp branch of tip: Commit-ID: 60ecc26ec5af567a55f362ad92c0cac8b894541c Gitweb: https://git.kernel.org/tip/60ecc26ec5af567a55f362ad92c0cac8b= 894541c Author: Thomas Gleixner AuthorDate: Wed, 25 Jun 2025 20:38:34 +02:00 Committer: Thomas Gleixner CommitterDate: Fri, 27 Jun 2025 20:13:12 +02:00 timekeeping: Provide time setter for auxiliary clocks Add clock_settime(2) support for auxiliary clocks. The function affects the AUX offset which is added to the "monotonic" clock readout of these clocks. Signed-off-by: Thomas Gleixner Acked-by: John Stultz Link: https://lore.kernel.org/all/20250625183757.995688714@linutronix.de --- kernel/time/timekeeping.c | 44 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 10c6e37..b6ac784 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -2765,9 +2765,53 @@ static int aux_get_timespec(clockid_t id, struct tim= espec64 *tp) return ktime_get_aux_ts64(id, tp) ? 0 : -ENODEV; } =20 +static int aux_clock_set(const clockid_t id, const struct timespec64 *tnew) +{ + struct tk_data *aux_tkd =3D aux_get_tk_data(id); + struct timekeeper *aux_tks; + ktime_t tnow, nsecs; + + if (!timespec64_valid_settod(tnew)) + return -EINVAL; + if (!aux_tkd) + return -ENODEV; + + aux_tks =3D &aux_tkd->shadow_timekeeper; + + guard(raw_spinlock_irq)(&aux_tkd->lock); + if (!aux_tks->clock_valid) + return -ENODEV; + + /* Forward the timekeeper base time */ + timekeeping_forward_now(aux_tks); + /* + * Get the updated base time. tkr_mono.base has not been + * updated yet, so do that first. That makes the update + * in timekeeping_update_from_shadow() redundant, but + * that's harmless. After that @tnow can be calculated + * by using tkr_mono::cycle_last, which has been set + * by timekeeping_forward_now(). + */ + tk_update_ktime_data(aux_tks); + nsecs =3D timekeeping_cycles_to_ns(&aux_tks->tkr_mono, aux_tks->tkr_mono.= cycle_last); + tnow =3D ktime_add(aux_tks->tkr_mono.base, nsecs); + + /* + * Calculate the new AUX offset as delta to @tnow ("monotonic"). + * That avoids all the tk::xtime back and forth conversions as + * xtime ("realtime") is not applicable for auxiliary clocks and + * kept in sync with "monotonic". + */ + aux_tks->offs_aux =3D ktime_sub(timespec64_to_ktime(*tnew), tnow); + + timekeeping_update_from_shadow(aux_tkd, TK_UPDATE_ALL); + return 0; +} + const struct k_clock clock_aux =3D { .clock_getres =3D aux_get_res, .clock_get_timespec =3D aux_get_timespec, + .clock_set =3D aux_clock_set, }; =20 static __init void tk_aux_setup(void)