[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9d197d92-3990-4e48-aa35-87a51eccb87a@linux.dev>
Date: Tue, 16 Sep 2025 14:02:56 +0100
From: Vadim Fedorenko <vadim.fedorenko@...ux.dev>
To: "Russell King (Oracle)" <rmk+kernel@...linux.org.uk>,
Richard Cochran <richardcochran@...il.com>
Cc: Ajay Kaher <ajay.kaher@...adcom.com>,
Alexey Makhalov <alexey.makhalov@...adcom.com>,
Andrew Lunn <andrew+netdev@...n.ch>,
Broadcom internal kernel review list
<bcm-kernel-feedback-list@...adcom.com>, Clark Wang <xiaoning.wang@....com>,
"David S. Miller" <davem@...emloft.net>,
David Woodhouse <dwmw2@...radead.org>, Eric Dumazet <edumazet@...gle.com>,
imx@...ts.linux.dev, Jakub Kicinski <kuba@...nel.org>,
Jonathan Lemon <jonathan.lemon@...il.com>, netdev@...r.kernel.org,
Nick Shi <nick.shi@...adcom.com>, Paolo Abeni <pabeni@...hat.com>,
Sven Schnelle <svens@...ux.ibm.com>,
Vladimir Oltean <vladimir.oltean@....com>, Wei Fang <wei.fang@....com>,
Yangbo Lu <yangbo.lu@....com>
Subject: Re: [PATCH net-next 2/2] ptp: rework ptp_clock_unregister() to
disable events
On 15/09/2025 15:42, Russell King (Oracle) wrote:
> the ordering of ptp_clock_unregister() is not ideal, as the chardev
> remains published while state is being torn down. There is also no
> cleanup of enabled pin settings, which means enabled events can
> still forward into the core.
>
> Rework the ordering of cleanup in ptp_clock_unregister() so that we
> unpublish the posix clock (and user chardev), disable any pins that
> have events enabled, and then clean up the aux work and PPS source.
>
> This avoids potential use-after-free and races in PTP clock driver
> teardown.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@...linux.org.uk>
> ---
> drivers/ptp/ptp_chardev.c | 13 +++++++++++++
> drivers/ptp/ptp_clock.c | 17 ++++++++++++++++-
> drivers/ptp/ptp_private.h | 2 ++
> 3 files changed, 31 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c
> index eb4f6d1b1460..640a98f17739 100644
> --- a/drivers/ptp/ptp_chardev.c
> +++ b/drivers/ptp/ptp_chardev.c
> @@ -47,6 +47,19 @@ static int ptp_disable_pinfunc(struct ptp_clock_info *ops,
> return err;
> }
>
> +void ptp_disable_all_pins(struct ptp_clock *ptp)
> +{
> + struct ptp_clock_info *info = ptp->info;
> + unsigned int i;
> +
> + mutex_lock(&ptp->pincfg_mux);
> + for (i = 0; i < info->n_pins; i++)
> + if (info->pin_config[i].func != PTP_PF_NONE)
> + ptp_disable_pinfunc(info, info->pin_config[i].func,
> + info->pin_config[i].chan);
> + mutex_unlock(&ptp->pincfg_mux);
> +}
> +
This part is questionable. We do have devices which have PPS out enabled
by default. The driver reads pins configuration from the HW during PTP
init phase and sets up proper function for pin in ptp_info::pin_config.
With this patch applied these pins have PEROUT function disabled on
shutdown and in case of kexec'ing into a new kernel the PPS out feature
needs to be manually enabled, and it breaks expected behavior.
Why do you need to clear up configured PEROUT function?
Powered by blists - more mailing lists