From: Javen <javen_xu@realsil.com.cn>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Vladimir Oltean <vladimir.oltean@nxp.com>,
"hkallweit1@gmail.com" <hkallweit1@gmail.com>,
"linux@armlinux.org.uk" <linux@armlinux.org.uk>,
"davem@davemloft.net" <davem@davemloft.net>,
"edumazet@google.com" <edumazet@google.com>,
"kuba@kernel.org" <kuba@kernel.org>,
"pabeni@redhat.com" <pabeni@redhat.com>,
"nb@tipi-net.de" <nb@tipi-net.de>,
"maxime.chevallier@bootlin.com" <maxime.chevallier@bootlin.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"daniel@makrotopia.org" <daniel@makrotopia.org>
Subject: RE: [PATCH net-next v4 3/3] net: phy: realtek: add hardware timestamping for RTL8127a
Date: Tue, 1 Dec 2026 05:50:52 +0000 [thread overview]
Message-ID: <a25da8faf3a644f7b73f283d1498f858@realsil.com.cn> (raw)
In-Reply-To: <907fa080-bc18-4c1f-8b52-b06b892cdaa5@lunn.ch>
>
>> When both mac and phy support ptp timestamp, and the user has not
>> selected a provider(dev->hwprov is NULL), the core uses the mac.
>
>We try to keep policy out of the kernel. It is policy to decide which stamper to
>use, so it should be userspace which decides and sets
>dev->hwprov. This is however a new feature, so we need to ensure it
>does not cause regressions with older code. So that is what this
>phy_is_default_hwtstamp() is about. The Marvell stampers have been around
>a while.
>
>Since yours is a new device, you should be using dev->hwprov. I guess it is a
>reasonably simple patch to ptp4l.
Hi Andrew,
When I tried this on RTL8127A, I found that the provider cannot be selected at all. r8169 has no ndo_hwtstamp_set(), so after dropping default_timestamp the netdev has no active time stamping source, and TSCONFIG_SET fails:
sudo tools/net/ynl/pyynl/cli.py \
--spec Documentation/netlink/specs/ethtool.yaml --do tsconfig-set \
--json '{"header":{"dev-name":"enp2s0"},"hwtstamp-provider":{"index":0,"qualifier":0}}'
There are two places in ethnl_set_tsconfig() that block it:
1. The entry check returns -EOPNOTSUPP before the provider attribute is even parsed, since there is no ndo_hwtstamp_set(), no default PHY and no hwprov yet.
2. Before switching the provider, the current source is disabled with a zero config through dev_set_hwtstamp_phylib(). With no hwprov and no default PHY it goes to the MAC path and returns -EOPNOTSUPP, as there is nothing to disable.
With the change below, the request is only let through when a provider is given.
net/ethtool/tsconfig.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/net/ethtool/tsconfig.c b/net/ethtool/tsconfig.c
index 2db0e7ba8b9f..9c983666a1b0 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,
struct hwtstamp_provider *hwprov = NULL;
struct net_device *dev = req_base->dev;
struct nlattr **tb = info->attrs;
+ bool has_hwts;
int ret;
if (!netif_device_present(dev))
return -ENODEV;
- 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;
if (tb[ETHTOOL_A_TSCONFIG_HWTSTAMP_PROVIDER]) {
@@ -411,9 +413,12 @@ static int ethnl_set_tsconfig(struct ethnl_req_info *req_base,
/* Disable current time stamping if we try to enable
* another one
*/
- ret = dev_set_hwtstamp_phylib(dev, &zero_config, info->extack);
- if (ret < 0)
- goto err_free_hwprov;
+ if (has_hwts) {
+ ret = dev_set_hwtstamp_phylib(dev, &zero_config,
+ info->extack);
+ if (ret < 0)
+ goto err_free_hwprov;
+ }
/* Change the selected hwtstamp source */
__hwprov = rcu_replace_pointer(dev->hwprov, hwprov,
Is this the right way to fix it? If so, I will add it as the first patch of v5.
Looking forward to your advice.
Thanks,
Javen
>
> Andrew
next prev parent reply other threads:[~2026-12-01 5:52 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 9:02 [PATCH net-next v4 0/3] net: phy: realtek: add PTP support " javen
2026-11-25 9:02 ` [PATCH net-next v4 1/3] r8169: hold MDIO bus lock while loading firmware javen
2026-11-29 9:50 ` netdev-bot+sashiko
2026-11-25 9:02 ` [PATCH net-next v4 2/3] net: phy: realtek: add PTP clock support for RTL8127a javen
2026-11-29 9:50 ` netdev-bot+sashiko
2026-11-25 9:02 ` [PATCH net-next v4 3/3] net: phy: realtek: add hardware timestamping " javen
2026-11-25 9:43 ` Vladimir Oltean
2026-11-26 6:13 ` Javen
2026-11-26 14:08 ` Andrew Lunn
2026-11-30 3:35 ` Javen
2026-12-01 1:25 ` Andrew Lunn
2026-12-01 5:50 ` Javen [this message]
2026-12-01 8:50 ` Nicolai Buchwitz
2026-12-01 9:17 ` Javen
2026-11-29 9:50 ` netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a25da8faf3a644f7b73f283d1498f858@realsil.com.cn \
--to=javen_xu@realsil.com.cn \
--cc=andrew@lunn.ch \
--cc=daniel@makrotopia.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=maxime.chevallier@bootlin.com \
--cc=nb@tipi-net.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vladimir.oltean@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®