Netdev List
 help / color / mirror / Atom feed
* [PATCH net v2 0/2] net: ethernet: ti: cpsw_ale: fix lost ALE entries
@ 2026-11-30 20:34 Manuel Janocha via B4 Relay
  2026-11-30 20:34 ` [PATCH net v2 1/2] net: ethernet: ti: cpsw_ale: serialize ALE table accesses Manuel Janocha via B4 Relay
  2026-11-30 20:34 ` [PATCH net v2 2/2] net: ethernet: ti: cpsw_ale: verify ALE table reads Manuel Janocha via B4 Relay
  0 siblings, 2 replies; 5+ messages in thread
From: Manuel Janocha via B4 Relay @ 2026-11-30 20:34 UTC (permalink / raw)
  To: Siddharth Vadapalli, Roger Quadros, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: linux-omap, netdev, Kuniyuki Iwashima, Manuel Janocha, stable

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, one patch each:

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 1 adds a lock to struct cpsw_ale.

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 2 reads
   every entry twice, rewriting the index each time, and retries until
   both reads match.

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, patch 1 only: 2 of 19 runs failed
 - net v7.4-rc3, both patches: 60 runs passed, lockdep enabled, no
   warnings
 - TI/PHYTEC 6.18 vendor kernel, patch 1 only: 1 of 29 runs failed
 - same kernel, patch 2 only (no lock): failed in the first run, with
   torn entries
 - same kernel, both patches: 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 1, which points to cause 2

Test coverage: both patches 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 are
compile-tested only.

Signed-off-by: Manuel Janocha <manuel.janocha@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 (2):
      net: ethernet: ti: cpsw_ale: serialize ALE table accesses
      net: ethernet: ti: cpsw_ale: verify ALE table reads

 drivers/net/ethernet/ti/cpsw_ale.c | 117 ++++++++++++++++++++++++++++++++-----
 drivers/net/ethernet/ti/cpsw_ale.h |   2 +
 2 files changed, 106 insertions(+), 13 deletions(-)
---
base-commit: ef3e21c61baa74e39a49b75318bd4541562ec43f
change-id: 20261126-cpsw-ale-lock-cc05d5bea7a0

Best regards,
--  
Manuel Janocha <manuel.janocha@amperfied.com>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net v2 1/2] net: ethernet: ti: cpsw_ale: serialize ALE table accesses
  2026-11-30 20:34 [PATCH net v2 0/2] net: ethernet: ti: cpsw_ale: fix lost ALE entries Manuel Janocha via B4 Relay
