Re: [PATCH net-next v3 0/3] rust: net: phy: suspend may run without phy_device->lock
From: SeungJong Ha
Date: Wed Nov 25 2026 - 04:40:54 EST
On Tue, 24 Nov 2026 21:57:47 +0900 (JST), FUJITA Tomonori wrote:
>
> 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?
[...]
Yes, that is simpler. I will do that in v4. Two things to check first:
- genphy_soft_reset() reads autoneg and writes suspended, so I would keep
it on &mut self. soft_reset gets &mut Device, and the SAFETY comment
says that the phy_mii_ioctl() path is outside the guarantee.
- read() and write() take the MDIO bus lock, and &Device cannot say
more than that the phy_device->lock state is off limits.
In read_mmd and write_mmd the bus lock is already held, so they
deadlock. A test driver whose read_mmd calls dev.read() hangs as soon
as the PHY binds, and lockdep reports recursive locking on
bus->mdio_lock. The path is phy_probe() -> genphy_read_abilities() ->
genphy_c45_read_eee_abilities() -> phy_read_mmd().
In match_phy_device they reach a device that may be bound to another
driver, which the netdev AI review pointed out on v1 [1].
Do you still want to keep these callbacks with &Device and document
this, or wait until they can get accessors that fit their context?
Best regards,
SeungJong
[1] https://lore.kernel.org/r/179454612500.2199510.688554972467066283@xxxxxxxxxx