๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26281

Re: [PATCH net v3 2/4] net: ethernet: ti: cpsw_ale: serialize ALE table accesses

#26281
From: netdev-bot+sashiko
Date: Thu, 03 Dec 2026 10:57
68 lines
10495 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The comment this patch adds to struct cpsw_ale
  (drivers/net/ethernet/ti/cpsw_ale.h, lines 99-101) says ale->lockโ€ฆ

--

net: ethernet: ti: cpsw_ale: serialize ALE table accesses

This patch adds a spinlock to struct cpsw_ale. The lock is taken with
spin_lock_bh() in all exported ALE functions that access the table
through the shared index and data registers. With it, concurrent
ndo_set_rx_mode() and VLAN or address operations on different ports can
no longer interleave register accesses and corrupt table entries.

[ ... ]

> diff --git a/drivers/net/ethernet/ti/cpsw_ale.h b/drivers/net/ethernet/ti/cpsw_ale.h
> index 87b7d1b3a34a9..f72db771bfa99 100644
> --- a/drivers/net/ethernet/ti/cpsw_ale.h
> +++ b/drivers/net/ethernet/ti/cpsw_ale.h
> @@ -96,6 +96,10 @@ struct cpsw_ale {
>  	u32			vlan_field_bits;
>  	unsigned long		*p0_untag_vid_mask;
>  	const struct ale_entry_fld *vlan_entry_tbl;
> +	/* serializes access to the ALE table (index and data registers),
> +	 * the VLAN mask mux registers and p0_untag_vid_mask
> +	 */
> +	spinlock_t		lock;
>  };

[Severity: Low]
This isn't a bug, but is the comment accurate for p0_untag_vid_mask? Only
the writers of the bitmap take the lock. The reader in the same header
does not:

drivers/net/ethernet/ti/cpsw_ale.h:
static inline int cpsw_ale_get_vlan_p0_untag(struct cpsw_ale *ale, u16 vid)
{
	return test_bit(vid, ale->p0_untag_vid_mask);
}

Its caller, cpsw_rx_vlan_encap() in cpsw_priv.c, runs in the RX path
without ale->lock:

	if (!cpsw_ale_get_vlan_p0_untag(cpsw->ale, vid)) {

The writer is cpsw_ale_set_vlan_untag(). It is reached from
__cpsw_ale_add_vlan(), cpsw_ale_vlan_del_modify_int() and
cpsw_ale_del_vlan(), which all hold ale->lock now. It uses
bitmap_set()/bitmap_clear() with nbits == 1, and these compile to the
non-atomic __set_bit()/__clear_bit().

Would it be clearer to say that the lock serializes writers of
p0_untag_vid_mask and that the RX path reads it without the lock? The
other option is to switch the writer to set_bit()/clear_bit(), which
makes the lockless read explicit.

The comment is also unchanged later in the series apart from the added
mention of the control registers.

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202-cpsw-ale-lock-v3-0-b40dc361d6b9%40amperfied.com
Technical Details
Message-ID: <179629543778.3146.6031678129130928601@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376491-linux-kernel-netdev=dewy.ru
References: <20261202-cpsw-ale-lock-v3-2-b40dc361d6b9@amperfied.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376491-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v3 2/4] net: ethernet: ti: cpsw_ale: serialize ALE
 table accesses
