From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795945814; b=iIjHAqM2J/cEAAbOWACZSP/sTHdKytDYiajxnjY520irL/n5UAuldyHmg/mM7kA5SKMa 9d0kgsQv94vlTld3gac3ctdAM8QRNKbKWT9bfR5FIMyC0TZHMQ/CrthwL/DbhXYfT+Gpg fZp9VV8zdj/po+h6QLv3KtOX5S0spCjcXjr9Bm3cZybV5KwV1VHAt05swlqBAOBsPNR4k p4BOsTx+l03pN53CPD0MtiFy2LKBu9ox2fWs88PMl8xIdAc2ic61BaUYfw3SVS/GtNw4H B4+3zq9zDAeZd6RQ/S2yYYNz7XzLPnfGLoz61Q45YqRwx9MdnFakxfbUQLPUrxLh8eA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795945814; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=zr6U5qVA5+IoVISytsi1lpSc5a4ElP8vuTD2mxlpJ3o=; b=t3bX0AtRDltkaQz1ixHhQ0bolbMl2/ZCRqe3ZvWMheuxrXyCViBqZqbcl8TpFlRaYvFu CPtDiqTo1jSUWw4a9uzu4PZ2OBBWGfYVajAE79GkUz2LlAQkSnPv2dq3KIc/4iG7uLH0/ WIEFZtySKUwmsoq/I7nHExtd4RsFkru0Mst9QqXK3C2wYq4XJk+s0y961zhCbtlnJnGIy 3ZKMQ57oTFKV7jJaJiUiBCTlvi9lSWEDbTmz8NQKmsx2Ss5ums7DC52yUwkMbtvtIlc3k acJ46fdJh0WrVecV0u7yej6TGrCyxvaQEoY8fijbsru2jGWq7iLv2Wp+4KwbLykLu/Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XyUZQbKa; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E197606A32F; Sun, 29 Nov 2026 09:50:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XyUZQbKa Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E91F1F000C1; Sun, 29 Nov 2026 09:50:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795945814; bh=zr6U5qVA5+IoVISytsi1lpSc5a4ElP8vuTD2mxlpJ3o=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=XyUZQbKa2uz+eJIO/L27uvEYQcncPM/JWnqsr3kd6Kd2qUz9DP3KdpRXqLLMlQs1Y glyOujpB5fC+nYLGvHcP1uGH4Vpzb/R7gKqXnN40hOu/1IY5bcOJ15Dgap7K5l85fD XSwdpaR/Z//yW2qz7ue6jbT5FIbvAoleN1eGN4NTF1xq26DcW9ZPgUhFJLlMee0Ug1 iirCmUtGZq/TajH92xV8ol2kchCB2E/vcI6zOcO2UQL4V2J/nUvntQYfn5V/uE4OVS T220Qe+QPMcZqVy3xpgRPETgy5TtyhZuMCnJLqTimTF6cIHhNAOxoc0eoDfkWiIguw gSpyO/zk+PtKA== Subject: Re: [PATCH net-next v4 2/3] net: phy: realtek: add PTP clock support for RTL8127a From: netdev-bot+sashiko@kernel.org To: javen_xu@realsil.com.cn Cc: andrew@lunn.ch, 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, vladimir.oltean@nxp.com Date: Sun, 29 Nov 2026 09:50:12 +0000 Message-ID: <179594581280.3146.11285763012972937249@kernel.org> In-Reply-To: <20261125090217.1198-3-javen_xu@realsil.com.cn> References: <20261125090217.1198-3-javen_xu@realsil.com.cn> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 2 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] The driver re-seeds the PHC from CLOCK_REALTIME on the next link-up whenever `ptp->time_set` is false. - [Medium] `rtl8127a_ptp_hwtstamp_enable(ptp, false)` ends by setting `RTL8127A_PHY_RST` (BIT(15) of PHY OCP 0xa640) at… -- net: phy: realtek: add PTP clock support for RTL8127a This adds a PTP hardware clock for the internal PHY of RTL8127A (RTL8261C). The clock can be read, set, stepped and frequency adjusted through vendor MMD registers. The frequency adjustment is cleared at probe, and the clock is seeded from the system time on the first link up after a PHY init or link loss. > diff --git a/drivers/net/phy/realtek/realtek_ptp.c b/drivers/net/phy/realtek/realtek_ptp.c > new file mode 100644 > index 0000000000000..83ee125517b00 > --- /dev/null > +++ b/drivers/net/phy/realtek/realtek_ptp.c [ ... ] > +int rtl8127a_ptp_config_init(struct phy_device *phydev) > +{ > + struct rtl8127a_ptp *ptp = phydev->priv; > + > + if (!ptp) > + return 0; > + > + mutex_lock(&ptp->lock); > + ptp->time_set = false; > + mutex_unlock(&ptp->lock); > + > + return 0; > +} > + > +void rtl8127a_ptp_link_change_notify(struct phy_device *phydev) > +{ > + struct rtl8127a_ptp *ptp = phydev->priv; > + struct timespec64 ts; > + int ret = 0; > + > + if (!ptp) > + return; > + > + if (!phydev->link) { > + mutex_lock(&ptp->lock); > + ptp->time_set = false; > + mutex_unlock(&ptp->lock); > + return; > + } > + > + mutex_lock(&ptp->lock); > + > + if (!ptp->time_set) { > + ktime_get_real_ts64(&ts); > + ret = rtl8127a_ptp_write_time(ptp, &ts); > + if (!ret) > + ret = rtl8127a_ptp_clkadj(ptp, RTL8127A_PTP_DIRECT_WRITE); [Severity: Medium] Won't this overwrite a PHC time that userspace has set or disciplined? time_set gets cleared, or is never set, in these cases: - rtl8127a_ptp_config_init() clears it on every phy_init_hw(). In r8169, rtl8169_init_phy() calls phy_init_hw() from rtl8169_up(), and rtl8169_up() runs from both rtl_open() and rtl8169_runtime_resume(). - rtl8127a_ptp_link_change_notify() clears it on any state change with phydev->link == 0. That covers cable flaps and phy_stop() on ifdown. - rtl8127a_ptp_settime64()->rtl8127a_ptp_settime() and rtl8127a_ptp_adjtime() never set time_set to true. So on the first link up after any of these, the PHC is stepped to CLOCK_REALTIME, even if the counter was never reset. For example, a TAI based PHC maintained by ptp4l or phc2sys would be stepped back to UTC, roughly 37 seconds off. The v3 changelog says the clock is kept running across PHY re-initializations, but v4 now re-seeds it after every phy_init_hw(). Is that intended? If the counter really is reset by these events, wouldn't the rate programmed with RTL8127A_PTP_RATE_WRITE be lost too? It is never re-applied here. The Kconfig help text says the clock "can be read and adjusted through the PTP clock device". Here those adjustments are replaced without any notice. The same logic is still present at the end of the series. The later commit "net: phy: realtek: add hardware timestamping for RTL8127a" only adds re-enabling of timestamping in link_change_notify. It leaves the time_set handling unchanged. > + if (ret) > + goto out; > + ptp->time_set = true; > + } [ ... ] > + ptp->phydev = phydev; > + ptp->info = rtl8127a_ptp_info; > + > + ret = rtl8127a_ptp_hwtstamp_enable(ptp, false); > + if (ret) > + return ret; > + > + ret = rtl8127a_ptp_adjfine(&ptp->info, 0); [Severity: Medium] Can the PHY still be in reset when adjfine runs here? rtl8127a_ptp_hwtstamp_enable(ptp, false) ends by setting the bit that this patch defines as the PHY reset: ret = rtl8127a_ptp_modify(ptp, RTL8127A_PHY_RST_CTL, 0, RTL8127A_PHY_RST); Nothing waits for the reset to finish or for the bit to self-clear. Right after that, rtl8127a_ptp_adjfine() writes the CFG_TIME rate staging registers and issues a RATE_WRITE EXEC on CLK_CFG. It then polls EXEC with only a 1 ms timeout. If the reset is still in progress, could the staging writes be lost, or could EXEC fail to clear? In that case probe would drop PTP with "PTP support disabled". rtl8127a_ptp_remove() issues the same reset while the PHC is still registered: rtl8127a_ptp_hwtstamp_enable(ptp, false); ptp_clock_unregister(ptp->clock); Could a concurrent clock_gettime() or clock_adjtime() then program CLK_CFG and CFG_TIME on a PHY that is in the middle of a reset? Nothing else in drivers/net/ touches 0xa640, so I couldn't confirm whether this reset affects the PTP block, or how long it takes. For comparison, genphy_soft_reset() polls BMCR_RESET before it continues. This sequence is also unchanged at the end of the series. > + if (ret) > + return ret; [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125090217.1198-1-javen_xu%40realsil.com.cn