@ 2026-11-30 20:34 ` Manuel Janocha via B4 Relay
  2026-12-01 20:35   ` netdev-bot+sashiko
  2026-11-30 20:34 ` [PATCH net v2 2/2] net: ethernet: ti: cpsw_ale: verify ALE table reads Manuel Janocha via B4 Relay
  1 sibling, 1 reply; 5+ messages in thread
From: Manuel Janocha via B4 Relay @ 2026-11-30 20:34 UTC (permalink / raw)
  To: Siddharth Vadapalli, Roger Quadros, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: linux-omap, netdev, Kuniyuki Iwashima, Manuel Janocha, stable

From: Manuel Janocha <manuel.janocha@amperfied.com>

The ALE table is accessed through a single index register
(ALE_TABLE_CONTROL) and three data registers (ALE_TABLE). Reading an
entry writes the index and then reads the data registers; writing an
entry fills the data registers and then writes the index with
ALE_TABLE_WRITE. Most operations (add/del ucast/mcast/vlan,
vlan_add_modify, flush_multicast, set_allmulti, set_unreg_mcast) are
read-modify-write sequences over several entries. The driver has no
lock around any of this.

This did not matter as long as the callers were serialized by someone
else. Both ports of a CPSW switch share one ALE, but the port VLAN
and address operations run under RTNL, while ndo_set_rx_mode() of
am65-cpsw and netcp runs under netif_addr_lock_bh() of one port only
and does not take RTNL. Since IPV6_ADD_MEMBERSHIP and friends no
longer hold RTNL, joining an IPv6 multicast group
(igmp6_group_added() -> dev_mc_add() -> ndo_set_rx_mode()) can run
concurrently with a VLAN or address operation on the other port, or
on the same port.

For example, on two CPUs:

  CPU0 (eth0 rx_mode, flush)     CPU1 (eth1 add_vid)
  cpsw_ale_read(A):
    writel(A, TABLE_CONTROL)
                                 cpsw_ale_read(B):
                                   writel(B, TABLE_CONTROL)
    readl(ALE_TABLE + 0..2)
      -> returns entry B
  cpsw_ale_write(A):
    entry B is written to index A

Entry A is lost and entry B exists twice. Interleaved writes can
equally mix the data words of two entries in one table slot. The same
happens inside the multi-entry loops, so entries are written back with
foreign data or are dropped.

Observed on an AM625 board with two am65-cpsw-nuss ports in dual EMAC
mode and seven VLANs on the second port: after boot the port VLAN
entry (VID 0), the unicast entry of the first port and two VLAN
entries were gone, copies of the unicast and of the broadcast entry
showed up at two other indexes. The switch then dropped every frame
received on the first port (p0_ale_vid_ingress_drop kept rising) while
the port could still transmit, and the board was unreachable.

Add a spinlock to struct cpsw_ale and take it in all exported
functions that access the table. cpsw and cpsw_new are not affected
in practice: since commit 0b8c878d1173 ("net: cpsw: Execute
ndo_set_rx_mode callback in a work queue") they run rx_mode from a
work item under RTNL and are already serialized. The lock is put into
the ALE library instead of repeating that approach in the other
drivers because the table protocol (index plus data registers) is an
invariant of the library itself, one lock covers all users including
the ageout timer, and it does not depend on every present and future
caller holding RTNL.

The lock is taken with spin_lock_irqsave(). netcp calls
cpsw_ale_add_vlan() and cpsw_ale_del_vlan() from netcp_rx_add_vid()
and netcp_rx_kill_vid() with netcp->lock held and interrupts
disabled, so the unlock must not re-enable them. ndo_set_rx_mode()
runs with bottom halves disabled and the dev_mc_add()/dev_uc_add()
family is not restricted to process context; the other callers run
in process context (RTNL, workqueue, ethtool, system suspend). A
sleeping lock cannot be used because of the atomic callers. The
register accesses under the lock are readl_relaxed()/writel_relaxed()
as before; this patch does not change the accessors. The regmap of
the ALE is only used for the version, feature and policer fields and
is not touched under the lock.

cpsw_ale_vlan_add_modify() calls cpsw_ale_add_vlan() with the lock
held, so the body of the latter moves into a static helper that does
not take the lock. The loops over all entries run with the lock held
for the number of table entries; that is the same amount of MMIO as
before, just not preemptible by the other port.

cpsw_ale_control_set() takes the lock around its read-modify-write
as well. ALE_PORTCTL holds several fields of one port in a single
word, so two unlocked updates can lose each other's change: the
am65-cpsw rx_mode path clearing ALE_PORT_MACONLY_CAF can overwrite an
ALE_PORT_STATE write from phylink mac_link_up()/mac_link_down() or
from STP, or the other way round. In the same way cpsw_ale_timer()
setting ALE_AGEOUT in ALE_CONTROL can overwrite a concurrent update
of the bypass or flood bits. cpsw_ale_control_get() stays unlocked.
The policer index registers are separate and left alone.

The lock is held longest when a VLAN is added: with the 512 entry
table of the AM625 a backport of this patch to the TI 6.18.59 vendor
kernel measured up to 1.1 ms in cpsw_ale_vlan_add_modify() called
from ndo_vlan_rx_add_vid(). That is VLAN configuration, not the data
path; the multicast add and delete paths hold it for less.

Discovery: observed on a test system and reproduced on the same board.
The reproducer joins IPv6 multicast groups in parallel on eth0, eth1
and a VLAN interface of eth1 while adding and deleting a VLAN on eth1.
It needs no kernel modification and no error injection. Without this
change eth0 stops receiving after about 30 seconds.

Testing: hardware test on an AM625 board (two CPSW ports,
am65-cpsw-nuss) with net at v7.4-rc3 (ef3e21c61baa) plus an
out-of-tree board device tree, built with PROVE_LOCKING,
DEBUG_SPINLOCK and DEBUG_ATOMIC_SLEEP. Without this patch the
reproducer kills reception within 120 seconds
(p0_ale_vid_ingress_drop 0 -> 2366 and rising; link down/up
recovers). With this patch it ran for 120 and for 300 seconds
(about 21800 joins and 87 VLAN add/delete cycles of three VLANs in
the longer run): eth0 and the VLANs kept receiving and lockdep stayed
silent. p0_ale_vid_ingress_drop rose by 1 and by 3 during the two
runs. Over all 19 runs on net v7.4-rc3 with this patch alone, 2
failed with the VID 0 entry overwritten again. A backport to the TI
vendor kernel 6.18.59 passed 28 of 29 runs of 120 to 300 seconds; one
120 second run lost the VID 0 entry again. These remaining failures
are not missing serialization: with the lock held, a table read can
still return a wrong entry, which the next patch handles. The legacy
cpsw, cpsw_new and netcp users of the ALE were only compile-tested
(arm64 and arm, W=1).

Tooling: the port to net, the locking analysis and this changelog were
prepared with an AI coding assistant (Claude).

Fixes: 1767bb2d47b7 ("ipv6: mcast: Don't hold RTNL for IPV6_ADD_MEMBERSHIP and MCAST_JOIN_GROUP.")
Cc: stable@vger.kernel.org
Signed-off-by: Manuel Janocha <manuel.janocha@amperfied.com>
---
 drivers/net/ethernet/ti/cpsw_ale.c | 86 +++++++++++++++++++++++++++++++++-----
 drivers/net/ethernet/ti/cpsw_ale.h |  2 +
 2 files changed, 78 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
index 9304405c9581..8434803335d5 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.c
+++ b/drivers/net/ethernet/ti/cpsw_ale.c
@@ -462,8 +462,10 @@ static void cpsw_ale_flush_mcast(struct cpsw_ale *ale, u32 *ale_entry,
 int cpsw_ale_flush_multicast(struct cpsw_ale *ale, int port_mask, int vid)
 {
 	u32 ale_entry[ALE_ENTRY_WORDS];
+	unsigned long irq_flags;
 	int ret, idx;
 
+	spin_lock_irqsave(&ale->lock, irq_flags);
 	for (idx = 0; idx < ale->params.ale_entries; idx++) {
 		cpsw_ale_read(ale, idx, ale_entry);
 		ret = cpsw_ale_get_entry_type(ale_entry);
@@ -491,6 +493,7 @@ int cpsw_ale_flush_multicast(struct cpsw_ale *ale, int port_mask, int vid)
 
 		cpsw_ale_write(ale, idx, ale_entry);
 	}
+	spin_unlock_irqrestore(&ale->lock, irq_flags);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(cpsw_ale_flush_multicast);
@@ -510,6 +513,7 @@ int cpsw_ale_add_ucast(struct cpsw_ale *ale, const u8 *addr, int port,
 		       int flags, u16 vid)
 {
 	u32 ale_entry[ALE_ENTRY_WORDS] = {0, 0, 0};
+	unsigned long irq_flags;
 	int idx;
 
 	cpsw_ale_set_vlan_entry_type(ale_entry, flags, vid);
@@ -520,15 +524,19 @@ int cpsw_ale_add_ucast(struct cpsw_ale *ale, const u8 *addr, int port,
 	cpsw_ale_set_blocked(ale_entry, (flags & ALE_BLOCKED) ? 1 : 0);
 	cpsw_ale_set_port_num(ale_entry, port, ale->port_num_bits);
 
+	spin_lock_irqsave(&ale->lock, irq_flags);
 	idx = cpsw_ale_match_addr(ale, addr, (flags & ALE_VLAN) ? vid : 0);
 	if (idx < 0)
 		idx = cpsw_ale_match_free(ale);
 	if (idx < 0)
 		idx = cpsw_ale_find_ageable(ale);
-	if (idx < 0)
+	if (idx < 0) {
+		spin_unlock_irqrestore(&ale->lock, irq_flags);
 		return -ENOMEM;
+	}
 
 	cpsw_ale_write(ale, idx, ale_entry);
+	spin_unlock_irqrestore(&ale->lock, irq_flags);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(cpsw_ale_add_ucast);
@@ -537,14 +545,19 @@ int cpsw_ale_del_ucast(struct cpsw_ale *ale, const u8 *addr, int port,
 		       int flags, u16 vid)
 {
 	u32 ale_entry[ALE_ENTRY_WORDS] = {0, 0, 0};
+	unsigned long irq_flags;
 	int idx;
 
+	spin_lock_irqsave(&ale->lock, irq_flags);
 	idx = cpsw_ale_match_addr(ale, addr, (flags & ALE_VLAN) ? vid : 0);
-	if (idx < 0)
+	if (idx < 0) {
+		spin_unlock_irqrestore(&ale->lock, irq_flags);
 		return -ENOENT;
+	}
 
 	cpsw_ale_set_entry_type(ale_entry, ALE_TYPE_FREE);
 	cpsw_ale_write(ale, idx, ale_entry);
+	spin_unlock_irqrestore(&ale->lock, irq_flags);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(cpsw_ale_del_ucast);
@@ -553,8 +566,10 @@ int cpsw_ale_add_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask,
 		       int flags, u16 vid, int mcast_state)
 {
 	u32 ale_entry[ALE_ENTRY_WORDS] = {0, 0, 0};
+	unsigned long irq_flags;
 	int idx, mask;
 
+	spin_lock_irqsave(&ale->lock, irq_flags);
 	idx = cpsw_ale_match_addr(ale, addr, (flags & ALE_VLAN) ? vid : 0);
 	if (idx >= 0)
 		cpsw_ale_read(ale, idx, ale_entry);
@@ -575,10 +590,13 @@ int cpsw_ale_add_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask,
 		idx = cpsw_ale_match_free(ale);
 	if (idx < 0)
 		idx = cpsw_ale_find_ageable(ale);
-	if (idx < 0)
+	if (idx < 0) {
+		spin_unlock_irqrestore(&ale->lock, irq_flags);
 		return -ENOMEM;
+	}
 
 	cpsw_ale_write(ale, idx, ale_entry);
+	spin_unlock_irqrestore(&ale->lock, irq_flags);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(cpsw_ale_add_mcast);
@@ -587,12 +605,16 @@ int cpsw_ale_del_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask,
 		       int flags, u16 vid)
 {
 	u32 ale_entry[ALE_ENTRY_WORDS] = {0, 0, 0};
+	unsigned long irq_flags;
 	int mcast_members = 0;
 	int idx;
 
+	spin_lock_irqsave(&ale->lock, irq_flags);
 	idx = cpsw_ale_match_addr(ale, addr, (flags & ALE_VLAN) ? vid : 0);
-	if (idx < 0)
+	if (idx < 0) {
+		spin_unlock_irqrestore(&ale->lock, irq_flags);
 		return -ENOENT;
+	}
 
 	cpsw_ale_read(ale, idx, ale_entry);
 
@@ -609,6 +631,7 @@ int cpsw_ale_del_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask,
 		cpsw_ale_set_entry_type(ale_entry, ALE_TYPE_FREE);
 
 	cpsw_ale_write(ale, idx, ale_entry);
+	spin_unlock_irqrestore(&ale->lock, irq_flags);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(cpsw_ale_del_mcast);
@@ -642,8 +665,8 @@ static void cpsw_ale_set_vlan_untag(struct cpsw_ale *ale, u32 *ale_entry,
 		bitmap_clear(ale->p0_untag_vid_mask, vid, 1);
 }
 
-int cpsw_ale_add_vlan(struct cpsw_ale *ale, u16 vid, int port_mask, int untag,
-		      int reg_mcast, int unreg_mcast)
+static int __cpsw_ale_add_vlan(struct cpsw_ale *ale, u16 vid, int port_mask,
+			       int untag, int reg_mcast, int unreg_mcast)
 {
 	u32 ale_entry[ALE_ENTRY_WORDS] = {0, 0, 0};
 	int idx;
@@ -681,6 +704,20 @@ int cpsw_ale_add_vlan(struct cpsw_ale *ale, u16 vid, int port_mask, int untag,
 	cpsw_ale_write(ale, idx, ale_entry);
 	return 0;
 }
+
+int cpsw_ale_add_vlan(struct cpsw_ale *ale, u16 vid, int port_mask, int untag,
+		      int reg_mcast, int unreg_mcast)
+{
+	unsigned long irq_flags;
+	int ret;
+
+	spin_lock_irqsave(&ale->lock, irq_flags);
+	ret = __cpsw_ale_add_vlan(ale, vid, port_mask, untag, reg_mcast,
+				  unreg_mcast);
+	spin_unlock_irqrestore(&ale->lock, irq_flags);
+
+	return ret;
+}
 EXPORT_SYMBOL_GPL(cpsw_ale_add_vlan);
 
 static void cpsw_ale_vlan_del_modify_int(struct cpsw_ale *ale,  u32 *ale_entry,
@@ -726,16 +763,21 @@ static void cpsw_ale_vlan_del_modify_int(struct cpsw_ale *ale,  u32 *ale_entry,
 int cpsw_ale_vlan_del_modify(struct cpsw_ale *ale, u16 vid, int port_mask)
 {
 	u32 ale_entry[ALE_ENTRY_WORDS] = {0, 0, 0};
+	unsigned long irq_flags;
 	int idx;
 
+	spin_lock_irqsave(&ale->lock, irq_flags);
 	idx = cpsw_ale_match_vlan(ale, vid);
-	if (idx < 0)
+	if (idx < 0) {
+		spin_unlock_irqrestore(&ale->lock, irq_flags);
 		return -ENOENT;
+	}
 
 	cpsw_ale_read(ale, idx, ale_entry);
 
 	cpsw_ale_vlan_del_modify_int(ale, ale_entry, vid, port_mask);
 	cpsw_ale_write(ale, idx, ale_entry);
+	spin_unlock_irqrestore(&ale->lock, irq_flags);
 
 	return 0;
 }
@@ -744,11 +786,15 @@ EXPORT_SYMBOL_GPL(cpsw_ale_vlan_del_modify);
 int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port_mask)
 {
 	u32 ale_entry[ALE_ENTRY_WORDS] = {0, 0, 0};
+	unsigned long irq_flags;
 	int members, idx;
 
+	spin_lock_irqsave(&ale->lock, irq_flags);
 	idx = cpsw_ale_match_vlan(ale, vid);
-	if (idx < 0)
+	if (idx < 0) {
+		spin_unlock_irqrestore(&ale->lock, irq_flags);
 		return -ENOENT;
+	}
 
 	cpsw_ale_read(ale, idx, ale_entry);
 
@@ -771,6 +817,7 @@ int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port_mask)
 	}
 
 	cpsw_ale_write(ale, idx, ale_entry);
+	spin_unlock_irqrestore(&ale->lock, irq_flags);
 
 	return 0;
 }
@@ -782,8 +829,10 @@ int cpsw_ale_vlan_add_modify(struct cpsw_ale *ale, u16 vid, int port_mask,
 	u32 ale_entry[ALE_ENTRY_WORDS] = {0, 0, 0};
 	int reg_mcast_members, unreg_mcast_members;
 	int vlan_members, untag_members;
+	unsigned long irq_flags;
 	int idx, ret = 0;
 
+	spin_lock_irqsave(&ale->lock, irq_flags);
 	idx = cpsw_ale_match_vlan(ale, vid);
 	if (idx >= 0)
 		cpsw_ale_read(ale, idx, ale_entry);
@@ -803,8 +852,9 @@ int cpsw_ale_vlan_add_modify(struct cpsw_ale *ale, u16 vid, int port_mask,
 	reg_mcast_members = (reg_mcast_members & ~port_mask) | reg_mask;
 	unreg_mcast_members = (unreg_mcast_members & ~port_mask) | unreg_mask;
 
-	ret = cpsw_ale_add_vlan(ale, vid, vlan_members, untag_members,
-				reg_mcast_members, unreg_mcast_members);
+	ret = __cpsw_ale_add_vlan(ale, vid, vlan_members, untag_members,
+				  reg_mcast_members, unreg_mcast_members);
+	spin_unlock_irqrestore(&ale->lock, irq_flags);
 	if (ret) {
 		dev_err(ale->params.dev, "Unable to add vlan\n");
 		return ret;
@@ -820,9 +870,11 @@ void cpsw_ale_set_unreg_mcast(struct cpsw_ale *ale, int unreg_mcast_mask,
 			      bool add)
 {
 	u32 ale_entry[ALE_ENTRY_WORDS];
+	unsigned long irq_flags;
 	int unreg_members = 0;
 	int type, idx;
 
+	spin_lock_irqsave(&ale->lock, irq_flags);
 	for (idx = 0; idx < ale->params.ale_entries; idx++) {
 		cpsw_ale_read(ale, idx, ale_entry);
 		type = cpsw_ale_get_entry_type(ale_entry);
@@ -841,6 +893,7 @@ void cpsw_ale_set_unreg_mcast(struct cpsw_ale *ale, int unreg_mcast_mask,
 				      unreg_members);
 		cpsw_ale_write(ale, idx, ale_entry);
 	}
+	spin_unlock_irqrestore(&ale->lock, irq_flags);
 }
 EXPORT_SYMBOL_GPL(cpsw_ale_set_unreg_mcast);
 
@@ -883,8 +936,10 @@ cpsw_ale_vlan_set_unreg_mcast_idx(struct cpsw_ale *ale, u32 *ale_entry,
 void cpsw_ale_set_allmulti(struct cpsw_ale *ale, int allmulti, int port)
 {
 	u32 ale_entry[ALE_ENTRY_WORDS];
+	unsigned long irq_flags;
 	int type, idx;
 
+	spin_lock_irqsave(&ale->lock, irq_flags);
 	for (idx = 0; idx < ale->params.ale_entries; idx++) {
 		int vlan_members;
 
@@ -907,6 +962,7 @@ void cpsw_ale_set_allmulti(struct cpsw_ale *ale, int allmulti, int port)
 
 		cpsw_ale_write(ale, idx, ale_entry);
 	}
+	spin_unlock_irqrestore(&ale->lock, irq_flags);
 }
 EXPORT_SYMBOL_GPL(cpsw_ale_set_allmulti);
 
@@ -1140,6 +1196,7 @@ int cpsw_ale_control_set(struct cpsw_ale *ale, int port, int control,
 			 int value)
 {
 	const struct ale_control_info *info;
+	unsigned long irq_flags;
 	int offset, shift;
 	u32 tmp, mask;
 
@@ -1160,9 +1217,11 @@ int cpsw_ale_control_set(struct cpsw_ale *ale, int port, int control,
 	offset = info->offset + (port * info->port_offset);
 	shift  = info->shift  + (port * info->port_shift);
 
+	spin_lock_irqsave(&ale->lock, irq_flags);
 	tmp = readl_relaxed(ale->params.ale_regs + offset);
 	tmp = (tmp & ~(mask << shift)) | (value << shift);
 	writel_relaxed(tmp, ale->params.ale_regs + offset);
+	spin_unlock_irqrestore(&ale->lock, irq_flags);
 
 	return 0;
 }
@@ -1540,6 +1599,7 @@ struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params)
 	ale = devm_kzalloc_obj(params->dev, *ale);
 	if (!ale)
 		return ERR_PTR(-ENOMEM);
+	spin_lock_init(&ale->lock);
 	ale->regmap = devm_regmap_init_mmio(params->dev, params->ale_regs,
 					    &ale_regmap_cfg);
 	if (IS_ERR(ale->regmap)) {
@@ -1639,23 +1699,29 @@ EXPORT_SYMBOL_GPL(cpsw_ale_create);
 
 void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data)
 {
+	unsigned long irq_flags;
 	int i;
 
+	spin_lock_irqsave(&ale->lock, irq_flags);
 	for (i = 0; i < ale->params.ale_entries; i++) {
 		cpsw_ale_read(ale, i, data);
 		data += ALE_ENTRY_WORDS;
 	}
+	spin_unlock_irqrestore(&ale->lock, irq_flags);
 }
 EXPORT_SYMBOL_GPL(cpsw_ale_dump);
 
 void cpsw_ale_restore(struct cpsw_ale *ale, u32 *data)
 {
+	unsigned long irq_flags;
 	int i;
 
+	spin_lock_irqsave(&ale->lock, irq_flags);
 	for (i = 0; i < ale->params.ale_entries; i++) {
 		cpsw_ale_write(ale, i, data);
 		data += ALE_ENTRY_WORDS;
 	}
+	spin_unlock_irqrestore(&ale->lock, irq_flags);
 }
 EXPORT_SYMBOL_GPL(cpsw_ale_restore);
 
diff --git a/drivers/net/ethernet/ti/cpsw_ale.h b/drivers/net/ethernet/ti/cpsw_ale.h
index 87b7d1b3a34a..8e47261161fe 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.h
+++ b/drivers/net/ethernet/ti/cpsw_ale.h
@@ -96,6 +96,8 @@ 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 registers */
+	spinlock_t		lock;
 };
 
 enum cpsw_ale_control {

-- 
2.34.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net v2 2/2] net: ethernet: ti: cpsw_ale: verify ALE table reads
  2026-11-30 20:34 [PATCH net v2 0/2] net: ethernet: ti: cpsw_ale: fix lost ALE entries Manuel Janocha via B4 Relay
  2026-11-30 20:34 ` [PATCH net v2 1/2] net: ethernet: ti: cpsw_ale: serialize ALE table accesses Manuel Janocha via B4 Relay
