Netdev List
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: xuanqiang.luo@linux.dev
Cc: netdev@vger.kernel.org, kuba@kernel.org,
	richardcochran@gmail.com, hkallweit1@gmail.com,
	linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com,
	pabeni@redhat.com, maxime.chevallier@bootlin.com,
	luoxuanqiang@kylinos.cn
Subject: Re: [PATCH net v5 4/4] net: phy: dp83640: fix per-bus clock lifetime
Date: Mon, 10 Aug 2026 16:50:19 +0200	[thread overview]
Message-ID: <57719c88-854b-4c92-956e-a673041b8587@lunn.ch> (raw)
In-Reply-To: <20260810141511.73204-5-xuanqiang.luo@linux.dev>

On Mon, Aug 10, 2026 at 10:15:11PM +0800, xuanqiang.luo@linux.dev wrote:
> From: Xuanqiang Luo <xuanqiang.luo@linux.dev>
> 
> Commit 42e2a9e11a1d ("net: phy: dp83640: improve phydev and driver
> removal handling") moved per-bus clock cleanup from module exit to the
> remove path. This leaves two lifetime problems.
> 
> dp83640_clock_get_bus() publishes a newly allocated clock before the
> driver allocates its per-PHY data and registers the PTP clock. If either
> operation fails, no PHY is bound and the remove callback cannot release
> the clock, leaking the clock and the MII bus device reference.
> 
> The remove path can also free a clock after dropping clock_lock. A
> concurrent probe may already have found the clock under
> phyter_clocks_lock and be waiting for clock_lock, allowing it to acquire
> a freed mutex and access the freed clock.
> 
> Use the PHY package infrastructure for the per-bus clock. PHY packages
> are tracked per MII bus, and the driver uses BROADCAST_ADDR as the
> package key so the DP83640 PHYs on the same bus share the same clock
> storage. Call phy_package_join() during probe and phy_package_leave() on
> probe errors and in remove.

Ah, i missed BROADCAST_ADDR. Looking at ext_write(), either accesses
are broadcast to all devices on the bus, or to the specific PHYs
address. There is no one address which is special. I was expecting to
see calls to __phy_package_write()/__phy_package_read() but those are
not needed.

Overall, using phy_packages has simplified this driver a lot.

Once you fix your email address, feel free to add Reviewed-by: Andrew
Lunn <andrew@lunn.ch>

    Andrew

  parent reply	other threads:[~2026-08-10 14:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-10 14:15 [PATCH net v5 0/4] net: phy: dp83640: fix shared clock lifetime and probe error cleanup xuanqiang.luo
2026-08-10 14:15 ` [PATCH net v5 1/4] net: phy: add PHY package locking helpers xuanqiang.luo
2026-08-10 14:15 ` [PATCH net v5 2/4] net: phy: dp83640: embed pin configuration in clock xuanqiang.luo
2026-08-10 14:15 ` [PATCH net v5 3/4] net: phy: dp83640: clear state after PTP registration failure xuanqiang.luo
2026-08-10 14:15 ` [PATCH net v5 4/4] net: phy: dp83640: fix per-bus clock lifetime xuanqiang.luo
2026-08-10 14:29   ` luoxuanqiang
2026-08-10 14:50   ` Andrew Lunn [this message]
2026-08-10 15:16     ` luoxuanqiang

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=57719c88-854b-4c92-956e-a673041b8587@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=luoxuanqiang@kylinos.cn \
    --cc=maxime.chevallier@bootlin.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=xuanqiang.luo@linux.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