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/2026…%40amperfied.com