Article View: linux.kernel.netdev
Article #26932Re: [PATCH net v4 4/4] net: ethernet: ti: cpsw_ale: verify ALE table reads
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 12:47
Date: Fri, 04 Dec 2026 12:47
164 lines
13707 bytes
13707 bytes
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
Technical Details
Message-ID:
<179638845330.3146.9315395558299268483@kernel.org>Path:
mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377363-linux-kernel-netdev=dewy.ruReferences:
<20261203-cpsw-ale-lock-v4-4-4ecfbc4bb042@amperfied.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377363-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v4 4/4] net: ethernet: ti: cpsw_ale: verify ALE table reads Date: Fri, 04 Dec 2026 12:47:33 +0000 Organization: Usenet Network Message-ID: <179638845330.3146.9315395558299268483@kernel.org> References: <20261203-cpsw-ale-lock-v4-4-4ecfbc4bb042@amperfied.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2765194"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:Nieof6Si6vbBZrXjbYoQbc/GVQ8= sha256:4ARWgFkx7wONjW5ephegUi/r9f3Q5SpigoyByfbta8Q= sha1:xDKdqZIG67xcVbxxhDCQ+kiTN4k= sha256:YyGwpugRY+DJjZndJzIhS1BeX0RfD1Q88fPk83H3CFo= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 95509117BED; Fri, 4 Dec 2026 15:48:24 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.541 X-Spam-Status: No, score=-3.541 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ydkl5Q8rlmG8; Fri, 4 Dec 2026 15:48:21 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377363-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 54B39117BE6; Fri, 4 Dec 2026 15:48:13 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id BA7D983C37; Fri, 4 Dec 2026 12:47:40 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796388460; b=rK0qr6CsrR2cAQotqzemw8jgWqL//kpx10IC/b13wqE3sX+aG1ZmugyASSUXOnygPSx0 shPOw5lq0nK2SGj6K0iDAvr1icdrbG8VgpAscpm79wvoHe3GCBzyYDCHFrQTkcGQGTK1T bbpCyM6MwJDhEpDc3lBr8Gh2m7t6PNunpEse01ulyxd9A+jfUjbRQ3sXsGMEajkIvFuRz UgBHf856DZVDa3iGPti+8gjk9ik53sINR2CZey2FG9UPGrKNaRI5DrPBh1mamNFH5dtRl R2GGhEtosA4ZodAQUSpx2a6RXuma7wjz2EoU+vbFbIPaLdFDZ5JeRRFlxRQBG3s9vfw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388460; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=rvNgTevriWKbKctKh7odqcIs/12l0Cpdpdssu5zIsSk=; b=CDMrPfQjteFOCa+/zURnsDURmS5FLvN+WvD+2c8XIQ9NVyCiXk5qO3nmrM6g9O4veO/O /89q7OYPPMi/V8CAvnK7JOrA7t1At5/+DKDvgVkgPlRSY8F5ercQqwxaS/3GXMvuB1aTP mFMS7/a1/CoEtkvbwgeJv98WRb1oHqaiyPNBbzo7cV8ynl8x1SHjekHQsHu98mJqAdZ+G p8xYxeP9gPrZcDfjsMRyvuHj1fzy99xvtk+xc27W1W5FIeOn/jYiEjzUmSnC+Yq+UsLWl GKgBgU/bGWB62NaIIDHR6ktNbVnAiBPCX8ORHhmv42Zerx9+/cGwAvaVbD1LomKD9xA== X-ARC-Authentication-Results: i=2; 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=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8EF04606A334; Fri, 4 Dec 2026 12:47:40 +0000 (UTC) X-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 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-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== X-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== X-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 X-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) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBB7F1F000CE; Fri, 4 Dec 2026 12:47:33 +0000 (UTC) X-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== X-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 X-In-Reply-To: <20261203-cpsw-ale-lock-v4-4-4ecfbc4bb042@amperfied.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list