mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: FUJITA Tomonori <tomo@flapping.org>
To: engineer.jjhama@gmail.com
Cc: tomo@flapping.org, andrew@lunn.ch, fujita.tomonori@gmail.com,
	tmgross@umich.edu, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
	ojeda@kernel.org, boqun@kernel.org, gary@garyguo.net,
	bjorn3_gh@protonmail.com, lossin@kernel.org,
	a.hindborg@kernel.org, aliceryhl@google.com, dakr@kernel.org,
	daniel.almeida@collabora.com, tamird@kernel.org,
	acourbot@nvidia.com, work@onurozkan.dev, hkallweit1@gmail.com,
	linux@armlinux.org.uk, netdev@vger.kernel.org,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v3 0/3] rust: net: phy: suspend may run without phy_device->lock
Date: Thu, 26 Nov 2026 08:11:55 +0900 (JST)	[thread overview]
Message-ID: <20261126.081155.1605990248496749195.tomo@flapping.org> (raw)
In-Reply-To: <CAGAB666qnAjFnf41PQmG5kWWSb+Au01OgspPhvREotLGXTYwXQ@mail.gmail.com>

On Wed, 25 Nov 2026 18:40:32 +0900
SeungJong Ha <engineer.jjhama@gmail.com> wrote:

> 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@gmail.com> 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.

Agreed.

> - 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?

Yes, please keep them with &Device and document it. The deadlock is not
a soundness problem. I will add accessors for the bus-locked context,
with a guard or a context type, as a follow-up.

For match_phy_device, &Device fixes both problems in [1]: read_paged()
needs &mut self, and read_mmd no longer gets &mut Device.

> [1] https://lore.kernel.org/r/179454612500.2199510.688554972467066283@kernel.org

      reply	other threads:[~2026-11-25 23:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 10:36 SeungJong Ha
2026-11-17 10:36 ` [PATCH net-next v3 1/3] rust: net: phy: drop unused read_mmd, write_mmd and match_phy_device SeungJong Ha
2026-11-17 10:36 ` [PATCH net-next v3 2/3] rust: net: phy: make Device generic over a lock context SeungJong Ha
2026-11-20  1:37   ` netdev-bot+sashiko
2026-11-23  3:11     ` SeungJong Ha
2026-11-23  4:31       ` Andrew Lunn
2026-11-17 10:36 ` [PATCH net-next v3 3/3] rust: net: phy: pass a MaybeLocked device to suspend SeungJong Ha
2026-11-24 12:57 ` [PATCH net-next v3 0/3] rust: net: phy: suspend may run without phy_device->lock FUJITA Tomonori
2026-11-25  9:40   ` SeungJong Ha
2026-11-25 23:11     ` FUJITA Tomonori [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261126.081155.1605990248496749195.tomo@flapping.org \
    --to=tomo@flapping.org \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=andrew@lunn.ch \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=engineer.jjhama@gmail.com \
    --cc=fujita.tomonori@gmail.com \
    --cc=gary@garyguo.net \
    --cc=hkallweit1@gmail.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=lossin@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=work@onurozkan.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®