Linux on ARM based TI OMAP SoCs
 help / color / mirror / Atom feed
* [PATCH net v3 0/4] net: ethernet: ti: cpsw_ale: fix lost ALE entries
@ 2026-12-02 10:29 Manuel Janocha via B4 Relay
  2026-12-02 10:29 ` [PATCH net v3 1/4] net: netcp: do not disable interrupts in the VLAN callbacks Manuel Janocha via B4 Relay
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Manuel Janocha via B4 Relay @ 2026-12-02 10:29 UTC (permalink / raw)
  To: Siddharth Vadapalli, Roger Quadros, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Vignesh Raghavendra
  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:

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>



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

end of thread, other threads:[~2026-12-03 10:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 10:29 [PATCH net v3 0/4] net: ethernet: ti: cpsw_ale: fix lost ALE entries Manuel Janocha via B4 Relay
2026-12-02 10:29 ` [PATCH net v3 1/4] net: netcp: do not disable interrupts in the VLAN callbacks Manuel Janocha via B4 Relay
2026-12-03 10:57   ` netdev-bot+sashiko
2026-12-02 10:29 ` [PATCH net v3 2/4] net: ethernet: ti: cpsw_ale: serialize ALE table accesses Manuel Janocha via B4 Relay
2026-12-03 10:57   ` netdev-bot+sashiko
2026-12-02 10:29 ` [PATCH net v3 3/4] net: ethernet: ti: cpsw_ale: serialize control register updates Manuel Janocha via B4 Relay
2026-12-02 10:29 ` [PATCH net v3 4/4] net: ethernet: ti: cpsw_ale: verify ALE table reads Manuel Janocha via B4 Relay
2026-12-03 10:57   ` 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