From: netdev-bot+sashiko@kernel.org
To: engineer.jjhama@gmail.com
Cc: fujita.tomonori@gmail.com, tmgross@umich.edu,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, ojeda@kernel.org,
boqun@kernel.org, gary@garyguo.net, bjorn3_gh@protonmail.com,
lossin@kernel.org, a.hindborg@kernel.org, aliceryhl@google.com,
dakr@kernel.org, daniel.almeida@collabora.com, tamird@kernel.org,
acourbot@nvidia.com, work@onurozkan.dev, andrew@lunn.ch,
hkallweit1@gmail.com, linux@armlinux.org.uk,
netdev@vger.kernel.org, rust-for-linux@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v4 2/2] rust: net: phy: pass &Device to suspend, read_mmd and write_mmd
Date: Fri, 27 Nov 2026 15:01:57 +0000 [thread overview]
Message-ID: <179579171759.3135.17093174832715178@kernel.org> (raw)
In-Reply-To: <20261126-exp-phy-rs-maybelocked-v4-2-16f9a10bb579@gmail.com>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] This patch adds doc comments to `Driver::read_mmd` and
`Driver::write_mmd` in rust/kernel/net/phy.rs.
--
rust: net: phy: pass &Device to suspend, read_mmd and write_mmd
This commit changes the suspend, read_mmd and write_mmd callbacks in the
Rust PHY abstraction to take &Device instead of &mut Device. The reason is
that PHYLIB does not always hold phy_device->lock when it calls them. It
also documents that read() and write() deadlock inside read_mmd and
write_mmd, and updates ax88796b_rust to match.
> diff --git a/rust/kernel/net/phy.rs b/rust/kernel/net/phy.rs
> index bb2cc6b3c94c8..d04a651ae62b2 100644
> --- a/rust/kernel/net/phy.rs
> +++ b/rust/kernel/net/phy.rs
[ ... ]
> @@ -627,12 +627,18 @@ fn resume(_dev: &mut Device) -> Result {
> }
>
> /// Overrides the default MMD read function for reading a MMD register.
> - fn read_mmd(_dev: &mut Device, _devnum: u8, _regnum: u16) -> Result<u16> {
> + ///
> + /// PHYLIB calls this with the MDIO bus lock held, so calling [`Device::read`] or
> + /// [`Device::write`] here deadlocks.
> + fn read_mmd(_dev: &Device, _devnum: u8, _regnum: u16) -> Result<u16> {
> build_error!(VTABLE_DEFAULT_ERROR)
> }
>
> /// Overrides the default MMD write function for writing a MMD register.
> - fn write_mmd(_dev: &mut Device, _devnum: u8, _regnum: u16, _val: u16) -> Result {
> + ///
> + /// PHYLIB calls this with the MDIO bus lock held, so calling [`Device::read`] or
> + /// [`Device::write`] here deadlocks.
> + fn write_mmd(_dev: &Device, _devnum: u8, _regnum: u16, _val: u16) -> Result {
[Severity: Low]
Should this list of deadlocking methods include Device::genphy_suspend()
as well?
The previous patch in the series ("rust: net: phy: take &self in methods
that do not need phy_device->lock") changed genphy_suspend() to take &self.
That means read_mmd and write_mmd can call it through the &Device they now
receive:
rust/kernel/net/phy.rs:Device::genphy_suspend() {
pub fn genphy_suspend(&self) -> Result {
let phydev = self.0.get();
...
to_result(unsafe { bindings::genphy_suspend(phydev) })
}
}
On the C side, that call takes the MDIO bus lock a second time:
phy_read_mmd()
phy_lock_mdio_bus(phydev)
__phy_read_mmd()
phydev->drv->read_mmd() <- Rust read_mmd callback
Device::genphy_suspend()
genphy_suspend()
phy_set_bits(phydev, MII_BMCR, BMCR_PDOWN)
phy_modify()
phy_lock_mdio_bus(phydev) <- deadlock on bus->mdio_lock
phy_write_mmd()->__phy_write_mmd()->drv->write_mmd follows the same path.
As far as I can tell, read(), write() and genphy_suspend() are the only
&Device methods that access the hardware. All three take the MDIO bus
lock, and the abstraction has no unlocked accessor along the lines of
__phy_read() or __mdiobus_read().
If that is right, a read_mmd or write_mmd override cannot safely reach the
bus at all. Could the doc comment say this, or at least name
genphy_suspend() next to read() and write()?
No in-tree Rust driver implements read_mmd or write_mmd today. Before this
series, &mut Device methods such as read_paged() could already deadlock
here in the same way. The incomplete wording itself is new in this patch.
> build_error!(VTABLE_DEFAULT_ERROR)
> }
>
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126-exp-phy-rs-maybelocked-v4-0-16f9a10bb579%40gmail.com
prev parent reply other threads:[~2026-11-27 15:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 14:08 [PATCH net-next v4 0/2] rust: net: phy: pass &Device to callbacks without exclusive access SeungJong Ha
2026-11-26 14:08 ` [PATCH net-next v4 1/2] rust: net: phy: take &self in methods that do not need phy_device->lock SeungJong Ha
2026-11-27 15:01 ` netdev-bot+sashiko
2026-11-26 14:08 ` [PATCH net-next v4 2/2] rust: net: phy: pass &Device to suspend, read_mmd and write_mmd SeungJong Ha
2026-11-27 15:01 ` 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=179579171759.3135.17093174832715178@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=andrew@lunn.ch \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=engineer.jjhama@gmail.com \
--cc=fujita.tomonori@gmail.com \
--cc=gary@garyguo.net \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=lossin@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=pabeni@redhat.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
/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