🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24982

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

#24982
From: Javen
Date: Tue, 01 Dec 2026 05:50
95 lines
13423 bytes
>
>> 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
Technical Details
Message-ID: <a25da8faf3a644f7b73f283d1498f858@realsil.com.cn>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374715-linux-kernel-netdev=dewy.ru
References: <20261125090217.1198-1-javen_xu@realsil.com.cn> <20261125090217.1198-1-javen_xu@realsil.com.cn> <20261125090217.1198-4-javen_xu@realsil.com.cn> <20261125090217.1198-4-javen_xu@realsil.com.cn> <awathfkR13ZQH6g9@lxl00025.wbi.nxp.com> <15f473435a41440da45c6d070edc1128@realsil.com.cn> <07ddc9e6-2604-47d4-9e68-eedfaa4ee142@lunn.ch> <43e9de91177b4ffaa7b1c22c45109578@realsil.com.cn> <907fa080-bc18-4c1f-8b52-b06b892cdaa5@lunn.ch>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374715-linux-kernel-netdev=dewy.ru
From: javen_xu@realsil.com.cn (Javen)
Newsgroups: linux.kernel.netdev
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
Organization: Usenet Network
Message-ID: <a25da8faf3a644f7b73f283d1498f858@realsil.com.cn>
References: <20261125090217.1198-1-javen_xu@realsil.com.cn>
 <20261125090217.1198-1-javen_xu@realsil.com.cn>
 <20261125090217.1198-4-javen_xu@realsil.com.cn>
 <20261125090217.1198-4-javen_xu@realsil.com.cn>
 <awathfkR13ZQH6g9@lxl00025.wbi.nxp.com>
 <15f473435a41440da45c6d070edc1128@realsil.com.cn>
 <07ddc9e6-2604-47d4-9e68-eedfaa4ee142@lunn.ch>
 <43e9de91177b4ffaa7b1c22c45109578@realsil.com.cn>
 <907fa080-bc18-4c1f-8b52-b06b892cdaa5@lunn.ch>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="1628816"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:2nQvJYthYrSHPt44ZDqLLHXz8WU= sha256:JRmY16Z7hG/bj3GqpY8KlMlCzrKzX+GNsOgy0y83E/o=
	sha1:JuxOX+Wb7f8l0pRnEYifxJqJc3E= sha256:qQzrWB+DOfifym2olwuG34MiJZQbsAHb1EX+T4etA98=
Content-Language: zh-CN
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 5665311724D; Tue,  1 Dec 2026 08:53:07 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.15
X-Spam-Status: No, score=-3.15 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, 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=realsil.com.cn
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 f2l4ckVfeKOJ;
	Tue,  1 Dec 2026 08:53:03 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-374715-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=realsil.com.cn
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 0B28511722E; Tue,  1 Dec 2026 08:52:54 +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 D25B6260C8; Tue,  1 Dec 2026 05:52:50 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail;
	t=1796104369;
	b=Q3ji6p3gzHkm6Xx/DxIrAJxyjZkWETAgy6lTkupIjHcQtP/pWUKnWghTbTbc8Fp1ZJVm
	 Av7CoOHwCocs7JsV44iisO52NrLTflIg27PO0mbAhC12gpwIIlqKWDAIFDCXCshv1mzKV
	 qS+Oz3ChEDJdluB5fE/+SdARNaWXGGRAAO7+rMY/YQZXmza89u9I0E2w82Pkna23qgWi5
	 QfwbcDe5NiadHOPDNoad5Vy7y14ee9vnFpCKSwOcwj1t/oGfYFzVSwh9K0SLxsOQgzcEo
	 vykjmJit8TUddY5r2aifisRBhxShIGh+yOVe9y2331vqnPmZ8T63nfOqoXaElVyMJqA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796104369;
	h=X-Original-To:Received:DMARC-Filter:X-SpamFilter-By:DKIM-Signature:
	 Received:Received:Received:From:To:CC:Subject:Thread-Topic:
	 Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:
	 Content-Language:Content-Type:Content-Transfer-Encoding:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version;
	bh=UVmRwVxIbAaGCPMyc9UUBNbi0KYs/upk9Via7VralfY=;
	b=MdF89xMr5GdcMIx3WlpqqSWTulfaOdfqMUGdJIvOCfXNp7OrCYzKfgABYQ06hTgBAmQT
	 29K6fM5Up3MKIC88secOqa+bW2Gmoo93/kHvvamjF4Noa8SDSMU6A3lh9kGapWzlW7Xih
	 H1DrvHPEIGQPe4qcekofC5O3ppzj2/RDMQI0/z/fXMmwQ5normAqdx3459soDgEbVZD/S
	 2dFfnhuw9YEOAzTXD6C4Eb14J+pOy9VO/fFYp5M0qxx0EIFhWOPhZInoTxAfe6qCI0Dh8
	 oZlZQaE870bNw7wVX6X4N8D9rEfecuw0cyDzqqC5cEiwVUVrvdtfhruZFuarjl5b+uw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=realsil.com.cn header.i=@realsil.com.cn header.a=rsa-sha256 header.s=dkim header.b=Q64e8E8a;
	dmarc=pass header.from=realsil.com.cn;
	spf=pass smtp.mailfrom=realsil.com.cn;
	arc=fail 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 475AF606A333;
	Tue,  1 Dec 2026 05:52:49 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=realsil.com.cn header.i=@realsil.com.cn header.a=rsa-sha256 header.s=dkim header.b=Q64e8E8a
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=211.75.126.72
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796104358;
	b=paAReECpebrtySa2KHQlDwWmBV7VdrmfoYyI2LntBFOeVh5omh502mf4UUQytjfx2zYA
	 93vJ9DdlmumMd08guhoAWpHbA8AneEeUjs68qbwhnvlAnRm7bfgn3c1SwHGnGzygs8ltR
	 CtTthyBNC3lWmo0m7Own4DRx5mjq6bKrRNLpF46UAtID2qmdST3mcBW4ypn37zT4jR0Pc
	 rWAQIGl/vCB3wnGiPdOUuErz/83ygLRszMcJnPs+Jmhsb163/kqtCehYqqENiGjIy+dNG
	 cIL3WV0n1LTOih61idES3eVtEaX5ZZxsqUvz6Z2mf2Ev0c136kKB8lOY8lx5Jo6tgDw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796104358;
	h=DMARC-Filter:X-SpamFilter-By:DKIM-Signature:Received:Received:
	 Received:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:
	 References:In-Reply-To:Accept-Language:Content-Language:
	 x-originating-ip:Content-Type:Content-Transfer-Encoding:MIME-Version;
	bh=UVmRwVxIbAaGCPMyc9UUBNbi0KYs/upk9Via7VralfY=;
	b=W79AbXSux1HSSGwy6pas11EyrsT+c2PQzagdjgHLQFJlkyGwyn+s39tq9vk753ukd5bH
	 0k57bDPvcN/i3XPa6Wkxrb7JKGpjWshuXeazSQueuvP1MVcNG4XR+7pAGwNNgUs2Y87+D
	 ubXmchpKrtPLSZAOM8PaXnFjDj5xtxayi3p2DJ/eipTu9jGu6IrJethxEgQK3X/CP1Hkh
	 URcXhmraDUnXQAitxnnwnZkf9bxQt2Ki8gqXo4fVWCKAxkgpnsIZ1i9by2W1KHkxzkTF/
	 oVmTKPdCb22Ni7qXRH1VtHFnkTLZy9qRGA6QIY6RoyI6BiQXvHuBwmwJJK0lRc1B+YA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=realsil.com.cn;
	spf=pass smtp.mailfrom=realsil.com.cn;
	dkim=pass header.d=realsil.com.cn header.i=@realsil.com.cn header.a=rsa-sha256 header.s=dkim header.b=Q64e8E8a;
	arc=none smtp.remote-ip=211.75.126.72
