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

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