๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #4890

Re: [PATCH net v2 2/2] sfc: ptp: avoid racing PPS timestamp updates

#4890
From: netdev-bot+sashiko
Date: Mon, 19 Oct 2026 11:58
104 lines
9216 bytes
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] The fix only covers drivers/net/ethernet/sfc/ptp.c.

--

sfc: ptp: avoid racing PPS timestamp updates

This commit removes the shared host_time_pps field from efx_ptp_data.
efx_ptp_process_times() now writes the PPS timestamp into storage that
the caller provides. efx_ptp_pps_worker() passes a stack-local
pps_event_time, and efx_ptp_change_mode() passes NULL.

> diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
> index c2f8b94592718..116b38079d8e6 100644
> --- a/drivers/net/ethernet/sfc/ptp.c
> +++ b/drivers/net/ethernet/sfc/ptp.c

[ ... ]

> @@ -1504,14 +1508,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]
Should the same change also go into drivers/net/ethernet/sfc/siena/ptp.c?

That file was split off from the code that commit 7c236c43b838 added,
and it still has the shared field. In the Siena copy of
efx_ptp_process_times():

	ptp->host_time_pps = *last_time;
	pps_sub_ts(&ptp->host_time_pps, delta);

The Siena efx_ptp_pps_worker() then copies it after synchronize returns:

	if (efx_ptp_synchronize(efx, PTP_SYNC_ATTEMPTS))
		return;

	ptp_evt.type = PTP_CLOCK_PPSUSR;
	ptp_evt.pps_times = ptp->host_time_pps;

Meanwhile, the timestamping config path can still rewrite that field:

siena_ptp_set_ts_config()
  efx_siena_ptp_change_mode()
    efx_ptp_synchronize(efx, PTP_SYNC_ATTEMPTS * 2)
      efx_ptp_process_times()

This is the same partially updated PPS timestamp race that the commit
message describes for efx_ptp_pps_worker() and change_mode.

The Siena efx_ptp_synchronize() also takes no driver lock around the
transaction, while the sfc version holds phc_lock. Only the MCDI request
itself is serialized. Two concurrent synchronizations could therefore
overlap on these:

	WRITE_ONCE(*start, 0) on the shared DMA start flag
	the ptp->timeset[] writes in efx_ptp_process_times()
	the sync stats counters

Since the patch carries the same Fixes tag, stable kernels that have the
Siena split would get this fix only for sfc. Could Siena get the same
treatment, meaning a caller-owned pps_event_time, NULL from
efx_siena_ptp_change_mode(), and serialization of efx_ptp_synchronize()?
If Siena is left out on purpose, could the commit message say so?

> @@ -1847,7 +1852,8 @@ int efx_ptp_change_mode(struct efx_nic *efx, bool enable_wanted,
>  				rc = efx_ptp_start(efx);
>  			if (rc == 0) {
>  				rc = efx_ptp_synchronize(efx,
> -							 PTP_SYNC_ATTEMPTS * 2);
> +							 PTP_SYNC_ATTEMPTS * 2,
> +							 NULL);
>  				if (rc != 0)
>  					efx_ptp_stop(efx);
>  			}

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261015114104.2531624-1-alex.austin%40amd.com
Technical Details
Message-ID: <179241112030.3135.17575594097702232193@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-348482-linux-kernel-netdev=dewy.ru
References: <20261015114104.2531624-3-alex.austin@amd.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-348482-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2 2/2] sfc: ptp: avoid racing PPS timestamp updates
Date: Mon, 19 Oct 2026 11:58:40 +0000
Organization: Usenet Network
Message-ID: <179241112030.3135.17575594097702232193@kernel.org>
References: <20261015114104.2531624-3-alex.austin@amd.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3595463"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:WzKI+1OyJJbaG30umX/YEXACirQ= sha256:lFl10PPCPS7IfXg+H1iawC7v3/5Dqc14WMCcxTTNRH0=
	sha1:eyvdWMWOgCNgZ6nEx+j+hb4/5xw= sha256:bdw6JGEjsPpSAUwjHq/Ga78P8tXsvm9ru2U8QB0QBX8=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id EEC631109C9; Mon, 19 Oct 2026 15:00:51 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.729
X-Spam-Status: No, score=-3.729 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.329, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id Mm_GahoxL2U2;
	Mon, 19 Oct 2026 15:00:44 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-348482-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id F156E11099E; Mon, 19 Oct 2026 15:00:24 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sea.lore.kernel.org (Postfix) with ESMTP id 3BB8761E31; Mon, 19 Oct 2026 11:58:43 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 08E614E73DD;
	Mon, 19 Oct 2026 11:58:43 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="j6i4hxcg"
X-Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18])
	(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 B4F224E50DE;
	Mon, 19 Oct 2026 11:58:41 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1792411122; cv=none; b=KeBGnNVYEPekdCNJimxbroHS9qAWg+APOTGPIFtI4s8fqB6wHQzBHIngA93dNUqByC29IfToEKp39Sp9h5wk0pq7aw9XDVRq61cbhX5wMY6WXa4u+NLSxWAU/wTgw+wZ7Wh1q2OxvD9LfNXwYrigufnmboA4Z18Kaitv0tn/PnM=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1792411122; c=relaxed/simple;
	bh=tpHEVwr5zi3cs6emQM/4XPpanYTAxTUpFrtREz6XgQA=;
	h=Subject:From:To:Cc:Date:Message-ID:In-Reply-To:References:
	 Content-Type:MIME-Version; b=KOyyL0lwZJE4Ft/MBYjn2fAbFaTZ3zLZ2sF9zTlX0/ZcVk01tX5J0lwVhlRndpZcTmJmi13w1pedkCuY6KsPRuJv7MMAhhiE3SURTXILbVHQLEWdSPDygcs3EQ0uqKX7s44tiE1oZxVBb6L6O76F7WMIltodT7P+kJMZdHPk/5I=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=j6i4hxcg; arc=none smtp.client-ip=100.103.45.18
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id C06611F000C5;
	Mon, 19 Oct 2026 11:58:40 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1792411121;
	bh=mBQRezzvWOaxmu6e2fGLCSHm5PK5c8WKYX6473SGzCU=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=j6i4hxcgR2q8/kpXiQGOOIEQisz8dy2aTGUN5Rwgc/D/Oz5EPy9EeAD8tAdg+67HM
	 GfiYoi0ciS1UZoMSgwpUJeUqqNc4nQ9nHtXwNf/17EYhkUJbtFQEgv7bQs5UL5GlWw
	 BIbP2kpb1sC3LcenDWDDcc8MLKYoEhOHbGAqK/K6IwqMuXiQpkZU1Pl9O+Wh20hvKG
	 NudFlwNC+9ZMuNUluQOG2PxfP0B83RTApx4sgev49aEInBHvzgVPvQjZhqud9hf0+T
	 l/BVzK3CNRDEbep4Ew8RyLhSGN6ybubHVVM7Qh3VXH/V0ScO16AfxXcPzyQzo3t+81
	 xZeeNliiAWcWw==
X-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-kernel@vger.kernel.org
X-In-Reply-To: <20261015114104.2531624-3-alex.austin@amd.com>
X-sashiko-severity: Medium
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>