From nobody Sun Oct 5 21:59:23 2025 Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 529EC1F09A5; Tue, 29 Jul 2025 14:55:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.132.182.106 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753800904; cv=none; b=Nq/WxontjWpd22CHN6+UiRRyA3BNa/AZFDNBTiOyHzi6F1Z2vZO17HXqDpiR2W/pBii+/8bwVIcyGs8L7+whMG7ni67bJavQnS8Rpb9Iykh0hF/9VK38zNn+mgB+ADpmJJ7wycEJiLTUXmzd89ORk3xtXsKPE/313ts7K+hLmp4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753800904; c=relaxed/simple; bh=5Yb699+rsbMz5MY8Tjobw7GxDIJ4xOnJTD3V/UuMd7Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=DgVWZi0DMpj3oWSwzNUFz41MJRJho8G14mjF/wfcl4p1whRuWSVOnORixK4VJACdk3B5atgFB72mUoygwqmhcTcgji8tN42jJZD+USEVbdj4/Fkaan9SSTy33WL3WVkaMAf3uyqd3evHdDlKrH6jNLphynPU8xTdPQcE8lCEg4g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foss.st.com; spf=pass smtp.mailfrom=foss.st.com; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b=Q3cY94cN; arc=none smtp.client-ip=185.132.182.106 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=foss.st.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b="Q3cY94cN" Received: from pps.filterd (m0288072.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56TDqD6E023729; Tue, 29 Jul 2025 16:54:42 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=selector1; bh= OiiqNbHmrqIpvUT8qdB7LVMaCcZtZqe0vh9TWwXn7ik=; b=Q3cY94cNSh8CMOm7 QuRnG/P+O/K3AavxTYfDaZsdAXscdk2oKOGAbvFFBtiHtcCSdeQlpBzur0/I572t 8/LUCp1WvGOYpA2Vb108E0bEpSMYLVUeMPBnB1e18vXLcKDD49k9SkhAHhQxDx/o BeDPiE0UM77YkqjocSP74JbYwTSUqBqwkZVqWXetoznMI7Mt9nCfJPZRCsKTJV10 KWBSnLuo0RnO/74pN95pSIM7TfGNZ4hMn//XZBhJJaWy1ZzB9FpOWut9C8wwUJds b4uS6Mal2Q58P7i/cpq0kKC1DkoZZwCwHyyjnV9gY2HaQtjWymtWo2SmqzLjd2ir 9U+haA== Received: from beta.dmz-ap.st.com (beta.dmz-ap.st.com [138.198.100.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 484memnux5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 29 Jul 2025 16:54:42 +0200 (MEST) Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 6E4BE4004B; Tue, 29 Jul 2025 16:53:18 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 402B576373F; Tue, 29 Jul 2025 16:52:18 +0200 (CEST) Received: from localhost (10.48.87.141) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Jul 2025 16:52:17 +0200 From: Gatien Chevallier Date: Tue, 29 Jul 2025 16:52:00 +0200 Subject: [PATCH net-next v2 1/2] drivers: net: stmmac: handle start time set in the past for flexible PPS Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250729-relative_flex_pps-v2-1-3e5f03525c45@foss.st.com> References: <20250729-relative_flex_pps-v2-0-3e5f03525c45@foss.st.com> In-Reply-To: <20250729-relative_flex_pps-v2-0-3e5f03525c45@foss.st.com> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Alexandre Torgue , Richard Cochran , Rob Herring , Krzysztof Kozlowski , Conor Dooley CC: , , , , , Gatien Chevallier X-Mailer: b4 0.14.2 X-ClientProxiedBy: SHFCAS1NODE1.st.com (10.75.129.72) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-07-29_03,2025-07-28_01,2025-03-28_01 In case the time arguments used for flexible PPS signal generation are in the past, consider the arguments to be a time offset relative to the MAC system time. This way, past time use case is handled and it avoids the tedious work of passing an absolute time value for the flexible PPS signal generation while not breaking existing scripts that may rely on this behavior. Signed-off-by: Gatien Chevallier --- drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 31 ++++++++++++++++++++= ++++ 1 file changed, 31 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net= /ethernet/stmicro/stmmac/stmmac_ptp.c index 3767ba495e78d210b0529ee1754e5331f2dd0a47..5c712b33851081b5ae1dbf2a098= 8919ae647a9e2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c @@ -10,6 +10,8 @@ #include "stmmac.h" #include "stmmac_ptp.h" =20 +#define PTP_SAFE_TIME_OFFSET_NS 500000 + /** * stmmac_adjust_freq * @@ -172,6 +174,10 @@ static int stmmac_enable(struct ptp_clock_info *ptp, =20 switch (rq->type) { case PTP_CLK_REQ_PEROUT: + struct timespec64 curr_time; + u64 target_ns =3D 0; + u64 ns =3D 0; + /* Reject requests with unsupported flags */ if (rq->perout.flags) return -EOPNOTSUPP; @@ -180,6 +186,31 @@ static int stmmac_enable(struct ptp_clock_info *ptp, =20 cfg->start.tv_sec =3D rq->perout.start.sec; cfg->start.tv_nsec =3D rq->perout.start.nsec; + + /* A time set in the past won't trigger the start of the flexible PPS ge= neration for + * the GMAC5. For some reason it does for the GMAC4 but setting a time i= n the past + * should be addressed anyway. Therefore, any value set it the past is c= onsidered as + * an offset compared to the current MAC system time. + * Be aware that an offset too low may not trigger flexible PPS generati= on + * if time spent in this configuration makes the targeted time already o= utdated. + * To address this, add a safe time offset. + */ + if (!cfg->start.tv_sec && cfg->start.tv_nsec < PTP_SAFE_TIME_OFFSET_NS) + cfg->start.tv_nsec +=3D PTP_SAFE_TIME_OFFSET_NS; + + target_ns =3D cfg->start.tv_nsec + ((u64)cfg->start.tv_sec * NSEC_PER_SE= C); + + stmmac_get_systime(priv, priv->ptpaddr, &ns); + if (ns > TIME64_MAX - PTP_SAFE_TIME_OFFSET_NS) + return -EINVAL; + + curr_time =3D ns_to_timespec64(ns); + if (target_ns < ns + PTP_SAFE_TIME_OFFSET_NS) { + cfg->start =3D timespec64_add_safe(cfg->start, curr_time); + if (cfg->start.tv_sec =3D=3D TIME64_MAX) + return -EINVAL; + } + cfg->period.tv_sec =3D rq->perout.period.sec; cfg->period.tv_nsec =3D rq->perout.period.nsec; =20 --=20 2.25.1 From nobody Sun Oct 5 21:59:23 2025 Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C869246BC4; Tue, 29 Jul 2025 14:55:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.132.182.106 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753800904; cv=none; b=fanRoKw9ziaT6JqUsxYHfE5oDpGq1ql+wpsGZbBmhjNrOOr5q/W6HunXHFxBq4xBZwEzCUJxJEDfRfBtvZHu9aJWKCrQvDPRtAbGywW4+Y57yNQ+jwZn4Fx3ULM+TtokGch4M2ncdaiUC1QD0O//QgOFgKgrQSF7B+vOq6VXmtE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753800904; c=relaxed/simple; bh=5rDR+UqN1NZbe+MiRbDZnIug9UCVJXza9xPJyMwrjlc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=QC04vcyfgx3aaVGQPXMYx9k3Bm/Ycz3sXirUcUWbRmm1eLDTAzCdS6LU35WnedwQgkW3ny9ytv8amGa8hKSJCklP8cUHvRXSxd70Di9VXlDk4VY2OSnoGsNY6Kbywq4Pa2GF6J+FhHaRwhOWmzA1tUMBCmqaUMz4Pw2bk3R1wzU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foss.st.com; spf=pass smtp.mailfrom=foss.st.com; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b=f/tV+cw8; arc=none smtp.client-ip=185.132.182.106 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=foss.st.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b="f/tV+cw8" Received: from pps.filterd (m0288072.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56TDqD6D023729; Tue, 29 Jul 2025 16:54:42 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=selector1; bh= f/Foo9POshykOfCA1tCQxxLdk6j4kVXsCtJfrKcrneA=; b=f/tV+cw8yLM1QTsX jftRGfiAZCia852woVLiue+QfJQkryig+H9TTOxqdiPp2rhMirV0lIeG1AxqOiBp lyTWhg8wj4RnQBYOUpUIZ1SRG455sxnsSvBAoU1ScbvIwMKaohFgRfZyLdMtG3yo UjAPkbHpUijYL5MQDZFrlKaXEQ0Lg0o3EJxaBM76tJn4aSYC/0qED+1x5zjcjEUk IGIMfx/4eB0QqecOkjd2PPCbk4Kg1mW2VGi4RH+lGiURbVuw+O5yzwwC4p8qAWEp LJm5Ssvv+TIfTnjsf9ge4cqz+nvm6JZucdDBFu1z7u2aT8FHpJV5G86NfcGw0kIz u4F9/g== Received: from beta.dmz-ap.st.com (beta.dmz-ap.st.com [138.198.100.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 484memnux3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 29 Jul 2025 16:54:42 +0200 (MEST) Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 6E3B94002D; Tue, 29 Jul 2025 16:53:18 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id E3340778886; Tue, 29 Jul 2025 16:52:18 +0200 (CEST) Received: from localhost (10.48.87.141) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Jul 2025 16:52:18 +0200 From: Gatien Chevallier Date: Tue, 29 Jul 2025 16:52:01 +0200 Subject: [PATCH net-next v2 2/2] ARM: dts: stm32: add missing PTP reference clocks on stm32mp13x SoCs Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250729-relative_flex_pps-v2-2-3e5f03525c45@foss.st.com> References: <20250729-relative_flex_pps-v2-0-3e5f03525c45@foss.st.com> In-Reply-To: <20250729-relative_flex_pps-v2-0-3e5f03525c45@foss.st.com> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Alexandre Torgue , Richard Cochran , Rob Herring , Krzysztof Kozlowski , Conor Dooley CC: , , , , , Gatien Chevallier X-Mailer: b4 0.14.2 X-ClientProxiedBy: SHFCAS1NODE1.st.com (10.75.129.72) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-07-29_03,2025-07-28_01,2025-03-28_01 ETH1/2 miss their PTP reference clock in the SoC device tree. Add them as the fallback is not correctly handled for PPS generation and it seems there's no reason to not add them. Signed-off-by: Gatien Chevallier --- arch/arm/boot/dts/st/stm32mp131.dtsi | 2 ++ arch/arm/boot/dts/st/stm32mp133.dtsi | 2 ++ 2 files changed, 4 insertions(+) diff --git a/arch/arm/boot/dts/st/stm32mp131.dtsi b/arch/arm/boot/dts/st/st= m32mp131.dtsi index 492bcf586361c487208439ed71a93c2bf83d5eb2..6f5720fb9fa1f58bd97b6bf19fc= 898f0fecb34d1 100644 --- a/arch/arm/boot/dts/st/stm32mp131.dtsi +++ b/arch/arm/boot/dts/st/stm32mp131.dtsi @@ -1602,11 +1602,13 @@ ethernet1: ethernet@5800a000 { "mac-clk-tx", "mac-clk-rx", "ethstp", + "ptp_ref", "eth-ck"; clocks =3D <&rcc ETH1MAC>, <&rcc ETH1TX>, <&rcc ETH1RX>, <&rcc ETH1STP>, + <&rcc ETH1PTP_K>, <&rcc ETH1CK_K>; st,syscon =3D <&syscfg 0x4 0xff0000>; snps,mixed-burst; diff --git a/arch/arm/boot/dts/st/stm32mp133.dtsi b/arch/arm/boot/dts/st/st= m32mp133.dtsi index e48838374f0df4e003aee5046e45b49986c1daea..0112c05b13e1f02e5ec4b4bffc9= a11b4bef1b9bc 100644 --- a/arch/arm/boot/dts/st/stm32mp133.dtsi +++ b/arch/arm/boot/dts/st/stm32mp133.dtsi @@ -81,11 +81,13 @@ ethernet2: ethernet@5800e000 { "mac-clk-tx", "mac-clk-rx", "ethstp", + "ptp_ref", "eth-ck"; clocks =3D <&rcc ETH2MAC>, <&rcc ETH2TX>, <&rcc ETH2RX>, <&rcc ETH2STP>, + <&rcc ETH2PTP_K>, <&rcc ETH2CK_K>; st,syscon =3D <&syscfg 0x4 0xff000000>; snps,mixed-burst; --=20 2.25.1