Linux on ARM based TI OMAP SoCs
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: manuel.janocha@amperfied.com
Cc: s-vadapalli@ti.com, rogerq@kernel.org, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, linux-omap@vger.kernel.org,
	netdev@vger.kernel.org, kuniyu@google.com,
	stable@vger.kernel.org
Subject: Re: [PATCH net v2 2/2] net: ethernet: ti: cpsw_ale: verify ALE table reads
Date: Tue, 01 Dec 2026 20:35:54 +0000	[thread overview]
Message-ID: <179615735433.3146.6015574901215340118@kernel.org> (raw)
In-Reply-To: <20261130-cpsw-ale-lock-v2-2-c7a59d2178bb@amperfied.com>

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

      reply	other threads:[~2026-12-01 20:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179615735433.3146.6015574901215340118@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=manuel.janocha@amperfied.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rogerq@kernel.org \
    --cc=s-vadapalli@ti.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox