Re: [PATCH net v3 2/2] net: ravb: serialize PTP clock teardown
Vadim Fedorenko <[email protected]>
| Newsgroups | gmane.linux.kernel.renesas-soc,gmane.linux.network,gmane.linux.kernel.stable |
|---|---|
| Message-ID | <[email protected]> |
On 06/08/2026 10:51, [email protected] wrote: > From: Xuanqiang Luo <[email protected]> > > ravb_get_ts_info() can run without RTNL while ravb_ptp_stop() unregisters > the PHC. The PTP interrupt handler can race with the same teardown, so both > paths may access the clock while it is being freed. > > Protect the clock pointer with priv->lock, clear it before unregistering > the PHC, and unregister the detached clock outside the lock. I think adding spinlock here is a bit of overkill. For ravb_get_ts_info() you can simply extend struct ravb_ptp to store clock index on init and reset it to -1 on ptp stop. For interrupt race I think ravb_ptp_stop() can be split into disable interrupt function (like ravb_ptp_disable()) and actual clock free. In this case ravb_ptp_disable() can be run before synchronize_irq() with ptp_clock_unregister() afterwards in teardown callbacks, like it's already done for ring allocations.