@ 2026-11-30 20:34 ` Manuel Janocha via B4 Relay
  2026-12-01 20:35   ` netdev-bot+sashiko
  1 sibling, 1 reply; 5+ messages in thread
From: Manuel Janocha via B4 Relay @ 2026-11-30 20:34 UTC (permalink / raw)
  To: Siddharth Vadapalli, Roger Quadros, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: linux-omap, netdev, Kuniyuki Iwashima, Manuel Janocha

From: Manuel Janocha <manuel.janocha@amperfied.com>

On AM62x (CPSW3G) a read of an ALE table entry occasionally returns the
contents of a different table index, or all zeros, although the access
sequence is the documented one and is serialized by the ALE lock.
Reading the data words again does not help, the wrong value is latched;
writing the index to ALE_TBLCTL again and then reading returns the
right entry.

The TRM states that after a write to ALE_TBLCTL any access to an ALE
register is stalled until the table operation completes, so software is
not expected to wait or poll. TI tracks the same symptom for the J7
CPSW as EXT_EP-12856, unresolved, with the workaround to trigger the
read twice.

A wrong read is not harmless: when the entry at the index of the
untagged VLAN reads as free, cpsw_ale_match_free() hands that index out
and the next multicast address overwrites the VLAN entry. Untagged
receive on the port is then dead until the link goes down and up again.

