Re: [PATCH net-next v3 2/3] rust: net: phy: make Device generic over a lock context

From: Andrew Lunn

Date: Sun Nov 22 2026 - 23:32:17 EST


On Mon, Nov 23, 2026 at 12:11:55PM +0900, SeungJong Ha wrote:
> 2026년 11월 20일 (금) 오전 10:37, <netdev-bot+sashiko@xxxxxxxxxx>님이 작성:
>
>
> > [Severity: Medium]
> >
> > Does this SAFETY comment justify the from_raw() call?
> >
> > The new Locked invariant says that no other thread accesses the
> > lock-protected phy_device state for the lifetime of a &mut Device<Locked>.
> > from_raw() now also requires the caller to be in the Ctx context.
> >
> > However, this comment and the Locked docs above both say that
> > phy_mii_ioctl() reaches this callback without phydev->lock while the
> > state machine may be running.
> [...]
> > Would one of these work instead?
> >
> > - take phydev->lock around phy_init_hw() in phy_mii_ioctl()
> > - weaken the Locked invariant and drop the accessors that rely on it
> > - give soft_reset a context that does not claim exclusive access
>
> This is why the Locked docs list these exceptions. Taking phydev->lock
> around phy_init_hw() in phy_mii_ioctl() does not look safe as is:
> vsc85xx_config_init() takes the lock itself through vsc85xx_mac_if_set(),
> so it would deadlock. Fixing that race belongs in phy_mii_ioctl() and
> seems separate from this patch.

phy_mii_ioctl() is meant to be a foot gun, bad things are expected to
happen if you use it.

/**
* phy_mii_ioctl - generic PHY MII ioctl interface
* @phydev: the phy_device struct
* @ifr: &struct ifreq for socket ioctl's
* @cmd: ioctl cmd to execute
*
* Note that this function is currently incompatible with the
* PHYCONTROL layer. It changes registers without regard to
* current state. Use at own risk.
*/

I would not spend any time on this.

Andrew