🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #8912

Re: [PATCH net v4 3/3] sfc: ptp: avoid racing PPS timestamp updates

#8912
From: netdev-bot+sashiko
Date: Fri, 30 Oct 2026 12:53
104 lines
11637 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] 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
Technical Details
Message-ID: <179336481210.3134.2636807043421655737@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-353771-linux-kernel-netdev=dewy.ru
References: <20261026123023.3566549-4-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-353771-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v4 3/3] sfc: ptp: avoid racing PPS timestamp updates
Date: Fri, 30 Oct 2026 12:53:32 +0000
Organization: Usenet Network
Message-ID: <179336481210.3134.2636807043421655737@kernel.org>
References: <20261026123023.3566549-4-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="2237892"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:aeyZjoxXnTM9TRVSnqmrQ7wAx+8= sha256:+QGG9Wd6ut5XqhUNyuG5U8rtjUpmCHGMSfCM9JKLIuw=
	sha1:zF6O/6lT9jg7Tms/ytVBb8+Bf58= sha256:Ly1S6o9cF9LpZbKOjBo1hJtlJRZSRuC41NQsxOXtyIE=
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 A666E125C95; Fri, 30 Oct 2026 15:59:36 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, 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, URIBL_BLOCKED=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 tbY3qnS_sglv;
	Fri, 30 Oct 2026 15:59:33 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-353771-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 38EC1125C91; Fri, 30 Oct 2026 15:59:25 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id A703F2A235; Fri, 30 Oct 2026 12:53:54 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793364824;
	b=vQztQi8GEAdX5Ul77h+02rhAxPsR4strXlF0DHYpwj8jeP10behLcJ8jzFGJVb6cE84O
	 74hANF7fEjIBOB6LMDUndYgBnYE+pZOW804JxdBTPB0dcAlYDZsvmg0aBcJbtoQnYfjGw
	 D+eZmLabOzuaP6oLPMYq1prOPtMp8/D5IhlAcQ+5/5atHFMlUd+AQNoj+KZsmZzhEMVrk
	 W4B34tYIF3dzKK880t/TBhzHuOGilzh4WuireI2hhCrr7ZF6limnSRFGwfkmuRrUxhmm+
	 MKzYuE2mRhbP0xpGgVOBg7LA52k57WEx15NTdEObdbKZ05vyLzLJJjg+5+1juNSi0Jw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793364824;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=frvv6tcU3LMgjEDgFGjkYc4XINTd2XEZyaxle6//g4U=;
	b=qPbti3iF0Qgo95N05eHe28dz2FweB6qJkmff+w1sdSyOrHivMlq0Sq/GxQ3ny3KVBPeE
	 Cz39X5rtQYNpKpywCo7Vb4CK0al6vD4nZw7z7tep2rz7mQBQWSvmj8V3Y7uhsyLlIre2M
	 TZOK6qsIuIqhffntd21duYVCfDklIxHwxHJFVwT1S9GAg33yjdVQrJGif5HHi48Vvsmt7
	 7g8aJDHc+5xjkdAhE2BnXoSxoZ8UnW9ij8K88zodVuvhqXaI/DuwfuYmNWoQih83IDfGR
	 durkNaJfhLw9+e7MIXrjzruPA/wXef6SQai52m7owIb5zsBBX9jZFpnYndJJ6/fpy9w==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=olIHMhsq;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id AA9E5606A321;
	Fri, 30 Oct 2026 12:53:44 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=olIHMhsq
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793364813;
	b=T8zaZJSI8fc3TueX3TEfF9oJtmxlqgJSUeCgHlsCsaCl58/oTxUa7oxTSUqlzkJfOiub
	 6WskblXVGTAPy9Lj7YG6KvGzzZSnr3roAwgD5JDai/Crof8D6vuQqjXFtbUCxfTVwaW+2
	 4A/5uc1ayRyEDgh4s614q3pNE1s2GKBQzhwiGy+TVryxKoJ7cuE30zmP9UsimrVDYs8t/
	 5C4PnaCB6QJgm8Ukf95/KV3dndROFDmM3j7QDYeuEjAjfXQ61sX0S8UcsLalNw002Klcl
	 CWm9uXg4cURJ9kym+o4KckrletxOhmE32RHow36CDiIt3Xlp8rF0vvQngHA4738RZ+g==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793364813;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=frvv6tcU3LMgjEDgFGjkYc4XINTd2XEZyaxle6//g4U=;
	b=pyrmxRqojubZOu+ijN1MHGcdnDpHm1xMnSemn33Ro8GjTMZSevO7jqtOq5fSz01xI6Ub
	 VboAnGYod1Ce/Ff/czZN8cAXLkiFUZtQrF5i33xl4jYvBIP+VwJ1hqAnZeT8e8OqLGu2e
	 hbiU8ZceqRDf0bDCeOKdTCTgFty/h9z2QdGm1FmHCkvNbKodeLVteeY3ehGZ8ZQMjBNrN
	 xT2QGzFgmM/IaG1RW1o9A2SlldXDu42CNHLxOmxbBaoS+fWNWGWmqAHAFEg2vtl8+WlWQ
	 3twWADxIb1G2tYgITUU1MyvacR5HlKtOGECSUcAy6BgPuhedo7I5lCokhThmgRAPUUg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=olIHMhsq;
	arc=none smtp.remote-ip=100.103.45.18
X-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 88029606A33A;
	Fri, 30 Oct 2026 12:53:33 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9205C1F00A02;
	Fri, 30 Oct 2026 12:53:32 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793364813;
	bh=frvv6tcU3LMgjEDgFGjkYc4XINTd2XEZyaxle6//g4U=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=olIHMhsq8Ahi4xlYkqsUDUAFN6cKOa0RiamKEXNGkWC+09PgsivGO1jODa/FSyJKC
	 9TgoBDgecOU5kdarcOOxcNL9EoZ9ivUREbqaaPBL0DO6220xwaotGHHP5C35YQLUul
	 pQ8BsTH/E3JrKhHeTIrO8YASxOCLqN/I9NElyHcA+klCJQnj5Wxe8/8ue/l5Zs8aTo
	 n6sJb/VDzhPcmCfO7HkXvg6j0Lx798u4TBgdHdAsjUSR4e0dwfwZizGjGChM+CFV5+
	 vN/SI5rfqshqZdIrLXGIGvXVOm+W3q6Vyaz1JlSUywq0IYaAPG4GG+r6j+iQl9fXha
	 3fp8sQlCj+XbA==
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-net-drivers@amd.com,
 linux-kernel@vger.kernel.org
X-In-Reply-To: <20261026123023.3566549-4-alex.austin@amd.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list