Article View: linux.kernel.netdev
Article #18053Re: [PATCH net-next v4 2/3] net: phy: acx00: report receive statistics
From: netdev-bot+sashiko
Date: Tue, 17 Nov 2026 18:50
Date: Tue, 17 Nov 2026 18:50
138 lines
12991 bytes
12991 bytes
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 receive-statistics baseline is invalidated only inside
acx00_ephy_soft_reset() (drivers/net/phy/xpowers/acx00.c), once that…
- [Medium] In __acx00_ephy_update_stats()
(drivers/net/phy/xpowers/acx00.c), the wrap adjustment hard-codes a…
--
net: phy: acx00: report receive statistics
This commit reports the ACx00 PHY receive packet, byte and CRC-error
counters through the generic PHY statistics interface. The free-running
hardware counters are polled through the update_stats callback and added
into 64-bit totals with wrap adjustment. The baseline is invalidated on
soft reset, power-off, resume, and after long polling gaps.
> diff --git a/drivers/net/phy/xpowers/acx00.c b/drivers/net/phy/xpowers/acx00.c
> index cee6c7ff0278e..fb53bac12195c 100644
> --- a/drivers/net/phy/xpowers/acx00.c
> +++ b/drivers/net/phy/xpowers/acx00.c
[ ... ]
> @@ -110,6 +144,124 @@ static int acx00_ephy_write_page(struct phy_device *phydev, int page)
[ ... ]
> +static int __acx00_ephy_update_stats(struct phy_device *phydev)
> +{
[ ... ]
> + /* Skip unusable samples without turning a statistics miss into a link error. */
> + if (ret || counts[ACX00_STAT_RX_BYTES] >= ACX00_RX_BYTES_WRAP)
> + return 0;
> +
> + /* Include sleep and read time; complete unseen cycles cannot be recovered. */
> + if (priv->stats_valid &&
> + ktime_ms_delta(ktime_get_boottime(), priv->stats_start) >=
> + (s64)ACX00_STATS_MAX_INTERVAL_MS)
> + priv->stats_valid = false;
> +
> + for (i = 0; i < ACX00_NUM_STATS; i++) {
> + u64 count = counts[i];
> +
> + if (priv->stats_valid) {
> + if (count < priv->stats_last[i])
> + count += i == ACX00_STAT_RX_BYTES ?
> + ACX00_RX_BYTES_WRAP : BIT_ULL(32);
[Severity: Medium]
Has the 2^32 rollover been measured for the packet (0x1b/0x1c) and
CRC-error (0x1d/0x1e) counters? The commit message gives hardware
measurements for the byte counter's 4,000,000,000 modulus. For the other
two counters it only says:
"The packet and CRC-error counters wrap at 2^32."
All three counters sit next to each other in page 9 and are read the same
way. If the packet or CRC counters wrap at 4e9 like the byte counter, each
wrap adds BIT_ULL(32) instead of 4e9. That would add an extra 294,967,296
to rx_packets_total or rx_errors on every wrap.
Only the byte sample is checked against its modulus above. The packet and
CRC samples are never range-checked, so nothing here would catch a wrong
modulus.
> + priv->stats[i] += count - priv->stats_last[i];
> + }
> + priv->stats_last[i] = counts[i];
> + }
> + priv->stats_valid = true;
> + priv->stats_start = start;
[ ... ]
> @@ -350,6 +506,10 @@ static int acx00_ephy_soft_reset(struct phy_device *phydev)
>
> mutex_lock(&priv->state_lock);
>
> + /* phylib may already have reset the counters before calling us. */
> + priv->stats_active = false;
> + priv->stats_valid = false;
> +
[Severity: Medium]
Can a concurrent poll count a BMCR reset as a counter wrap before this
invalidation runs?
phy_mii_ioctl() in drivers/net/phy/phy.c writes BMCR_RESET before it
reaches the driver's soft_reset:
mdiobus_write(phydev->mdio.bus, prtad, devad, val);
if (prtad == phydev->mdio.addr &&
devad == MII_BMCR &&
val & BMCR_RESET)
return phy_init_hw(phydev);
This path runs under RTNL only. It holds neither phydev->lock nor
state_lock, and it does not stop the state machine.
Meanwhile, _phy_state_machine() in PHY_NOLINK or PHY_RUNNING calls
phy_update_stats()->acx00_ephy_update_stats().
Suppose that poll takes state_lock after the BMCR_RESET write but before
acx00_ephy_soft_reset() takes it. Then stats_active and stats_valid are
still true. __acx00_ephy_update_stats() reads the cleared page-9 counters
and sees count < stats_last[i]. It then adds ACX00_RX_BYTES_WRAP or
BIT_ULL(32) and commits the result to priv->stats[].
Clearing stats_valid here afterwards does not remove that delta.
rx_bytes_total would grow by about 4e9 minus the old byte baseline.
rx_packets_total and rx_errors would each grow by about 2^32 minus their
baselines.
The commit message says the invalidation covers the case where "phylib may
already have reset the PHY through BMCR or its reset signal". Does that
hold if a poll runs between the reset write and soft_reset?
This needs CAP_NET_ADMIN and a narrow timing window. Still, nothing in the
driver orders the reset write against the collector.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113-submit-acx00-phy-stats-v1-v4-0-986b8a4a1871%40gmail.com
Technical Details
Message-ID:
<179494142597.3136.3833380345536721828@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365541-linux-kernel-netdev=dewy.ruReferences:
<20261113-submit-acx00-phy-stats-v1-v4-2-986b8a4a1871@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365541-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v4 2/3] net: phy: acx00: report receive statistics Date: Tue, 17 Nov 2026 18:50:25 +0000 Organization: Usenet Network Message-ID: <179494142597.3136.3833380345536721828@kernel.org> References: <20261113-submit-acx00-phy-stats-v1-v4-2-986b8a4a1871@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2402869"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:XGiV6YsClfNeNVhBVwQJ/D9GbhY= sha256:7SkRmFpLHARyM5OjOkSUdjATYzvUsFUD1Y+CZ4oK9ZM= sha1:ok8ymf7kD9Dk/9iCVb+Z3Ue5mdQ= sha256:A4HDGYp8UXfHWEm7bmIx9mjLgtWPtA46DFX+gLzwGn8= 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 99BBD115048; Tue, 17 Nov 2026 21:51:48 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, 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] 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 udB8Mv56oBRM; Tue, 17 Nov 2026 21:51:38 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-365541-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 923DC115011; Tue, 17 Nov 2026 21:51:28 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 4971D49084; Tue, 17 Nov 2026 18:50:42 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794941428; b=lZKYe4Ev8vsT79AgZeyK5/+klcDRoOfK7Flbs7dW3TUYE1wOdKksZEXAuoEuDgOJAJ2l cMGZW7JTolduuOMhiKuBJ7c4Q9HD1kbTaAsC/k3663ctj/VjeZ2tGYnUPX9e7lLkwMKiX mKyf6TUcTwJEjgfCr4ZIig1eDepamFX9jgtlYEiSzrorL1HxqEWZ1St8i79bWSiqNvuXJ QFuTLAVW+IQViCwwIMK5fxHw1Ln6/qj4tWFgWdSb4AP/zleEEdLzvYv8AQp5Caklk9A8r XfisUFsan5KV+V+Na4yjCZKEJLkZ7c58hVokXcV5ms7pDen41uKVmHnw06OsAmQtm6w== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794941428; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=ASGl5+9UfMcAHtxJsuDrc0AyGWrXaLdzmZsgdHF+Olg=; b=l+NDrMocn7CsedvOCxfANbVa4PDptDFhCGleZ2Aaz6nwxb687xZyMO+kNBd86CWbqL6l bUiXTBoahYBTyREJORtCjQEmgGhji/Ptz3caVhcJxXSkP1WwwE8LEoz1cIaHwXvVUp2Kw 0VdBdr/2XK5iXEJ/qMbAkzYikUDoX5kykr3+bSutFRb5+oKNRy3spllP64XupdZVBFq6f xCfHj9oDPk3/6yMsifActreJpZiWSBBAyl/ftynoyu5akDfPgdiGj2uYUg6SKpiWY00ag EIqi41U2tZw+fWEShXEi4MCLEFMRuxVo9eSJKJekYua/Q9pXReTzAnRgFv6MuJnRcNg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Oj8lyOJR; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3ED5E606A33E; Tue, 17 Nov 2026 18:50:28 +0000 (UTC) X-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=Oj8lyOJR X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794941427; b=Kkl7NSfBndk3CawvV2PZGQuJqLJqbdQHvUURdZQ5Yo0HER24fFkwpBF+r7rV5BWPLKel weHqHXMuY+Ed85FBztyzFPoBEAqv7OAZ/nmzcEdHTZw6BHpv3vvB2cJEHoNFx99Oo60a5 rDxlvviXFKaEmGYlHtf+egTiLZwAt8xCM4KATMImuQQqqYDaHbsRrvA8/0OIG5ifcCv1K LoSAboE1l2to/hxrHtSCaxENmZ9V7qC1xUCzj7l/y5unq8Souz80AQNb3hBEjEX5fOuaV no4W+RXOB3AKhtgejlGwFznKlLwxPa5WMtw3r/uIeOSIgjF5bI/HpVRb5HBupbuSU+w== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794941427; 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=ASGl5+9UfMcAHtxJsuDrc0AyGWrXaLdzmZsgdHF+Olg=; b=zJzikdJ/VR9uClkehy7S313zuY3wwN2vAl7D4IFuOPlXbGv9bUVhwCq8jQ2sdE3Io/Qv r2QLy5hw8DFhX/h778731StGrVe8Lzbt1LVqyrKiuCqtDYWuUfLEwh+VnzQFA4g0DqEIT QBhvxTSi7J14EcDeiJRjAihQ/sZFstP0fmrQv9UuImkr7tEby/1HgR2dbWFUliX5tG+Q6 QEypLWFixMIAhzWhBWCNXCk5jnonFgb81rF5xR8Hbe1zSkvUXa/YF+2dmyO25fXg5oK+r ckLrkAhvSdpmOTO65R7cR0zt+YwhSjA++02n4mAyT/cwNf+7Fc5WKVympEM/Y6AXu5Q== X-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=Oj8lyOJR; arc=none smtp.remote-ip=100.103.45.18 X-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 6150F606A88C; Tue, 17 Nov 2026 18:50:27 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 678831F000C7; Tue, 17 Nov 2026 18:50:26 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794941427; bh=ASGl5+9UfMcAHtxJsuDrc0AyGWrXaLdzmZsgdHF+Olg=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Oj8lyOJRy12FzTHJuF3ItrUi22LOeODYcjjvYaVf0R5VspvkUkQ9DlgMSUmyAwHCt U/Wa5SKtphcFcdE28EjtXvWjXEOnsLyQu9Njs/LdXhFHeNMNAJnatVGmptpBja6Z+h dOaG9+r2UXQ1sHG3WCPPF7ogrcTgLPAGsWug0+6FGFSCI5Vc9v2rEKHI8fNf+GU6Wh sdcgeApDgT3OVYqgtPpvblmidMLpt2jVluox/yvcoaUztNZ2WMktTrRpEQVAodtZnG pnhJBiy+R5ixSCRGLpi4SzT6ZyTlh/GnjsttI1znlUHtu7CqiuqV7NJl0BMrvJTEhZ l53yhArI/32Jg== X-Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, corbet@lwn.net, skhan@linuxfoundation.org, rdunlap@infradead.org, o.rempel@pengutronix.de, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, stable+noautosel@kernel.org X-In-Reply-To: <20261113-submit-acx00-phy-stats-v1-v4-2-986b8a4a1871@gmail.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list