In testing, either the first or the second of two consecutive reads was
the wrong one, so taking the second read is not sufficient. Read every
entry twice, each time after writing the index, and retry until both
reads match. After four unsuccessful tries warn (ratelimited) and
return the last read. Every table read now costs two index writes and
six data reads instead of one and three, and the loops over the table
hold the ALE lock correspondingly longer.

Testing: AM625 board (PHYTEC phyCORE-AM62x, two CPSW ports in dual EMAC
mode with VLAN interfaces), reproducer as in the previous patch
(multicast joins and leaves on both ports plus VLAN add and delete,
120 seconds per run). On the TI vendor kernel 6.18, which has the same
table access code, the previous patch alone failed in 1 of 29 runs and
this patch alone, without the lock, failed in the first run with torn
entries. With both patches 400 runs passed, and the retry corrected
mismatching reads at index 0 and index 64. On net v7.4-rc3 with both
patches 60 runs passed.

Tooling: this patch and its changelog were prepared with an AI coding
assistant (Claude).

Fixes: db82173f23c5 ("netdev: driver: ethernet: add cpsw address lookup engine support")
Signed-off-by: Manuel Janocha <manuel.janocha@amperfied.com>
---
 drivers/net/ethernet/ti/cpsw_ale.c | 31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
index 8434803335d5..bef324bc171e 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.c
+++ b/drivers/net/ethernet/ti/cpsw_ale.c
@@ -339,17 +339,42 @@ static inline void cpsw_ale_set_addr(u32 *ale_entry, const u8 *addr)
 		cpsw_ale_set_field(ale_entry, 40 - 8*i, 8, addr[i]);
 }
 
