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, vigneshr@ti.com, linux-omap@vger.kernel.org,
netdev@vger.kernel.org, kuniyu@google.com
Subject: Re: [PATCH net v3 4/4] net: ethernet: ti: cpsw_ale: verify ALE table reads
Date: Thu, 03 Dec 2026 10:57:18 +0000 [thread overview]
Message-ID: <179629543898.3146.12845633090160671237@kernel.org> (raw)
In-Reply-To: <20261202-cpsw-ale-lock-v3-4-b40dc361d6b9@amperfied.com>
Thank you for your contribution! Sashiko AI review found 6 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 4 · 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] cpsw_ale_dump() ignores the new -EIO from cpsw_ale_read() and
keeps the last unverified read in the dump buffer.
- [Medium] The new -EIO give-up path in the delete helpers leaves the ALE
entry, and its p0_untag_vid_mask bit, in place, while the am65 callers…
- [Medium] am65_cpsw_nuss_ndo_slave_set_mac_address() (am65-cpsw-
nuss.c:1778-1784) ignores the returns of cpsw_ale_del_ucast() and…
- [Medium] CPSW_ALE_F_TBL_READ_VERIFY is added to the "am64-cpswxg" entry
of cpsw_ale_id_match[] (cpsw_ale.c:1586).
- [Low] cpsw_ale_flush_multicast(), cpsw_ale_set_unreg_mcast() and
cpsw_ale_set_allmulti() now `continue` past any index whose verified…
- [Low] cpsw_ale_read() accepts an entry as soon as two back-to-back
reads match (memcmp(prev, ale_entry) == 0).
--
net: ethernet: ti: cpsw_ale: verify ALE table reads
This patch adds a CPSW_ALE_F_TBL_READ_VERIFY feature flag for the
am64-cpswxg ALE. With the flag set, each table read is done twice, and
the pair is retried until both reads match. After four failed tries the
read returns -EIO. The callers of cpsw_ale_read() are changed to return
-EIO or to skip the unreadable index.
> diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
> index 69861d451ce41..d2a718ebdf609 100644
> --- a/drivers/net/ethernet/ti/cpsw_ale.c
> +++ b/drivers/net/ethernet/ti/cpsw_ale.c
[ ... ]
> +/* Returns idx, or -EIO if the entry could not be read reliably */
> +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);
> +
> + if (!(ale->features & CPSW_ALE_F_TBL_READ_VERIFY)) {
> + cpsw_ale_read_entry(ale, idx, ale_entry);
> + return idx;
> + }
> +
> + 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;
> + }
[Severity: Low]
The commit message names all zeros as one of the misread modes. If both
reads of a live entry return zeros, memcmp() matches and the entry is
accepted, and it decodes as ALE_TYPE_FREE.
cpsw_ale_match_free() then hands out that index based only on the type
check:
type = cpsw_ale_get_entry_type(ale_entry);
if (type == ALE_TYPE_FREE)
return idx;
The next cpsw_ale_add_mcast(), cpsw_ale_add_ucast() or
__cpsw_ale_add_vlan() would then overwrite the live entry. That is the
untagged VLAN failure described in the changelog.
The changelog acknowledges this limit and supports it only with "In
testing the two reads of a failing pair differed". Could the free-slot
path get an extra check, since that is where a false FREE does damage?
For example, the chosen index could be re-read just before the write, or
more agreeing reads could be required there.
> +
> + dev_warn_ratelimited(ale->params.dev,
> + "ALE table read of entry %d did not stabilize\n",
> + idx);
> +
> + return -EIO;
> }
[Severity: Medium]
When this returns -EIO, what happens to the data left behind for
cpsw_ale_dump()? It ignores the return value:
drivers/net/ethernet/ti/cpsw_ale.c:cpsw_ale_dump() {
...
for (i = 0; i < ale->params.ale_entries; i++) {
cpsw_ale_read(ale, i, data);
data += ALE_ENTRY_WORDS;
}
...
}
The buffer then holds the second read of the last mismatching pair.
That value is known to be unreliable: it can be all zeros or another
index's entry.
On am64-cpswxg this buffer is written back to hardware on resume:
am65_cpsw_nuss_suspend()
cpsw_ale_dump(common->ale, common->ale_context)
cpsw_ale_read() returns -EIO, which is ignored
am65_cpsw_nuss_resume()
cpsw_ale_restore(common->ale, common->ale_context)
cpsw_ale_write() on every index, with no check
Suppose the give-up path hits the index of the untagged VLAN during
suspend. Could resume then free or replace that entry, which is the
failure this patch is meant to prevent?
The changelog says "The callers leave the hardware entry alone in that
case" and "cpsw_ale_dump() cannot report an error and keeps what was
read". It doesn't mention the write-back in cpsw_ale_restore().
[ ... ]
> @@ -466,7 +502,8 @@ int cpsw_ale_flush_multicast(struct cpsw_ale *ale, int port_mask, int vid)
>
> spin_lock_bh(&ale->lock);
> for (idx = 0; idx < ale->params.ale_entries; idx++) {
> - cpsw_ale_read(ale, idx, ale_entry);
> + if (cpsw_ale_read(ale, idx, ale_entry) < 0)
> + continue;
[Severity: Low]
With this continue, an index whose read gave up keeps its old port mask
in hardware, and cpsw_ale_flush_multicast() still returns 0. The new
skips in cpsw_ale_set_unreg_mcast() and cpsw_ale_set_allmulti() work the
same way, and both of those functions return void.
am65_cpsw_nuss_ndo_slave_set_rx_mode() calls cpsw_ale_set_allmulti() and
cpsw_ale_flush_multicast() and ignores both results. After a flush or an
allmulti change, can the ALE keep forwarding multicast to a port the
stack removed, or keep withholding flooding the stack enabled, until the
next rx_mode change?
The only signal is the ratelimited warning, and nothing re-applies the
change.
> ret = cpsw_ale_get_entry_type(ale_entry);
> if (ret != ALE_TYPE_ADDR && ret != ALE_TYPE_VLAN_ADDR)
> continue;
> @@ -524,6 +561,10 @@ int cpsw_ale_add_ucast(struct cpsw_ale *ale, const u8 *addr, int port,
>
> spin_lock_bh(&ale->lock);
> idx = cpsw_ale_match_addr(ale, addr, (flags & ALE_VLAN) ? vid : 0);
> + if (idx == -EIO) {
> + spin_unlock_bh(&ale->lock);
> + return -EIO;
> + }
[Severity: Medium]
Before this patch, cpsw_ale_add_ucast() could only fail with -ENOMEM,
and cpsw_ale_del_ucast() only with -ENOENT. Are the callers ready for
the new -EIO, which means nothing was written to hardware?
am65_cpsw_nuss_ndo_slave_set_mac_address() ignores both return values:
cpsw_ale_del_ucast(common->ale, ndev->dev_addr,
HOST_PORT_NUM, 0, 0);
cpsw_ale_add_ucast(common->ale, sockaddr->sa_data,
HOST_PORT_NUM, ALE_SECURE, 0);
am65_cpsw_port_set_sl_mac(port, addr);
eth_commit_mac_addr_change(ndev, sockaddr);
It then returns 0. If cpsw_ale_add_ucast() returns -EIO, the new MAC is
never programmed into the host port entry, yet the netdev reports the
new address. Could host unicast receive to the new MAC stop working in
that case?
am65_cpsw_nuss_ndo_slave_set_rx_mode() also ignores the result of
cpsw_ale_add_mcast(). An address on the netdev multicast list might
therefore never reach the ALE.
> if (idx < 0)
> idx = cpsw_ale_match_free(ale);
> if (idx < 0)
[ ... ]
> @@ -785,10 +840,13 @@ int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port_mask)
> idx = cpsw_ale_match_vlan(ale, vid);
> if (idx < 0) {
> spin_unlock_bh(&ale->lock);
> - return -ENOENT;
> + return idx;
> }
>
> - cpsw_ale_read(ale, idx, ale_entry);
> + if (cpsw_ale_read(ale, idx, ale_entry) < 0) {
> + spin_unlock_bh(&ale->lock);
> + return -EIO;
> + }
[Severity: Medium]
On this -EIO path the VLAN entry stays in the ALE. The call
cpsw_ale_set_vlan_untag(ale, ale_entry, vid, 0), which clears the
p0_untag_vid_mask bit, is also skipped. The same holds for the -EIO now
returned by cpsw_ale_del_ucast(), cpsw_ale_del_mcast() and
cpsw_ale_vlan_del_modify(). Do the am65 callers handle this?
am65_cpsw_nuss_ndo_slave_kill_vid() returns -EIO to the 8021q core,
which removes the VID from its software state anyway.
am65_cpsw_port_vlan_del() returns early when cpsw_ale_del_vlan() fails.
It then also skips deleting the host MAC ucast entry and the broadcast
mcast entry for that VID.
am65_cpsw_port_mdb_del() ignores the result and always returns 0, so the
bridge sees the MDB delete as successful:
/* Ignore error as error code is returned only when entry is already removed */
cpsw_ale_del_mcast(cpsw->ale, mdb->addr, del_mask,
ALE_VLAN, mdb->vid);
The SWITCHDEV_FDB_DEL_TO_DEVICE case in
am65_cpsw_switchdev_event_work() also ignores the return value of
cpsw_ale_del_ucast().
The comments in am65-cpsw-switchdev.c that justify ignoring these errors
("error is returned only if the unicast entry is not present", "error is
returned only if the multicast entry is not present", and the MDB one
above) are no longer accurate after this change.
Could this leave stale VLAN, unicast or multicast entries forwarding
traffic for state the stack considers removed? These entries would also
keep their table slots. cpsw_ale_match_free() never sees them as free,
and cpsw_ale_find_ageable() does not reclaim VLAN or multicast entries.
[ ... ]
> @@ -1518,7 +1584,8 @@ static const struct cpsw_ale_dev_id cpsw_ale_id_match[] = {
> },
> {
> .dev_id = "am64-cpswxg",
> - .features = CPSW_ALE_F_STATUS_REG | CPSW_ALE_F_HW_AUTOAGING,
> + .features = CPSW_ALE_F_STATUS_REG | CPSW_ALE_F_HW_AUTOAGING |
> + CPSW_ALE_F_TBL_READ_VERIFY,
[Severity: Medium]
The commit message says:
"Add the feature flag CPSW_ALE_F_TBL_READ_VERIFY and set it only for
am64-cpswxg."
and:
"The J7 variant was not tested and is left alone."
Is the "am64-cpswxg" ALE dev_id actually limited to AM64/AM62x? In
am65-cpsw-nuss.c, am64x_cpswxg_pdata, j722s_cpswxg_pdata,
j7200_cpswxg_pdata, j721e_cpswxg_pdata and j784s4_cpswxg_pdata all
select it, for example:
static const struct am65_cpsw_pdata j7200_cpswxg_pdata = {
.quirks = 0,
.ale_dev_id = "am64-cpswxg",
The "j721e-cpswxg" entry in cpsw_ale_id_match[] doesn't seem to have any
user under drivers/.
If so, the doubled reads, the longer ALE lock hold times in the table
loops, and the new -EIO and skip paths also apply on J7200, J721E
CPSW9G, J784S4 and J722S. The Fixes: tag points at the AM64 commit, so
stable backports would bring the same change to those SoCs.
Should the commit message describe this, or should the flag be scoped
differently?
> .reg_fields = ale_fields_cpsw_nu,
> .num_fields = ARRAY_SIZE(ale_fields_cpsw_nu),
> .vlan_entry_tbl = vlan_entry_k3_cpswxg,
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202-cpsw-ale-lock-v3-0-b40dc361d6b9%40amperfied.com
prev parent reply other threads:[~2026-12-03 10:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 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=179629543898.3146.12845633090160671237@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=vigneshr@ti.com \
/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