Article View: linux.kernel.netdev
Article #27331Re: [PATCH net-next v5 1/4] net: ethtool: tsconfig: allow selecting a provider
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 10:32
Date: Sat, 05 Dec 2026 10:32
178 lines
14502 bytes
14502 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message for "net: ethtool: tsconfig: allow selecting a
provider" is inaccurate and leaves out user-visible effects.
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but this patch
makes it reachable on more devices: dev->hwprov->phydev can be leftβ¦
--
net: ethtool: tsconfig: allow selecting a provider
This patch relaxes the early check in ethnl_set_tsconfig(). A request that
carries ETHTOOL_A_TSCONFIG_HWTSTAMP_PROVIDER is now accepted even when the
device has no ndo_hwtstamp_set(), no default PHY time stamper and no
previously selected dev->hwprov. In that case the call that disables the
current time stamping config is skipped before the new provider is
installed.
> A hwtstamp provider can obly ne selected with ETHTOOL_MSG_TSCONFIG_SET
> when the device already has an active time stamping source: a MAC
> implementing ndo_hwtstamp_set(), a PHY flagged as default_timestamp, or
> a previously selected dev->hwprov.
>
> This patch makes it possible to select a PHY time stamper on a MAC
> without time stamping support. New phy drivers are expected to reply on
> dev->hwprov rather than default_timestamp.
[ ... ]
> Changes in v5:
> - new file.
[Severity: Low]
This isn't a bug, but there are some typos and inaccuracies here:
"obly ne selected" should be "only be selected".
"expected to reply on" should be "expected to rely on".
"new file" is wrong, since the patch doesn't add a file.
The subject "allow selecting a provider" sounds as if provider selection
wasn't possible before. What is actually new is that a provider can be
selected on a device with no hw timestamping source at all. Could the
subject say that?
The message sets a policy that PHY drivers should rely on dev->hwprov
rather than default_timestamp. Should it also say what this means for the
legacy interfaces?
Take a MAC without ndo_hwtstamp_set, such as r8169, with no hwprov selected
and default_timestamp false. In that case dev_set_hwtstamp_phylib() ends up
with phy_ts == false:
net/core/dev_ioctl.c:dev_set_hwtstamp_phylib() {
...
if (!phy_ts || dev->see_all_hwtstamp_requests) {
if (!ops->ndo_hwtstamp_set)
return -EOPNOTSUPP;
...
}
On the same device:
dev_get_hwtstamp_phylib() also returns -EOPNOTSUPP.
__ethtool_get_ts_info() reports only the MAC's get_ts_info.
So users of SIOCSHWTSTAMP, SIOCGHWTSTAMP and ETHTOOL_GET_TS_INFO, such as
ptp4l, can't find or use the PHY time stamper until something selects it
with ETHTOOL_MSG_TSCONFIG_SET. The RTL8127a PHY driver later in the series
doesn't set default_timestamp, so it is affected. The kernel-doc of
phy_is_default_hwtstamp() may also be a good place to document this
policy.
The errno that userspace sees also changes. Before this patch, a
TSCONFIG_SET with a provider on a device without hw timestamping failed
right away with -EOPNOTSUPP. It now goes through
tsconfig_set_hwprov_from_desc():
net/ethtool/tsconfig.c:tsconfig_set_hwprov_from_desc() {
...
ret = ethtool_net_get_ts_info_by_phc(dev, &ts_info, hwprov_desc);
if (!ret && dev->netdev_ops->ndo_hwtstamp_set) {
/* Found */
source = HWTSTAMP_SOURCE_NETDEV;
} else {
phy = ethtool_phy_get_ts_info_by_phc(dev, &ts_info, hwprov_desc);
if (IS_ERR(phy)) {
if (PTR_ERR(phy) == -ENODEV)
NL_SET_ERR_MSG_ATTR(info->extack,
tb[ETHTOOL_A_TSCONFIG_HWTSTAMP_PROVIDER],
"phc not in this net device topology");
...
}
This path can return -ENODEV with "phc not in this net device topology" in
three cases:
The PHC is not a topology PHY.
The qualifier is not PRECISE.
The PHC is the MAC's own, as reported by get_ts_info, but the MAC lacks
ndo_hwtstamp_set.
In the last case the message is misleading. Should the commit message
mention the errno change? Is this extack text right for the MAC PHC case?
> diff --git a/net/ethtool/tsconfig.c b/net/ethtool/tsconfig.c
> index 2db0e7ba8b9f5..9c983666a1b02 100644
> --- a/net/ethtool/tsconfig.c
> +++ b/net/ethtool/tsconfig.c
> @@ -300,14 +300,16 @@ static int ethnl_set_tsconfig(struct ethnl_req_info *req_base,
[ ... ]
> - if (!dev->netdev_ops->ndo_hwtstamp_set &&
> - !phy_is_default_hwtstamp(dev->phydev) &&
> - !netdev_ops_lock_dereference(dev->hwprov, dev))
> + has_hwts = dev->netdev_ops->ndo_hwtstamp_set ||
> + phy_is_default_hwtstamp(dev->phydev) ||
> + netdev_ops_lock_dereference(dev->hwprov, dev);
> + if (!has_hwts && !tb[ETHTOOL_A_TSCONFIG_HWTSTAMP_PROVIDER])
> return -EOPNOTSUPP;
[Severity: High]
This isn't a bug introduced by this patch, but the patch makes it reachable
on more devices. PHY-only provider selection now works on MACs without hw
timestamping. Can dev->hwprov->phydev then be left pointing at a freed SFP
module PHY on those devices too?
tsconfig_set_hwprov_from_desc() stores the phy_device pointer without
taking a reference:
hwprov->phydev = phy;
That phy comes from ethtool_phy_get_ts_info_by_phc(). It walks every PHY in
dev->link_topo, including a module PHY behind a PHY-driven SFP cage.
The only teardown code that clears a PHY-backed dev->hwprov is in
phy_detach():
drivers/net/phy/phy_device.c:phy_detach() {
...
if (hwprov && hwprov->phydev == phydev) {
rcu_assign_pointer(dev->hwprov, NULL);
kfree_rcu(hwprov, rcu_head);
}
...
}
A module PHY behind a PHY-driven cage is never attached with
phy_attach_direct(). When the module is removed, this is the path:
sfp_sm_phy_detach()
sfp_remove_phy()
phy_sfp_disconnect_phy()
phy_link_topo_del_phy(dev, phy);
phy_device_remove(sfp->mod_phy);
phy_device_free(sfp->mod_phy);
Nothing on that path checks or clears dev->hwprov. Afterwards,
skb_clone_tx_timestamp() and skb_defer_rx_timestamp() would load
hwprov->phydev, read phydev->mii_ts, and call mii_ts->txtstamp() or
mii_ts->rxtstamp() through freed memory. dev_set_hwtstamp_phylib() and
dev_get_hwtstamp_phylib() dereference the same stale pointer.
Before this patch, selecting such a PHY needed a MAC with ndo_hwtstamp_set
or another hw timestamping source. Does anything clear dev->hwprov when the
SFP module PHY is removed from the link topology?
[ ... ]
--
Sashiko AI review Β· https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201094454.1150-1-javen_xu%40realsil.com.cn
Technical Details
Message-ID:
<179646675646.3146.9173679701484398773@kernel.org>Path:
mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!peer04.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377932-linux-kernel-netdev=dewy.ruReferences:
<20261201094454.1150-2-javen_xu@realsil.com.cn>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!peer04.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377932-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v5 1/4] net: ethtool: tsconfig: allow selecting a provider Date: Sat, 05 Dec 2026 10:32:36 +0000 Organization: Usenet Network Message-ID: <179646675646.3146.9173679701484398773@kernel.org> References: <20261201094454.1150-2-javen_xu@realsil.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3007287"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:Yqvb/MzjWYAI2P7LTq3+sWSd/A4= sha256:IY5WN4jsAiCWEizzjNxUAsgsxNzMEV3lDggF3Tgqy00= sha1:ZMe2TuMvbuvll35VUzYRDIwuxBs= sha256:XNHOll4Q1UbRa3YZo1MvZrHoQb4OGyKoA5E0JkWhwno= 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 1D714117DE9; Sat, 5 Dec 2026 13:32:54 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.641 X-Spam-Status: No, score=-3.641 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.142, 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, URIBL_BLOCKED=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 FzAzHnXe6MLP; Sat, 5 Dec 2026 13:32:50 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-377932-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 87B02117DE3; Sat, 5 Dec 2026 13:32:41 +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 A808628CFE; Sat, 5 Dec 2026 10:32:39 +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=1796466759; b=zzGO5Vqrbo3545k9r9BbPb52e9thMpbz21ZrtTbIUe6AGDq/rZZFbjVdY7Qt+rO1yUlr 2V8jTf9vBuGsLRvo5o1BLMZrDz1g5IGNWHH466QSFCmKwHXnc+BhCrb+ASQghSoI35lDU 5ROmwFSvmKUrct1I2kQ1JfhjHpYz07AekMl9pHK4XYe9/GHUHRTqL7YgHP/2uDl2v3XEM XwymLQlLUc584NQITCqOQjcNh6CP10xKB8Yfcs9a7vhSsVQjakdGJb1DhwpPrwznSftl/ K1ezOhYsBduutYJXxT9Qyx3DPeBk/bakieHxbCUKJMpVHL0AMa0PNRUiDffPGe3r8SA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796466759; 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=oUvvCEGezvZvfjy/EaODrWPCB4Hnd3ZkEVs/jnEX11I=; b=Lf/XeklsjW3Z7xV0jI8CisN+RH1xNyJ1c21rSOp3UbRw+l7sxmAO1qlSaNAjx8htCKsN XRibHOA77d82JsEXgrf4Ya2g08jFdTr4F8iww+4c2G2xZRfpDFQ99IShOOq+KDxkt9DnS ihXbNrDLBQaiDQps/oaqsP7duAmiTUGmcX7tq+x1fI+oAReEfF6Bn277snvenw5UVjFFY XkDmEdQZF4Jf5HtqzC76dwglvSlIvvqw5/+VzIbmktQJX5jcRyrX+k86Rx7SAJKgHQ89V LqIs7o512YEleOj5i6X9Bg3mUYEWu0UJBO9Or1XTuRX/6ogfGKD49WZq4IcZVT7glhA== 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=Boavzawj; 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 DD043606A334; Sat, 5 Dec 2026 10:32:38 +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=Boavzawj 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=1796466758; b=elRSkyLXyFsql1iT40LM0Hc6gGoAH2acbwqkXXM5kOmNcfflIK2elvtL9JApqB9OsL3f jI6dj+Y083QfM+1/eGknuusUpwQmDCMLFfW4x00BVRI3LQMWTi6+iqvwwi1JaHcF7SxEL K3Q2XCyzZ9CRbYZZ7OV2qtuX5oZtiVYHwB/V/zqudT7WpPatBEJGjItUBstgT6uA9NfYd Vws1FOlSPk1ZPlWpZh8ZY6o1fDnBUYaCW8MKjB3/Z05ArGn8jTJuxXRafAX2PovivNw3R 3imKkypRQ711yeSOJpHlqF6FTecyfllYWh6Ymz+78KQ6BctzBZ6EyzfXz0tAsqmAq0w== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796466758; 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=oUvvCEGezvZvfjy/EaODrWPCB4Hnd3ZkEVs/jnEX11I=; b=aML7p6lR5ZT9zndDwI9o1WTlEoD/zN5iuHIjoeq19e7a6IvWP1TpGyFxzhDKZ8WSYTG4 sSuI1OhQ8eppOU7AhMyw9aYPDYc8nnwasqTDtBt5z16Z55rL7VrWd2m6UMcRhbdtkVa1F bVjuNswIqpLES2Rdao17inc1t96KC1fx94Y2SL4aTYawwvECTt82hGNd+WO42G4AZf9kg z0Q/8ezbMsKyX9AsrylVChXb0D87W8zyQNFgqjez4sCuYZpR7+jY+h9w81g1aMA7oG7UG U8wKuZc/0wGVgcaoSo+1NasqMM5590h/FBDJ2VUDG9Ig/k3l8gwJ3whNeNtZWjXG8jA== 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=Boavzawj; 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 073F9606A322; Sat, 5 Dec 2026 10:32:37 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id E392A1F00936; Sat, 5 Dec 2026 10:32:36 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796466757; bh=oUvvCEGezvZvfjy/EaODrWPCB4Hnd3ZkEVs/jnEX11I=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=BoavzawjZvE3tAdzNNjn/ch35isELMPet1QhDNIQWNCOwBhSa5zFsVaKAfv9clw4Q EhHBz8D/m+xPFy4eWIPTWf7bILDHaEZjzdIFpveq+Y2GUgbZIxLDXMbNUNXa+7Qo+7 anxGjp4zE7ntfSY4Q0l6FoYYxdwIb9QFF04fcYtOsUAoSY1iJAqH0d2bxXC1hNzAmE TL8GH4UH1SwROA7PqjJ56N9qtBZJ5/0SnbFdDvzTzNVARytDEzr5tkAAHU9c3c8QyM fDshV2vZvFTIBnWfvgXRUoXyvteNIHatY2vmYT2HpHgAriDTufjp5eL8tkspc12YQ7 ki8rHMgAk/bLQ== X-Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, nb@tipi-net.de, maxime.chevallier@bootlin.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, daniel@makrotopia.org, vladimir.oltean@nxp.com X-In-Reply-To: <20261201094454.1150-2-javen_xu@realsil.com.cn> X-sashiko-severity: Low 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 X-Received-Bytes: 14305