Article View: linux.kernel.netdev
Article #26354[PATCH net v4 0/4] net: ethernet: ti: cpsw_ale: fix lost ALE entries
From: Manuel Janocha via B4 Relay
Date: Thu, 03 Dec 2026 12:14
Date: Thu, 03 Dec 2026 12:14
125 lines
15263 bytes
15263 bytes
On AM62x/AM625 with both CPSW3G ports in dual EMAC mode and VLAN
interfaces on top, reception of untagged frames on a port can stop. The
port VLAN entry at ALE index 0 had been overwritten by an IPv6
multicast entry (33:33:...). Only link down/up recovers the port.
Two independent causes were found:
1. The ALE table is accessed through an index register and three data
registers. The read-modify-write sequences in cpsw_ale.c run
concurrently from different contexts, for example ndo_set_rx_mode()
of one port against VLAN add/kill on the other, without any lock.
Entries get lost or mixed. Patch 2 adds a lock to struct cpsw_ale
and patch 3 extends it to the control register updates. Patch 1 is
a prerequisite of patch 2: netcp calls into the ALE with interrupts
disabled, which does not work with the lock taken by
spin_lock_bh().
2. Even with the lock held, a table read occasionally returns the
content of another index or all zeros. Reading the data words again
without rewriting the index stays wrong, rewriting the index and
reading again returns the right entry. Either of two consecutive
reads can be the bad one. If the VLAN entry reads as free, its
index is handed out as a free slot and overwritten. Patch 4 reads
every entry twice, rewriting the index each time, and retries until
both reads match. It is enabled for the am64-cpswxg ALE, on which
the problem was seen; am65-cpsw-nuss also uses that ALE for the J7
CPSWxG instances.
The AM62x TRM (SPRUIV7) says that after a write to ALE_TBLCTL any ALE
register access is stalled until the table operation completes, so the
access sequence in the driver is as documented. TI lists a matching
unresolved issue for the J7 CPSW in its public tracker as EXT_EP-12856
(workaround: trigger the read twice); AM62x is not listed there.
Measured on a PHYTEC phyCORE-AM62x (CPSW3G, two ports in dual EMAC
mode, VLAN sub-interfaces). Stress: multicast joins and leaves on
both ports plus VLAN add/remove, 120 seconds per run.
- net v7.4-rc3, table lock only: 2 of 19 runs failed
- net v7.4-rc3, table lock and read verification: 60 runs passed,
lockdep enabled, no warnings
- TI/PHYTEC 6.18 vendor kernel, table lock only: 1 of 29 runs failed
- same kernel, read verification only (no lock): failed in the first
run, with torn entries
- same kernel, lock and read verification: 400 runs passed;
mismatching reads were caught and corrected by the retry (seen at
index 0 and index 64)
- a 6.6 based kernel without the patches also fails (run 8); it does
not have the commit named in patch 2, which points to cause 2
- net v7.4-rc3, v3 of this series (all four patches): 60 runs
passed, lockdep enabled, no warnings, the read verification never
gave up
All results except the last one are from v1 and v2 of the patches
(table lock taken with spin_lock_bh() in v1 and spin_lock_irqsave() in
v2, read verification for all ALE variants).
Test coverage: the table lock and the read verification together were
run-tested on net v7.4-rc3 and on the 6.18 vendor kernel, which has the
same cpsw_ale.c table access code. The legacy cpsw, cpsw_new and netcp
users of the ALE, the netcp change in patch 1, the control register
lock in patch 3 and the suspend error path added to patch 4 in v4 are
compile-tested only.
Signed-off-by: Manuel Janocha <manuel.janocha@amperfied.com>
---
Changes in v4:
- Patch 1: changelog names the patch that depends on it and why; it
carries the Fixes tag of patch 2 so both are backported together
- Patch 2: lock comment says that only the writers of
p0_untag_vid_mask are serialized and the RX path reads it without
the lock
- Patch 4: cpsw_ale_dump() returns -EIO if an entry could not be
verified; am65_cpsw_nuss_suspend() then fails instead of saving the
entry for cpsw_ale_restore()
- Patch 4: changelog says that am65-cpsw-nuss uses the am64-cpswxg ALE
for the J7 CPSWxG instances too
- Link to v3: https://patch.msgid.link/20261202-cpsw-ale-lock-v3-0-b40dc361d6b9@amperfied.com
Changes in v3:
- New patch 1: netcp VLAN callbacks use spin_lock_bh() instead of
spin_lock_irqsave()
- Patch 2: take the ALE lock with spin_lock_bh() instead of
spin_lock_irqsave(), so hard interrupts stay enabled during the table
scans; lock comment names what the lock protects
- New patch 3: the locking of cpsw_ale_control_set() is split out of
the table lock patch, with its own Fixes tag
- Patch 4: verify reads only for am64-cpswxg through a feature flag,
Fixes tag changed accordingly
- Patch 4: return -EIO if a read cannot be verified; the callers leave
the entry alone
- Link to v2: https://patch.msgid.link/20261130-cpsw-ale-lock-v2-0-c7a59d2178bb@amperfied.com
Changes in v2:
- Patch 1: use spin_lock_irqsave() instead of spin_lock_bh(): netcp
calls cpsw_ale_add_vlan()/cpsw_ale_del_vlan() with interrupts
disabled
- Patch 1: also lock the read-modify-write in cpsw_ale_control_set()
- Patch 1: correct the changelog: affected drivers (cpsw/cpsw_new are
already serialized by their rx_mode work item), accessors are the
_relaxed variants; test results updated
- New patch 2: verify ALE table reads (hardware read glitch seen with
the lock in place)
- Link to v1: https://patch.msgid.link/20261127-cpsw-ale-lock-v1-1-a72772d9a5ae@amperfied.com
---
Manuel Janocha (4):
net: netcp: do not disable interrupts in the VLAN callbacks
net: ethernet: ti: cpsw_ale: serialize ALE table accesses
net: ethernet: ti: cpsw_ale: serialize control register updates
net: ethernet: ti: cpsw_ale: verify ALE table reads
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 5 +-
drivers/net/ethernet/ti/cpsw_ale.c | 199 +++++++++++++++++++++++++------
drivers/net/ethernet/ti/cpsw_ale.h | 8 +-
drivers/net/ethernet/ti/netcp_core.c | 10 +-
4 files changed, 176 insertions(+), 46 deletions(-)
---
base-commit: ef3e21c61baa74e39a49b75318bd4541562ec43f
change-id: 20261126-cpsw-ale-lock-cc05d5bea7a0
Best regards,
--
Manuel Janocha <manuel.janocha@amperfied.com>
Technical Details
Message-ID:
<20261203-cpsw-ale-lock-v4-0-4ecfbc4bb042@amperfied.com>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!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376577-linux-kernel-netdev=dewy.ruShow 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!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376577-linux-kernel-netdev=dewy.ru From: devnull+manuel.janocha.amperfied.com@kernel.org (Manuel Janocha via B4 Relay) Newsgroups: linux.kernel.netdev Subject: [PATCH net v4 0/4] net: ethernet: ti: cpsw_ale: fix lost ALE entries Date: Thu, 03 Dec 2026 12:14:14 +0000 Organization: Usenet Network Message-ID: <20261203-cpsw-ale-lock-v4-0-4ecfbc4bb042@amperfied.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="2484216"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:+bMHXCY4OuO1sHc2mfIKGaNaBXs= sha256:GY4Wb3ojS0EpJfXIOlZBDmljjHuPRY9HEPO7u3EwW/I= sha1:/aRQfrDZsnNyhqmUp+J5L7T0IH0= sha256:zb2ZBkl215Lu63HciggU7RFOUcgnzs/C68XYJ4cGSO0= 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 E72DE11792B; Thu, 3 Dec 2026 15:16:22 +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 ZxDAembWqhpl; Thu, 3 Dec 2026 15:16:19 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-376577-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 8AE0B1178DD; Thu, 3 Dec 2026 15:16:11 +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 5422234223; Thu, 3 Dec 2026 12:15:00 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=fail 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 03E2E606A69F; Thu, 3 Dec 2026 12:14:26 +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=BtLxunqs X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail; t=1796300060; b=Bbw4rn6kaINtdyKxhWNiR1tPxZyrZvIdwBY3hRVw+xS1zXuvwaigUTZblobRD8vFTWKy vSM9f/Nzv3DGuMEnu3gTr6S6uNkaPZk8ZrAKFGxduBtu3P8lUbzx6QPXCR1+WsnSg+c9l vWzxWlf4QG7jhC3vl8GboNQDSwHL7okxmCmDPZOP01GZsDkLESZtppxPFIMMt6Y1Y/P7N vPR+Q5+arqCFNi1p5AZHl6Ra4p89npom8BZCWG5K7Ntx9wpUifF1+uzpqGBdtznxNjnAt bV1xmwQy6MqScqGr+SjTXEVFBj8UpmkJciNxmtPicxIhMWzbDSzR93VYzLsbna1623g== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796300060; h=Received:DKIM-Signature:Received:From:Subject:Date:Message-Id: MIME-Version:Content-Type:Content-Transfer-Encoding:X-B4-Tracking: X-Change-ID:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key: X-Endpoint-Received:X-Original-From:Reply-To; bh=rn7WkztKgzoZ5WoEX+LXMieU6vwv+tg5ABw6UQRivkA=; b=SeO724N3hT4IdsL6Mlf3+P8JbVjS5UsnRXO2Po4+pFREXp+Y9v+f7+EY/Hc5SZj/bbSM Y/H0w3pJwalW1aUkU7tH0R+wyUvSg1xP337r1/77ltLENuKKTh6ngYzUMEBnfxe/eQCUo QD8hZVE8njphQ+hJVNI5saKCmJq4j8ZXWYQNJBDFKRHzzDlYPQ1PAEQME1lNie+EYI3ei M3vvx3sSplC/OtL2mlLCP2wwbRyi26MoDPZClMqW7m/nV6RtYG8iagIgWL+8gJ6WxaUKT 89OiRzhKy3KtBECII6mB+OlkiDLoAU+U+tgrBIiHijH+iTWIAEeYSsSaBiO6QNvI/FQ== 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=BtLxunqs; arc=fail 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 0DAC1606BCE9; Thu, 3 Dec 2026 12:14:19 +0000 (UTC) X-Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 X-ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796300059; b=b9J2wirekHsB1BV+Vqyijv/IlZMSQZslKeOQpg4xIlTp13/RJRTj62RaVb2gAztzyINQ fZt85Zicfipbx3CfUBq4hy5+vMQEZq2+f3o0F+uk78wS0dbGYCORarKqaOKfDBljKMOYg G6cJaDFN99JFBhmvXFWfxMnMKaUf3++UKQyxLWVs0fDUWToT7dJ/eZRQBAUag8LtJnUlR vxJVIYW0T1xOHrFXWsYwt2q/eB3/3g8rtCLRZ0dWnWkaAYqmd05ca4YklKCtmx+fpS+on n+/JmU2pWtOWVcrX6evuPly7KqaDFYHxVctPnCFVprUiC6J9yYkepTrh50lBdZiTvNg== X-ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796300059; h=DKIM-Signature:Received:From:Subject:Date:Message-Id:MIME-Version: Content-Type:Content-Transfer-Encoding:X-B4-Tracking:X-Change-ID:To: Cc:X-Mailer:X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To; bh=rn7WkztKgzoZ5WoEX+LXMieU6vwv+tg5ABw6UQRivkA=; b=XnV7Zq5MiaR5XJmjzPM1i6PDjdSvU3Q6xigOIzlGzw2W6U+h0n0Fjxp9i9pHOm8wSVJI 9Wtwg1MCQOaHYDYJcb/GKg0AcruYVzDAPK53aJQMS3MU/F9lqp3+35PMaPRP4RA78wU4q +bI8qnaui1mnHBJljGgMFite0+Porf1dH7dZlIiQHner+VIbUdqN4199Jo/evyXKQjPpe k585KZ1q2S6+vu9Cjy9lyw+p9+gJ9DtGrirW4uxr4o6WYCOToKy4o7w2vmaU+NSrN/+/z ig3NuNcRBQxNWr5g1UQXJ35gfxnsRCrgR7FpzOvOWYFzGTlRwhVTXTYc/BrxkfTMD9A== X-ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 X-Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id AA85F1F00A1E; Thu, 3 Dec 2026 12:14:18 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796300059; bh=rn7WkztKgzoZ5WoEX+LXMieU6vwv+tg5ABw6UQRivkA=; h=From:Subject:Date:To:Cc:Reply-To; b=BtLxunqs+e2iTdmPoGqQUIbCOXzX5XDKSSBX9rDkfjcnj26lctbTLkEZj6NPzuco8 KG5ImNuDZlKZVybOy/jafLCOciytM2VwdnMxrYhx7TG61e7NwOAXuMSlbP4u0RG9vT ZQdSe54hWzn+lmqGbHws/BpLeWfoiCyPq+H2H6jmG9I6yDI4IYxqB3G04ST8zd0rrp eiA0s6LZsmUcHgrwmrevcCYQFgt2DWzMimS/LvosWYIv6hXsxzKag7ov+nk4UR7dF2 4yu58+oRGfpkEw3IL+rmXxrDXPL5R5F3+oyn4w8w1U7De1V/vVTDlQYDSYiq+fuaF7 6/53G3dal5Njw== X-Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 3AF834F968; Thu, 3 Dec 2026 12:14:18 +0000 (UTC) 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 X-B4-Tracking: v=1; b=H4sIABZdEWsC/23Nyw6CMBAF0F8hXVvTlkfFlf9hXEzbQaq80iJqC P9uQRMNcTPJTO6cOxKPzqIn+2gkDgfrbduEJdlERJfQnJFaE3YimMg4FxnVnb9TqJBWrb5SrVl qUoUggZHw0zks7GPxjqTBnpzeR39TF9T9LM2x0vq+dc+ldeBL+FMgVwUDp5yCFFIKk0MKeIC6Q 1dYNFvd1os/iB8hZmtB0HCSkOZGcLlT6p8Qf4Uw1kIcBJUwo+OMm0zla2GaphcT/YiGSQEAAA= = X-Change-ID: 20261126-cpsw-ale-lock-cc05d5bea7a0 X-Cc: linux-omap@vger.kernel.org, netdev@vger.kernel.org, Kuniyuki Iwashima <kuniyu@google.com>, Manuel Janocha <manuel.janocha@amperfied.com>, stable@vger.kernel.org X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796300057; l=6204; i=manuel.janocha@amperfied.com; s=20261127; h=from:subject:message-id; bh=4Dc26cmjHh4Zvg1Fty3BjPTsNsBD2N88hya1JrwED9Q=; b=XO1EFQwxNXPEpk/nN2eHbvHua9FmFQMsfG8EWeXvImfhcppWgZzNAltwbCt+v7qGUOO4pTTFd ZwbljwnP+DgAoHc7t1C1vuzGTbedTPhACqyeCimkgkQFR/i3K1iNhmP X-Developer-Key: i=manuel.janocha@amperfied.com; a=ed25519; pk=DEqXiAa78UfHuuvMWJsylc0F41gl8N+i7WtqrDb4xCQ= X-Endpoint-Received: by B4 Relay for manuel.janocha@amperfied.com/20261127 with auth_id=1666 X-Original-From: Manuel Janocha <manuel.janocha@amperfied.com> X-Reply-To: manuel.janocha@amperfied.com