RE: [PATCH net-next v4 3/3] net: phy: realtek: add hardware timestamping for RTL8127a

From: Javen

Date: Tue Dec 01 2026 - 04:18:43 EST


Hi Nicolai,
>
>Hi Javen
>
>On 1.12.2026 06:50, Javen wrote:
>
>> [...]
>
>> 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;
>
>Looks right. My gate (036778a4fad1) only covered the default PHY, and
>tsconfig_set_hwprov_from_desc() already refuses a NETDEV source without
>ndo_hwtstamp_set, so this can only select a PHY.
>
>>
>> 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.
>
>IMHO yes.
>
>Note that rtl8169_close() disconnects the PHY, and phy_detach() clears
>dev->hwprov. So user space has to select the PHY again after every
>down/up.
>

Thanks for review.

I will add this patch as the first patch of v5.
And thanks for the reminder. I plan to resolve this issue in ptp4l.

Thanks,
Javen