Article View: linux.kernel.netdev
Article #17729Re: [PATCH net 3/4] net: phy: quiesce the state machine during MII resets
From: netdev-bot+sashiko
Date: Tue, 17 Nov 2026 09:15
Date: Tue, 17 Nov 2026 09:15
184 lines
14678 bytes
14678 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 2
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 does not fully close the bug it describes.
- [Low] The commit message's only concrete symptom, "A statistics update
in this window can interpret cleared hardware counters as a…
- [Low] The patch carries `Fixes: 00db8189d984` (the original 2005 phylib
commit), so stable will select it for every maintained LTS branch.
--
net: phy: quiesce the state machine during MII resets
This commit sends Clause 22 BMCR_RESET writes from SIOCSMIIREG through a
new helper, phy_mii_ioctl_reset(). The helper disables and drains the PHY
state machine work and waits for BMCR_RESET to clear via phy_poll_reset().
It then calls phy_init_hw() and re-enables and triggers the state machine.
> phy_mii_ioctl() performs a BMCR reset write and calls phy_init_hw() while
> the PHY state machine remains active. The worker can access the PHY after
> reset but before the driver has restored its configuration and software
> state. A statistics update in this window can interpret cleared hardware
> counters as a wraparound.
[Severity: Low]
Which driver does the wraparound case refer to?
The worker only reaches driver statistics code through phy_update_stats()
in _phy_state_machine():
drivers/net/phy/phy.c:_phy_state_machine() {
...
case PHY_NOLINK:
case PHY_RUNNING:
err = phy_check_link_status(phydev);
func = &phy_check_link_status;
if (!err)
err = phy_update_stats(phydev);
break;
...
}
The in-tree .update_stats callbacks either add read-clear counters to a
software total or assign absolute values:
qcom_phy_update_stats(): hw_stats->rx_pkts += cnt;
dp83tg720_update_stats(): priv->stats.tx_pkt_cnt += count;
dp83td510_update_stats(), gpy_update_stats(),
xway_gphy_update_stats(), kszphy_update_stats(): accumulate with +=
lan8842_update_stats(): assigns absolute values
None of them keeps a previous snapshot or computes a delta. It doesn't look
like any of them can mistake a reset for a wrap.
The in-tree effects of the worker running mid-reset look different. One is
a spurious link down/up from reading BMSR during the reset. Another is
possible double counting if the reset clears a read-clear enable that
config_init() restores, for example qcom_phy_counter_config().
The ethtool statistics read path (ETHTOOL_GPHYSTATS) doesn't seem to be a
gap. It and SIOCSMIIREG are both serialized by RTNL or the netdev ops lock.
Could the commit message describe the actual in-tree failure, or name the
driver it refers to? The Fixes: tag will send this to all stable branches.
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 4ac72a1b4f427..5da8a699446c0 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -297,6 +297,30 @@ void phy_ethtool_ksettings_get(struct phy_device *phydev,
> }
> EXPORT_SYMBOL(phy_ethtool_ksettings_get);
>
> +static int phy_mii_ioctl_reset(struct phy_device *phydev, u16 val)
> +{
> + int ret;
> +
> + /* Keep the worker out until the driver has restored its state. */
> + disable_delayed_work_sync(&phydev->state_queue);
[Severity: Low]
Will this build on the stable trees that the Fixes: tag selects?
The patch carries Fixes: 00db8189d984, the original 2005 phylib commit. That
means it will be picked for every maintained stable branch.
disable_delayed_work_sync() and enable_delayed_work() were added in v6.10
by commit 86898fa6b8cd ("workqueue: Implement disable/enable for (delayed)
work items"). They don't exist in 6.6, 6.1, 5.15 or older trees.
Should there be a stable version limit such as "Cc: stable # 6.10+", a
note about the dependency, or a different quiescing approach for older
trees?
> +
> + ret = phy_write(phydev, MII_BMCR, val);
> + if (ret < 0)
> + goto out;
> +
> + ret = phy_poll_reset(phydev);
> + if (ret)
> + goto out;
> +
> + phydev->autoneg = AUTONEG_ENABLE;
> + ret = phy_init_hw(phydev);
> +out:
> + if (enable_delayed_work(&phydev->state_queue))
> + phy_trigger_machine(phydev);
> +
> + return ret;
> +}
> +
> /**
> * phy_mii_ioctl - generic PHY MII ioctl interface
> * @phydev: the phy_device struct
> @@ -349,6 +373,9 @@ int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd)
> } else {
> prtad = mii_data->phy_id;
> devad = mii_data->reg_num;
> + if (prtad == phydev->mdio.addr &&
> + devad == MII_BMCR && val & BMCR_RESET)
> + return phy_mii_ioctl_reset(phydev, val);
> }
>
> if (mdio_phy_id_is_c45(mii_data->phy_id))
[Severity: Medium]
Can the old reset path at the end of the SIOCSMIIREG case still call
phy_init_hw() while the state machine is active?
The new early return only exists in the Clause 22 else branch. The old
check at the end of phy_mii_ioctl() is still there:
if (prtad == phydev->mdio.addr &&
devad == MII_BMCR &&
val & BMCR_RESET)
return phy_init_hw(phydev);
With a Clause 45 form phy_id, prtad and devad come from
mdio_phy_id_prtad() and mdio_phy_id_devad(). This path is taken when all of
the following hold:
- prtad matches the attached PHY's address
- the MMD is 0, which equals MII_BMCR
- val_in has bit 15 set
- the bus accepts the C45 write
phy_mii_ioctl()
mdiobus_c45_write(...)
case MII_BMCR: phydev->autoneg = AUTONEG_ENABLE;
phy_init_hw(phydev)
None of disable_delayed_work_sync(), phy_poll_reset() or
phy_trigger_machine() runs on this path. phy_init_hw() can also do its own
BMCR reset through drv->soft_reset (for example genphy_soft_reset()) while
the worker is running.
For Clause 22 IDs the tail branch is now dead code. That leaves
phy_mii_ioctl() with two reset paths, one quiesced and one not. Could the
leftover branch be removed, or routed through phy_mii_ioctl_reset()?
The later patch in this series, "net: phy: reinitialize the PHY after an
MII reset", doesn't change phy.c. Its phylink_phy_write() returns early for
C45 IDs, so drivers that use phy_do_ioctl() without phylink still reach
this path.
Could the commit message also say that genuine Clause 45 resets
(MDIO_MMD_PMAPMD / MDIO_CTRL1 with MDIO_CTRL1_RESET) are out of scope? This
patch doesn't intercept them either.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113-submit-phy-mii-reset-v1-v1-0-02a55f352a91%40gmail.com
Technical Details
Message-ID:
<179490695420.3136.9645842823943433050@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365093-linux-kernel-netdev=dewy.ruReferences:
<20261113-submit-phy-mii-reset-v1-v1-3-02a55f352a91@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365093-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net 3/4] net: phy: quiesce the state machine during MII resets Date: Tue, 17 Nov 2026 09:15:54 +0000 Organization: Usenet Network Message-ID: <179490695420.3136.9645842823943433050@kernel.org> References: <20261113-submit-phy-mii-reset-v1-v1-3-02a55f352a91@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2288530"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:UwSntdO83KTYfF7LyZ4Z3PbzF10= sha256:/rK+gsaTBmWuzyIy5mdfsT9/JpJcsOhyDEhVAcTFLQI= sha1:rSfZBjNlk941lVQluzz7h91p4J8= sha256:4WHcYUM+E9IiJ2FRxtwmnynClPdEAGY00Xi5cEnbatk= 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 94335114EB4; Tue, 17 Nov 2026 12:16:23 +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 MQqa4-XPCrWT; Tue, 17 Nov 2026 12:16:19 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-365093-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 2E7DE114EB9; Tue, 17 Nov 2026 12:16:11 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id CC11927868; Tue, 17 Nov 2026 09:16:07 +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=1794906961; b=nZwBuZ4UymalRV2P9tBlZEsD2L2VCMALSDRsubO0bSCqSBvEfMkdDgHYTWeHfzteXA42 nA5EAxEMGBQWkK54r8GNGcXzaI8z3k9b0BUmXGQZuPxGwNg3BBHZjJkTl7T4fNsK122y0 M6I7R2ZRvVuPCHJ0sHwlYjbT2FHjRIMo+ZBH53HcRI6inFTS0d3WOTBAi7NoLZo78zQUM hOrBAF0qmx5SNaFwQyLSgA7yfFdFnc0qVX7NTvjPC4EGF7j9xQ6P1KF1zGyTcn3Nx22cB ekKfV2eaaki30A5vLyi/b66e/vqIg5BYuIeNEP9nW8hL13qh7i+22uUSbh2blU+3Y0g== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794906961; 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=0m8XnYVT9DjCg9I39JLr1uBTaZ2tfQtT3Fs85gKbuOE=; b=MQZLnGzX1z2noDGJhAzU91WqIFLxF+6m9+b4dhK5rK1OJm2kxHHhZnC/ay/SWBp9etjw ZWhpT49A0ja2379nA1JsBYvt3F/Pd8k5dGsESEBE83HZ/jV0/7m4qnIsjrMDsXzJsRu9a bxVzpyy+mhMd9FY6tx8ROzCk6Ip+qqbL8PFCw3ziD2aWKazdcGZyVX7mHEnPiNAx5h1Vx +vVG7p/+YmywmnVxgOxYWUWhS6T9zPw2Wnx000iwKL7AcDdfoOTQP86FTSG4IRDJFVuoD XfDqJD8Qf5vbEPDBzLhYZw/UF+E4RTTOlfd9hHcrH07GSTJSQFrgoYsq42hJN5jfF3w== 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=WmFgFoqp; 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 4BCA3606A329; Tue, 17 Nov 2026 09:16:01 +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=WmFgFoqp 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=1794906955; b=I0B1763LBYZggl0y0szvE/ljqS99orIUHjb6b3FR6/GMCrl4oWieq1WL8TUZpRekND1B PhzzK6SAtLa9OSVAQtkCTIKP8vTzQeRRKrc2vY6bemMKLfMp+T0SCeL59siiwdGT9Z+rF +Z9ILZljilCsCm5Nk+G490+qPbl4psYbGc3SwlcLoAjLNOp/+Cs3dZhLHp/ZFgs0PCuqF ud9LfG+L54ULM6aJaUt6ASjd3yCeHW1V+xqS9qD9l69mg7NyAmOdxeckKhnDZ1b+JYDh5 lRmYPunzz9iyOmQa9oMLYUATCvkN0XyguKu2Y2jKnjEa6xWOqNZKCJBdLA0Httd0rEw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794906955; 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=0m8XnYVT9DjCg9I39JLr1uBTaZ2tfQtT3Fs85gKbuOE=; b=nLdXH1Hk6Yu4OO47NvlrtYapY+eCwlQWDD1CY8cGPzVA3Axua53OV7IbGGxOE5ct0XRD vTuZjkk7Nig4bpKUISYo/zoP5i859EovK0h4XDqsy1gU+mWuDUARVKNFpV0LMMlM3x935 VTcSwv9lVdhpoEC+VGzb/HsS12FS79UYKZ9MAxqar/cLlSnrkaHem28VTg2Bv02VelVsY Q8QeZDBGF2gWRvjWE2Z7K2W8+BjQmvlrPX/FS2kP/BaRBR0h2RRKUekA6zsbUtoXMwnM/ pbssVFYkuhcyVdJ8qsfHZRo8cUzjvrLlAVJ59Mqwb591JCwuVNehR68XUDs9/Vobgqg== 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=WmFgFoqp; 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 6ABE8606A32F; Tue, 17 Nov 2026 09:15:55 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F28A1F000C7; Tue, 17 Nov 2026 09:15:54 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794906955; bh=0m8XnYVT9DjCg9I39JLr1uBTaZ2tfQtT3Fs85gKbuOE=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=WmFgFoqpb77+UHTiRGgwU5eNNEv8FcJEOLy/ya6rFr2FaujsxbqFZ7NWeUlPIrNyt 0PVK83q6cUC08QLvsvZgdJX6FeCTBMv/czsgx981v57GSmFQAcjwyH9tL9zl0s3hoo qLdMpE08LGJhEUYRUhcuKfJ//COdhToVEyYztSn0mlBiEoIpW9yndtVRIg3dd0qKNo caLfoJxbrBLJeTefW7RJzkXIasnwNdy1JwIMiBft7mSuqGxllrsMcTBJUS7EVTpDpU 5qSJcYi60aIhUzOvh1NL65v+ZjYEs5VA6ieYx32geaFiT1x4RPvpFqW4rwTY8Lr/yX DtlLHKg6QiGHQ== X-Cc: hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, michael.chan@broadcom.com, hauke@hauke-m.de, andrew@lunn.ch, netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-In-Reply-To: <20261113-submit-phy-mii-reset-v1-v1-3-02a55f352a91@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