From: netdev-bot+sashiko@kernel.org
To: mmyangfl@gmail.com
Cc: netdev@vger.kernel.org, andrew@lunn.ch, olteanv@gmail.com,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, linux@armlinux.org.uk,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v3 6/6] net: dsa: motorcomm: Use safe 64-bit counter reader
Date: Wed, 09 Sep 2026 15:16:18 +0000 [thread overview]
Message-ID: <178896697810.219967.14368913869844106724@kernel.org> (raw)
In-Reply-To: <20260906131414.2683362-7-mmyangfl@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider:
Critical: 0 · High: 0 · Medium: 0 · Low: 1
- [Low] The patch is a functional bug fix (it removes spurious ~4 GiB
jumps in the 64-bit MIB byte counters that are exported to userspace)…
--
net: dsa: motorcomm: Use safe 64-bit counter reader
This switches the multi-word MIB counters in yt921x_mib_read() over to a
new helper, yt921x_counter_read(), which re-reads the low word after the
high word and retries until the pair is consistent. The single-word path
keeps its existing software wrap extension.
> diff --git a/drivers/net/dsa/motorcomm/mib.c b/drivers/net/dsa/motorcomm/mib.c
> index 8601d25fe9887..cfae2977a77b9 100644
> --- a/drivers/net/dsa/motorcomm/mib.c
> +++ b/drivers/net/dsa/motorcomm/mib.c
> @@ -102,29 +102,26 @@ static int yt921x_mib_read(struct yt921x_priv *priv, int port)
> for (size_t i = 0; i < ARRAY_SIZE(yt921x_mib_descs); i++) {
> const struct yt921x_mib_desc *desc = &yt921x_mib_descs[i];
> u32 reg = YT921X_MIBn_DATA0(port) + desc->offset;
> - u32 val0;
> - u64 val;
> -
> - res = yt921x_reg_read(priv, reg, &val0);
> - if (res)
> - break;
>
> if (desc->size <= 1) {
> u64 old_val = buf[i];
> + u32 val0;
> + u64 val;
> +
> + res = yt921x_reg_read(priv, reg, &val0);
> + if (res)
> + break;
>
> val = (old_val & ~(u64)U32_MAX) | val0;
> if (val < old_val)
> val += 1ull << 32;
> - } else {
> - u32 val1;
>
> - res = yt921x_reg_read(priv, reg + 4, &val1);
> + buf[i] = val;
> + } else {
> + res = yt921x_counter_read(priv, reg, &buf[i]);
> if (res)
> break;
> - val = ((u64)val1 << 32) | val0;
> }
> -
> - buf[i] = val;
> }
[Severity: Low]
Should this hunk carry a Fixes: tag and a stable Cc?
The commit message describes a concrete user-visible misbehaviour
("producing a spurious ~4 GiB jump"), and the racy sequence it replaces is
already in a released kernel. At the baseline the same code lives in
drivers/net/dsa/motorcomm/chip.c:yt921x_mib_read():
res = yt921x_reg_read(priv, reg, &val0);
...
res = yt921x_reg_read(priv, reg + 4, &val1);
if (res)
break;
val = ((u64)val1 << 32) | val0;
git blame attributes that two-transaction read to 186623f4aa724c ("net:
dsa: Add Motorcomm YT921x DSA switch support"), and the earlier patches in
this series only moved it from chip.c into mib.c:yt921x_mib_read().
The affected entries are the desc->size > 1 counters, i.e. rx_good_bytes,
rx_bad_bytes and tx_good_bytes in struct yt921x_mib_stats, which are
reported through the periodic MIB poll and the DSA get_stats64()/ethtool
paths.
Without a Fixes: tag pointing at 186623f4aa724c, would this hunk be
distinguishable from the surrounding refactor for backporting purposes?
[ ... smi.c and smi.h hunks snipped, no comments ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260906131414.2683362-1-mmyangfl%40gmail.com
prev parent reply other threads:[~2026-09-09 15:16 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-06 13:14 [PATCH net-next v3 0/6] net: dsa: motorcomm: MIB fixup David Yang
2026-09-06 13:14 ` [PATCH net-next v3 1/6] net: dsa: motorcomm: Rename MIB stuffs David Yang
2026-09-09 15:16 ` netdev-bot+sashiko
2026-09-09 17:32 ` David Yang
2026-09-06 13:14 ` [PATCH net-next v3 2/6] net: dsa: motorcomm: Split MIB buffers David Yang
2026-09-09 15:16 ` netdev-bot+sashiko
2026-09-06 13:14 ` [PATCH net-next v3 3/6] net: dsa: motorcomm: Split MIB module David Yang
2026-09-09 15:16 ` netdev-bot+sashiko
2026-09-06 13:14 ` [PATCH net-next v3 4/6] net: dsa: motorcomm: Use u64_stats_t for MIB stats David Yang
2026-09-09 15:16 ` netdev-bot+sashiko
2026-09-06 13:14 ` [PATCH net-next v3 5/6] net: dsa: motorcomm: Fix MIB synchronization David Yang
2026-09-09 15:16 ` netdev-bot+sashiko
2026-09-09 17:45 ` David Yang
2026-09-06 13:14 ` [PATCH net-next v3 6/6] net: dsa: motorcomm: Use safe 64-bit counter reader David Yang
2026-09-09 15:16 ` netdev-bot+sashiko [this message]
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=178896697810.219967.14368913869844106724@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mmyangfl@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.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