Date: Thu, 03 Dec 2026 10:57:17 +0000
Organization: Usenet Network
Message-ID: <179629543778.3146.6031678129130928601@kernel.org>
References: <20261202-cpsw-ale-lock-v3-2-b40dc361d6b9@amperfied.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2465041"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:ii8AL4vc858rpLduvT0M8MBjiBg= sha256:F6PXZo9FDB3+9dZHaLXh6bb6yVD/xqempBuIwTv0LTU=
	sha1:XUkLJE5k0rw/aIgwhZ57pLkAxOo= sha256:vBzh0EifHez6FNbBGk2D12aM873/GV3ICbvQpv59O08=
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 C94D51178D6; Thu,  3 Dec 2026 13:57:49 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.64
X-Spam-Status: No, score=-3.64 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, 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 JDRFKu6Na6KX;
	Thu,  3 Dec 2026 13:57:46 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-376491-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 32D0F1178D8; Thu,  3 Dec 2026 13:57:35 +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 088362C3B9; Thu,  3 Dec 2026 10:57:22 +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=1796295439;
	b=3i+MN3Qqi8EHsFm3VY7cOJWFfer8ebXr49XDZL8Hg7I0iN9OD9ULE/p85S2NBQ5mT2XL
	 wmkULCSi4qLpftqrRlMOhnFPKQX40ZpAtkvpzXJuHrpKikllFwMqqnqZNRXOse60s16m5
	 6RL6lQSRo//EB7HMvDB+L88psOqmz9zFCiAQrM27G+O1fRMJuLQTuwgFnNmoc65233hux
	 J6pQKpYjOrC6UZ/TY0CgW3dF/EKfau8WsymrqNQCC1De9fvX2BdnqHvAWyr3xxPRWJd3I
	 WdzmqEgq7iN0Xzd1U2JFiXGMxyzSWisc06SJNr5C+vzZKhEq6/EIQuNd8aI+gP1+pRQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796295439;
	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=AnSimTw85NnVSl+82RTnLOvieIHfXH/feCjknrvlaPo=;
	b=4kRs5rt9U1Mh/0VoJXn5qpHvho/AIkN67Q24b7Nz4uDUfrike3WdUOiyPqxW++HdvVVT
	 roiuOFcs14G/UVSHVAYroJOxMo1SNwl5RDFDIo49YCHBuVkY0B9A/nXKcfA0V9YZMNcrw
	 TMSXr2q40VEKsj2xaLaMOETq7D7U0WAKUn2/neeKBoyfO8rkjAl6ika4DMFXvtFQ4FLfg
	 nqir+HEQnqXd3k0c8MeV0Er18bsmZkBfpxdAk8HBN9wfSL4e6pCGUQ5yuDxijrSMo2nxK
	 yJnBWaUwMuPpEZtEc010J0Xn6taHm8VnBuFsmDJnotMeopf28baFK4x/TDci+e6C2mQ==
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=MgGqPdcm;
	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 C860D606A33D;
	Thu,  3 Dec 2026 10:57:19 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=MgGqPdcm
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=1796295439;
	b=vqM/w455VVP9gp+tj3mV8fKByr1IBHjjzKX7TKwTSSZmuUIWMuQPiM+VXUQHTguhguJZ
	 DBhyKy7hHKOqCBU5ito/q4vugFcK8eAtU1SkGc2CHn+yzzC0b4NEasVbm+Jjn7IVM56Q9
	 sE+fJ5mWSqmf/kBr9UnmW3yjM9yPHXEPWS5rxJsNNAuG8hbZ1v+Hrlg4nB8Os025SBqOn
	 sPm4SZ6vnxvEQzQHfsnrUULW1pKz8H5DPabTM7/3R4X7w5HKHQUMB+KhRqtKxU3iiOgXG
	 muOASAjlu9zYcA3t+m+B8Pq64C4RVKVEzodYANdSwzYzx6ShZ21BKtwYXgX7BrRbaeg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796295439;
	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=AnSimTw85NnVSl+82RTnLOvieIHfXH/feCjknrvlaPo=;
	b=TfxrjkoWiD2Ox4M5cC4Sp0U2sve7pby/ju5+fNC+kJO+NLkL48JZVHvQ7peMubOJ3WF9
	 ZskutqyDl4D+IT8sMGKOtp+4eSQvFD6+tkHGZkpaVMXIsjO5INoRruNmYQUgjJOH4RDBo
	 gBTIyzSJODCUZhqM7P3+OK/y2JmlgQNMSQO16XWRX/3FA4fm5kscI8L9MRAp1xlmfbIyq
	 ImL5vlTheBRXKQOi3wwvxhbvF9j/Rko7PbkLWt4j034TdjZdVerfGO5MACENl9+JkC4e+
	 4v8TXAuwqzcSE7nq8hoakPOTO1xexXibwA07730sfPlD6IFsmWw5MmOrj+0gZ897c0g==
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=MgGqPdcm;
	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 EA3D2606A332;
	Thu,  3 Dec 2026 10:57:18 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37FCA1F000C1;
	Thu,  3 Dec 2026 10:57:18 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796295438;
	bh=AnSimTw85NnVSl+82RTnLOvieIHfXH/feCjknrvlaPo=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=MgGqPdcmTyglvCwLvYAWbPck1tS6GVG5Cb0xARSgElr2nFuoyJ5RhU5w87FW4nHGX
	 gsv1KcI0qPXktF27mJ7MlvqT5lF4CY0MmOM+2vjac84Cg+ExcKk6OCOo/PYc/5g0Qr
	 uVb3j7tm448sMHwJ7XyyTUsWHOE78ptHKhc5MVKLzL3fv/PT+XsbluNu69U+rDXrl6
	 QENmkfNXA2d6HqHGdBcCPry/r+0uw3U7QWL+3V3950ED4hGG0C5pFAF2lS3Mj9P53g
	 0bR914drDtaN1C9cHlLILeQnsd//ItvvlEJM6+mTD7MbPtGguDPYban9cHbN0+zOsZ
	 e8MOvIt+LqRKQ==
X-Cc: s-vadapalli@ti.com, rogerq@kernel.org, andrew+netdev@lunn.ch,
 davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 vigneshr@ti.com, linux-omap@vger.kernel.org, netdev@vger.kernel.org,
 kuniyu@google.com
X-In-Reply-To: <20261202-cpsw-ale-lock-v3-2-b40dc361d6b9@amperfied.com>
X-sashiko-severity: Low
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