Re: [PATCH net-next v3 0/3] rust: net: phy: suspend may run without phy_device->lock

From: FUJITA Tomonori

Date: Tue Nov 24 2026 - 07:58:17 EST


On Tue, 17 Nov 2026 19:36:18 +0900
SeungJong Ha <engineer.jjhama@xxxxxxxxx> wrote:

> Patch 1 drops `read_mmd`, `write_mmd` and `match_phy_device`, which make
> the same claim but are called under other conditions, and have no users.
> Patch 2 makes `Device` generic over a lock context and documents when
> the `Locked` callbacks run without the lock, and patch 3 gives `suspend`
> the `MaybeLocked` one.

Can we use &Device and &mut Device instead of the new context types?

&mut Device means exclusive access to the state that phy_device->lock
protects. &Device makes no such claim. Methods that use that state
(state(), set_speed(), ...) and read_paged() take &mut self. phy_id(),
read(), write() and genphy_suspend() take &self.

Then suspend, match_phy_device, read_mmd and write_mmd get &Device, and
1/3 is not needed. I would rather not drop callbacks. I want to make it
easy to write new PHY drivers in Rust.

For phy_mii_ioctl(), I agree with Andrew. The SAFETY comment can just
say that this path is outside the guarantee.

I tried this on 7.4-rc4. It builds, and the only driver change is the
suspend signature in ax88796b_rust.