X-Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F76B606A31A;
	Tue,  1 Dec 2026 05:52:36 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3F76B606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=realsil.com.cn
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=realsil.com.cn
X-SpamFilter-By: ArmorX SpamTrap 5.80 with qID 6B15oqvbF3992233, This message is accepted by code: ctloc85258
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=realsil.com.cn;
	s=dkim; t=1796104253;
	bh=UVmRwVxIbAaGCPMyc9UUBNbi0KYs/upk9Via7VralfY=;
	h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To:
	 Content-Type:Content-Transfer-Encoding:MIME-Version;
	b=Q64e8E8aMjX2PlHq+72gIqZA2jbi++8kinhee05uvWOgAO1WViBT8vbBzYh/keKAl
	 5GHVj4PY/8OUMa15fdxnYCFUMt9s3FWop3lrP6YglagM8s7KOa8vPXJ1TS2KRj4QYi
	 zSAo0L1lF1jeGjFHKnVKQd6q/oYA6jj1zHdDbxmzelyfmU8HcqNDojzxjaBrm3xMqQ
	 yuva18VBJx3tOXLRiPrORd+UyrEQkAfMldLCmkN3qzZOSOO5Iw/E3NYAQnkKSjumwv
	 WygjP6MJffO3+YTmFZiTa0m5eP7uZ8qTp7EaXrMf9sL5QBm+AWcly4FZj/RIXDzLAh
	 Bq0/UTrV+3Xnw==
X-Received: from RS-EX-MBS3.realsil.com.cn ([172.29.17.103])
	by rtits2.realtek.com.tw (8.15.2/3.29/5.94) with ESMTPS id 6B15oqvbF3992233
	(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL);
	Tue, 1 Dec 2026 13:50:53 +0800
X-Received: from RS-EX-MBS3.realsil.com.cn (172.29.17.103) by
 RS-EX-MBS3.realsil.com.cn (172.29.17.103) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.2.2562.56; Tue, 1 Dec 2026 13:50:53 +0800
X-Received: from RS-EX-MBS3.realsil.com.cn ([172.29.17.103]) by
 RS-EX-MBS3.realsil.com.cn ([172.29.17.103]) with mapi id 15.02.2562.056; Tue,
 1 Dec 2026 13:50:53 +0800
X-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>
X-Thread-Topic: [PATCH net-next v4 3/3] net: phy: realtek: add hardware
 timestamping for RTL8127a
X-Thread-Index: AQHdfLusREI69QMHwUie9alKwtUlK7c+iZ7RgAFTcXCAAAKPgIAGGtwwgADrjgCAAM1H4A==
X-In-Reply-To: <907fa080-bc18-4c1f-8b52-b06b892cdaa5@lunn.ch>
X-Accept-Language: zh-CN, en-US
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