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=1796319993; b=4d2mrOWI0RTsMGhlCeB0bqB1Mp55/UZa4TvvBK8vn+sTgW4h3TAooClXQmeBONbFmAZV vvBBlqgZ1Y2NCjL/0SLZqUpftJEI55Xf1HkEHPuW9YXSTwQ3UdOzqpsWWGzH2OgCaH5Ir 9D2TOu6gsBNe3Jf9JOJ0uSTTZ6naxhic0bjaRTJb7kgahRk6+nuat+Zj6/ZgFFpfBm8Sh RMr/cXZ28yCWTWBCAZUtn8aI+wiZf7a7oqCrpq9vurQj69jF0lZaeLUFs2EkSlzXQ/vEO lsARDu3TLZuMJkuVA+YhFKzDfKfIKOg5IJcE+ZCpOga1NIlzMcqLdLO2DcyqwG5O9rA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796319993; 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=aJzVuj4OWBcLtiAc9IqnYIYpG5PWB/qT0Auyb2iKHfw=; b=ySODwcAPcDOzj5zocuSmyDB9uQahcsjbAG5gnhI9T8AnYBzsRg0RlkkDP15F0k9OdKd9 3fhYjVmq5/secam0SlQGIYgoesV17eTcu3MQYm1TM6u83vRAJ+Xgu1SNCKdf4jXVn40xo Y9a184j4vlRPbDA6GrUqh8pWfdjzFOX501I1Ec1iKBYaDalTJhAgn+HzJ/i+G05JOkrwl H5Dghohs4ZJYU5OB+pF+t2TTdgqefAMz9eJtUwGfsI6gxfGxJyXqJ7Fs1bOZFwgiu6EJ6 qHz3a7hcyknHu0AnTS//3vscm2AqVuIt6fChtFvHRL4aAh4Xas+kd2hVCjFfu2MN35Q== 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=N1VbR0DA; 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 B7097606A33E; Thu, 3 Dec 2026 17:46:33 +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=N1VbR0DA Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24F871F00923; Thu, 3 Dec 2026 17:46:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796319993; bh=aJzVuj4OWBcLtiAc9IqnYIYpG5PWB/qT0Auyb2iKHfw=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=N1VbR0DAC7KEJtmueO4orbpLWloSBzz49PqZiZfsy/tq5OTEeGt4sQ45aL9RX+Rxs 3+4L1qzNAV8y7KU76UOxnfQtetM65SacVzYP6g7DJ3a+t/brgzHrV6fKMewFyJoGMX 6U++urutxUuVzebVCyItuwX+/SlApm3NwgA+rSTouV5fP+YTZwjnGWitI/y1AQgcoT bL4dOSvjdjIE9p8hXk7EcABc5k0xeS9QcwRcHBQe+htYpbkoUxUYDNL1M+PKwZDFqf U6pygGFS4AQdhhzFF8n6hfZBpcn2vNhBdUkYVf9bB887I7VBD3tVfpTIRYqoouQNkz GUd22ZWFgC4zg== Subject: Re: [PATCH net-next v13 07/15] net: ethernet: oa_tc6: Support for hardware timestamp From: netdev-bot+sashiko@kernel.org To: Selvamani.Rajagopal@onsemi.com Cc: andrew+netdev@lunn.ch, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, parthiban.veerasooran@microchip.com, horms@kernel.org, corbet@lwn.net, skhan@linuxfoundation.org, rdunlap@infradead.org, richardcochran@gmail.com, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, edumazet@kernel.org, piergiorgio.beruto@gmail.com, willemb@google.com, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, jerry.ray@microchip.com, ciprian.regus@analog.com Date: Thu, 03 Dec 2026 17:46:31 +0000 Message-ID: <179631999173.3146.3476539071105534145@kernel.org> In-Reply-To: <20261202-s2500-mac-phy-support-v13-7-a2908fad2693@onsemi.com> References: <20261202-s2500-mac-phy-support-v13-7-a2908fad2693@onsemi.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-doc@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 6 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 5 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] Nothing times out or reclaims a TX timestamp capture register (TTSCA/B/C), or the skb parked on it, if the MAC-PHY never reports the… - [Low] The commit message does not match the code on how short RX frames are counted. - [Low] oa_tc6_init() now registers a netdevice notifier for every OA TC6 device, including LAN865X and ADIN1140, which never register a PHC and… - [Low] If an in-flight frame that already holds a TX timestamp capture register is discarded, oa_tc6_cleanup_ongoing_tx_skb() clears the… - [Low] oa_tc6_set_hwtstamp_settings() programs the hardware in three separate writes: STATUS0 (W1C, conditional), then INT_MASK0, then… - [Low] The new NETDEV_DOWN notifier adds a writer of netdev->stats.tx_dropped that runs at the same time as the threaded… -- net: ethernet: oa_tc6: Support for hardware timestamp This adds hardware timestamp support to the OPEN Alliance TC6 framework. It provides PTP clock registration helpers and exports hwtstamp and ethtool helpers for vendor drivers. TX timestamps are tracked through three capture registers, RX timestamps are parsed from the 8 bytes the MAC-PHY prepends, and a netdevice notifier releases skbs waiting for a TX timestamp on interface down. > diff --git a/drivers/net/ethernet/oa_tc6/oa_tc6_main.c b/drivers/net/ethernet/oa_tc6/oa_tc6_main.c > index 341d13c97f91f..3bb274d0f647d 100644 > --- a/drivers/net/ethernet/oa_tc6/oa_tc6_main.c > +++ b/drivers/net/ethernet/oa_tc6/oa_tc6_main.c [ ... ] > @@ -49,6 +62,222 @@ static int oa_tc6_get_parity(u32 p) [ ... ] > +/* Pause new timestamp requests while an off request is pending. */ > +static void oa_tc6_req_tx_hwtstamp(struct oa_tc6 *tc6, struct sk_buff *skb) > +{ > + u8 tsc; > + > + lockdep_assert_held(&tc6->tx_skb_lock); > + [ ... ] > + tsc = tc6->ttsc_current_id; > + if ((tc6->ttsc_pending | tc6->ttsc_held) & > + BIT(tsc - OA_TC6_TTSCA_REG_ID)) { > + tc6->tx_hwtstamp_err++; > + return; > + } [Severity: Medium] What frees a capture register if the MAC-PHY never reports the TTSCAx event for it? Only oa_tc6_events_handle() clears ttsc_held, and only when a PTP clock is registered and STATUS0 has the matching bit set. On ifdown, oa_tc6_netdev_event()->oa_tc6_cleanup_tx_tstamp_skbs(tc6, true) does: if (hold) tc6->ttsc_held |= tc6->ttsc_pending; tc6->ttsc_pending = 0; A down/up cycle therefore turns the pending bit into a held bit instead of freeing the register. Until then, oa_tc6_queue_tx_tstamp_skb() keeps the skb on ttsc_skb_list with no expiry, and the skb keeps its socket's wmem charge. When the register at ttsc_current_id is busy, the check above returns without advancing ttsc_current_id. Does one stuck register then make every later TX timestamp request fail, even with the other two registers free? TX_OFF also seems affected. oa_tc6_hwtstamp_req_process() only claims a TX_OFF request when nothing is pending or held: if (tc6->ts_cfg_new.tx_type == HWTSTAMP_TX_ON || !(tc6->ttsc_pending | tc6->ttsc_held)) { With a stuck bit, wouldn't every attempt to turn TX timestamping off get -ETIMEDOUT from oa_tc6_hwtstamp_post()? FTSE would stay set and the TTSC interrupts unmasked until unbind. One possible trigger in this series: s2500_stop()->s2500_shutdown() clears TXEN before NETDEV_DOWN, while a TSC-tagged frame may still be buffered in the MAC-PHY. A frame the MAC-PHY drops, for example after collisions, could leave its register stuck in the same way. The commit message and the oa_tc6_hwtstamp_set() kernel-doc mention the 100 ms -ETIMEDOUT and "may wait for outstanding TX timestamps". They do not say TX timestamping can stay unusable in this case. Do these registers need a timeout or some other way to be released? [ ... ] > +static int oa_tc6_update_ts_in_rx_skb(struct oa_tc6 *tc6) > +{ > + unsigned int expected_len = ETH_HLEN; > + struct sk_buff *skb = tc6->rx_skb; > + struct oa_tc6_ts_info_rx *ski; > + __be32 ts_val[2]; > + u32 ts[2]; > + > + ski = oa_tc6_tsinfo_rx(skb); > + if (ski->rtsa) > + expected_len += OA_TC6_TSTAMP_SZ; > + > + if (skb->len < expected_len) { > + tc6->netdev->stats.rx_length_errors++; > + tc6->netdev->stats.rx_errors++; > + return -EINVAL; > + } [Severity: Low] The commit message says: RX frame shorter than ETH_HLEN (plus 8 bytes when timestamp is present) is dropped now and counted in rx_length_errors and rx_dropped. The code increments rx_length_errors and rx_errors. The caller, oa_tc6_submit_rx_skb(), then calls oa_tc6_free_rx_skb(), which updates no counter, so rx_dropped is never incremented. Should the commit message say rx_errors instead of rx_dropped? This drop path also applies to every OA TC6 user, not only timestamping hardware. [ ... ] > @@ -624,6 +860,14 @@ static void oa_tc6_cleanup_ongoing_rx_skb(struct oa_tc6 *tc6) > > static void oa_tc6_cleanup_ongoing_tx_skb(struct oa_tc6 *tc6) > { > + if (tc6->ongoing_tx_skb && > + oa_tc6_tsinfo_tx(tc6->ongoing_tx_skb)->tsc) { > + u8 tsc = oa_tc6_tsinfo_tx(tc6->ongoing_tx_skb)->tsc; > + > + spin_lock_bh(&tc6->tx_skb_lock); > + tc6->ttsc_pending &= ~BIT(tsc - OA_TC6_TTSCA_REG_ID); > + spin_unlock_bh(&tc6->tx_skb_lock); > + } > oa_tc6_drop_tx_skb(tc6, tc6->ongoing_tx_skb); > tc6->ongoing_tx_skb = NULL; > } [Severity: Low] Should tx_hwtstamp_lost be incremented here as well? oa_tc6_req_tx_hwtstamp() has already claimed a register for this skb and set SKBTX_IN_PROGRESS, but the timestamp is never delivered. struct ethtool_ts_stats defines @lost as requests "where the timestamping information from the hardware never arrived for submission with the skb". oa_tc6_cleanup_tx_tstamp_skbs() does increment tx_hwtstamp_lost for each skb it drops. This path is reached through oa_tc6_free_ongoing_skbs() from the device error branch of oa_tc6_try_spi_transfer(), from oa_tc6_disable_traffic() and from oa_tc6_exit(). > @@ -649,6 +893,26 @@ static void oa_tc6_free_pending_skbs(struct oa_tc6 *tc6) [ ... ] > +static int oa_tc6_netdev_event(struct notifier_block *nb, unsigned long event, > + void *ptr) > +{ > + struct oa_tc6 *tc6 = container_of(nb, struct oa_tc6, netdev_nb); > + > + if (event == NETDEV_DOWN && > + netdev_notifier_info_to_dev(ptr) == tc6->netdev) { > + oa_tc6_cleanup_waiting_tx_skb(tc6); [Severity: Low] Can a tx_dropped update be lost here? oa_tc6_cleanup_waiting_tx_skb() releases tx_skb_lock before it drops the skb: spin_lock_bh(&tc6->tx_skb_lock); skb = oa_tc6_detach_waiting_tx_skb(tc6); spin_unlock_bh(&tc6->tx_skb_lock); oa_tc6_drop_tx_skb(tc6, skb); oa_tc6_drop_tx_skb() then does a plain tc6->netdev->stats.tx_dropped++. The threaded IRQ handler keeps running across ifdown. Its error path, oa_tc6_try_spi_transfer()->oa_tc6_free_ongoing_skbs()-> oa_tc6_cleanup_ongoing_tx_skb(), does the same unlocked increment. Until now, oa_tc6_cleanup_waiting_tx_skb() was only called from teardown paths that are serialized against the IRQ thread. > + oa_tc6_cleanup_tx_tstamp_skbs(tc6, true); > + } > + > + return NOTIFY_DONE; > } [ ... ] > @@ -1463,6 +1785,14 @@ struct oa_tc6 *oa_tc6_init(struct spi_device *spi, struct net_device *netdev, > goto phy_exit; > } > > + tc6->netdev_nb.notifier_call = oa_tc6_netdev_event; > + ret = register_netdevice_notifier(&tc6->netdev_nb); [Severity: Low] This notifier is registered for every OA TC6 device, including LAN865X and ADIN1140, which never register a PHC. On NETDEV_DOWN, oa_tc6_netdev_event() frees the queued non-timestamp waiting_tx_skb through oa_tc6_drop_tx_skb(), which increments tx_dropped. Before this patch the queued frame stayed in waiting_tx_skb across ifdown. The commit message only says: A netdevice notifier registered in oa_tc6_init() releases the skbs waiting for a TX timestamp when the interface goes down. "Drop the queued TX frame on interface down" appears only in the v13 changelog below the --- line, which does not end up in git. Could the commit message say that a queued normal frame is dropped on ifdown for all OA TC6 devices? Could it also say that each probed device registers a global netdevice notifier? > + if (ret) { > + dev_err(&tc6->spi->dev, > + "Failed to register netdev notifier: %d\n", ret); > + goto phy_exit; > + } [ ... ] > diff --git a/drivers/net/ethernet/oa_tc6/oa_tc6_tstamp.c b/drivers/net/ethernet/oa_tc6/oa_tc6_tstamp.c > new file mode 100644 > index 0000000000000..1806aa81a2852 > --- /dev/null > +++ b/drivers/net/ethernet/oa_tc6/oa_tc6_tstamp.c [ ... ] > +static int oa_tc6_set_hwtstamp_settings(struct oa_tc6 *tc6, > + const struct hwtstamp_config *ts_cfg) > +{ [ ... ] > + ret = oa_tc6_write_register(tc6, OA_TC6_REG_INT_MASK0, irqm); > + if (ret) { > + dev_err(&tc6->spi->dev, "failed to write IRQM register\n"); > + return ret; > + } > + > + ret = oa_tc6_write_register(tc6, OA_TC6_REG_CONFIG0, cfg0); > + if (ret) { > + dev_err(&tc6->spi->dev, "failed to write CFG0 register\n"); > + return ret; > + } [Severity: Low] If this CONFIG0 write fails, INT_MASK0 has already been changed and is not restored, while tc6->ts_cfg keeps the old configuration. Can the hardware and the driver then disagree about the timestamping state? Take TX_ON to TX_OFF as an example. TTSCAA/B/C are now masked, FTSE stays enabled, and ts_cfg.tx_type is still HWTSTAMP_TX_ON. oa_tc6_req_tx_hwtstamp() would keep tagging frames with a TSC whose captures no longer raise an interrupt. Wouldn't those skbs stay on ttsc_skb_list and their registers stay pending? In the opposite case, TX_OFF to TX_ON with a failed CONFIG0 write, the TTSC interrupts are left unmasked while ts_cfg still says off. > + spin_lock_bh(&tc6->tx_skb_lock); > + tc6->ts_cfg = *ts_cfg; > + spin_unlock_bh(&tc6->tx_skb_lock); [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202-s2500-mac-phy-support-v13-0-a2908fad2693%40onsemi.com