Article View: linux.kernel.netdev
Article #23592Re: [PATCH net-next v4 2/2] rust: net: phy: pass &Device to suspend, read_mmd and write_mmd
From: netdev-bot+sashiko
Date: Fri, 27 Nov 2026 15:01
Date: Fri, 27 Nov 2026 15:01
96 lines
11873 bytes
11873 bytes
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
Technical Details
Message-ID:
<179579171759.3135.17093174832715178@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372793-linux-kernel-netdev=dewy.ruReferences:
<20261126-exp-phy-rs-maybelocked-v4-2-16f9a10bb579@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372793-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev 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 Organization: Usenet Network Message-ID: <179579171759.3135.17093174832715178@kernel.org> References: <20261126-exp-phy-rs-maybelocked-v4-2-16f9a10bb579@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="756051"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:0HnNrziSf6OfEVCNoLsF1U0K34s= sha256:CluqFX7NQN2LYaw3X5QwOQoNt/IZjlVeQcYHCMMx0tc= sha1:NJJ81g/W5PbckPihcuuGgAlUaoI= sha256:3lo4ddmWkSU87J6VF6b/xiockMndFFgBPCrtd/Tp830= 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 8BFE1125F63; Fri, 27 Nov 2026 18:02:29 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.501 X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[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 PtZml5-4N5D7; Fri, 27 Nov 2026 18:02:25 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-372793-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 0CE05125F60; Fri, 27 Nov 2026 18:02:12 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 990BF603980; Fri, 27 Nov 2026 15:02:11 +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=1795791730; b=NyD3Mlf2hqneEXT28pBNnlCmkyLY0n2FaySDv/tBGTf1xKzjRqz2IP+ojYjPsfDiwre5 7w5l1kh3IUUoIm1D2iEq+FjRWJvxkNkl0gqivHf0i8nToV4H0AFya4PXHDeSIqqlWomNu HaWPazbHQaDtfwPvE5eVQlK8xTBZbEK3ev/vtoISbUAsXnRLyvRVk2FakEHQAW3/e/h8B MnhJDhF3IEQZzLqISyNLGGs12Nl63YUs2gthsY7YgvPzLLd2aIhCpb8eHs6ShoLY4sTXG etGKXdflkvD3iy27yqPx2xLtIAXbXD72/8l05FSqYlCJdTg3+kBePTcxcERTLsFJT9A== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795791730; 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=gavLcZVGISvYCgA5MKkRgGqRprf3c04aAEhyObo7WH0=; b=5jTAMHRgoWqjQnG1EODnq3UWx21GzWwWy5j1RlQB1yJVoa5Ng9IE8kmm8942cMcLr2PR FkyY3LhFOauELGbmi1Z+O8J5kAwjyITv17tTZ1gqEY3u/KreVuGlPeALqKqC+ev2NNuXz P9OiMOGYrRHkrNhpY0ReCvGXi58OpTeCGNesq1Oak3MOqoAjGWsrjqcJb69+l127zLm7H 4SFhaJX8cLmMpBv4hIYZK8RXPFkyEvUL0ohhAku3ok2XpnAgD8hYL1fozoUrtQ0+4Q7Uy Dfj6KWg4L3FbYhvO1Y/Y4LlJtuvjaWykKWIMcW9PyUJgXn/t2oOJJLgv30SUiJ+hJgQ== 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=Y1AMsJGm; 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 D15F8606A324; Fri, 27 Nov 2026 15:02:10 +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=Y1AMsJGm 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=1795791720; b=GW+F9bqsKpVfkkZwpyXVx7PIT35U9aDD0iVP5LiBe6MAowUnr2wT7BFZFVIAlFdJnRJx 541k5TVYOSThNNHb32yr1QaTacT27ZGv0v9tXafFH4JoZ1j9JkZXqnESSRD/d7mYAhuj2 CxD8VmF7W/KmKKPgHOSOyLxCIT90k2nP1q4rX+naxQGx2U9xKT9VJR0JDeEft0pBDMubK 1Yqvunqqo+P/y/BDc7aFQbmKgAVCFNtF3sR11p0tpVjz2NZv0XOfxgi05F5QEDajssQfX 9pyweCRnXZM1P+w5/30ieSMeYzUuKdNQrzaXnuXoSdLNQgLVjAniAZi9dPGBw4r5piQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795791720; 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=gavLcZVGISvYCgA5MKkRgGqRprf3c04aAEhyObo7WH0=; b=O102nt/n56VkMWQPUlodKC2N0CMCxZNthT0P1QRhDocFC97xM2/ZzulG4QOi1ta/b1Ul gBr00t5NbhmVm9dW6gjqRu/Dq4+94rj6rcxrirCGl3a5EzRqH9ucaKISXrSGBrCUKeOsT OlSF1Hm1L9LKsMK39eT1LNx0jngg37mf4RL2yQQSNdxJB2ycYPQQBb/5QN8t2HoJWIu7m CiRN7q1dy3a/PZldsFS+2vkn4UgdgSxVm5JAX3XUmuT/S7ejUYXmjSbLl8yPC8k+2kzUK B0dyUIdUxvxKW55nY2rxX61vP/y7LnW514XwLZXyWk5xTaI5WL4TeTZECcF9G+6oJ4A== 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=Y1AMsJGm; 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 ED992606A332; Fri, 27 Nov 2026 15:01:59 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 084ED1F00925; Fri, 27 Nov 2026 15:01:57 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795791719; bh=gavLcZVGISvYCgA5MKkRgGqRprf3c04aAEhyObo7WH0=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Y1AMsJGmTSoeBnJeSnK81ArrXDkJlSz8cl90Ch0PEgJFym2qaMEqwG2rjjmbcIULK 7qC+7uCyZ3fhasBkePeZdgwQLCwfhMWcnQs2tZnb/MBczoaLPHJdeIuPG/YHcTBQqS TvsLYpc4pfTzVKKVtvjgG4FOQW2+5YTVqO8CYdMySRX0qpu1Ai3OA5oTerxtqa7475 sLh9VxikgXx2xZEwW+f5mwKXKD4cWBoFbo9Q4f12PMPc/yF05HYcWJAPUJDDGUlTXT cCLszI7953dHgNgzfitXeK4Z/A7waQIZMJTD5wcxp8vuk6tiyH2c+IiJA/TQwz11lt k5HPUfAw/s96A== X-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 X-In-Reply-To: <20261126-exp-phy-rs-maybelocked-v4-2-16f9a10bb579@gmail.com> X-sashiko-severity: Low 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