Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 0 (1) · Medium: 1 · 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] This patch adds a new -EIO return to the cpsw_ale add, delete and modify paths for the case where a verified read never stabilizes. Pre-existing issues: - [High] This problem wasn't introduced by this patch, but am65_cpsw_nuss_probe() allocates common->ale_context with… -- net: ethernet: ti: cpsw_ale: verify ALE table reads The commit adds the feature flag CPSW_ALE_F_TBL_READ_VERIFY for the am64-cpswxg ALE. With the flag set, every table read is done twice and retried until both reads match. After four failed tries cpsw_ale_read() returns -EIO, and the add, delete, modify and dump paths in cpsw_ale.c now pass that -EIO back to their callers.
> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c > index 0ad6145822445..9c969f5af1b64 100644 > --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c > +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c > @@ -3723,7 +3723,10 @@ static int am65_cpsw_nuss_suspend(struct device *dev) > struct net_device *ndev; > int i, ret; > > - cpsw_ale_dump(common->ale, common->ale_context); > + ret = cpsw_ale_dump(common->ale, common->ale_context); > + if (ret) > + return ret; > +
[Severity: High] This is a pre-existing issue, but now that the suspend result depends on this dump: can common->ale_context be NULL here? am65_cpsw_nuss_probe() allocates it and does not check the result: drivers/net/ethernet/ti/am65-cpsw-nuss.c:am65_cpsw_nuss_probe() { ... common->ale_context = devm_kzalloc(dev, ale_entries * ALE_ENTRY_WORDS * sizeof(u32), GFP_KERNEL); ret = am65_cpsw_init_cpts(common); ... } If that allocation fails, probe still completes. On the next system suspend, this call chain writes through the NULL pointer: am65_cpsw_nuss_suspend()->cpsw_ale_dump()->cpsw_ale_read()->cpsw_ale_read_entry() On resume, cpsw_ale_restore(common->ale, common->ale_context) would also read through it. Should probe return -ENOMEM when this allocation fails?
> diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c > index 69861d451ce41..9d0d9fdb716c0 100644 > --- a/drivers/net/ethernet/ti/cpsw_ale.c > +++ b/drivers/net/ethernet/ti/cpsw_ale.c
[ ... ]
> @@ -397,7 +430,8 @@ static int cpsw_ale_match_vlan(struct cpsw_ale *ale, u16 vid) > int type, idx; > > 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) > + return -EIO; > type = cpsw_ale_get_entry_type(ale_entry); > if (type != ALE_TYPE_VLAN) > continue;
[ ... ]
> @@ -667,8 +717,10 @@ static int __cpsw_ale_add_vlan(struct cpsw_ale *ale, u16 vid, int port_mask, > int idx; > > idx = cpsw_ale_match_vlan(ale, vid); > - if (idx >= 0) > - cpsw_ale_read(ale, idx, ale_entry); > + if (idx == -EIO) > + return -EIO;
[Severity: Medium] Does this -EIO reach anything that acts on it? cpsw_ale_match_vlan() and cpsw_ale_match_addr() stop at the first index whose read fails. That index does not have to be the entry being looked up. When that happens, __cpsw_ale_add_vlan(), cpsw_ale_add_ucast() and cpsw_ale_add_mcast() return before cpsw_ale_match_free() or cpsw_ale_write() runs, so nothing is written to the table. The am65-cpsw-nuss callers that program the entries the port needs ignore the return value. For example, in am65_cpsw_nuss_common_open(): cpsw_ale_add_vlan(common->ale, 0, port_mask, port_mask, port_mask, port_mask & ~ALE_PORT_HOST); If this fails, no VID 0 entry exists and untagged receive is dead, but open still returns 0. That is the symptom the commit message describes as its motivation. am65_cpsw_nuss_ndo_slave_set_mac_address() ignores both results. It then commits the new MAC and returns 0: 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_nuss_ndo_slave_set_rx_mode() flushes the port from every mcast entry first and then ignores the result of each re-add: cpsw_ale_flush_multicast(common->ale, port_mask, -1); ... cpsw_ale_add_mcast(common->ale, ha->addr, port_mask, 0, 0, 0); When a re-add fails, that group is gone from hardware and nothing retries it. am65_cpsw_init_port_emac_ale(), am65_cpsw_init_port_switch_ale() and am65_cpsw_init_stp_ale_entry() also ignore the add_ucast/add_mcast results for the host MAC, broadcast and STP entries. The commit message says: After four unsuccessful tries warn (ratelimited) and return -EIO. The callers leave the hardware entry alone in that case: ... The add functions return -EIO without allocating a free slot or writing, the delete functions return -EIO instead of -ENOENT. That is true inside cpsw_ale.c. In am65-cpsw-nuss.c, where these entries are actually programmed, the error is dropped and the driver reports success. Should these callers propagate or retry on -EIO? Alternatively, should the match functions skip the unreadable index when it cannot be the entry being looked up?
> + if (idx >= 0 && cpsw_ale_read(ale, idx, ale_entry) < 0) > + return -EIO;
[ ... ]
-- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40amperfied.com