Netdev List
 help / color / mirror / Atom feed
From: Javen <javen_xu@realsil.com.cn>
To: Nicolai Buchwitz <nb@tipi-net.de>
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>
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	[thread overview]
Message-ID: <d88a3c255e50437a9e5f348519a735bf@realsil.com.cn> (raw)
In-Reply-To: <f3abdf1bd4bb98dba9c3a4e4861b4f65@tipi-net.de>

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

  reply	other threads:[~2026-12-02  8:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  9:44 [PATCH net-next v5 0/4] net: phy: realtek: add PTP support for RTL8127a javen
2026-12-01  9:44 ` [PATCH net-next v5 1/4] net: ethtool: tsconfig: allow selecting a provider javen
2026-12-01 10:06   ` Nicolai Buchwitz
2026-12-01 10:34   ` Maxime Chevallier
2026-12-01 10:44     ` Nicolai Buchwitz
2026-12-01  9:44 ` [PATCH net-next v5 2/4] r8169: hold MDIO bus lock while loading firmware javen
2026-12-01 10:18   ` Nicolai Buchwitz
2026-12-01  9:44 ` [PATCH net-next v5 3/4] net: phy: realtek: add PTP clock support for RTL8127a javen
2026-12-01 10:23   ` Nicolai Buchwitz
2026-12-02  8:55     ` Javen [this message]
2026-12-01  9:44 ` [PATCH net-next v5 4/4] net: phy: realtek: add hardware timestamping " javen
2026-12-01 10:36   ` Nicolai Buchwitz
2026-12-02  8:30     ` Javen

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=d88a3c255e50437a9e5f348519a735bf@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