Re: [PATCH net v5 4/4] net: phy: dp83640: fix per-bus clock lifetime
luoxuanqiang <[email protected]>
| Newsgroups | org.kernel.vger.netdev |
|---|---|
| Message-ID | <[email protected]> |
在 2026/8/10 22:50, Andrew Lunn 写道: > On Mon, Aug 10, 2026 at 10:15:11PM +0800, [email protected] wrote: >> From: Xuanqiang Luo <[email protected]> >> >> 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 <[email protected]> > > Andrew Thanks for the reply. I will fix the address and send v6 after 24 hours. Thanks, Xuanqiang