* [PATCH net-next] net: dsa: motorcomm: Do not do the redundant MIB clear
@ 2026-10-10 23:10 David Yang
2026-10-11 23:11 ` netdev-bot+sashiko
0 siblings, 1 reply; 2+ messages in thread
From: David Yang @ 2026-10-10 23:10 UTC (permalink / raw)
To: netdev
Cc: David Yang, Andrew Lunn, Vladimir Oltean, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-kernel
The MIB clear in yt921x_chip_setup() is redundant: it runs right after
hard reset of the hardware, which already zeroes MIB counters.
It did not execute the right procedure either: ALL_PORT must be lifted
from latched value before CLEAN is fired. It works only because the
reset lifts the MIB control register (and counters altogether).
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().
Signed-off-by: David Yang <mmyangfl@gmail.com>
---
drivers/net/dsa/motorcomm/chip.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
index 980d066a4bea..43e8af90ffc9 100644
--- a/drivers/net/dsa/motorcomm/chip.c
+++ b/drivers/net/dsa/motorcomm/chip.c
@@ -3996,12 +3996,6 @@ static int yt921x_chip_setup(struct yt921x_priv *priv)
return res;
#endif
- /* Clear MIB */
- ctrl = YT921X_MIB_CTRL_CLEAN | YT921X_MIB_CTRL_ALL_PORT;
- res = yt921x_reg_write(priv, YT921X_MIB_CTRL, ctrl);
- if (res)
- return res;
-
/* Miscellaneous */
res = yt921x_reg_set_bits(priv, YT921X_SENSOR, YT921X_SENSOR_TEMP);
if (res)
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] net: dsa: motorcomm: Do not do the redundant MIB clear
2026-10-10 23:10 [PATCH net-next] net: dsa: motorcomm: Do not do the redundant MIB clear David Yang
@ 2026-10-11 23:11 ` netdev-bot+sashiko
0 siblings, 0 replies; 2+ messages in thread
From: netdev-bot+sashiko @ 2026-10-11 23:11 UTC (permalink / raw)
To: mmyangfl
Cc: netdev, andrew, olteanv, davem, edumazet, kuba, pabeni,
linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-11 23:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-10 23:10 [PATCH net-next] net: dsa: motorcomm: Do not do the redundant MIB clear David Yang
2026-10-11 23:11 ` netdev-bot+sashiko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox