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=1795618245; b=kd0C0npn6FFwpWr8kbfuk8ZPbxXusvap2yJeRxOl1z2H9l4VWKsTHIpTCQ+y3TXy67rF ocpk37oYc2J/aR5PmwUGIGel1kVT2qLlyJZ+ODoO2Bk2Xy1Vojd0GKw6xLymQuS8UirLh Dll4hiKbT5VY1HFEiY50+ODGxyILXix54XBWJhCnh06O/8YxBS/E5uLxqAHtAvWyNc6LG utgQjIrzF2LCEAJRF1opDDpoaYmHpnkW+FpvVYvR8uPoOl1GP6m9Et6CbOQirW7l91fq4 QvurjLo7ImxK/bdtQ/wXtv5CwxuVCuUKvI/IBjIKDIJoMAA7i1tlDJEloKS0Z2xT7xQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795618245; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=yt378NC0+q+XGudM1P6jFRMNUeKF/t7gsegzrFyNaYs=; b=iQcusHCC4mur4AWXinz1PcHcgjsS+uRCCQHDvGia9Vj2I2zBcpyWTpn4b415T6kbOhqr ueMUafE/aRoa+xhC1eZiFJSjZkpHJLGZ80XOTbR5NVGpuT99DUxJ0/nMy8bGaxS+UKTcc aH9aI9UDFAlsYj77Sk0tPnxNTRxhyYZ6b6MfuJsTRghyporCap2eh/OgPa+IygFYIRJIe TJaybsP7hYu2gnf4rzAfOkXBoIcR5f0pfQ7c7bQOdaZpnbImdYXdRsM6PlzngZ+3VcVSd 4JlDP2SvNT59JiEvLWt16Lw/daYzfKEd1p7UzRzULyIgZMpPjbhJOZSvsQbe9OaEvDA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Mhih9hLI; 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 6C4B8606A321; Wed, 25 Nov 2026 14:50:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Mhih9hLI Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCB761F000C6; Wed, 25 Nov 2026 14:50:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795618245; bh=yt378NC0+q+XGudM1P6jFRMNUeKF/t7gsegzrFyNaYs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Mhih9hLIj1lJh3ym/F9RCXGgh/ZLb6AwFIUuQpqjlYXk7KEYBct4L2fpf8KTFwoVb 9xma8ctgPH+jeO8JUOnYapS72QPCAinysDn19jKA8J4NiuT2tVwvQZ49wA9AGcmwVS 3ixJI1qcOFN1equrkn/kxx4W/C9GD5Mmjw+Rk2N4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Nicolai Buchwitz , James Clark , Vadim Fedorenko , Paolo Abeni , Sasha Levin Subject: [PATCH 7.3 0173/1005] net: stmmac: ptp: switch to gettimex64() interface Date: Wed, 25 Nov 2026 15:25:11 +0100 Message-ID: <20261125143825.793658631@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261125143821.729802100@linuxfoundation.org> References: <20261125143821.729802100@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: James Clark [ Upstream commit d7804253678eb18d2be950e0542364b50be096a9 ] The stmmac PTP support currently implements the gettime64 callback to retrieve the hardware clock time. Update the implementation to provide the gettimex64 callback instead, adding support for the PTP_SYS_OFFSET_EXTENDED ioctl. The system clock readings are taken around the read of the nanoseconds register in get_systime(), so get_systime() gains a ptp_system_timestamp argument. Reviewed-by: Nicolai Buchwitz Assisted-by: LLM Signed-off-by: James Clark Reviewed-by: Vadim Fedorenko Link: https://patch.msgid.link/20261008103809.1848255-1-jjc@jclark.com Signed-off-by: Paolo Abeni Stable-dep-of: 23d96de472f7 ("net: stmmac: re-apply taprio offload in __stmmac_open() and stmmac_resume()") Signed-off-by: Sasha Levin --- drivers/net/ethernet/stmicro/stmmac/hwif.h | 5 ++++- .../ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 7 +++++-- .../net/ethernet/stmicro/stmmac/stmmac_ptp.c | 21 ++++++++++--------- .../stmicro/stmmac/stmmac_selftests.c | 4 ++-- .../net/ethernet/stmicro/stmmac/stmmac_tc.c | 3 ++- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index 9925b789bcc9f..bfcc930fd831f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -496,6 +496,8 @@ struct stmmac_ops { #define stmmac_fpe_map_preemption_class(__priv, __args...) \ stmmac_do_callback(__priv, mac, fpe_map_preemption_class, __args) +struct ptp_system_timestamp; + /* PTP and HW Timer helpers */ struct stmmac_hwtimestamp { void (*config_hw_tstamping) (void __iomem *ioaddr, u32 data); @@ -505,7 +507,8 @@ struct stmmac_hwtimestamp { int (*config_addend) (void __iomem *ioaddr, u32 addend); int (*adjust_systime) (void __iomem *ioaddr, u32 sec, u32 nsec, int add_sub, int gmac4); - void (*get_systime) (void __iomem *ioaddr, u64 *systime); + void (*get_systime)(void __iomem *ioaddr, u64 *systime, + struct ptp_system_timestamp *sts); void (*get_ptptime)(void __iomem *ioaddr, u64 *ptp_time); void (*timestamp_interrupt)(struct stmmac_priv *priv); void (*hwtstamp_correct_latency)(struct stmmac_priv *priv); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c index b9a985fa772c9..870c740b4a506 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c @@ -183,7 +183,8 @@ static int adjust_systime(void __iomem *ioaddr, u32 sec, u32 nsec, 10, 100000); } -static void get_systime(void __iomem *ioaddr, u64 *systime) +static void get_systime(void __iomem *ioaddr, u64 *systime, + struct ptp_system_timestamp *sts) { u64 ns, sec0, sec1; @@ -191,8 +192,10 @@ static void get_systime(void __iomem *ioaddr, u64 *systime) sec1 = readl_relaxed(ioaddr + PTP_STSR); do { sec0 = sec1; + ptp_read_system_prets(sts); /* Get the TSSS value */ - ns = readl_relaxed(ioaddr + PTP_STNSR); + ns = readl(ioaddr + PTP_STNSR); + ptp_read_system_postts(sts); /* Get the TSS value */ sec1 = readl_relaxed(ioaddr + PTP_STSR); } while (sec0 != sec1); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c index 3bfcc9760dce7..e54a3c8878265 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c @@ -89,7 +89,8 @@ static int stmmac_adjust_time(struct ptp_clock_info *ptp, s64 delta) u64 cycle_time; mutex_lock(&priv->est_lock); - priv->ptp_clock_ops.gettime64(&priv->ptp_clock_ops, ¤t_time); + priv->ptp_clock_ops.gettimex64(&priv->ptp_clock_ops, + ¤t_time, NULL); current_time_ns = timespec64_to_ktime(current_time); time.tv_nsec = priv->est->btr_reserve[0]; time.tv_sec = priv->est->btr_reserve[1]; @@ -114,15 +115,15 @@ static int stmmac_adjust_time(struct ptp_clock_info *ptp, s64 delta) } /** - * stmmac_get_time - * + * stmmac_get_timex - read the PTP clock, with system timestamps if requested * @ptp: pointer to ptp_clock_info structure * @ts: pointer to hold time/result + * @sts: pointer to hold system timestamps around the read, or NULL * - * Description: this function will read the current time from the - * hardware clock and store it in @ts. + * Return: 0 */ -static int stmmac_get_time(struct ptp_clock_info *ptp, struct timespec64 *ts) +static int stmmac_get_timex(struct ptp_clock_info *ptp, struct timespec64 *ts, + struct ptp_system_timestamp *sts) { struct stmmac_priv *priv = container_of(ptp, struct stmmac_priv, ptp_clock_ops); @@ -130,7 +131,7 @@ static int stmmac_get_time(struct ptp_clock_info *ptp, struct timespec64 *ts) u64 ns = 0; read_lock_irqsave(&priv->ptp_lock, flags); - stmmac_get_systime(priv, priv->ptpaddr, &ns); + stmmac_get_systime(priv, priv->ptpaddr, &ns, sts); read_unlock_irqrestore(&priv->ptp_lock, flags); *ts = ns_to_timespec64(ns); @@ -200,7 +201,7 @@ static int stmmac_enable(struct ptp_clock_info *ptp, target_ns = cfg->start.tv_nsec + ((u64)cfg->start.tv_sec * NSEC_PER_SEC); - stmmac_get_systime(priv, priv->ptpaddr, &ns); + stmmac_get_systime(priv, priv->ptpaddr, &ns, NULL); if (ns > TIME64_MAX - PTP_SAFE_TIME_OFFSET_NS) return -EINVAL; @@ -304,7 +305,7 @@ const struct ptp_clock_info stmmac_ptp_clock_ops = { .pps = 0, .adjfine = stmmac_adjust_freq, .adjtime = stmmac_adjust_time, - .gettime64 = stmmac_get_time, + .gettimex64 = stmmac_get_timex, .settime64 = stmmac_set_time, .enable = stmmac_enable, }; @@ -321,7 +322,7 @@ const struct ptp_clock_info dwmac1000_ptp_clock_ops = { .pps = 0, .adjfine = stmmac_adjust_freq, .adjtime = stmmac_adjust_time, - .gettime64 = stmmac_get_time, + .gettimex64 = stmmac_get_timex, .settime64 = stmmac_set_time, .enable = dwmac1000_ptp_enable, }; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c index 6c01fdb6667e6..57aedf5228081 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c @@ -1887,7 +1887,7 @@ static int stmmac_test_tbs(struct stmmac_priv *priv) return ret; read_lock_irqsave(&priv->ptp_lock, flags); - stmmac_get_systime(priv, priv->ptpaddr, &curr_time); + stmmac_get_systime(priv, priv->ptpaddr, &curr_time, NULL); read_unlock_irqrestore(&priv->ptp_lock, flags); if (!curr_time) { @@ -1909,7 +1909,7 @@ static int stmmac_test_tbs(struct stmmac_priv *priv) /* Check if expected time has elapsed */ read_lock_irqsave(&priv->ptp_lock, flags); - stmmac_get_systime(priv, priv->ptpaddr, &curr_time); + stmmac_get_systime(priv, priv->ptpaddr, &curr_time, NULL); read_unlock_irqrestore(&priv->ptp_lock, flags); if ((curr_time - start_time) < STMMAC_TBS_LT_OFFSET) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c index a7721b2eee968..399d5cb427005 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c @@ -1070,7 +1070,8 @@ static int tc_taprio_configure(struct stmmac_priv *priv, mutex_lock(&priv->est_lock); /* Adjust for real system time */ - priv->ptp_clock_ops.gettime64(&priv->ptp_clock_ops, ¤t_time); + priv->ptp_clock_ops.gettimex64(&priv->ptp_clock_ops, ¤t_time, + NULL); current_time_ns = timespec64_to_ktime(current_time); time = stmmac_calc_tas_basetime(qopt->base_time, current_time_ns, qopt->cycle_time); -- 2.53.0