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=1796466758; b=elRSkyLXyFsql1iT40LM0Hc6gGoAH2acbwqkXXM5kOmNcfflIK2elvtL9JApqB9OsL3f jI6dj+Y083QfM+1/eGknuusUpwQmDCMLFfW4x00BVRI3LQMWTi6+iqvwwi1JaHcF7SxEL K3Q2XCyzZ9CRbYZZ7OV2qtuX5oZtiVYHwB/V/zqudT7WpPatBEJGjItUBstgT6uA9NfYd Vws1FOlSPk1ZPlWpZh8ZY6o1fDnBUYaCW8MKjB3/Z05ArGn8jTJuxXRafAX2PovivNw3R 3imKkypRQ711yeSOJpHlqF6FTecyfllYWh6Ymz+78KQ6BctzBZ6EyzfXz0tAsqmAq0w== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E392A1F00936; Sat, 5 Dec 2026 10:32:36 +0000 (UTC) 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== Subject: Re: [PATCH net-next v5 1/4] net: ethtool: tsconfig: allow selecting a provider From: netdev-bot+sashiko@kernel.org To: javen_xu@realsil.com.cn 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 Date: Sat, 05 Dec 2026 10:32:36 +0000 Message-ID: <179646675646.3146.9173679701484398773@kernel.org> In-Reply-To: <20261201094454.1150-2-javen_xu@realsil.com.cn> References: <20261201094454.1150-2-javen_xu@realsil.com.cn> X-sashiko-severity: Low 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 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