-static int cpsw_ale_read(struct cpsw_ale *ale, int idx, u32 *ale_entry)
+/*
+ * A table read occasionally returns the entry of another index or all
+ * zeros. Reading the data words again does not help, but writing the
+ * index again and reading returns the right entry. Either of two
+ * consecutive reads can be the wrong one, so read twice and compare.
+ */
+#define ALE_TABLE_READ_RETRIES	4
+
+static void cpsw_ale_read_entry(struct cpsw_ale *ale, int idx, u32 *ale_entry)
 {
 	int i;
 
-	WARN_ON(idx > ale->params.ale_entries);
-
 	writel_relaxed(idx, ale->params.ale_regs + ALE_TABLE_CONTROL);
 
 	for (i = 0; i < ALE_ENTRY_WORDS; i++)
 		ale_entry[i] = readl_relaxed(ale->params.ale_regs +
 					     ALE_TABLE + 4 * i);
+}
+
+static int cpsw_ale_read(struct cpsw_ale *ale, int idx, u32 *ale_entry)
+{
+	u32 prev[ALE_ENTRY_WORDS];
+	int tries;
+
+	WARN_ON(idx > ale->params.ale_entries);
+
+	for (tries = 0; tries < ALE_TABLE_READ_RETRIES; tries++) {
+		cpsw_ale_read_entry(ale, idx, prev);
+		cpsw_ale_read_entry(ale, idx, ale_entry);
+		if (!memcmp(prev, ale_entry, sizeof(prev)))
+			return idx;
+	}
+
+	dev_warn_ratelimited(ale->params.dev,
+			     "ALE table read of entry %d did not stabilize\n",
+			     idx);
 
 	return idx;
 }

