From: netdev-bot+sashiko@kernel.org
To: jjc@jclark.com
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
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 [thread overview]
Message-ID: <179626594629.3146.11520970966751095781@kernel.org> (raw)
In-Reply-To: <023fbf9c6866eb976bb77673aca2704b5c6121e7.1796179313.git.jjc@jclark.com>
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
prev parent reply other threads:[~2026-12-03 2:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 2:42 [PATCH net-next v3 0/3] net: ethernet: ti: am65-cpts: add PTP_SYS_OFFSET_PRECISE support James Clark
2026-12-02 2:42 ` [PATCH net-next v3 1/3] dt-bindings: net: ti,k3-am654-cpts: add ti,gtc-push James Clark
2026-12-02 2:42 ` [PATCH net-next v3 2/3] net: ethernet: ti: am65-cpts: wait after each event FIFO pop James Clark
2026-12-03 2:45 ` netdev-bot+sashiko
2026-12-02 2:42 ` [PATCH net-next v3 3/3] net: ethernet: ti: am65-cpts: implement PTP_SYS_OFFSET_PRECISE James Clark
2026-12-03 2:45 ` netdev-bot+sashiko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179626594629.3146.11520970966751095781@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=bigeasy@linutronix.de \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=jjc@jclark.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.kaistra@linutronix.de \
--cc=netdev@vger.kernel.org \
--cc=nm@ti.com \
--cc=pabeni@redhat.com \
--cc=r-sharma3@ti.com \
--cc=richardcochran@gmail.com \
--cc=robertcnelson@gmail.com \
--cc=robh@kernel.org \
--cc=rogerq@kernel.org \
--cc=s-vadapalli@ti.com \
--cc=vadim.fedorenko@linux.dev \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox