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

From: SeungJong Ha

Date: Sun Nov 22 2026 - 22:12:16 EST


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.

The other two options would change drivers: ax88796b_rust's soft_reset
needs genphy_soft_reset(), and the Locked callbacks need set_speed() and
the other field accessors. Documenting the exception is the minimal
compromise that keeps the abstraction usable without changing driver
code.

This series only separates the methods by lock context. Other contexts,
such as the device contexts (Bound, Core) of device::Device, are a
follow-up.

Best regards,
SeungJong Ha