Article View: linux.kernel.netdev
Article #26109Re: [PATCH net-next v3 3/3] net: ethernet: ti: am65-cpts: implement PTP_SYS_OFFSET_PRECISE
From: netdev-bot+sashiko
Date: Thu, 03 Dec 2026 02:45
Date: Thu, 03 Dec 2026 02:45
116 lines
12337 bytes
12337 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] In am65_cpts_gtc_push_try()
(drivers/net/ethernet/ti/am65-cpts.c), the cycles returned by…
--
net: ethernet: ti: am65-cpts: implement PTP_SYS_OFFSET_PRECISE
This adds getcrosststamp support to the TI K3 CPTS driver. It routes a
GTC counter bit, exported on the GTC push event output, to a CPTS
hardware timestamp input. The CPTS timestamp of that edge is paired with
the computed GTC edge value, which is derived from clocksource snapshots
taken around enabling the input.
> diff --git a/drivers/net/ethernet/ti/am65-cpts.c b/drivers/net/ethernet/ti/am65-cpts.c
> index d5c0a6a079656..a00e34954a9f0 100644
> --- a/drivers/net/ethernet/ti/am65-cpts.c
> +++ b/drivers/net/ethernet/ti/am65-cpts.c
[ ... ]
> +static int am65_cpts_gtc_push_read(ktime_t *device,
> + struct system_counterval_t *system,
> + void *ctx)
> +{
> + struct am65_cpts_gtc_push *push = ctx;
> +
> + *device = ns_to_ktime(push->ts);
> + system->cycles = push->cycles;
> + system->cs_id = CSID_ARM_ARCH_COUNTER;
> + system->use_nsecs = false;
> +
> + return 0;
> +}
[ ... ]
> +static int am65_cpts_gtc_push_try(struct am65_cpts *cpts, clockid_t clock_id,
> + struct system_time_snapshot *before,
> + struct am65_cpts_gtc_push *push)
> +{
[ ... ]
> + ktime_get_snapshot_id(clock_id, before);
> + am65_cpts_gtc_push_enable(cpts, true);
> + ktime_get_snapshot_id(clock_id, &after);
> +
> + if (!before->valid || !after.valid ||
> + before->cs_id != CSID_ARM_ARCH_COUNTER ||
> + after.cs_id != CSID_ARM_ARCH_COUNTER) {
> + ret = -ENODEV;
> + goto disable;
> + }
> +
> + edge = am65_cpts_gtc_push_next_edge(before->cycles);
[Severity: Medium]
What happens here when the arch timer clocksource is reading the virtual
counter with a non-zero CNTVOFF?
The only check is that cs_id is CSID_ARM_ARCH_COUNTER. On arm64, when Linux
is entered at EL1, arch_counter_register() in
drivers/clocksource/arm_arch_timer.c picks the virtual counter:
if ((IS_ENABLED(CONFIG_ARM64) && !is_hyp_mode_available()) ||
arch_timer_uses_ppi == ARCH_TIMER_VIRT_PPI ||
In that case before->cycles is CNTVCT, which is GTC - CNTVOFF. The cs_id is
still CSID_ARM_ARCH_COUNTER, so this check passes.
A boot at EL2 is fine, because el2_setup.h clears CNTVOFF_EL2, and a VHE
host sees an offset of 0. A hypervisor can leave CNTVOFF non-zero, though.
Xen, for example, gives each domain, dom0 included, a virtual timer offset.
If CNTVOFF mod 2^16 is not 0, am65_cpts_gtc_push_next_edge() predicts an
edge that is not a real GTC edge. The CPTS timestamp of the real edge is
still paired with that value in am65_cpts_gtc_push_read().
The check in am65_cpts_gtc_push_wait() compares one virtual count with
another, so it would not catch the offset. As far as I can tell,
PTP_SYS_OFFSET_PRECISE would then return a PHC/system pair that is off by up
to one push period (about 328 us at 200 MHz), and no error is reported.
The commit message states the assumption:
The driver reads the GTC through the clocksource, which assumes that
the clocksource counter value equals the GTC count, that is a CNTVOFF
of 0.
The code does not enforce it, though. Could getcrosststamp be withheld
when !is_hyp_mode_available(), or the setup otherwise detected, so that
an unsupported configuration gets -EOPNOTSUPP instead of wrong values?
> + if (edge <= after.cycles) {
> + dev_dbg(cpts->dev, "%s: edge %llu during enable\n",
> + __func__, edge);
> + ret = -EAGAIN;
> + goto disable;
> + }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1796179313.git.jjc%40jclark.com
Technical Details
Message-ID:
<179626594629.3146.11520970966751095781@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376242-linux-kernel-netdev=dewy.ruReferences:
<023fbf9c6866eb976bb77673aca2704b5c6121e7.1796179313.git.jjc@jclark.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376242-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v3 3/3] net: ethernet: ti: am65-cpts: implement PTP_SYS_OFFSET_PRECISE Date: Thu, 03 Dec 2026 02:45:46 +0000 Organization: Usenet Network Message-ID: <179626594629.3146.11520970966751095781@kernel.org> References: <023fbf9c6866eb976bb77673aca2704b5c6121e7.1796179313.git.jjc@jclark.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2125633"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:oCt1lCux8aNH92e/IBlaTbSE3Ro= sha256:eRS40278d2XWzqtTnStSnaf3tI0QQkZTQsY5WjhbV4I= sha1:FrW9XZJwYPsoJHQQ+VER01Pyy+4= sha256:S0dE/DY0YUrHdVM1wRPoSPjR7SVCT9vG6mYWCEQc2Gk= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 0B2D31177F1; Thu, 3 Dec 2026 05:46:11 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rmse2mhtqsg2; Thu, 3 Dec 2026 05:46:03 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-376242-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 294981177F0; Thu, 3 Dec 2026 05:45:53 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 7677929BAA; Thu, 3 Dec 2026 02:45:49 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796265949; b=vY++cc07Fmf1q2a0W2cYAwBW39GBOIIZJP6fcOMLCHwIiPWcS6VTWkaAFy2DqpAMl1IU p9F4awx0hgc78BsvgV3UDsak7X7xD0v1SEtNS8xLoqpx3NwBu3MzMZoXHYQB1AqfKZotF 1ESmEW2XirMNMoBY7rT7oYfodIGhnaaV/izSoONWp9EA/BJk05XhsOTeMShRdi6kielyx WpswIFPTu/iX+RfSHvC7gOyBtW66QEeWyc+nbfCQkuSd5gkeil+K5xSbDHy1ukWzDP47Y wcFglOg8aN29OCrlqkKpU89W+mljwCQvsXvmYvfsNVmmXNoK0eiu0p4Ty6d1k9O48Dg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796265949; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=OjHGvaHIMhOURaa7xE1YXSzXRub/3asHTTrVwZrfqus=; b=HXTzMPNqrfg3miT5axjAart4l9cJknp2BpyeOhukbsx/rt7ugZyI2JSug+Ibmn4yyX+C ch3e9hDYztyXqnmDHQITJT2S+p0s2TI+KvADUBAHS/7oCFtbnczdrZq6+JlrIORCVsjAR Js1Z3p6vwgEs/PAHIBXy8vPDCZqfuPas8ceBu6VIZv4QFQK9h4hs63/uMQgjbiQorB7pU eHuJMNK1+LicLv77dlwDh2IycxVx1tmueXGtUn/yT4tHafU8JTCrQ5Atl8caq4s7ShrY5 dxGarOwb/lVGYZDiBbsIWoordjSMS8sb9WT06FKyyvuw2rmggw/4nevxob249nzVZ9g== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=oQDYbvv7; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4ED47606A336; Thu, 3 Dec 2026 02:45:49 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=oQDYbvv7 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796265948; b=Jr+IIZhyQwAcd6NijLi0E8jIXu2VY/mnrrNiVDUG/6rpkxCf1SeHL3M8o0lKXcycKKLq V1tBjuwZ5nm6rk6o9ndgdqeyfP8ClsrAjdOb1YygECqj0Ql8phSkPre1hMoFJ62wooxtE VzIf+OycLQq9uQtpUmn2LpEFX1E1Dx8kMpbB+RHylqWkhiy9iM3WjqQs1jQz15LN/fFZ/ yu4fJWy7XL4mbX0xPLIKrZ+Ku/IOdJ+VyMTJgSZ0nvTmPn0oiOr2BqIWJGvaGRtzPshAP VmKqVytHYFZtUDlS69yAe9vu3QYE+8Y3ntaKTcpKu8mB2m0LSgvufUWhPQ1daeo7Vkg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796265948; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=OjHGvaHIMhOURaa7xE1YXSzXRub/3asHTTrVwZrfqus=; b=iXzw1IwYkZGqD+k44JfpIhA5PGHKQzL4BANf6Yl6+oBlacxsMArSERBrT1csArksJ+hR qsSnpkpE1mPaKjdG5s3J5rLUaR0Db1BMpAUaDRh4mHxBjbHDMOE0RRS5qiCAhAPiEUZCm oNw3LfL1OX0iDhlZ1fy21STia4v6G+rW3ad1G58u7r6Uo/X64rDqCjpETLpBIEzVBAJEx gJtsi8QcqaNzHgnVFocoO8wO217iLXNNbChagRLdWUKEl8t7YLCK3zR9v+ubLT9eaE94w zbFOEayTnu1+FM9ky22jhI6JIi1tNd/S0f8kfVl+Jj1Cck6ngB7nDF/gGn7og5Dks5w== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=oQDYbvv7; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B512606A32D; Thu, 3 Dec 2026 02:45:48 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6DD61F000C1; Thu, 3 Dec 2026 02:45:46 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796265948; bh=OjHGvaHIMhOURaa7xE1YXSzXRub/3asHTTrVwZrfqus=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=oQDYbvv7G6w6NRhuyHvUxlknIMxwutU4pAvxS5f+9gfQa9aZXz7a45EIEcgpcULQI V02LzMuruqL9UdhkMV3WAFkXQC5S1XvZ8DVGpPe/a3eqjfCfmDGVi4dTeJGtoB+E1c RtIU8P03qzpS0IdvIpgY7VGjMmbHPFStblmIzL7z6HQDGrFNUOOWJrOwrwmm4VXAkF T4NCu4K5kZWNr0IEUTB75lQgNS7cvsPE5fWlK2aM/4Fz+lUZdN8jlCQGanyNtCP/Lo xu/L6XfO/HgqfiXUZab16uQPImLTDwbravRh9A8w+FEOBXa6iwbHXiNTW4NzXdrbS0 NtbwcUIitHJCQ== X-Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, s-vadapalli@ti.com, rogerq@kernel.org, bigeasy@linutronix.de, martin.kaistra@linutronix.de, vadim.fedorenko@linux.dev, r-sharma3@ti.com, robertcnelson@gmail.com, horms@kernel.org, nm@ti.com, vigneshr@ti.com, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-In-Reply-To: <023fbf9c6866eb976bb77673aca2704b5c6121e7.1796179313.git.jjc@jclark.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list