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=1796009831; b=gmgqUSKHthWUWHvZ+JavI3NJCfJjgsaTc3vVTfgrSzlW00vMQzlJANH3zKNBsvd9kWxk 7Fa/6NUUh9hIIl2k8CEytJBKSgrztqS7z387ttdcVqERfbECfeg8NtBDpv3MYR+Pnjlfo 3DCPtTrSEw5f04EDQng1rwTmJy81lBaqkmUiLGe8wu4azzxc9JseCdTWiYZHDwjBs//dS 93OQTOxT+tIAiLZ17t6E7qYdlMuUphRlGkb5zDEuYi7oVJ3t9RuhC7lxQifAleTEwTQ9X FbJ4GI3DDrRFAzFc7xznAdto+sr6cKp0/QGstYIxFkM+utpwRqAQrxumxTIBAuPJURA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796009831; 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=VpNM+D8+ypXneGf9ksskoLaFUoO0ctYWOVVQdJS5sXs=; b=a0bOHN9K1P+j1ugvnQ2G0b+WP9pkxJoB6qjcSj0uQOpAOyckwh8wjbRnqsr6YqTyUdkE Eo2nXB/W8AvbpAxMWgXtcy7Ktkqr6xFMcM+MNdODsxDOXrSWcu5h9CILHUpkjPOe0M1DE 2CDXXHwglITCZsZfz5h2vRZChN/ih7xWxfqiEw6q1ly/VmoRmKeqC9TEwsF6ffSaYtQ8d tEoKb4Hr9OPjrgv8EV8s0zk/TxzbzR+tlFITGEvzw0XygjpcMR54ANTTzrEJxUvaw3cwW xDBemTCJKWBRwn48b/JckDWXdyzv4rXOCFmHgLYe5kNU/0RyCQ6tAn8YwySRtMlCk/w== 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=ET29753K; 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 41592606A31C; Mon, 30 Nov 2026 03:37:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 41592606A31C 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=ET29753K X-SpamFilter-By: ArmorX SpamTrap 5.80 with qID 6AU3ZXhL43024735, This message is accepted by code: ctloc85258 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=realsil.com.cn; s=dkim; t=1796009734; bh=VpNM+D8+ypXneGf9ksskoLaFUoO0ctYWOVVQdJS5sXs=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:Content-Transfer-Encoding:MIME-Version; b=ET29753KuvF4ACMSVN9BvykHO8ZPHD6bgvEbkzKa7yxuLxo4yfMRFcJYQL2tbYY8u URuwqati6rA7N+V8OHcm4ksz/4qGNxk6wY/GSPQgj7TAQT2c+VmLVt1TvJRwAvTWQ0 yYbxNWHlSNbCe8IwE2DYvfjmYiNyFENuo+IfHPJ3j5iH1Txs6p9w1LP81tpFsEJZSO NJ5Rv1Z4slSC08yGL4CLnRDQEQPcEjmmkzTxldAmf0O91WSxuhPmrntLKAjY3KX3Et TvOQzonxPldUz4dMd+2BP2IoVGqSRO56zYRwKcW4YnPwnZLbL+qFzEXV6I2pf07IfU Xy+kPMaZyeXJw== Received: from RS-EX-MBS4.realsil.com.cn ([172.29.17.104]) by rtits2.realtek.com.tw (8.15.2/3.29/5.94) with ESMTPS id 6AU3ZXhL43024735 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 30 Nov 2026 11:35:34 +0800 Received: from RS-EX-MBS3.realsil.com.cn (172.29.17.103) by RS-EX-MBS4.realsil.com.cn (172.29.17.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.56; Mon, 30 Nov 2026 11:35:34 +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; Mon, 30 Nov 2026 11:35:34 +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+iZ7RgAFTcXCAAAKPgIAGGtww Date: Mon, 30 Nov 2026 03:35:34 +0000 Message-ID: <43e9de91177b4ffaa7b1c22c45109578@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> <15f473435a41440da45c6d070edc1128@realsil.com.cn> <07ddc9e6-2604-47d4-9e68-eedfaa4ee142@lunn.ch> In-Reply-To: <07ddc9e6-2604-47d4-9e68-eedfaa4ee142@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 > >On Thu, Nov 26, 2026 at 06:13:55AM +0000, Javen wrote: >> > >> > >> >On Wed, Nov 25, 2026 at 05:02:16PM +0800, javen wrote: >> >> + phydev->default_timestamp =3D true; >> > >> >Enabling new instances of phydev->default_timestamp is not an option >> >that you have. Did you research why it exists? >> >> Hi Vladimir, >> > >> Thanks for review. I understand that phydev->default_timestamp was >> introduced to preserve legacy behavior. However, RTL8127A doesn't >> support mac ptp. The PHY is the only hardware timestamping block >> available on this link. Without setting default_timestamp =3D true, the >> current core framework simply breaks for this PHY-only chip. >> How would you prefer handling such hardware without mac ptp? Any >> suggestion would be great helpful. > >That sounds like something is broken somewhere. This should only come into >effect when there are two stampers available, e.g. a Marvell PHY connected= to >a Marvell Switch. As far as i remember, the PHY one is partially broken, s= o you >want to use the MAC one, if available. > >However, if there is no choice, i would not expect default_timestamp to do >anything. > >Please spend some time to understand what is going on here. Hi Andrew, I think the problem is in how the core picks the default timestamp. 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. It uses the phy onl= y if the phy driver sets default_timestamp, which is kept for the old behav= iour. static inline bool phy_is_default_hwtstamp(struct phy_device *phydev) { return phy_has_hwtstamp(phydev) && phydev->default_timestamp; } But this does not check if the MAC support timestamp. RTL8127 is the PHY on= ly. Without default_timestamp, the core still picks the MAC, and the hardwa= re timestamping does not work. - skb_clone_tx_timestamp() and skb_defer_rx_timestamp() return early, so no packet reaches the PHY - ethtool -T reports software timestamping only - SIOCSHWTSTAMP and SIOCGHWTSTAMP return -EOPNOTSUPP - tsconfig-set also returns -EOPNOTSUPP, so the user cannot select the PHY by hand either I think that when mac cannot support timestamp but phy support, phy should = be the default timestamp. I have prepared patch below. If the mac has hwtst= amp NDOs, nothing changes. diff --git a/net/core/dev.h b/net/core/dev.h index 4e9e8cd15697..7bc3c65c249d 100644 --- a/net/core/dev.h +++ b/net/core/dev.h @@ -418,5 +418,6 @@ int dev_set_hwtstamp_phylib(struct net_device *dev, int dev_get_hwtstamp_phylib(struct net_device *dev, struct kernel_hwtstamp_config *cfg); int net_hwtstamp_validate(const struct kernel_hwtstamp_config *cfg); +bool dev_phy_is_default_hwtstamp(struct net_device *dev); =20 #endif diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c index f6029f60c1dc..db345fe13744 100644 --- a/net/core/dev_ioctl.c +++ b/net/core/dev_ioctl.c @@ -32,6 +32,16 @@ static int dev_ifname(struct net *net, struct ifreq *ifr= ) return netdev_get_name(net, ifr->ifr_name, ifr->ifr_ifindex); } =20 +bool dev_phy_is_default_hwtstamp(struct net_device *dev) +{ + struct phy_device *phydev =3D dev->phydev; + + if (phy_is_default_hwtstamp(phydev)) + return true; + + return phy_has_hwtstamp(phydev) && !dev->netdev_ops->ndo_hwtstamp_set; +} + /* * Perform a SIOCGIFCONF call. This structure will change * size eventually, and there is nothing I can do about it. @@ -274,7 +284,7 @@ int dev_get_hwtstamp_phylib(struct net_device *dev, return -EOPNOTSUPP; } =20 - if (phy_is_default_hwtstamp(dev->phydev)) + if (dev_phy_is_default_hwtstamp(dev)) return phy_hwtstamp_get(dev->phydev, cfg); =20 if (!dev->netdev_ops->ndo_hwtstamp_get) @@ -351,7 +361,7 @@ int dev_set_hwtstamp_phylib(struct net_device *dev, =20 cfg->qualifier =3D hwprov->desc.qualifier; } else { - phy_ts =3D phy_is_default_hwtstamp(dev->phydev); + phy_ts =3D dev_phy_is_default_hwtstamp(dev); if (phy_ts) phydev =3D dev->phydev; } diff --git a/net/core/timestamping.c b/net/core/timestamping.c index a50a7ef49ae8..4dcf803b0bb3 100644 --- a/net/core/timestamping.c +++ b/net/core/timestamping.c @@ -10,6 +10,7 @@ #include #include #include +#include "dev.h" =20 static unsigned int classify(const struct sk_buff *skb) { @@ -43,7 +44,7 @@ void skb_clone_tx_timestamp(struct sk_buff *skb) phydev =3D hwprov->phydev; } else { phydev =3D skb->dev->phydev; - if (!phy_is_default_hwtstamp(phydev)) { + if (!dev_phy_is_default_hwtstamp(skb->dev)) { rcu_read_unlock(); return; } @@ -86,7 +87,7 @@ bool skb_defer_rx_timestamp(struct sk_buff *skb) phydev =3D hwprov->phydev; } else { phydev =3D skb->dev->phydev; - if (!phy_is_default_hwtstamp(phydev)) { + if (!dev_phy_is_default_hwtstamp(skb->dev)) { rcu_read_unlock(); return false; } diff --git a/net/ethtool/common.c b/net/ethtool/common.c index ec67fbd6bb86..b15446daef58 100644 --- a/net/ethtool/common.c +++ b/net/ethtool/common.c @@ -1089,7 +1089,7 @@ int __ethtool_get_ts_info(struct net_device *dev, struct phy_device *phydev =3D dev->phydev; =20 ethtool_init_tsinfo(info); - if (phy_is_default_hwtstamp(phydev) && + if (dev_phy_is_default_hwtstamp(dev) && phy_has_tsinfo(phydev)) { err =3D phy_ts_info(phydev, info); /* Report the phc source only if we have a real diff --git a/net/ethtool/tsconfig.c b/net/ethtool/tsconfig.c index 2db0e7ba8b9f..b099329ada06 100644 --- a/net/ethtool/tsconfig.c +++ b/net/ethtool/tsconfig.c @@ -44,7 +44,7 @@ static int tsconfig_prepare_data(const struct ethnl_req_i= nfo *req_base, int ret; =20 if (!dev->netdev_ops->ndo_hwtstamp_get && - !phy_is_default_hwtstamp(dev->phydev) && + !dev_phy_is_default_hwtstamp(dev) && !netdev_ops_lock_dereference(dev->hwprov, dev)) return -EOPNOTSUPP; =20 @@ -306,7 +306,7 @@ static int ethnl_set_tsconfig(struct ethnl_req_info *re= q_base, return -ENODEV; =20 if (!dev->netdev_ops->ndo_hwtstamp_set && - !phy_is_default_hwtstamp(dev->phydev) && + !dev_phy_is_default_hwtstamp(dev) && !netdev_ops_lock_dereference(dev->hwprov, dev)) return -EOPNOTSUPP; =20 --=20 2.43.0 I tested it on RTL8127A with net-next. With this patch, and with default_ti= mestamp removed from the Realtek PHY driver, ptp4l works with PHY hardware = timestamps. I also have a question about the approach. Would you prefer: 1) a new helper in net/core, as in the patch above, or 2) changing phy_is_default_hwtstamp() itself? For 2), phy_is_default_hwtstamp() only gets the phydev, so it would have to= check the MAC through phydev->attached_dev. Then include/linux/phy.h would= need to include linux/netdevice.h, which it does not do today. Any advice would be appreciated. Thanks, Javen > > Andrew