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=1796157355; b=4oXBUsUNR7XndQNHroS3ucYi+Cf7V1Y8XuECxMlgeYQhkISuQng5alrGbme2cIi39YCS 3WkDxUz39/SvKSV4VYCB8xQcOin2Z1MSiwBY9hjaDzRvfuFVSuknb2W1Z87bKRG8g20nD +kNlb+s5MakSUiXBguX7G1p2rJFsFkhKiye1TVDElk9acOvw5C6xgJGZdVbyfj4u5nSJU 4Eiuv6V++TQPB/vnki/OZs9cQMHzI6TxSgE/1ipK6rwKNkFphcLP2BzgmYCCJkF4yFt67 iShTOSCeOD2EJY8uhZ0UuTxHmp5bmACAsO4J9aUQnW7DWHphhS7y8sFIij1S5iA6uEg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796157355; 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=Yfa3ZM2BEwTvzCV/U5LjizJ0u41oYkEKltXWvF+NbAU=; b=Q/9G7Tq4Le8BaOcFPt9lPm2MtBZ82J51udPIE1w/AtR7B/4tQnYDlY/wXmL48VjzGxJi qFEbnATamA8ObaVaoq90zQQYl7KwvUJp6SIFkK3HzAiKxP+ry8UH69VbRckpofSrMgzE6 sQdQR9YIdQNdgfozySsazxOmZbuASjQEQTPu1UNtx9drjySCsqQyZVtHb6e5EkXABPBw+ bv6tZO4dY4YILZ66Ie9/U0A0OuwEYFcQLKj/oPnQWmoxJp7z0GGXyETsqbGvC/4O6eqYN kO/p0ah1xYbynIkQJX7YDpIKsxzQn0S0rQ7G+p3YcOnUNGC5sl4sEFQDdSaWt8/WHiw== 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=FPgd4j7Q; 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 75765606A32D; Tue, 1 Dec 2026 20:35:55 +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=FPgd4j7Q Received: by smtp.kernel.org (Postfix) with ESMTPSA id B688A1F000C1; Tue, 1 Dec 2026 20:35:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796157355; bh=Yfa3ZM2BEwTvzCV/U5LjizJ0u41oYkEKltXWvF+NbAU=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=FPgd4j7QgeTZqDkZsyR/P4LRFckPhftEmiuY5XuU4XAWX2i83LMrvRzdq7oHzrtOt 04l7tOU/d6UXGNeBXwTMfg8xiqydL3vZR6+7KX4sHLFR+F/KwsLi4OpwTH2nrF0pEM VfvY/GOwRaJW2NkXY57SidrhWdMX3hOXeJqUo40ZapDx940gbegZV/5RN4vw//rvdb zs7xJxRT/tIcMi4GT6eyX/sq1/seYMYMiyx/HJvX/PXRVUH5AQXpAkfxdtqHX+qL1D GxArfPnVB5Ltuf8U86En7FLxgt3loqns0BCZ3lu+YVbZu1bbAawuqmcUBSZy3YQ0Qe 2b4wGguMXCyVQ== Subject: Re: [PATCH net v2 2/2] 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, linux-omap@vger.kernel.org, netdev@vger.kernel.org, kuniyu@google.com, stable@vger.kernel.org Date: Tue, 01 Dec 2026 20:35:54 +0000 Message-ID: <179615735433.3146.6015574901215340118@kernel.org> In-Reply-To: <20261130-cpsw-ale-lock-v2-2-c7a59d2178bb@amperfied.com> References: <20261130-cpsw-ale-lock-v2-2-c7a59d2178bb@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 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/20261130-cpsw-ale-lock-v2-0-c7a59d2178bb%40amperfied.com