From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB47B606A332 for ; Thu, 3 Dec 2026 02:46:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=a9zbAeRe; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=oQDYbvv7 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version: Content-Transfer-Encoding:Content-Type:References:In-Reply-To:Message-ID:Date :Cc:To:From:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=OjHGvaHIMhOURaa7xE1YXSzXRub/3asHTTrVwZrfqus=; b=a9zbAeReNjJ3nSrk+mHZDzgZh9 iDsF6N32BH0bAhUlreyVB75eE6JY7nKhpbh5WP4q7m+ZYEtk9+Chrsftf6adVAXeLSU8qnzS5JTax 5SjBc4zyiF3WTxQz6LIbjK38tBC7FDvqGRDWvSMlw0awU8F0/jvSMcqnepLcSu32ZKGgzXYNW0Ks3 mAcmc+OO8DOgskfkoQ/pp5afDPwfyRd3J/D9Hd5lFwtTUh+adnVpwFuUb3mgtrUnAN4S1cbpsicLV sj0ulxBABYM3VPKF7CZ1oZQzHI8+EhB0GrIt9CgZzSHsV+pQ314RZ0ahNHmnSzGxvo+vRprDHFeMh nMXagliw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYwpZ-0000000DGrR-0XXy; Thu, 03 Dec 2026 02:45:57 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYwpQ-0000000DGq5-3Ry0 for linux-arm-kernel@lists.infradead.org; Thu, 03 Dec 2026 02:45:50 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 21F4440523; Thu, 3 Dec 2026 02:45:48 +0000 (UTC) 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-Archived-By: MIME-Version: 1.0 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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