Article View: linux.kernel.netdev
Article #14937Re: [PATCH net-next 3/3] net: ethernet: ti: am65-cpts: implement PTP_SYS_OFFSET_PRECISE
From: netdev-bot+sashiko
Date: Thu, 12 Nov 2026 07:25
Date: Thu, 12 Nov 2026 07:25
171 lines
14424 bytes
14424 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 3 · 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] The optional ti,gtc-push property fails in two different ways
in am65_cpts_of_parse() (drivers/net/ethernet/ti/am65-cpts.c).
- [Medium] am65_cpts_gtc_push_select() in
drivers/net/ethernet/ti/am65-cpts.c writes the EXPBIT_SEL field of…
- [Medium] am65_cpts_gtc_push_select() in
drivers/net/ethernet/ti/am65-cpts.c reads GTC_CFG0_PUSHEVT back only…
--
net: ethernet: ti: am65-cpts: implement PTP_SYS_OFFSET_PRECISE
This commit adds getcrosststamp support to the TI K3 CPTS driver. It uses
the Global Timebase Counter push event output, routed to a CPTS hardware
timestamp input. For each request the driver enables the push input,
waits for an event and pairs the PHC timestamp with the computed GTC
edge, retrying up to three times. The feature is enabled when the CPTS
node has a ti,gtc-push property naming the GTC CFG0 syscon and the push
input.
> diff --git a/drivers/net/ethernet/ti/am65-cpts.c b/drivers/net/ethernet/ti/am65-cpts.c
> index 0d71147f3c291..70b0d43bfe788 100644
> --- a/drivers/net/ethernet/ti/am65-cpts.c
> +++ b/drivers/net/ethernet/ti/am65-cpts.c
[ ... ]
> @@ -797,6 +839,226 @@ static int am65_cpts_ptp_enable(struct ptp_clock_info *ptp,
[ ... ]
> +/* select the counter bit the GTC exports on its push event output */
> +static int am65_cpts_gtc_push_select(struct am65_cpts *cpts)
> +{
> + u32 val;
> + int ret;
> +
> + ret = regmap_update_bits(cpts->gtc, AM65_CPTS_GTC_PUSHEVT,
> + AM65_CPTS_GTC_PUSHEVT_EXPBIT_SEL,
> + FIELD_PREP(AM65_CPTS_GTC_PUSHEVT_EXPBIT_SEL,
> + AM65_CPTS_GTC_PUSH_BIT));
[Severity: Medium]
Is it safe for this driver to own the EXPBIT_SEL field of GTC_CFG0_PUSHEVT?
The register belongs to the SoC-wide GTC, not to the CPTS.
am65_cpts_ptp_getcrosststamp() rewrites it on every PTP_SYS_OFFSET_PRECISE
request. The previous value is never saved or restored, on success or on
error.
The GTC push event output goes into the Time Sync Router, which can send
it to other timesync capture inputs, SYNC_OUT pins, or software on other
cores. Suppose one of those consumers expects a different exported bit.
Won't its signal frequency change after the first request from Linux, and
then be forced back to bit 15 on every later request?
The ti,gtc-push binding added in this series describes the GTC as the
SoC's system counter. It doesn't give this CPTS exclusive ownership of the
push output.
> + if (ret)
> + return ret;
> + /* flush the posted write before the input is enabled */
> + return regmap_read(cpts->gtc, AM65_CPTS_GTC_PUSHEVT, &val);
[Severity: Medium]
Should val be checked here, to confirm that EXPBIT_SEL now reads back as
AM65_CPTS_GTC_PUSH_BIT?
am65_cpts_gtc_push_next_edge() and the window check in
am65_cpts_gtc_push_wait() both assume rising edges at k * 2^16 + 2^15:
if ((s64)(popped - edge) < 0 ||
(s64)(popped - edge) >= (s64)AM65_CPTS_GTC_PUSH_PERIOD) {
...
return -EAGAIN;
}
push->cycles = edge;
The write might not take effect. For example, the CFG0 region could be
firewalled or read-only in some security configuration, or another agent
could rewrite the field. Then the exported bit b' is not 15.
With b' < 15, the first event comes from an edge before the expected
bit-15 edge. If IRQ thread latency puts popped past edge, the attempt is
accepted with push->cycles = edge. The result is off by up to that
latency.
With b' = 16, every bit-16 edge falls 2^15 cycles after a bit-15 edge,
which is inside the window. About half of attempts would pass while being
about 164 us off at 200 MHz.
In both cases, wouldn't PTP_SYS_OFFSET_PRECISE return a wrong
cross-timestamp to userspace with no error? The syscon regmap is uncached,
so a FIELD_GET() on val would catch the mismatch.
[ ... ]
> @@ -1160,6 +1423,24 @@ static int am65_cpts_of_parse(struct am65_cpts *cpts, struct device_node *node)
> }
> }
>
> + if (of_property_present(node, "ti,gtc-push")) {
> + gtc = syscon_regmap_lookup_by_phandle_args(node, "ti,gtc-push",
> + 1, &prop[0]);
> + if (IS_ERR(gtc))
> + return dev_err_probe(cpts->dev, PTR_ERR(gtc),
> + "Failed to get GTC syscon\n");
[Severity: Medium]
Should a failed syscon lookup be fatal here? A bad index just below only
logs an error and leaves the feature disabled.
Returning here makes am65_cpts_create() return ERR_PTR(ret).
am65_cpsw_init_cpts() in am65-cpsw-nuss.c then fails the whole CPSW probe:
if (IS_ERR(cpts)) {
int ret = PTR_ERR(cpts);
of_node_put(node);
dev_err(dev, "cpts create err %d\n", ret);
return ret;
}
So a problem with the optional cross-timestamp property takes down the
Ethernet interface.
A correct DT can also hit this. TI_K3_AM65_CPTS does not select or depend
on MFD_SYSCON, and ARCH_K3 does not select it either:
config TI_K3_AM65_CPTS
tristate "TI K3 AM65x CPTS"
depends on ARCH_K3 && OF
depends on PTP_1588_CLOCK
With CONFIG_MFD_SYSCON=n, the syscon stub returns ERR_PTR(-ENOTSUPP). Any
DT with ti,gtc-push would then stop Ethernet from probing. The same
happens if the phandle points at a node without the "syscon" compatible.
The existing ti,pps handling and the new index check both treat errors as
non-fatal. Could this path do the same, or should a Kconfig dependency on
MFD_SYSCON be added?
> +
> + if (prop[0] > 7 ||
> + (cpts->pps_present && prop[0] == cpts->pps_hw_ts_idx)) {
> + dev_err(cpts->dev,
> + "invalid GTC push HWx_TS_PUSH index: %u\n",
> + prop[0]);
> + } else {
> + cpts->gtc = gtc;
> + cpts->gtc_push_hw_idx = prop[0];
> + }
> + }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1794284248.git.jjc%40jclark.com
Technical Details
Message-ID:
<179446830443.2199510.10552580927894870264@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361563-linux-kernel-netdev=dewy.ruReferences:
<fd826c118aec02c06bde92ff9c20f1958c214b3d.1794284248.git.jjc@jclark.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361563-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next 3/3] net: ethernet: ti: am65-cpts: implement PTP_SYS_OFFSET_PRECISE Date: Thu, 12 Nov 2026 07:25:04 +0000 Organization: Usenet Network Message-ID: <179446830443.2199510.10552580927894870264@kernel.org> References: <fd826c118aec02c06bde92ff9c20f1958c214b3d.1794284248.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="1034062"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:Oo6KOF2CNqWxSNSCnEPba2kE8SI= sha256:4+lxkGJWejJf7TcRELwbCTH6/WHMD9+y9IkpO4Bxso4= sha1:J/iV9pPWIuhz0TnHktDBaM/i+sM= sha256:qYLBkB/JI6yLsCQ+1q4OOZECh2gtizBbKDuNyS6K6i0= 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 37237114139; Thu, 12 Nov 2026 10:27:02 +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 7PzRyU2DmiYE; Thu, 12 Nov 2026 10:26:57 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-361563-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 9B202114136; Thu, 12 Nov 2026 10:26:48 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 3CEAA3F10E; Thu, 12 Nov 2026 07:25:23 +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=1794468307; b=uAGdR0iGlquVuKXLWatJoQZEJSHNc5EdoIDK47L+h3zpXdylHT91bOfpBw2om+tVVDae JFn8KvFNa4Zr6WeK2L5ErbO4itPsI8Su7tz3Mnng+XfInKZy7u40114dagF6C68JQu8qu q+lkktHQL+9wdxoKe4p0N8w91eHdoiE4asI9zx0u5VjaqbRrEcWukYXSpPlrLliyIMray xjdiPZUaZPvARsWK551bekKDwW9m6tW4R0POoZ9acp2Q3XXv3+zPd70JGK8/7mRGs/9VX jdwykrDz6o0ZbZ27r4ox83zejZYgAx84d5g8hZrcfqb6fCIaumB0Fdoeknzh8/FIq0w== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794468307; 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=pqC808M/mZK8wr2GU+lcOwmAS4GPcScAPoGXHMQXl8k=; b=aun6cbQisJcQKjotmCxXPTduc8zJ167OIs/VKBPFbhwm2SySTreXNQUeqlazNbMontAl iiSTj9KaEFaj0vS8cr5EdkARivPMd1wAcBCxmv6acbnlh0nOOPVsbgr+RgjJBnN6RRM8R nSoi2866jyF/ZgDgMZSbfxHIZl8yNOCrq1WqxlYpAblwf0ZANx/tc2d99ZvnXULRYDQlI d0rk+ZGrXpmNf7fyB6ea30C8WGh0MA5A2nfD0uU95uNuPuBzihgmhxXbdG3kMVZX1nbmR GqP9gk+Wn296whslruTsjsMjq4PIOc2O9pFic7tuDGAnMMdmtYTHYcqmYOEnDHDl++A== 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=HNdFc70J; 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 A1A44606A8A9; Thu, 12 Nov 2026 07:25:07 +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=HNdFc70J 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=1794468306; b=qQAsRpXFNg350XGTYbHQ2tEz3kBSTO1sB44NjGRSISx3d3eI0NBAiQ6iUnbLV39FxBcy K+11/Bs07LW14jAG+i/EQnxrsOdJPm0wsje5goupPvPWugiZQ+5jBGenY0zYjkgBzLVr6 9duh61ft9eHhs3HuA0zchjrNq2vzK1SGPdZVnIs37uhUUfF6EbF4ZV5ceIPSnEHQ9CfxH OXfvg3Fwlc5xyEFSL/NKNZQrxrbXbEVarLmKpbt9gzE/YUipwVOM7oO4UCgqVep5Af1cM xF9dmtk++Q+D7KSu3LCuDvuHMpFd7HxumwKFOwsgrSC/uJ0vpb48QaUjT+zp1O6AkPQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794468306; 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=pqC808M/mZK8wr2GU+lcOwmAS4GPcScAPoGXHMQXl8k=; b=sxAB5HKNndDMkoXDPT2hkpMGSzdSwF7VjrT+cWP31epCbaNTucnX0e9X1vzPA3Fyka7l LBT9G3aDYvTJCngp4we7FiHbckJZp4s7GaQoNlPBKAtA6pmtqBLo8lYuu94pMSbVb3m2p KnzOiZ7/gjLy7Ll6+GkigixkBEVbJNuYeBkBtDPkDShcIzWfgNaXc5GIrIdShs1o7eu/P ISJlqpEJsgMa2NiiGUTC2VniDSRcO0uNqbkzvYT2IaLPOdBXj8jxjC/nN4aWhMELzYHG0 SH3bMBfaXlvrNDfP9aR/3fKtytq4571dZGit11tJFX9qqFRl33JZkTUH15FsJqmAXbA== 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=HNdFc70J; 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 C16D6606A32E; Thu, 12 Nov 2026 07:25:06 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDBD01F00A07; Thu, 12 Nov 2026 07:25:04 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794468306; bh=pqC808M/mZK8wr2GU+lcOwmAS4GPcScAPoGXHMQXl8k=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=HNdFc70JhZjcvuKLNs4EfjWppFCSNim5jLbVVJZPo/oeyyFA52BKRw44NrvWunV3t GpbLsLTioy6nWuxiGDslqUkEIzHr7brGuBroD5x0jF01ySwD4gIqg120R9/4fDqEyp 1hrtJKFfSQLmZfwJwQyoCbGpSOhRQfHuEfzRA8CHJRPhKrYMCUetbo9ltrMneLJd1x Ld12HPfg1BDRSsBSlnDNByHdlS1RkoQEhhC7BCrms0Qi//fzYgL75T431SRysdNcoL XVWfWspPl0vyg3OATolqSYZSMS5LW/DhDnAxQaRNzsYFeuTjd3hPuVkYJblRle4nL4 2yqVn/RVOEQZA== 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, lee@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, nm@ti.com, vigneshr@ti.com, c-vankar@ti.com, netdev@vger.kernel.org, devicetree@vger.kernel.org, mfd@lists.linux.dev, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-In-Reply-To: <fd826c118aec02c06bde92ff9c20f1958c214b3d.1794284248.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