From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=211.75.126.72 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== 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== 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 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) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3F76B606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=realsil.com.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=realsil.com.cn Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=realsil.com.cn header.i=@realsil.com.cn header.a=rsa-sha256 header.s=dkim header.b=Q64e8E8a X-SpamFilter-By: ArmorX SpamTrap 5.80 with qID 6B15oqvbF3992233, This message is accepted by code: ctloc85258 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== 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 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 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 From: Javen To: Andrew Lunn CC: Vladimir Oltean , "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" Subject: RE: [PATCH net-next v4 3/3] net: phy: realtek: add hardware timestamping for RTL8127a Thread-Topic: [PATCH net-next v4 3/3] net: phy: realtek: add hardware timestamping for RTL8127a Thread-Index: AQHdfLusREI69QMHwUie9alKwtUlK7c+iZ7RgAFTcXCAAAKPgIAGGtwwgADrjgCAAM1H4A== Date: Tue, 1 Dec 2026 05:50:52 +0000 Message-ID: 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> <15f473435a41440da45c6d070edc1128@realsil.com.cn> <07ddc9e6-2604-47d4-9e68-eedfaa4ee142@lunn.ch> <43e9de91177b4ffaa7b1c22c45109578@realsil.com.cn> <907fa080-bc18-4c1f-8b52-b06b892cdaa5@lunn.ch> In-Reply-To: <907fa080-bc18-4c1f-8b52-b06b892cdaa5@lunn.ch> Accept-Language: zh-CN, en-US Content-Language: zh-CN Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 > >> 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 stam= per 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 i= s 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_timesta= mp 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,"qua= lifier":0}}' There are two places in ethnl_set_tsconfig() that block it: 1. The entry check returns -EOPNOTSUPP before the provider attribute is eve= n parsed, since there is no ndo_hwtstamp_set(), no default PHY and no hwpro= v yet. 2. Before switching the provider, the current source is disabled with a zer= o config through dev_set_hwtstamp_phylib(). With no hwprov and no default P= HY 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 g= iven. 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 =3D NULL; struct net_device *dev =3D req_base->dev; struct nlattr **tb =3D info->attrs; + bool has_hwts; int ret; =20 if (!netif_device_present(dev)) return -ENODEV; =20 - if (!dev->netdev_ops->ndo_hwtstamp_set && - !phy_is_default_hwtstamp(dev->phydev) && - !netdev_ops_lock_dereference(dev->hwprov, dev)) + has_hwts =3D 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; =20 if (tb[ETHTOOL_A_TSCONFIG_HWTSTAMP_PROVIDER]) { @@ -411,9 +413,12 @@ static int ethnl_set_tsconfig(struct ethnl_req_info *r= eq_base, /* Disable current time stamping if we try to enable * another one */ - ret =3D dev_set_hwtstamp_phylib(dev, &zero_config, info->extack); - if (ret < 0) - goto err_free_hwprov; + if (has_hwts) { + ret =3D dev_set_hwtstamp_phylib(dev, &zero_config, + info->extack); + if (ret < 0) + goto err_free_hwprov; + } =20 /* Change the selected hwtstamp source */ __hwprov =3D 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