Article View: linux.kernel.netdev
Article #25680RE: [PATCH net-next v5 3/4] net: phy: realtek: add PTP clock support for RTL8127a
From: Javen
Date: Wed, 02 Dec 2026 08:55
Date: Wed, 02 Dec 2026 08:55
107 lines
13119 bytes
13119 bytes
Hi Nicolai,
>
>Hi Javen
>
>On 1.12.2026 10:44, javen wrote:
>> From: Javen Xu <javen_xu@realsil.com.cn>
>>
>> The internal PHY of RTL8127A (RTL8261C, PHY ID 0x001cc890) contains a
>> PTP block with a free running clock that can be read, set, stepped and
>> frequency adjusted through vendor MMD registers.
>>
>> Register a PTP hardware clock for it. All register accesses go through
>> the normal blocking MDIO path, multi register sequences are serialized
>> by a driver mutex. The frequency adjustment is cleared at probe. The
>> clock is set from the system time when the link comes up for the first
>> time after a PHY init or link loss.
>
>The code doesn't do this anymore, and time_set is unused. Please drop both.
>
>>
>> Signed-off-by: Javen Xu <javen_xu@realsil.com.cn>
>> ---
>> Changes in v3:
>> - Keep the clock running across PHY re-initializations, only start it
>> from the system time if the counter has been reset
>> - Only bracket the latching EXEC write with the system timestamps in
>> gettimex64()
>> - Clear phydev->priv in remove()
>> - Add defines for the PHY reset register
>> - Depend on NETWORK_PHY_TIMESTAMPING from this patch on
>>
>> Changes in v4:
>> - Set the clock from the system time on link up, after a PHY init or
>> link loss
>> - Don't fail the PHY probe if PTP setup fails
>>
>> Changes in v5:
>> - Don't set the clock from the system time on link up, leave the time
>> to userspace.
>> ---
>
>> [...]
>
>> +static int rtl8127a_ptp_poll(struct rtl8127a_ptp *ptp, u16 reg, u16
>> mask,
>> + bool set)
>> +{
>> + int ret, val;
>> +
>> + ret = read_poll_timeout(rtl8127a_ptp_read, val,
>> + val < 0 || !!(val & mask) == set, 1, 1000,
>> + false, ptp, reg);
>
>Could use phy_read_mmd_poll_timeout() ?
>
>> [...]
>
>> +static int rtl8127a_ptp_hwtstamp_enable(struct rtl8127a_ptp *ptp,
>> +bool
>> enable)
>> +{
>> + int ret;
>> +
>> + mutex_lock(&ptp->lock);
>> +
>> + ret = rtl8127a_ptp_modify(ptp, RTL8127A_PTP_SYNCE_CTL,
>> + RTL8127A_PTP_SYNCE_EN, 0);
>> + if (ret)
>> + goto out;
>> +
>> + if (enable) {
>
>Unused until 4/4, maybe move it there ?
>
>> [...]
>
>> +static int rtl8127a_ptp_adjfine(struct ptp_clock_info *info, long
>> scaled_ppm)
>> +{
>> + struct rtl8127a_ptp *ptp = container_of(info, struct
>> +rtl8127a_ptp,
>> info);
>> + s32 ppb = scaled_ppm_to_ppb(scaled_ppm);
>
>diff_by_scaled_ppm() would keep the full resolution.
>
>> [...]
>
>> +static int rtl8127a_ptp_gettimex64(struct ptp_clock_info *info,
>> + struct timespec64 *ts,
>> + struct ptp_system_timestamp *sts) {
>
>What happens when r8169 is runtime suspended? Nothing on this path
>resumes it.
I think we could resume the MAC around the PHC callbacks with pm_runtime_resume_and_get(phydev->mdio.bus->parent), or only take a reference with pm_runtime_get_if_active() and return -EBUSY while the MAC is suspended, so the PHC doesn't wake up the NIC (and re-init the PHY) while there is no link.
Which one do you prefer?
Thanks,
Javen
Technical Details
Message-ID:
<d88a3c255e50437a9e5f348519a735bf@realsil.com.cn>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375654-linux-kernel-netdev=dewy.ruReferences:
<20261201094454.1150-1-javen_xu@realsil.com.cn> <20261201094454.1150-4-javen_xu@realsil.com.cn> <f3abdf1bd4bb98dba9c3a4e4861b4f65@tipi-net.de>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375654-linux-kernel-netdev=dewy.ru From: javen_xu@realsil.com.cn (Javen) Newsgroups: linux.kernel.netdev Subject: RE: [PATCH net-next v5 3/4] net: phy: realtek: add PTP clock support for RTL8127a Date: Wed, 2 Dec 2026 08:55:32 +0000 Organization: Usenet Network Message-ID: <d88a3c255e50437a9e5f348519a735bf@realsil.com.cn> References: <20261201094454.1150-1-javen_xu@realsil.com.cn> <20261201094454.1150-4-javen_xu@realsil.com.cn> <f3abdf1bd4bb98dba9c3a4e4861b4f65@tipi-net.de> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Injection-Info: usenet.network; logging-data="1928217"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:NalNaqCBkbWWdn/akWZprT5q5m0= sha256:Vr909h2Kmg2PUO097HXthyPRZW5pksyGFAoLrWuY2kk= sha1:tsqfsJnUnsyyAbXKatFMadLs2fc= sha256:CyQFGdlojfQJ8PAXR+bVVtPfGbIPMTTwYf1FVt4IiNY= 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 C22311175BA; Wed, 2 Dec 2026 11:56:52 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.151 X-Spam-Status: No, score=-3.151 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] 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 8vVsPaOfLZhz; Wed, 2 Dec 2026 11:56:49 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-375654-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 20F291175A9; Wed, 2 Dec 2026 11:56:37 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 9795E60173F; Wed, 2 Dec 2026 08:56:36 +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=1796201794; b=XYH7iW3WqTpIUn0uDq7kxMknGl2XFz2+ORKBVReuwRydvlelzwB/RXhLbNBF1QaHYodJ r8PVJGYov/xXsswtzlEeGA/r5wdzrDUpBAjaIaXLfd+IOHgiap1Bmi1MJeewgjPTqJS21 sNKbTiDuxqs1+g1KpZawdS3BG6naWZZxeiXpmlx4Lu2qnIvC5nEcME1Sorq/v5NjwY51w MD1K9dTD9YdXNN/e6Coy6Ya500IUmU00XWPY6NevXRGVxeAOGE9BH/TCmsq1FfJ8rbwC5 yLDRt9QeCSDRhL0csAnnwcjrp3gPjieuU3QEuU7x4Dv1Z9lIutDToafZjGC2PSkGYLw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796201794; 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=8er3tMuGEF8RBymBQ+EkE6khKuChT71MCRMU83qXVsg=; b=z9LdOQSFu3IAb3Yg6yFFSPp8iDq4EJihCAnEjDt06jWKHh3IuQXWb09P2C8KzUJ/PXJj PZ/GABxb2jcmziJc5Pk1v3c55d3OL1iFwT2f26/VJgD+F5mflapRJrNvtFXy3U4lGQ/JC 5ugb5oKqMxepACFkHhn6kbpm603JoglN1RBJLH0r6pJtAbGDNJlHo4vzIRdAH4x1Tf93R Vkn2/KbHfmuUewOBeSWs5cXfK3A0GG+Gvlay+5SXUE1/hnyoMRUxdco21waYWqN/V6oe+ cOq74CAv0yBKH7C/hEXzrXWlRVFh38azvyUXZmVuSbS5PYoW5DDDwJwCSk47EfyoO3Q== 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="U/G52yAK"; 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 A4191606A33A; Wed, 2 Dec 2026 08:56:34 +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=U/G52yAK 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=1796201793; b=vC23t9UTIHv/ovNoNgG002ENfntQcJ9Bkl03A9B9jriP0oIOMn63XHMuQhEoBCy9bnB/ NcNNH+w9vjBmtHyf7vbrM3xKyFE0jjk7GqCEBzIW/KellK4Sr6XWgVKjd9cmyntydzKWD BXk2DsAT2tXC9bTjSDfxo43b52LPf9Lxd+BRtuyiebDOiApxv4wQPjI5gambvHIdcCGHt nwkU3bW0uRTmn57s/C8U/2J3fL7QpB5SWLFzD1RHhOnEdpGWNtjIR2KZ/7Vn5H0bWYt9N WD9GkLhZR3dV715tcYSIZvaNFAwsJBcuUDcpXpfjW+UhlptSTRAAcSulHmwt3knYxcg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796201793; 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=8er3tMuGEF8RBymBQ+EkE6khKuChT71MCRMU83qXVsg=; b=VezGIVhWeXRITKwQg7vbZ9+iDLgj5QKw8dr3angUSlSKc7j/HPJZpzeTmhr9UcxjEV+E dimKmmZPgf5Q7zCqBoM0rr/5aYcVkIPK4th9dMzesg/9I/XCqlFni1sy2SSTRLVdHSS4/ KcVes7zUN3cZexTiPVxe9SKCkwi+FB0Vv++f62ECDY6xnlYJwAiBU59nNmV5pG/3Pp8be 9E0WNZS1UYs/9Rd6hbpZwgISWgHu/6LDuOZr0V+3eUrlseCzMjEprj2tAPt5760G5ypvP lHC0GjAXh7qJ6xyxuMJYqVDi88FL6hXbhsRLfsYjlkrvWxruxxbYkmBm9I8Zh+wzZGg== 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="U/G52yAK"; 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 BB12E606A327; Wed, 2 Dec 2026 08:56:32 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BB12E606A327 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 6B28tWEv9827329, 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=1796201735; bh=8er3tMuGEF8RBymBQ+EkE6khKuChT71MCRMU83qXVsg=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:Content-Transfer-Encoding:MIME-Version; b=U/G52yAKqLz3tx/WaEqz+ZUQL8RKwfX7SjOezS9SETI57mfKS60Mb6kd+7YYppPZ4 lj6FPEuNOvt8+AD1TafSrAxAqyJIkTtfHcO+0IVrmQ0ddrRqCPaCZaDpHUzSTWpr47 akyLrR8rlIAlf7PS3NFBawxSc+MzduUlq7yA9cIdfYBMNjh4U7zx/ggRQ3tR+hKnAq TzYtDM6qgzfJkRkiGpghB7tUIBWvzb/QXBIZ4oj3JCnn7qDH1V5IxBOJiluAGeARZ2 X/O0arpeqWZVRBlklg8h+QphmLmJNdU5XR6wXzZk2E/vs+zX+QvRj/XXVfu8CxR3Qi pNMR7qsCU4dFg== X-Received: from RS-EX-MBS1.realsil.com.cn ([172.29.17.101]) by rtits2.realtek.com.tw (8.15.2/3.29/5.94) with ESMTPS id 6B28tWEv9827329 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 2 Dec 2026 16:55:34 +0800 X-Received: from RS-EX-MBS3.realsil.com.cn (172.29.17.103) by RS-EX-MBS1.realsil.com.cn (172.29.17.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.56; Wed, 2 Dec 2026 16:55:32 +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; Wed, 2 Dec 2026 16:55:32 +0800 X-CC: "andrew@lunn.ch" <andrew@lunn.ch>, "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>, "vladimir.oltean@nxp.com" <vladimir.oltean@nxp.com> X-Thread-Topic: [PATCH net-next v5 3/4] net: phy: realtek: add PTP clock support for RTL8127a X-Thread-Index: AQHdgXihWXtWRJ6B0UWGXiAMAYnp7bdHcvkAgAH/EGA= X-In-Reply-To: <f3abdf1bd4bb98dba9c3a4e4861b4f65@tipi-net.de> 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