-- 
2.34.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net v2 1/2] net: ethernet: ti: cpsw_ale: serialize ALE table accesses
  2026-11-30 20:34 ` [PATCH net v2 1/2] net: ethernet: ti: cpsw_ale: serialize ALE table accesses Manuel Janocha via B4 Relay
@ 2026-12-01 20:35   ` netdev-bot+sashiko
  0 siblings, 0 replies; 5+ messages in thread
From: netdev-bot+sashiko @ 2026-12-01 20:35 UTC (permalink / raw)
  To: manuel.janocha
  Cc: s-vadapalli, rogerq, andrew+netdev, davem, edumazet, kuba, pabeni,
	linux-omap, netdev, kuniyu, stable

Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 2

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 new spinlock is always taken with spin_lock_irqsave() and
  held across one or more full scans of the ALE table.
- [Low] The patch fixes two races but the Fixes: tag covers only one.
- [Low] The new field comment in struct cpsw_ale (cpsw_ale.h:99, '/*
  serializes access to the ALE table registers */') describes less than…

--

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_irqsave() in every exported function that touches the ALE
table, and around the read-modify-write in cpsw_ale_control_set(). The
locked body of cpsw_ale_add_vlan() moves into a new
__cpsw_ale_add_vlan() helper, so that cpsw_ale_vlan_add_modify() can
call it with the lock already held.

> diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
> index 9304405c9581a..8434803335d5b 100644
> --- a/drivers/net/ethernet/ti/cpsw_ale.c
> +++ b/drivers/net/ethernet/ti/cpsw_ale.c
> @@ -462,8 +462,10 @@ static void cpsw_ale_flush_mcast(struct cpsw_ale *ale, u32 *ale_entry,
>  int cpsw_ale_flush_multicast(struct cpsw_ale *ale, int port_mask, int vid)
>  {
>  	u32 ale_entry[ALE_ENTRY_WORDS];
> +	unsigned long irq_flags;
>  	int ret, idx;
>  
> +	spin_lock_irqsave(&ale->lock, irq_flags);
>  	for (idx = 0; idx < ale->params.ale_entries; idx++) {
>  		cpsw_ale_read(ale, idx, ale_entry);
>  		ret = cpsw_ale_get_entry_type(ale_entry);

[Severity: Medium]
On non-PREEMPT_RT kernels, does taking ale->lock with spin_lock_irqsave()
here keep local hard interrupts disabled for a whole ALE table walk?

Before this patch the am65-cpsw rx_mode path ran only under
netif_addr_lock_bh(), so hard IRQs stayed enabled. With this patch each
call of am65_cpsw_nuss_ndo_slave_set_rx_mode() does:

  cpsw_ale_set_allmulti()     full table scan, IRQs off
  cpsw_ale_flush_multicast()  full table read and write-back, IRQs off
  cpsw_ale_add_mcast()        once per mc address, up to three scans
                              (match_addr, match_free, find_ageable)
                              in one IRQ-off section

An unprivileged user can reach this path, and it does not take RTNL:

  setsockopt(IPV6_ADD_MEMBERSHIP)
    igmp6_group_added()
      dev_mc_add()
        am65_cpsw_nuss_ndo_slave_set_rx_mode()

cpsw_ale_vlan_add_modify() first calls cpsw_ale_match_vlan(). It then
calls __cpsw_ale_add_vlan(), which runs match_vlan, match_free and
find_ageable again, all in the same IRQ-off section. The changelog
measured up to 1.1 ms there on the 512-entry AM625 table.

cpsw_ale_dump() and cpsw_ale_restore() also walk the whole table with
IRQs off. They are called from ethtool get_regs and from
suspend/resume.

NetCP NU ALEs read their table size from ALE_STATUS in multiples of
1024 entries, so the scans there can take longer still.

The later commit "net: ethernet: ti: cpsw_ale: verify ALE table reads"
makes each cpsw_ale_read() at least two index writes and six data
reads. By the end of the series each of these IRQ-off windows is at
least twice as long.

The irqsave variant seems to be needed only for netcp_rx_add_vid() and
netcp_rx_kill_vid(), which already hold netcp->lock with IRQs off.

The changelog says:

  "That is VLAN configuration, not the data path"

and:

  "just not preemptible by the other port"

It does not say that hard IRQs are now off for the whole scan. Is this
interrupt latency intended? If so, could the changelog say so? If not,
could the lock be taken so that the am65-cpsw paths avoid long hard
IRQ-off windows?

[ ... ]

> @@ -1160,9 +1217,11 @@ int cpsw_ale_control_set(struct cpsw_ale *ale, int port, int control,
>  	offset = info->offset + (port * info->port_offset);
>  	shift  = info->shift  + (port * info->port_shift);
>  
> +	spin_lock_irqsave(&ale->lock, irq_flags);
>  	tmp = readl_relaxed(ale->params.ale_regs + offset);
>  	tmp = (tmp & ~(mask << shift)) | (value << shift);
>  	writel_relaxed(tmp, ale->params.ale_regs + offset);
> +	spin_unlock_irqrestore(&ale->lock, irq_flags);
>  
>  	return 0;
>  }

[Severity: Low]
The Fixes: tag points to 1767bb2d47b7 ("ipv6: mcast: Don't hold RTNL
for IPV6_ADD_MEMBERSHIP and MCAST_JOIN_GROUP."). That commit explains
the ALE table race. Does the lost-update race in cpsw_ale_control_set()
depend on it?

cpsw_ale_timer() runs in timer softirq and calls:

    cpsw_ale_control_set(ale, 0, ALE_AGEOUT, 1);

RTNL does not exclude this timer. cpsw_ale_aging_start() arms it for
every ALE without CPSW_ALE_F_HW_AUTOAGING, including legacy cpsw and
cpsw_new. The changelog says those two drivers "are not affected in
practice".

The phylink resolve work also does not run under RTNL. It calls
am65_cpsw_nuss_mac_link_up() and am65_cpsw_nuss_mac_link_down(), which
set ALE_PORT_STATE with a read-modify-write of the same ALE_PORTCTL word
that am65_cpsw_slave_set_promisc() changes for ALE_PORT_MACONLY_CAF.

Stable trees without 1767bb2d47b7 (6.12, 6.6, 6.1 and so on) would not
get this part of the fix. Could the cpsw_ale_control_set() change go
into a separate patch with its own Fixes: tag? Alternatively, the
changelog could say that this part fixes an older bug.

[ ... ]

> diff --git a/drivers/net/ethernet/ti/cpsw_ale.h b/drivers/net/ethernet/ti/cpsw_ale.h
> index 87b7d1b3a34a9..8e47261161fea 100644
> --- a/drivers/net/ethernet/ti/cpsw_ale.h
> +++ b/drivers/net/ethernet/ti/cpsw_ale.h
> @@ -96,6 +96,8 @@ 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 registers */
> +	spinlock_t		lock;
>  };

[Severity: Low]
This isn't a bug, but the comment describes less than the lock actually
protects. Besides the table registers, the code also relies on
ale->lock for:

  - the read-modify-write of non-table registers in
    cpsw_ale_control_set() (ALE_CONTROL, ALE_UNKNOWNVLAN*,
    ALE_PORTCTL(n), AM65_CPSW_ALE_THREAD_DEF_REG)
  - the read-modify-write of ALE_VLAN_MASK_MUX(idx) in
    cpsw_ale_vlan_set_unreg_mcast_idx(), and the writes in
    cpsw_ale_set_vlan_mcast()
  - the non-atomic bitmap_set() and bitmap_clear() on
    ale->p0_untag_vid_mask in cpsw_ale_set_vlan_untag()

The later commit "net: ethernet: ti: cpsw_ale: verify ALE table reads"
leaves the comment unchanged. Could the comment be extended to cover
these as well?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130-cpsw-ale-lock-v2-0-c7a59d2178bb%40amperfied.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net v2 2/2] net: ethernet: ti: cpsw_ale: verify ALE table reads
  2026-11-30 20:34 ` [PATCH net v2 2/2] net: ethernet: ti: cpsw_ale: verify ALE table reads Manuel Janocha via B4 Relay
@ 2026-12-01 20:35   ` netdev-bot+sashiko
  0 siblings, 0 replies; 5+ messages in thread
From: netdev-bot+sashiko @ 2026-12-01 20:35 UTC (permalink / raw)
  To: manuel.janocha
  Cc: s-vadapalli, rogerq, andrew+netdev, davem, edumazet, kuba, pabeni,
	linux-omap, netdev, kuniyu, stable

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · 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 patch applies an erratum workaround to every ALE variant,
  but the commit message only gives evidence for some of them.
- [Medium] When all ALE_TABLE_READ_RETRIES (4) read pairs disagree,
  cpsw_ale_read() (cpsw_ale.c:361-380) logs dev_warn_ratelimited() and…

--

net: ethernet: ti: cpsw_ale: verify ALE table reads

This patch addresses ALE table reads on AM62x (CPSW3G) that sometimes
return another index's entry or all zeros. cpsw_ale_read() now reads each
entry twice, writing the index before each read, and retries until both
reads match. After four failed tries it warns (ratelimited) and returns
the last read.

> diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
> index 8434803335d5b..bef324bc171ea 100644
> --- a/drivers/net/ethernet/ti/cpsw_ale.c
> +++ b/drivers/net/ethernet/ti/cpsw_ale.c

[ ... ]

> +static int cpsw_ale_read(struct cpsw_ale *ale, int idx, u32 *ale_entry)
> +{
> +	u32 prev[ALE_ENTRY_WORDS];
> +	int tries;
> +
> +	WARN_ON(idx > ale->params.ale_entries);
> +
> +	for (tries = 0; tries < ALE_TABLE_READ_RETRIES; tries++) {
> +		cpsw_ale_read_entry(ale, idx, prev);
> +		cpsw_ale_read_entry(ale, idx, ale_entry);

[Severity: Medium]
Should this workaround be limited to the ALE variants that are known to be
affected?

The commit message describes the problem on AM62x, which uses the
am64-cpswxg ALE, and cites EXT_EP-12856 for the J7 CPSW. cpsw_ale_read()
is the only table read path for every user of the ALE library, though.
That includes these entries in cpsw_ale_id_match[]:

	.dev_id = "cpsw",
	.tbl_entries = 1024,
	...
	.dev_id = "66ak2h-xgbe",
	.tbl_entries = 2048,
	...
	.dev_id = "66ak2el",
	.dev_id = "66ak2g",
	.dev_id = "am65x-cpsw2g",

These are AM335x/AM437x/DRA7/DM814x, Keystone NetCP and AM65x. On all of
them, every table read now costs at least two index writes and six data
reads instead of one and three. On the retry path it can reach eight
writes and 24 reads.

With the previous patch in the series, the full table scans in
cpsw_ale_match_free(), cpsw_ale_flush_multicast(),
cpsw_ale_vlan_add_modify() and similar functions run under
spin_lock_irqsave(&ale->lock). On the 1024 and 2048 entry tables the extra
cost is therefore spent with interrupts disabled.

The commit message does not say these variants are affected or that they
were tested. Could the per-variant .features field in cpsw_ale_id_match[]
or the am65-cpsw pdata quirks be used to enable this only where it is
needed?

There is also the Fixes: tag:

    Fixes: db82173f23c5 ("netdev: driver: ethernet: add cpsw address lookup engine support")

That is the original 2012 AM335x cpsw ALE commit. The tag implies the
erratum has existed on all CPSW hardware since then, and it would bring
the doubled cost to every CPSW/NetCP platform in stable. Is that the
intended target for the tag?

> +		if (!memcmp(prev, ale_entry, sizeof(prev)))
> +			return idx;
> +	}
> +
> +	dev_warn_ratelimited(ale->params.dev,
> +			     "ALE table read of entry %d did not stabilize\n",
> +			     idx);
>  
>  	return idx;
>  }

[Severity: Medium]
When all four read pairs disagree, the give-up path returns the same
value as a verified read and leaves the last unverified read in
ale_entry[]. No caller checks the return value. Can the problem this
patch fixes still happen on that path?

cpsw_ale_match_free() still accepts any entry whose type field reads as
free:

	for (idx = 0; idx < ale->params.ale_entries; idx++) {
		cpsw_ale_read(ale, idx, ale_entry);
		type = cpsw_ale_get_entry_type(ale_entry);
		if (type == ALE_TYPE_FREE)
			return idx;
	}

If the last read of the untagged VLAN entry is all zeros, that index is
still handed to cpsw_ale_add_mcast(), cpsw_ale_add_ucast() or
__cpsw_ale_add_vlan(), and cpsw_ale_write() overwrites the live entry.

The read-modify-write loops are affected too. cpsw_ale_set_unreg_mcast(),
cpsw_ale_set_allmulti() and cpsw_ale_flush_multicast() write the buffer
back to idx for every VLAN or address entry. cpsw_ale_add_mcast(),
cpsw_ale_del_mcast() and cpsw_ale_vlan_add_modify() do the same for a
matched index. If the buffer holds another index's entry, writing it to
idx loses one entry and duplicates another.

On am65-cpsw, cpsw_ale_dump() saves the table into common->ale_context at
suspend, and cpsw_ale_restore() writes all of it back at resume. A bad
read there becomes a persistent wrong entry.

The two-read comparison also only catches wrong reads that differ from
each other. If both reads in a pair latch the same wrong value, such as
all zeros, the memcmp() passes. The commit message says that in testing
one of the two reads was wrong, but it does not rule this case out.

cpsw_ale_read() already returns int. Could it return an error such as
-EIO on the give-up path? cpsw_ale_match_free() and
cpsw_ale_match_ageable() could then skip that index, and the
read-modify-write loops could skip the write-back. The hardware entry
would then be left as it is.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130-cpsw-ale-lock-v2-0-c7a59d2178bb%40amperfied.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-12-01 20:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 20:34 [PATCH net v2 0/2] net: ethernet: ti: cpsw_ale: fix lost ALE entries Manuel Janocha via B4 Relay
2026-11-30 20:34 ` [PATCH net v2 1/2] net: ethernet: ti: cpsw_ale: serialize ALE table accesses Manuel Janocha via B4 Relay
2026-12-01 20:35   ` netdev-bot+sashiko
2026-11-30 20:34 ` [PATCH net v2 2/2] net: ethernet: ti: cpsw_ale: verify ALE table reads Manuel Janocha via B4 Relay
2026-12-01 20:35   ` netdev-bot+sashiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox