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

From: SeungJong Ha

Date: Mon Nov 16 2026 - 08:17:51 EST


On Mon, Nov 16, 2026 at 4:33 PM <netdev-bot+sashiko@xxxxxxxxxx> wrote:

> [Severity: Medium]
> Does PHYLIB really guarantee exclusive access for Driver::suspend?
[...]
> [Severity: Low]
> Is Driver::resume actually called without the lock?

Until v2, I had left suspend and resume out of the context analysis
because the existing comments already said the lock might not be held.
Running it now, resume is always called with the lock held, while suspend
is not.

v3 will give suspend the MaybeLocked context, list resume with the locked
callbacks, and fix both SAFETY comments. I'll also move dev.genphy_suspend()
into MaybeLocked context (while it holds MDIO bus lock by itself)

> [Severity: Medium]
> Does a shared reference give match_phy_device any protection here?

No. I had kept match_phy_device for API compatibility, but like read_mmd
and write_mmd it has no Rust user, so v3 will drop it.


> [Severity: Low]
> The commit message says:
>
> Update the documentation and SAFETY comments to match.
>
> The from_raw() callers in Adapter<T> weren't updated, though. None of
> them says which context it is in or why; they all get Ctx = Locked by
> inference.

I'll try to compose better SAFETY comments on v3.

Best regards,
SeungJong

pw-bot: cr