From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796388454; b=zwEy7RpV9MrVYZ2yWcDfbTFnC1ohzQ/EqS4JVOFncwio8dGdCJS4g2GsY4TVmg+a9d21 mlM1xT4SdnZKkMCcv78ivQGPrzzFpA1iNuVCRRNRCiKVFlhaoJAL7NaCo4DIHW7gsnQPC RiSQv1eryIX7103Zk/EuAoafmuSamZBQhf9XgGKY4CZZCOqiVo3pAXZ/drkiRe0wUehod nJrWlYoH3WFudAn+emN2ZCCTeAqc77GplcoAPl3i2UMDHVN4I/b/Y2THfY4FyarO6ly4g tRQJZElW3sFKxUjUned7/3z8klmHzNBqG/LX0Bd81MwPjkB5I/JD6hP6skPQLUEU9tw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388454; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=rvNgTevriWKbKctKh7odqcIs/12l0Cpdpdssu5zIsSk=; b=OHVuxoQq0uP4353Qlz0ReQcUC5MUGLZd3HcqeFe7iFNMJbzDIvXEndYmzeFP8x/mWEoM YSpvoy1vq4A7cRz3xY9MocpG8DQV4PvbEa4ignoge8+uTTINT/YaCPxIKF8CxUDzlgsf6 2fafsVVu5Ohp29XZhyaia4TePmMJK4/M8fozYV3evBDSR6y9NpBgEjQMd1ss/C+Ongyap ETHY/WTG+MAuofISzk0JIHooXMqQhtBi05TqjsOkVxlSC+vx2wZ5ZxGybpN80uZ4C4rYS TPdikK0x9oI29Af7R+VI4o3NbEazIDvmWxevpvjAJLvK9Pd1k1Ieu4b4idcHB4w8org== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CcJKsxB5; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B0225606A332; Fri, 4 Dec 2026 12:47:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CcJKsxB5 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBB7F1F000CE; Fri, 4 Dec 2026 12:47:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796388454; bh=rvNgTevriWKbKctKh7odqcIs/12l0Cpdpdssu5zIsSk=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=CcJKsxB5ETLmO46BsLMXSe7OtDs4eEFVVU9D7BwbJLAqI0D8SQxIEI4yFowkuYCaY Eiqs+vtPpkRi5AwG4FouBeEg58ppVbTrR7Mo4/xo8FKvapwlU7OjZu8K59XW6hlUQx cM1XvzU9lb3Ewevt83DrrJrBuvaIS4g56hOVSHdgPwKWKCtsPTE61R2jk31UNz9y1B /BKmRewwY4Vk221DuvzQ01NAIk8Fjm4tPaa43rGLRRRqfKaA/wqykkbTLgrUJuf6NQ 3VEGn8s1vndVXNWHqtHNxjXdsl3mUF3UH4buYZqYEFCl6B3LZtDeVdKbO9H1MjtoRt TtU3enQ4SimBw== Subject: Re: [PATCH net v4 4/4] net: ethernet: ti: cpsw_ale: verify ALE table reads 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 Date: Fri, 04 Dec 2026 12:47:33 +0000 Message-ID: <179638845330.3146.9315395558299268483@kernel.org> In-Reply-To: <20261203-cpsw-ale-lock-v4-4-4ecfbc4bb042@amperfied.com> References: <20261203-cpsw-ale-lock-v4-4-4ecfbc4bb042@amperfied.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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/20261203-cpsw-ale-lock-v4-0-4ecfbc4bb042%40amperfied.com