🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #2053

Re: [PATCH net-next] net: dsa: motorcomm: Do not do the redundant MIB clear

#2053
From: netdev-bot+sashiko
Date: Sun, 11 Oct 2026 23:11
89 lines
9022 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · 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] The commit message's last paragraph gives a reason why the
  removed MIB clear needs no replacement anywhere else, and both parts…

--

net: dsa: motorcomm: Do not do the redundant MIB clear

This patch removes the MIB clear from yt921x_chip_setup(). The commit
message argues it is redundant because a hardware reset happens right
before it. It also argues that nothing else needs to handle MIB state,
because per-port state is always freshly allocated.

> Nor should we take care of it elsewhere: .port_setup() should not clear
> it, and .setup() runs at most once per registration, so per-port state
> is always freshly allocated by .port_setup().

[Severity: Medium]
Is this paragraph accurate? Both of its claims seem to conflict with the
DSA core and with the driver's own port setup code.

On ".setup() runs at most once per registration": in net/dsa/dsa.c,
dsa_switch_remove() calls dsa_tree_teardown() on the whole tree. That
reaches dsa_switch_teardown() for every member switch, which does:

    ds->setup = false;

When the removed switch probes again, the call chain is:

dsa_switch_probe()->dsa_tree_setup()->dsa_switch_setup()
    err = ds->ops->setup(ds);

This runs for every switch in the tree, including a yt921x that never
unregistered.

On "per-port state is always freshly allocated by .port_setup()":
yt921x_dsa_port_setup() only allocates the MIB block when none exists:

    if (!pm && (BIT(port) & yt921x_info_ports_mask(info))) {
        pm = devm_kzalloc(dev, sizeof(*pm), GFP_KERNEL);
        ...
        /* Start disabled, so that the enable below always pairs with
         * either this disable or the one from a previous teardown
         */

yt921x_dsa_port_teardown() deliberately keeps the block:

    /* get_stats64() might not be synchronized with port_teardown(), hold
     * the MIB block till the device teardown
     */

So on a second .setup() within one registration, yt921x_dsa_setup() calls
yt921x_chip_reset(). Per this commit message, that zeroes the hardware
counters. pm->data[] and pm->stats still hold the old accumulated values.

yt921x_mib_read() says "MIB buffer must be zeroed before" and extends the
32-bit counters like this:

    val = (old_val & ~(u64)U32_MAX) | val0;
    if (val < old_val)
        val += 1ull << 32;

After a re-setup, won't the first poll treat the reset counters as a wrap?
That would add about 2^32 to each 32-bit counter. The 64-bit counters would
go backwards to small values. These values then show up in get_stats64,
ethtool -S and the rmon/mac/pause stats.

The removed write to YT921X_MIB_CTRL never cleared the software buffer, so
this patch does not change runtime behaviour here. The concern is that the
commit message says no handling is needed, based on invariants the code does
not appear to guarantee.

Could the commit message be corrected? Alternatively, should
yt921x_dsa_port_setup() clear pm->data and pm->stats when it reuses an
existing block, since every .setup() hard-resets the chip?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261010231015.2600207-1-mmyangfl%40gmail.com
Technical Details
Message-ID: <179176030531.434549.15766940452679334921@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-344639-linux-kernel-netdev=dewy.ru
References: <20261010231015.2600207-1-mmyangfl@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-344639-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next] net: dsa: motorcomm: Do not do the redundant MIB clear
Date: Sun, 11 Oct 2026 23:11:45 +0000
Organization: Usenet Network
Message-ID: <179176030531.434549.15766940452679334921@kernel.org>
References: <20261010231015.2600207-1-mmyangfl@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1639484"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:9GVtr/y6HoTAK/qndwQOF4IJe/I= sha256:/txywRyhi4uX8wW9ShecSj4Q/2bt2ftya0eL7Q+7xX8=
	sha1:YlVui9SiT/fMo1klgMG7Maljxqo= sha256:SxiIhHhax+CeC7YEQP/tLbyWfiMeu7smYXaZWd/t21c=
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 A3D9C10FA96; Mon, 12 Oct 2026 02:12:00 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.74
X-Spam-Status: No, score=-3.74 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.241, 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 M4AdoL31H2NE;
	Mon, 12 Oct 2026 02:11:57 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-344639-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 92EE710F9B5; Mon, 12 Oct 2026 02:11:50 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sto.lore.kernel.org (Postfix) with ESMTP id 9B1D9602C68; Sun, 11 Oct 2026 23:11:49 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id DBC58469857;
	Sun, 11 Oct 2026 23:11:47 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BWF7aSUp"
X-Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id C787C314D13;
	Sun, 11 Oct 2026 23:11:46 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1791760307; cv=none; b=AMMNNqwfkKoF31NTTgjM7SluSVk0i/Ck7XlzY2ZrpvfD6wSxyYrgruOgsD486QxFfPXdZlzdeJJ5lZJmuawlfNB4BZ1ASzSL9/ZDRlPqwTvtD3j+uezU/bseVsYmOVn7NpE3SsCiVAA6+k7S4j59ILpziptX1YUhpwvj3rPyYEw=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1791760307; c=relaxed/simple;
	bh=L6t6eTegQPAOeQuhMTa9PTtwUFRsC5wObH5Mjwu7cEU=;
	h=Subject:From:To:Cc:Date:Message-ID:In-Reply-To:References:
	 Content-Type:MIME-Version; b=TrqKdVCZAQjMpi0cSXjHUlpC0kfXpfvdDvj3GjGUAlvVFofPO0+VH9oMA5I4Z/Zuapf64N4UH3jGfhBcW1Z9evJ8qbHAm9cgwK3DnndgnKuHZBA4jZtB+E1qaJyk2Q5K4AhMABCojlhRUB+MmIppcce4RelUiPFD+t530gBm2ac=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BWF7aSUp; arc=none smtp.client-ip=100.103.45.18
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id C497B1F0089B;
	Sun, 11 Oct 2026 23:11:45 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1791760306;
	bh=z5pOc8cLCfkjIfWcLR1xQNYyoRYgZOxxSZvfhh7g+Nc=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=BWF7aSUpJoro1SGTcMPhW+z8A6y0pcfbt5YtNCSu4Y+b3dTSe5DgVmjIFhGwqdeRD
	 4UxglLlBEH2hl7czxokmhf6nJSOHj4mM/cwH7VeLsVXfkRrYh18Jgmg0g7mJCaZ5pk
	 ZnefNlgrBLf0sSGmsjOy0VvO//amgmTlPW46LGmyV7fUhj/R2EbBSDCQjzDla9qA1J
	 0BUGZWkBSelqCiSQDGKCENIpeiH/xcXu/jBBillE027vC4h65xp+8MhMMG9gxWwSCQ
	 hROGFu3SlnoFGCOKJr+QRBJvBx2oItZtiQzXMYYnR8XmfHrxStEV3r+g299o87dSRR
	 PRjfB2fVRD9CQ==
X-Cc: netdev@vger.kernel.org, andrew@lunn.ch, olteanv@gmail.com,
 davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 linux-kernel@vger.kernel.org
X-In-Reply-To: <20261010231015.2600207-1-mmyangfl@gmail.com>
X-sashiko-severity: Medium
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>