Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: alex.austin@amd.com
Cc: ecree.xilinx@gmail.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, richardcochran@gmail.com, alucerop@amd.com,
	pieter.jansen-van-vuuren@amd.com, netdev@vger.kernel.org,
	linux-net-drivers@amd.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v4 3/3] sfc: ptp: avoid racing PPS timestamp updates
Date: Fri, 30 Oct 2026 12:53:32 +0000	[thread overview]
Message-ID: <179336481210.3134.2636807043421655737@kernel.org> (raw)
In-Reply-To: <20261026123023.3566549-4-alex.austin@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · 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] This patch removes the shared ptp->host_time_pps race from
  drivers/net/ethernet/sfc/ptp.c, but the same race is still present in…

--

sfc: ptp: avoid racing PPS timestamp updates

This patch removes the shared host_time_pps field from struct
efx_ptp_data in sfc/ptp.c. efx_ptp_synchronize() now returns the PPS
timestamp through storage owned by the caller. The PPS worker therefore
no longer copies a field that a concurrent SIOCSHWTSTAMP-driven
synchronization could be rewriting.

> diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
> index e26269fae38d6..37511f234d76d 100644
> --- a/drivers/net/ethernet/sfc/ptp.c
> +++ b/drivers/net/ethernet/sfc/ptp.c

[ ... ]

> @@ -1500,14 +1504,15 @@ static void efx_ptp_pps_worker(struct work_struct *work)
>  {
>  	struct efx_ptp_data *ptp =
>  		container_of(work, struct efx_ptp_data, pps_work);
> +	struct pps_event_time host_time_pps = {};
>  	struct efx_nic *efx = ptp->efx;
>  	struct ptp_clock_event ptp_evt;
>  
> -	if (efx_ptp_synchronize(efx, PTP_SYNC_ATTEMPTS))
> +	if (efx_ptp_synchronize(efx, PTP_SYNC_ATTEMPTS, &host_time_pps))
>  		return;
>  
>  	ptp_evt.type = PTP_CLOCK_PPSUSR;
> -	ptp_evt.pps_times = ptp->host_time_pps;
> +	ptp_evt.pps_times = host_time_pps;
>  	ptp_clock_event(ptp->phc_clock, &ptp_evt);
>  }

[Severity: Medium]
This fixes the race in sfc/ptp.c. Is the same race still present in the
Siena copy of this code, drivers/net/ethernet/sfc/siena/ptp.c? That file
also descends from the Fixes target 7c236c43b838, and this patch doesn't
touch it.

In siena/ptp.c, efx_ptp_process_times() still writes the shared field:

drivers/net/ethernet/sfc/siena/ptp.c:efx_ptp_process_times() {
    ...
	/* Set PPS timestamp to match NIC top of second */
	ptp->host_time_pps = *last_time;
	pps_sub_ts(&ptp->host_time_pps, delta);
    ...
}

The Siena efx_ptp_pps_worker() copies it after synchronization returns,
with no lock held:

drivers/net/ethernet/sfc/siena/ptp.c:efx_ptp_pps_worker() {
    ...
	ptp_evt.type = PTP_CLOCK_PPSUSR;
	ptp_evt.pps_times = ptp->host_time_pps;
	ptp_clock_event(ptp->phc_clock, &ptp_evt);
}

Meanwhile, the SIOCSHWTSTAMP path can run another synchronization:

efx_siena_ptp_change_mode()
    efx_ptp_synchronize(efx, PTP_SYNC_ATTEMPTS * 2)
        efx_ptp_process_times()
            ptp->host_time_pps = *last_time;

Can this give the partially updated PPS timestamp that the commit message
describes, but for Siena NICs?

Siena also looks more exposed than sfc was before this series. The Siena
efx_ptp_synchronize() takes no phc_lock or any other mutex. The
WRITE_ONCE(*start, 0) handshake runs before efx_siena_mcdi_rpc_start(),
and the ptp->timeset[] processing runs after efx_siena_mcdi_rpc_finish().
Could two concurrent synchronizations clobber each other's state there
too?

The earlier patch in this series, "sfc: ptp: serialize host and MC
synchronization transactions", seems to have handled that only for sfc.

Should the same caller-owned out-parameter change, along with the
serialization, also be applied to siena/ptp.c? If not, could the commit
message say why Siena is left out?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261026123023.3566549-1-alex.austin%40amd.com

  reply	other threads:[~2026-10-30 12:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26 12:30 [PATCH net v4 0/3] sfc: fix PTP synchronization races Alex Austin
2026-10-26 12:30 ` [PATCH net v4 1/3] sfc: ptp: drop the stale frequency reset in efx_ptp_start() Alex Austin
2026-10-30 12:53   ` netdev-bot+sashiko
2026-10-30 14:45     ` Austin, Alex (DCCG)
2026-10-26 12:30 ` [PATCH net v4 2/3] sfc: ptp: serialize host and MC synchronization transactions Alex Austin
2026-10-30 12:53   ` netdev-bot+sashiko
2026-10-30 14:50     ` Austin, Alex (DCCG)
2026-10-26 12:30 ` [PATCH net v4 3/3] sfc: ptp: avoid racing PPS timestamp updates Alex Austin
2026-10-30 12:53   ` netdev-bot+sashiko [this message]
2026-10-30 14:52     ` Austin, Alex (DCCG)

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=179336481210.3134.2636807043421655737@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=alex.austin@amd.com \
    --cc=alucerop@amd.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=ecree.xilinx@gmail.com \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-net-drivers@amd.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pieter.jansen-van-vuuren@amd.com \
    --cc=richardcochran@gmail.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