Linux on ARM based TI OMAP SoCs
 help / color / mirror / Atom feed
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 v4 4/4] net: ethernet: ti: cpsw_ale: verify ALE table reads
Date: Fri, 04 Dec 2026 12:47:33 +0000	[thread overview]
Message-ID: <179638845330.3146.9315395558299268483@kernel.org> (raw)
In-Reply-To: <20261203-cpsw-ale-lock-v4-4-4ecfbc4bb042@amperfied.com>

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

  reply	other threads:[~2026-12-04 12:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 12:14 [PATCH net v4 0/4] net: ethernet: ti: cpsw_ale: fix lost ALE entries Manuel Janocha via B4 Relay
2026-12-03 12:14 ` [PATCH net v4 1/4] net: netcp: do not disable interrupts in the VLAN callbacks Manuel Janocha via B4 Relay
2026-12-03 12:14 ` [PATCH net v4 2/4] net: ethernet: ti: cpsw_ale: serialize ALE table accesses Manuel Janocha via B4 Relay
2026-12-04 12:47   ` netdev-bot+sashiko
2026-12-03 12:14 ` [PATCH net v4 3/4] net: ethernet: ti: cpsw_ale: serialize control register updates Manuel Janocha via B4 Relay
2026-12-04 12:47   ` netdev-bot+sashiko
2026-12-04 13:18     ` Janocha, Manuel
2026-12-03 12:14 ` [PATCH net v4 4/4] net: ethernet: ti: cpsw_ale: verify ALE table reads Manuel Janocha via B4 Relay
2026-12-04 12:47   ` netdev-bot+sashiko [this message]
2026-12-04 13:18     ` Janocha, Manuel

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=179638845330.3146.9315395558299268483@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