Re: [PATCH net-next v2 1/2] drivers: net: stmmac: handle start time set in the past for flexible PPS
From: Simon Horman
Date: Tue Jul 29 2025 - 12:58:33 EST
On Tue, Jul 29, 2025 at 04:52:00PM +0200, Gatien Chevallier wrote:
> 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 <gatien.chevallier@xxxxxxxxxxx>
> ---
> 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..5c712b33851081b5ae1dbf2a0988919ae647a9e2 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"
>
> +#define PTP_SAFE_TIME_OFFSET_NS 500000
> +
> /**
> * stmmac_adjust_freq
> *
> @@ -172,6 +174,10 @@ static int stmmac_enable(struct ptp_clock_info *ptp,
>
> switch (rq->type) {
> case PTP_CLK_REQ_PEROUT:
> + struct timespec64 curr_time;
> + u64 target_ns = 0;
> + u64 ns = 0;
> +
I think you need to wrap this case in {}, as is already done for the following
case.
Clang 20.1.8 W=1 build warn about the current arrangement as follows.
.../stmmac_ptp.c:177:3: warning: label followed by a declaration is a C23 extension [-Wc23-extensions]
177 | struct timespec64 curr_time;
| ^
1 warning generated.
GCC 8.5.0 (but not 15.1.0) also flags this problem.
Also, please note:
## Form letter - net-next-closed
The merge window for v6.17 has begun and therefore net-next is closed
for new drivers, features, code refactoring and optimizations. We are
currently accepting bug fixes only.
Please repost when net-next reopens after 11th August.
RFC patches sent for review only are obviously welcome at any time.
See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle
--
pw-bot: defer