Netdev List
 help / color / mirror / Atom feed
From: Javen <javen_xu@realsil.com.cn>
To: Nicolai Buchwitz <nb@tipi-net.de>
Cc: Andrew Lunn <andrew@lunn.ch>,
	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>,
	"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 09:17:05 +0000	[thread overview]
Message-ID: <43f871d3b77848ca8b82c98b183f8919@realsil.com.cn> (raw)
In-Reply-To: <d6e37f9025e047d73b684c184673c122@tipi-net.de>

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

  reply	other threads:[~2026-12-01  9:18 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 for RTL8127a 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
2026-12-01  8:50               ` Nicolai Buchwitz
2026-12-01  9:17                 ` Javen [this message]
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=43f871d3b77848ca8b82c98b183f8919@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