From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6DD61F000C1; Thu, 3 Dec 2026 02:45:46 +0000 (UTC) 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== Subject: Re: [PATCH net-next v3 3/3] net: ethernet: ti: am65-cpts: implement PTP_SYS_OFFSET_PRECISE 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 Date: Thu, 03 Dec 2026 02:45:46 +0000 Message-ID: <179626594629.3146.11520970966751095781@kernel.org> In-Reply-To: <023fbf9c6866eb976bb77673aca2704b5c6121e7.1796179313.git.jjc@jclark.com> References: <023fbf9c6866eb976bb77673aca2704b5c6121e7.1796179313.git.jjc@jclark.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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