🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25742

[PATCH net v3 0/4] net: ethernet: ti: cpsw_ale: fix lost ALE entries

#25742
From: Manuel Janocha via B4 Relay
Date: Wed, 02 Dec 2026 10:29
109 lines
15929 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 only for the am64-cpswxg ALE, on
   which the problem was seen.

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 and the control register
lock in patch 3 are compile-tested only.

Signed-off-by: Manuel Janocha <manuel.janocha@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/cpsw_ale.c   | 189 ++++++++++++++++++++++++++++-------
 drivers/net/ethernet/ti/cpsw_ale.h   |   5 +
 drivers/net/ethernet/ti/netcp_core.c |  10 +-
 3 files changed, 163 insertions(+), 41 deletions(-)
---
base-commit: ef3e21c61baa74e39a49b75318bd4541562ec43f
change-id: 20261126-cpsw-ale-lock-cc05d5bea7a0

Best regards,
--  
Manuel Janocha <manuel.janocha@amperfied.com>
Technical Details
Message-ID: <20261202-cpsw-ale-lock-v3-0-b40dc361d6b9@amperfied.com>
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu.MISMATCH!feed-eu-txt.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375723-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu.MISMATCH!feed-eu-txt.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375723-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 v3 0/4] net: ethernet: ti: cpsw_ale: fix lost ALE entries
Date: Wed, 02 Dec 2026 10:29:26 +0000
Organization: Usenet Network
Message-ID: <20261202-cpsw-ale-lock-v3-0-b40dc361d6b9@amperfied.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network; logging-data="1949991"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:IDnHlQBBYyU9eWyQim+DBm2Uoqs= sha256:GetA9scVyoSvRkf1tkXoJ5dPy4HxXdLsbd3gknAmzfU= sha1:pp1q60bXkwRwQy0jeGWBeRd40m0= sha256:QwZRuQsyWrpT61Dp1Ofnhi9jMUcvynrXoSCpk94AkdY=
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 99E7D1175FF; Wed,  2 Dec 2026 13:30:15 +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 Q0N1XGoE9qnC; Wed,  2 Dec 2026 13:30:12 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-375723-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 41F6F1175C3; Wed,  2 Dec 2026 13:30:00 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 2B9BD2030C; Wed,  2 Dec 2026 10:29:53 +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=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796207387; b=h9CXiJHNwNH3D+8x+LMdd9DuytcE34V4n5krt8rb5vXkajsCBBLDu9WT0fFhfFVZ1Y/O 2wpfuzonlw6QoGxnXRxrRR/L64ZiRwzXEuJz9vvmWzi8YY2QBswmTWWJiXgJ56fCRaHXU lMPBmYASmGQKqMvWcMrRKCwA7p/C9R9hSPQZPu+GaZ2O37vEIII84TnwkOLAZWE5jLLDs WmgTvrRtZOdBQn6is2qQBcWdxV+9PgiUh4vxyZtLT+q+s4Af+M+1WKT7RX9btxoY2MH19 Ipse3HbKi21wUE6KBX0Ol/NN4bSpKJVprqgqHFp+O1cmZ4/yG0cN74OItwctaxeJ0kQ==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796207387; h=X-Original-To:Received:Received:DKIM-Signature:Received:From:Subject: Date:Message-Id:X-Mailing-List:List-Id:List-Post:List-Help: List-Subscribe:List-Unsubscribe:List-Owner:Precedence: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=FnaN5gwUmsAugOy9PvQYZ3aFlm44/XjUqsd/EEX/WU4=; b=NpjcuGRQ2eR1PPeFFt7vuSzW+ok+cCdiH/sA97DazumDLuByzmcG82a51hp5GJsQLsTn X0EF6IpVrocP8JVpTPmE68fn1DCikWr1/AWBWhNvaidBQ2iMGGnnpZr229B+2WrM9mibq P/LYi8qoPqG6egt2p7GShb38/GhgWoqhG4JNpE3tM6Cw01zzx/RpX3RREFkflPFM/Itlu 3HAOiN6lY8T390Qp5QAijtvRCmXDAVTjUaIjRjXDl4ach90sWUv/PX1dLTQ2PZ2iKqY7C htbWQopuAEof0ujjZWQAdi9tIbqlz/Xee/ReHARrvWQl9IiQVXuSE/Gwv9efYwINbrw==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fORA1vq6; 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 0BDD7606A69D; Wed,  2 Dec 2026 10:29:47 +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=fORA1vq6
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796207381; b=19PHcYkyALMksxbrnEy5DOJSz6IF3Xa7gxXzhlohL8cMgacu4QwCmXuLTx7Jm/KAQML8 O4jQ1B36yPsaZZ4mvyolvbFAuVEkc+1VSGds5Mf2nZA9c00A1BSn0jxDPsMG2BmjoPsx1 yD7CTx6YS0CVASGJ4gX1Lf2QhRLxFG87TqcR2mWQf6Y0appUBdVTDIvugIRCCxFgjH/wW MUkwsSzTXbG+BJeAiuTQpQ0ZMiPaDN2CHSagTW3VQJsNnQKsflMn7TWFvcqKH83O222/y EInM9FrjkgEC8PlwLut6zCGxLSRgmID28D3G8UFEU2r4v8WojuRtTNdu2KaWt9gjNEA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796207381; 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=FnaN5gwUmsAugOy9PvQYZ3aFlm44/XjUqsd/EEX/WU4=; b=m1DsnTyP9ZzIuBvihz7MKxMjwi53G0gx5u3bJmc9LcPklkM4Mm2F+XNqRTrowaRGIMpO L28CvbHHncmgxLUDX+Cx1BmDr6vWbiicpLZHNApfF16ao9QLXcf/Ol9JZSQcd83PZ/xHC 69zteb18uF34O6ceLByqQfnthLqJHWjdwanjS4It/HSkIhMX3gIufg5b8Vz5wiKxoJxLa hq/8m8R7oJLSODcGHGFntqg6CCAHksRZERR+uVRYUVtShwuRpXptT+wdhLl65A0PmA/9l OWxMOkWeDL30GGgEKx+2Ygk/4WWLpDrA3U/ACUEirAyRd7KiGutqRLjnbMuh1Bxjmgw==
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=fORA1vq6; arc=pass header.oldest-pass=0 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 26AD6606A32A; Wed,  2 Dec 2026 10:29:41 +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=1796207380; b=Db/S2AjoS693auOpRMIOpDd+/CIdp14RfZIiJxhnc2nDoq4AZuxvU+wHy4roxjBEl6Rg xF2EJwJC1CZ32bhE2yczvmZBrCMLUA5zYgdFo7X8lQXY6EmCYj7dyNXCyD4BXzC8S2nuR 2QUpTUJERgoA2Z6YASR+lESybTcf1F8kt7hNzcM5eRYP/LrAJd1gRaEjlSlugzwf88XX8 OoO2Lj7dbHqupD1mFxqmCwae5bsijyzh8z0ZtD5OcB6kvHVNiVzzEa/yS5rZuC6ZjdMXs Ia03g9ybHNt3IDkDm3qwaUzqee8R6jXoo6QvmP6KWUzxLtJpySKaVshKo6pqV0viMSg==
X-ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796207380; 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=FnaN5gwUmsAugOy9PvQYZ3aFlm44/XjUqsd/EEX/WU4=; b=YSWCiOoxFieLbWPEU+uha/fmHqLw35Yo9YTt0f53FQpNaBmsRD4qFWym21R5zyjnI2PH ejfTTM16HV8RJbUqDbI5Ng+tAxlGjGrKnkUCNyB8v+wtuZlh8VK3H1GCAIPQif3Gfx+xi r9d4i8IW17e7VeDrILf4oqleQayexiL08fCbZBUgx4Yaz8VP3shtPJo69tKpsU21k94SV lAXi6e9kYUoTDp5suHPkxSeM5ZaYW+v179IJloaHU97QEB5u5JCKXv4EP3NYCrdRwMUHn yhfs1nzphvJyiUt3knqxguHHuasalrre4AjBrwGGfD4kAT02duiZgncQlIvPZl7C+5Q==
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 109A61F000C1; Wed,  2 Dec 2026 10:29:30 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796207380; bh=FnaN5gwUmsAugOy9PvQYZ3aFlm44/XjUqsd/EEX/WU4=; h=From:Subject:Date:To:Cc:Reply-To; b=fORA1vq6GG7Ily1+Nbbru8dLeNxRVJJB0Kg/Qrh1EuzBFaT32etDjakJwGb3Br2wl U3CzrLQH1nL6kIqBn0IDtT7Tn19vRjpieRKbkAsgOwWr4VrdxAZI5an+ddwa0BwEs5 WKHYSVrBn6SBFO++orVFzj7o6btVn54HhhLMPAahMb8wDQ+gjzkGDRchPwzSdGw4F0 VpguF7Fp7C5/3cZBHuwre5FYlQoUwHpMtCNGznZc3k1onmTKIAXfuh29eBRCLeKRMZ WIWTjnaUQrc4pPJJ/FpOqWYgCUZrVdZh8rF5Ag49K+u2BFE7oR2dphlskP4pezpzQf meArywkkmlVpA==
X-Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 82FED4F38C; Wed,  2 Dec 2026 10:29:29 +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=H4sIAAbzD2sC/12NQQ6CMBREr0K6toZ+AhVX3sO4+LQfqQIlLVYN4 e5CdWFYzmTmvYl5coY8OyYTcxSMN7ZfQrZLmGqwvxI3eskMUiiEgIKrwT85tsRbq+5cqTTXeUU oMWXLZ3BUm1fknVlPI7t8S/+obqTGlbTOGuNH697RGkQc/wRyIwiCC44SpARdYo50wm4gVxvSe 2W7yA/wR8jSLQH4UknMSw1CHqpqS5jn+QMpAHrEBwEAAA==
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=1796207368; l=5371; i=manuel.janocha@amperfied.com; s=20261127; h=from:subject:message-id; bh=rVB4IaLHqOL/suDNukMC6VNzp9XfUbu5kDZrkCe+hGM=; b=zSLot8WY44hnbQnP8Bg6uNarEyCR55HXs/4C7aYPjvNA9cNPVvX19NMpczBXnp5aT+1G5EILF KQLAWth6AcODW2/iWJjCwIScMenSimNLJfiuLNha0wWUTEKXq/6i2RR
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
X-Received-Bytes: 15621